public abstract class AbstractDockableSelection extends JPanel implements DockableSelection
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 Dockable
s and their title-text/icon. Subclasses get
automatically informed about changes.JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
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.
|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
AbstractDockableSelection()
Creates a new selection
|
Modifier and Type | Method and Description |
---|---|
void |
addDockableSelectionListener(DockableSelectionListener listener)
Adds a listener that gets informed when the state of this selection changes.
|
protected void |
cancel()
Cancels 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
Dockable s 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.
|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
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, isPaintingOrigin, 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
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, transferFocusDownCycle, validate, validateTree
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, transferFocusBackward, transferFocusUpCycle
protected final Action UP
protected final Action DOWN
protected final Action LEFT
protected final Action RIGHT
protected final Action CANCEL
protected final Action SELECT
public AbstractDockableSelection()
public void addDockableSelectionListener(DockableSelectionListener listener)
DockableSelection
addDockableSelectionListener
in interface DockableSelection
listener
- the new listenerpublic void removeDockableSelectionListener(DockableSelectionListener listener)
DockableSelection
removeDockableSelectionListener
in interface DockableSelection
listener
- the new listenerpublic boolean hasChoices(DockController controller)
DockableSelection
controller
has at least two different
Dockable
s which would be shown on this DockableSelection
.hasChoices
in interface DockableSelection
controller
- the controller which might not have any children at alltrue
if opening this DockableSelection
gives
the user a choice, false
if this selection would not show
anythingpublic Component getComponent()
DockableSelection
getComponent
in interface DockableSelection
public void open(DockController controller)
DockableSelection
open
in interface DockableSelection
controller
- the controller for which the selection will happenpublic void close()
DockableSelection
close
in interface DockableSelection
public DockController getController()
protected boolean selectable(Dockable dockable)
dockable
fits the requirements for
an element that can be selected.dockable
- the element to checktrue
if dockable
should be shown
on this selectionprotected abstract void up()
protected abstract void down()
protected abstract void left()
protected abstract void right()
protected abstract void insert(int index, Dockable dockable)
index
- the location of the dockable in the list of all known dockables.dockable
- the new elementprotected abstract void remove(int index, Dockable dockable)
index
- the index of the removed elementdockable
- the removed elementprotected abstract void titleChanged(int index, Dockable dockable)
dockable
changed.index
- the location of dockable
dockable
- the element whose title changedprotected abstract void iconChanged(int index, Dockable dockable)
dockable
changed.index
- the location of dockable
dockable
- the element whose icon changedprotected abstract void select(Dockable dockable)
dockable
- the element to select, can be null
protected void setSelection(Dockable dockable)
dockable
- the currently selected dockableprotected void cancel()
protected void select()
setSelection(Dockable)