bibliothek.gui.dock.focus
Class AbstractDockableSelection

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by bibliothek.gui.dock.focus.AbstractDockableSelection
All Implemented Interfaces:
DockableSelection, ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
DefaultDockableSelection

public abstract class AbstractDockableSelection
extends JPanel
implements DockableSelection

This DockableSelection is also a JPanel. It implements the methods needed to interact with DockableSelectionListener. It uses the input map to register actions for when an arrow key or a controlling key is pressed. This selection also observes the set of available Dockables and their title-text/icon. Subclasses get automatically informed about changes.

Author:
Benjamin Sigg
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  Action CANCEL
          Action called when the escape or return key was pressed.
protected  Action DOWN
          Action called when the down arrow key was pressed.
protected  Action LEFT
          Action called when the left arrow key was pressed.
protected  Action RIGHT
          Action called when the right arrow key was pressed.
protected  Action SELECT
          Action called when the space or enter key was pressed.
protected  Action UP
          Action called when the up arrow key was pressed.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AbstractDockableSelection()
          Creates a new selection
 
Method Summary
 void addDockableSelectionListener(DockableSelectionListener listener)
          Adds a listener that gets informed when the state of this selection changes.
protected  void cancel()
          Cancles this selection
 void close()
          Called when the current selection is no longer needed either because a selection was done or was canceled.
protected abstract  void down()
          Called when a down arrow key was pressed.
 Component getComponent()
          Gets the component which represents the selection.
 DockController getController()
          Gets the currently used controller.
 boolean hasChoices(DockController controller)
          Checks whether controller has at least two different Dockables which would be shown on this DockableSelection.
protected abstract  void iconChanged(int index, Dockable dockable)
          Called when the icon of dockable changed.
protected abstract  void insert(int index, Dockable dockable)
          Called when a new dockable can be selected.
protected abstract  void left()
          Called when a left arrow key was pressed.
 void open(DockController controller)
          Called when a new selection is about to happen.
protected abstract  void remove(int index, Dockable dockable)
          Called when a dockable is no longer selectable.
 void removeDockableSelectionListener(DockableSelectionListener listener)
          Removes a listener that gets informed when the state of this selection changes.
protected abstract  void right()
          Called when a right arrow key was pressed.
protected  void select()
          Selects the currently selected dockable.
protected abstract  void select(Dockable dockable)
          Called when this selection is forced to select a specific dockable.
protected  boolean selectable(Dockable dockable)
          Decides whether dockable fits the requirements for an element that can be selected.
protected  void setSelection(Dockable dockable)
          Informs this selection which dockable is currently selected.
protected abstract  void titleChanged(int index, Dockable dockable)
          Called when the title text of dockable changed.
protected abstract  void up()
          Called when an up arrow key was pressed.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, 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, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, 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, setEnabled, 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, addImpl, 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, setLayout, 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, imageUpdate, 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

UP

protected final Action UP
Action called when the up arrow key was pressed.


DOWN

protected final Action DOWN
Action called when the down arrow key was pressed.


LEFT

protected final Action LEFT
Action called when the left arrow key was pressed.


RIGHT

protected final Action RIGHT
Action called when the right arrow key was pressed.


CANCEL

protected final Action CANCEL
Action called when the escape or return key was pressed.


SELECT

protected final Action SELECT
Action called when the space or enter key was pressed.

Constructor Detail

AbstractDockableSelection

public AbstractDockableSelection()
Creates a new selection

Method Detail

addDockableSelectionListener

public void addDockableSelectionListener(DockableSelectionListener listener)
Description copied from interface: DockableSelection
Adds a listener that gets informed when the state of this selection changes.

Specified by:
addDockableSelectionListener in interface DockableSelection
Parameters:
listener - the new listener

removeDockableSelectionListener

public void removeDockableSelectionListener(DockableSelectionListener listener)
Description copied from interface: DockableSelection
Removes a listener that gets informed when the state of this selection changes.

Specified by:
removeDockableSelectionListener in interface DockableSelection
Parameters:
listener - the new listener

hasChoices

public boolean hasChoices(DockController controller)
Description copied from interface: DockableSelection
Checks whether controller has at least two different Dockables which would be shown on this DockableSelection.

Specified by:
hasChoices in interface DockableSelection
Parameters:
controller - the controller which might not have any children at all
Returns:
true if opening this DockableSelection gives the user a choice, false if this selection would not show anything

getComponent

public Component getComponent()
Description copied from interface: DockableSelection
Gets the component which represents the selection. The result of this method should always be the same.

Specified by:
getComponent in interface DockableSelection
Returns:
the representation of this selection

open

public void open(DockController controller)
Description copied from interface: DockableSelection
Called when a new selection is about to happen.

Specified by:
open in interface DockableSelection
Parameters:
controller - the controller for which the selection will happen

close

public void close()
Description copied from interface: DockableSelection
Called when the current selection is no longer needed either because a selection was done or was canceled.

Specified by:
close in interface DockableSelection

getController

public DockController getController()
Gets the currently used controller.

Returns:
the controller for which this selection shows content

selectable

protected boolean selectable(Dockable dockable)
Decides whether dockable fits the requirements for an element that can be selected.

Parameters:
dockable - the element to check
Returns:
true if dockable should be shown on this selection

up

protected abstract void up()
Called when an up arrow key was pressed.


down

protected abstract void down()
Called when a down arrow key was pressed.


left

protected abstract void left()
Called when a left arrow key was pressed.


right

protected abstract void right()
Called when a right arrow key was pressed.


insert

protected abstract void insert(int index,
                               Dockable dockable)
Called when a new dockable can be selected.

Parameters:
index - the location of the dockable in the list of all known dockables.
dockable - the new element

remove

protected abstract void remove(int index,
                               Dockable dockable)
Called when a dockable is no longer selectable.

Parameters:
index - the index of the removed element
dockable - the removed element

titleChanged

protected abstract void titleChanged(int index,
                                     Dockable dockable)
Called when the title text of dockable changed.

Parameters:
index - the location of dockable
dockable - the element whose title changed

iconChanged

protected abstract void iconChanged(int index,
                                    Dockable dockable)
Called when the icon of dockable changed.

Parameters:
index - the location of dockable
dockable - the element whose icon changed

select

protected abstract void select(Dockable dockable)
Called when this selection is forced to select a specific dockable.

Parameters:
dockable - the element to select, can be null

setSelection

protected void setSelection(Dockable dockable)
Informs this selection which dockable is currently selected.

Parameters:
dockable - the currently selected dockable

cancel

protected void cancel()
Cancles this selection


select

protected void select()
Selects the currently selected dockable.

See Also:
setSelection(Dockable)