Package edu.wisc.ssec.mcidasv.ui
Class DraggableTabbedPane
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTabbedPane
edu.wisc.ssec.mcidasv.ui.DraggableTabbedPane
- All Implemented Interfaces:
DragGestureListener
,DragSourceListener
,DropTargetListener
,MouseListener
,MouseMotionListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,SwingConstants
public class DraggableTabbedPane
extends JTabbedPane
implements DragGestureListener, DragSourceListener, DropTargetListener, MouseListener, MouseMotionListener
This is a rather simplistic drag and drop enabled JTabbedPane. It allows
users to use drag and drop to move tabs between windows and reorder tabs.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
(package private) class
(package private) class
private static class
To be perfectly honest I'm still a bit fuzzy about DataFlavors.static class
private static class
Used to simply provide a reference to the originating DraggableTabbedPane while we're dragging and dropping.Nested classes/interfaces inherited from class javax.swing.JTabbedPane
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
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
FieldsModifier and TypeFieldDescriptionprivate String
RGB string for the color of the current tab.private int
private int
private DragSource
Used for starting the dragging process.private DropTarget
Used for signaling that we'll accept drops (registers listeners).private McvComponentGroup
The component group holding our components.private static final String
Path to icon that represents the default button state.private static final String
Path to icon that represents the pressed button state.private static final String
Path to icon that represents the rollover button state.private IntegratedDataViewer
Keep around this reference so that we can access the UI Manager.private static final String
Path to the icon we'll use as an index indicator.private static final String
private static final String
private final Image
The actual image that we'll use to display the index indications.private static final org.slf4j.Logger
protected static boolean
Used to signal across all DraggableTabbedPanes that the component currently being dragged originated in another window.private int
The tab index that the user is currently over.private static Color
private static final long
private int
The tab index where the drag started.private static Color
private static final int
Local shorthand for the actions we're accepting.private IdvWindow
The IDV window that contains this tabbed pane.Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
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
-
Constructor Summary
ConstructorsConstructorDescriptionDraggableTabbedPane
(IdvWindow win, IntegratedDataViewer idv, McvComponentGroup group) Mostly just registers that this component should listen for drag and drop operations. -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
void
doDrop
(int srcIdx, int dstIdx) Moves a component to its new index within the component group.void
Handles what happens at the very end of a drag and drop.void
void
Triggered when the user drags intodropTarget
.void
void
Triggered when the user drags out ofdropTarget
.void
Triggered when the user does a (platform-dependent) drag initiating gesture.void
void
Triggered continually while the user is dragging overdropTarget
.void
Triggered when a drop has happened overdropTarget
.void
void
void
void
void
void
void
void
void
private void
newWindowDrag
(ComponentHolder dragged, Point drop) Handle the user dropping a tab outside of a McV window.void
Overridden so that McIDAS-V can draw an indicator of a dragged tab's possible new position.private void
private ComponentHolder
"Quietly" removes the dragged component from its group.void
setSelectedIndex
(int index) Overriden so that McIDAS-V can change the window title upon changing tabs.static boolean
showTabArea
(McvComponentGroup mcvCompGroup, JTabbedPane tabbedPane) Methods inherited from class javax.swing.JTabbedPane
add, add, add, add, add, addChangeListener, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfComponent, indexOfTab, indexOfTab, indexOfTabComponent, insertTab, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, 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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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
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, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
serialVersionUID
- See Also:
-
logger
-
VALID_ACTION
Local shorthand for the actions we're accepting.- See Also:
-
IDX_ICON
Path to the icon we'll use as an index indicator.- See Also:
-
unselected
-
selected
-
INDEX_COLOR_METAL
- See Also:
-
INDEX_COLOR_UGLY_TABS
- See Also:
-
INDICATOR
The actual image that we'll use to display the index indications. -
ICON_DEFAULT
Path to icon that represents the default button state.- See Also:
-
ICON_PRESSED
Path to icon that represents the pressed button state.- See Also:
-
ICON_ROLLOVER
Path to icon that represents the rollover button state.- See Also:
-
outsideDrag
Used to signal across all DraggableTabbedPanes that the component currently being dragged originated in another window. This'll let McV determine if it has to do a quiet ComponentHolder transfer. -
sourceIndex
The tab index where the drag started. -
overIndex
The tab index that the user is currently over. -
draggedAtX
-
draggedAtY
-
dragSource
Used for starting the dragging process. -
dropTarget
Used for signaling that we'll accept drops (registers listeners). -
group
The component group holding our components. -
window
The IDV window that contains this tabbed pane. -
idv
Keep around this reference so that we can access the UI Manager. -
currentTabColor
RGB string for the color of the current tab.
-
-
Constructor Details
-
DraggableTabbedPane
Mostly just registers that this component should listen for drag and drop operations.- Parameters:
win
- The IDV window containing this tabbed pane.idv
- The main IDV instance.group
- TheMcvComponentGroup
that holds this component's tabs.
-
-
Method Details
-
dragGestureRecognized
Triggered when the user does a (platform-dependent) drag initiating gesture. Used to populate the things that the user is attempting to drag.- Specified by:
dragGestureRecognized
in interfaceDragGestureListener
-
dragEnter
Triggered when the user drags intodropTarget
.- Specified by:
dragEnter
in interfaceDropTargetListener
-
dragExit
Triggered when the user drags out ofdropTarget
.- Specified by:
dragExit
in interfaceDropTargetListener
-
dragOver
Triggered continually while the user is dragging overdropTarget
. McIDAS-V uses this to draw the index indicator.- Specified by:
dragOver
in interfaceDropTargetListener
- Parameters:
e
- Information about the current state of the drag.
-
drop
Triggered when a drop has happened overdropTarget
.- Specified by:
drop
in interfaceDropTargetListener
- Parameters:
e
- State that we'll need in order to handle the drop.
-
removeDragged
"Quietly" removes the dragged component from its group. If the last component in a group has been dragged out of the group, the associated window will be killed.- Returns:
- The removed component.
-
doDrop
Moves a component to its new index within the component group.- Parameters:
srcIdx
- The old index of the component.dstIdx
- The new index of the component.
-
paint
Overridden so that McIDAS-V can draw an indicator of a dragged tab's possible new position.- Overrides:
paint
in classJComponent
-
setSelectedIndex
Overriden so that McIDAS-V can change the window title upon changing tabs.- Overrides:
setSelectedIndex
in classJTabbedPane
-
newWindowDrag
Handle the user dropping a tab outside of a McV window. This will create a new window and add the dragged tab to the ComponentGroup within the newly created window. The new window is the same size as the origin window, with the top centered over the location where the user released the mouse.- Parameters:
dragged
- The ComponentHolder that's being dragged around.drop
- The x- and y-coordinates where the user dropped the tab.
-
dragDropEnd
Handles what happens at the very end of a drag and drop. Since I could not find a better method for it, tabs that are dropped outside of a McV window are handled with this method.- Specified by:
dragDropEnd
in interfaceDragSourceListener
-
dragEnter
- Specified by:
dragEnter
in interfaceDragSourceListener
-
dragExit
- Specified by:
dragExit
in interfaceDragSourceListener
-
dragOver
- Specified by:
dragOver
in interfaceDragSourceListener
-
dropActionChanged
- Specified by:
dropActionChanged
in interfaceDragSourceListener
-
dropActionChanged
- Specified by:
dropActionChanged
in interfaceDropTargetListener
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
processMouseEvents
-
addTab
- Overrides:
addTab
in classJTabbedPane
-
addTab
-
showTabArea
-