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) classprivate static classTo be perfectly honest I'm still a bit fuzzy about DataFlavors.static classprivate static classUsed 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.ModelListenerNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringRGB string for the color of the current tab.private intprivate intprivate DragSourceUsed for starting the dragging process.private DropTargetUsed for signaling that we'll accept drops (registers listeners).private McvComponentGroupThe component group holding our components.private static final StringPath to icon that represents the default button state.private static final StringPath to icon that represents the pressed button state.private static final StringPath to icon that represents the rollover button state.private IntegratedDataViewerKeep around this reference so that we can access the UI Manager.private static final StringPath to the icon we'll use as an index indicator.private static final Stringprivate static final Stringprivate final ImageThe actual image that we'll use to display the index indications.private static final org.slf4j.Loggerprotected static booleanUsed to signal across all DraggableTabbedPanes that the component currently being dragged originated in another window.private intThe tab index that the user is currently over.private static Colorprivate static final longprivate intThe tab index where the drag started.private static Colorprivate static final intLocal shorthand for the actions we're accepting.private IdvWindowThe IDV window that contains this tabbed pane.Fields inherited from class javax.swing.JTabbedPane
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUTFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields 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 TypeMethodDescriptionvoidvoidvoiddoDrop(int srcIdx, int dstIdx) Moves a component to its new index within the component group.voidHandles what happens at the very end of a drag and drop.voidvoidTriggered when the user drags intodropTarget.voidvoidTriggered when the user drags out ofdropTarget.voidTriggered when the user does a (platform-dependent) drag initiating gesture.voidvoidTriggered continually while the user is dragging overdropTarget.voidTriggered when a drop has happened overdropTarget.voidvoidvoidvoidvoidvoidvoidvoidvoidprivate voidnewWindowDrag(ComponentHolder dragged, Point drop) Handle the user dropping a tab outside of a McV window.voidOverridden so that McIDAS-V can draw an indicator of a dragged tab's possible new position.private voidprivate ComponentHolder"Quietly" removes the dragged component from its group.voidsetSelectedIndex(int index) Overriden so that McIDAS-V can change the window title upon changing tabs.static booleanshowTabArea(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, updateUIMethods 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, updateMethods 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, validateTreeMethods 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- TheMcvComponentGroupthat 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:
dragGestureRecognizedin interfaceDragGestureListener
-
dragEnter
Triggered when the user drags intodropTarget.- Specified by:
dragEnterin interfaceDropTargetListener
-
dragExit
Triggered when the user drags out ofdropTarget.- Specified by:
dragExitin interfaceDropTargetListener
-
dragOver
Triggered continually while the user is dragging overdropTarget. McIDAS-V uses this to draw the index indicator.- Specified by:
dragOverin interfaceDropTargetListener- Parameters:
e- Information about the current state of the drag.
-
drop
Triggered when a drop has happened overdropTarget.- Specified by:
dropin 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:
paintin classJComponent
-
setSelectedIndex
Overriden so that McIDAS-V can change the window title upon changing tabs.- Overrides:
setSelectedIndexin 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:
dragDropEndin interfaceDragSourceListener
-
dragEnter
- Specified by:
dragEnterin interfaceDragSourceListener
-
dragExit
- Specified by:
dragExitin interfaceDragSourceListener
-
dragOver
- Specified by:
dragOverin interfaceDragSourceListener
-
dropActionChanged
- Specified by:
dropActionChangedin interfaceDragSourceListener
-
dropActionChanged
- Specified by:
dropActionChangedin interfaceDropTargetListener
-
mouseClicked
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseMoved
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
processMouseEvents
-
addTab
- Overrides:
addTabin classJTabbedPane
-
addTab
-
showTabArea
-