org.tanager.ui
Class CPlaylistViewer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.AbstractButton
                  extended by org.tanager.ui.CScrollablePane
                      extended by org.tanager.ui.CPlaylistViewer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.ItemSelectable, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants, IButtonHandler, IDownButtonCallback, ILeftButtonCallback, IMenuButtonCallback, IPowerButtonCallback, IUpButtonCallback
Direct Known Subclasses:
CSelectablePlaylistViewer

public class CPlaylistViewer
extends CScrollablePane
implements IDownButtonCallback, IUpButtonCallback, ILeftButtonCallback

This class represents a scollable pane that shows the current playlist.

Version:
$Revision: 1.2.2.6 $
Author:
Bob Lavey
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.AbstractButton
javax.swing.AbstractButton.AccessibleAbstractButton, javax.swing.AbstractButton.ButtonChangeListener
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private static boolean debugPlaylistViewerButton_
           Represents whether or not we want to output menu selection debugging information to the console.
private  CDownButtonAction downButtonCallback_
           Represents the down button callback.
private  CLeftButtonAction leftButtonCallback_
           Represents the left button callback.
protected  javax.swing.JTable playlistTable_
           Represents the table that contains the playlist.
private static long serialVersionUID
           Represents the universal version ID of this class.
private  CUpButtonAction upButtonCallback_
           Represents the up button callback.
 
Fields inherited from class org.tanager.ui.CScrollablePane
menuButtonCallback_, powerButtonCallback_
 
Fields inherited from class javax.swing.AbstractButton
actionListener, BORDER_PAINTED_CHANGED_PROPERTY, changeEvent, changeListener, CONTENT_AREA_FILLED_CHANGED_PROPERTY, DISABLED_ICON_CHANGED_PROPERTY, DISABLED_SELECTED_ICON_CHANGED_PROPERTY, FOCUS_PAINTED_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, itemListener, MARGIN_CHANGED_PROPERTY, MNEMONIC_CHANGED_PROPERTY, model, MODEL_CHANGED_PROPERTY, PRESSED_ICON_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CPlaylistViewer(CPlaylistTypeEnum playlistType, java.util.Vector playlist, CUIStateContext uiStateContext)
           This is the only constructor allowed for a CPlaylistViewer object.
 
Method Summary
protected  void addMouseDoubleClickListener(CMouseDoubleClickListener listener)
           This method is used to add a CMouseDoubleClickListener to the playlist table.
 void addPlaylistViewerListener(IPlaylistViewerListener listener)
           This method adds a new listener to the collection.
private  void configureAlbumColumn(javax.swing.table.TableColumn albumColumn, int extraWidth)
           This method configures the album column.
private  void configureArtistColumn(javax.swing.table.TableColumn artistColumn, int extraWidth)
           This method configures the artist column.
private  void configureDateDownloadedColumn(javax.swing.table.TableColumn dateDownloadedColumn)
           This method configures the date downloaded column.
private  void configureTitleColumn(javax.swing.table.TableColumn titleColumn, int extraWidth)
           This method configures the song title column.
private  javax.swing.JTable createAndConfigurePlaylistTable(java.util.Vector playlist)
           This method creates the playlist table and confgures it to be read-only and row-scrollable.
protected  void debugPlaylistViewerButton(java.lang.String dbg)
           This method is used to output debug information to the console.
 void downButtonPressed()
           This method is used to process the downButtonPressed() event and will move down from the current playlist table row to the one directly below it.
 CDownButtonAction getDownButtonCallback()
           This method returns the implementor's down button callback.
 CLeftButtonAction getLeftButtonCallback()
           This method returns the implementor's left button callback.
protected  javax.swing.JTable getPlaylistTable()
          Poseidon-generated accessor method.
 CUpButtonAction getUpButtonCallback()
           This method returns the implementor's up button callback.
 void leftButtonPressed()
           This method is used to process the leftButtonPressed() event.
private  void scrollToRow(int newRow)
           This method is used to scroll to the given row in the playlist table, and it must make sure the row is displayed in the viewport.
 boolean supportsDownButton()
           This method indicates whether or not the implementor supports the down button.
 boolean supportsLeftButton()
           This method indicates whether or not the implementor supports the left button.
 boolean supportsUpButton()
           This method indicates whether or not the implementor supports the up button.
 void upButtonPressed()
           This method is used to process the upButtonPressed() event and will move up from the current playlist table row to the one directly above it.
 
Methods inherited from class org.tanager.ui.CScrollablePane
addListener, getListeners, getMenuButtonCallback, getMiddleButtonCallback, getMouseDoubleClickCallback, getPowerButtonCallback, getRightButtonCallback, getStopButtonCallback, getTheUIStateContext, menuButtonPressed, powerButtonPressed, setScrollPane, supportsMenuButton, supportsMiddleButton, supportsMouseDoubleClick, supportsPowerButton, supportsRightButton, supportsStopButton
 
Methods inherited from class javax.swing.AbstractButton
addActionListener, addChangeListener, addImpl, addItemListener, checkHorizontalKey, checkVerticalKey, configurePropertiesFromAction, createActionListener, createActionPropertyChangeListener, createChangeListener, createItemListener, doClick, doClick, fireActionPerformed, fireItemStateChanged, fireStateChanged, getAction, getActionCommand, getActionListeners, getChangeListeners, getDisabledIcon, getDisabledSelectedIcon, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getItemListeners, getLabel, getMargin, getMnemonic, getModel, getMultiClickThreshhold, getPressedIcon, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getSelectedObjects, getText, getUI, getVerticalAlignment, getVerticalTextPosition, imageUpdate, init, isBorderPainted, isContentAreaFilled, isFocusPainted, isRolloverEnabled, isSelected, paintBorder, paramString, removeActionListener, removeChangeListener, removeItemListener, setAction, setActionCommand, setBorderPainted, setContentAreaFilled, setDisabledIcon, setDisabledSelectedIcon, setDisplayedMnemonicIndex, setEnabled, setFocusPainted, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabel, setLayout, setMargin, setMnemonic, setMnemonic, setModel, setMultiClickThreshhold, setPressedIcon, setRolloverEnabled, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID

Represents the universal version ID of this class. This ID is recommended for all classes that implement the Serializable interface.

See Also:
Constant Field Values

upButtonCallback_

private final CUpButtonAction upButtonCallback_

Represents the up button callback.


downButtonCallback_

private final CDownButtonAction downButtonCallback_

Represents the down button callback.


leftButtonCallback_

private final CLeftButtonAction leftButtonCallback_

Represents the left button callback.


playlistTable_

protected javax.swing.JTable playlistTable_

Represents the table that contains the playlist.


debugPlaylistViewerButton_

private static boolean debugPlaylistViewerButton_

Represents whether or not we want to output menu selection debugging information to the console.

Constructor Detail

CPlaylistViewer

public CPlaylistViewer(CPlaylistTypeEnum playlistType,
                       java.util.Vector playlist,
                       CUIStateContext uiStateContext)

This is the only constructor allowed for a CPlaylistViewer object. The caller must supply the playlist type and the playlist vector.

Semantics:
  1. call our superclass' constructor passing the given playlist type as the pane's title, and passing the given UI State Context
  2. call our createAndConfigurePlaylistTable() method to create a new JTable representation of the playlist vector
  3. call our configureDateDownloadedColumn() method to configure the date downloaded column
  4. calculate the width of the columns, and if it's smaller than the area it need to fill, calculate a padding amount
  5. call our configureTitleColumn(), configureArtistColumn(), and configureAlbumColumn() methods to configure the title, artist, and album columns
  6. create a new JList to hold the playlist table
  7. call our superlass' setScrollPane() method with the new JList

Parameters:
playlistType - the playlist type
playlist - the playlist vector
uiStateContext - the State Context that controls the menus
Method Detail

addPlaylistViewerListener

public void addPlaylistViewerListener(IPlaylistViewerListener listener)

This method adds a new listener to the collection.

Semantics:
  1. call the super class' addListener method with the given listener

Parameters:
listener - a reference to an object implementing the IPlaylistViewerListener interface

createAndConfigurePlaylistTable

private javax.swing.JTable createAndConfigurePlaylistTable(java.util.Vector playlist)

This method creates the playlist table and confgures it to be read-only and row-scrollable.

Semantics:
  1. create a new CPlaylistViewerTableModel using the given playlist vector
  2. create a new JTable using the new CPlaylistViewerTableModel
  3. configure the table to not allow resizing or moving of the columns, to not show the gridlines, to only allow entire rows to be selected, and set the first row to be selected initially
  4. return the new JTable

Parameters:
playlist - the playlist vector
Returns:
the playlist table

configureDateDownloadedColumn

private void configureDateDownloadedColumn(javax.swing.table.TableColumn dateDownloadedColumn)

This method configures the date downloaded column.

Semantics:
  1. create a new CPlaylistViewerCellRenderer renderer object, so the cell will be displayed normally even when it has the focus
  2. set the cell to be center justified and have a width large enough to hold its heading name

Parameters:
dateDownloadedColumn - the column containing the date downloaded field

configureTitleColumn

private void configureTitleColumn(javax.swing.table.TableColumn titleColumn,
                                  int extraWidth)

This method configures the song title column.

Semantics:
  1. create a new CPlaylistViewerCellRenderer renderer object, so the cell will be displayed normally even when it has the focus
  2. set the cell width to include any additional padding

Parameters:
titleColumn - the column containing the album field
extraWidth - extra column width padding required to make the table fit in the area it needs to fill

configureArtistColumn

private void configureArtistColumn(javax.swing.table.TableColumn artistColumn,
                                   int extraWidth)

This method configures the artist column.

Semantics:
  1. create a new CPlaylistViewerCellRenderer renderer object, so the cell will be displayed normally even when it has the focus
  2. set the cell width to include any additional padding

Parameters:
artistColumn - the column containing the album field
extraWidth - extra column width padding required to make the table fit in the area it needs to fill

configureAlbumColumn

private void configureAlbumColumn(javax.swing.table.TableColumn albumColumn,
                                  int extraWidth)

This method configures the album column.

Semantics:
  1. create a new CPlaylistViewerCellRenderer renderer object, so the cell will be displayed normally even when it has the focus
  2. set the cell width to include any additional padding

Parameters:
albumColumn - the column containing the album field
extraWidth - extra column width padding required to make the table fit in the area it needs to fill

getPlaylistTable

protected javax.swing.JTable getPlaylistTable()

Poseidon-generated accessor method.

Returns:

addMouseDoubleClickListener

protected void addMouseDoubleClickListener(CMouseDoubleClickListener listener)

This method is used to add a CMouseDoubleClickListener to the playlist table.

Parameters:
listener -

supportsUpButton

public boolean supportsUpButton()

This method indicates whether or not the implementor supports the up button.

Semantics:
  1. return true

Specified by:
supportsUpButton in interface IButtonHandler
Overrides:
supportsUpButton in class CScrollablePane
Returns:

supportsDownButton

public boolean supportsDownButton()

This method indicates whether or not the implementor supports the down button.

Semantics:
  1. return true

Specified by:
supportsDownButton in interface IButtonHandler
Overrides:
supportsDownButton in class CScrollablePane
Returns:

supportsLeftButton

public boolean supportsLeftButton()

This method indicates whether or not the implementor supports the left button.

Semantics:
  1. return true

Specified by:
supportsLeftButton in interface IButtonHandler
Overrides:
supportsLeftButton in class CScrollablePane
Returns:
true

getUpButtonCallback

public CUpButtonAction getUpButtonCallback()

This method returns the implementor's up button callback. Note: that this method is only valid when supportsUpButton() returns true

Semantics:
  1. return our up button callback

Specified by:
getUpButtonCallback in interface IButtonHandler
Overrides:
getUpButtonCallback in class CScrollablePane
Returns:
our up button callback

getDownButtonCallback

public CDownButtonAction getDownButtonCallback()

This method returns the implementor's down button callback. Note: that this method is only valid when supportsDownButton() returns true

Semantics:
  1. return our down button callback

Specified by:
getDownButtonCallback in interface IButtonHandler
Overrides:
getDownButtonCallback in class CScrollablePane
Returns:
our down button callback

getLeftButtonCallback

public CLeftButtonAction getLeftButtonCallback()

This method returns the implementor's left button callback. Note: that this method is only valid when supportsLeftButton() returns true

Semantics:
  1. return our left button callback

Specified by:
getLeftButtonCallback in interface IButtonHandler
Overrides:
getLeftButtonCallback in class CScrollablePane
Returns:
our left button callback

upButtonPressed

public void upButtonPressed()

This method is used to process the upButtonPressed() event and will move up from the current playlist table row to the one directly above it. This is part of the IUpButtonCallback interface.

Semantics:
  1. get the index of the currently-selected playlist row and decrement it
  2. if the index is greater than or equal to 0
    1. call our scrollToRow() method passing the new row

Specified by:
upButtonPressed in interface IUpButtonCallback

downButtonPressed

public void downButtonPressed()

This method is used to process the downButtonPressed() event and will move down from the current playlist table row to the one directly below it. This is part of the IDownButtonCallback interface.

Semantics:
  1. get the index of the currently-selected playlist row and increment it
  2. if the index is less than the number of rows in the table
    1. call our scrollToRow() method passing the new row

Specified by:
downButtonPressed in interface IDownButtonCallback

leftButtonPressed

public void leftButtonPressed()

This method is used to process the leftButtonPressed() event. This is part of the ILeftButtonCallback interface.

Semantics:
  1. call each listener's previousPane() method

Specified by:
leftButtonPressed in interface ILeftButtonCallback

debugPlaylistViewerButton

protected void debugPlaylistViewerButton(java.lang.String dbg)

This method is used to output debug information to the console.

Parameters:
dbg -

scrollToRow

private void scrollToRow(int newRow)

This method is used to scroll to the given row in the playlist table, and it must make sure the row is displayed in the viewport.

Semantics:
  1. get the visible rectangle before scrolling
  2. scroll to the new row
  3. get the new visible rectangle and set the horizontal (x-axis) position to be the same as before scrolling
  4. call the table's scrollRectToVisible() to ensure the new scroll position is visible

Parameters:
newRow -