public class DraggableTabbedPane extends javax.swing.JTabbedPane implements java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
Modifier and Type | Class and Description |
---|---|
static class |
DraggableTabbedPane.ButtonState |
(package private) class |
DraggableTabbedPane.CloseableMetalTabbedPaneUI |
(package private) class |
DraggableTabbedPane.CloseableTabbedPaneUI |
private static class |
DraggableTabbedPane.DraggableTabFlavor
To be perfectly honest I'm still a bit fuzzy about DataFlavors.
|
static class |
DraggableTabbedPane.TabButton |
private static class |
DraggableTabbedPane.TransferableIndex
Used to simply provide a reference to the originating
DraggableTabbedPane while we're dragging and dropping.
|
javax.swing.JTabbedPane.AccessibleJTabbedPane, javax.swing.JTabbedPane.ModelListener
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
currentTabColor
RGB string for the color of the current tab.
|
private int |
draggedAtX |
private int |
draggedAtY |
private java.awt.dnd.DragSource |
dragSource
Used for starting the dragging process.
|
private java.awt.dnd.DropTarget |
dropTarget
Used for signaling that we'll accept drops (registers listeners).
|
private McvComponentGroup |
group
The component group holding our components.
|
private static java.lang.String |
ICON_DEFAULT
Path to icon that represents the default button state.
|
private static java.lang.String |
ICON_PRESSED
Path to icon that represents the pressed button state.
|
private static java.lang.String |
ICON_ROLLOVER
Path to icon that represents the rollover button state.
|
private ucar.unidata.idv.IntegratedDataViewer |
idv
Keep around this reference so that we can access the UI Manager.
|
private static java.lang.String |
IDX_ICON
Path to the icon we'll use as an index indicator.
|
private static java.lang.String |
INDEX_COLOR_METAL |
private static java.lang.String |
INDEX_COLOR_UGLY_TABS |
private java.awt.Image |
INDICATOR
The actual image that we'll use to display the index indications.
|
private static org.slf4j.Logger |
logger |
protected static boolean |
outsideDrag
Used to signal across all DraggableTabbedPanes that the component
currently being dragged originated in another window.
|
private int |
overIndex
The tab index that the user is currently over.
|
private static java.awt.Color |
selected |
private static long |
serialVersionUID |
private int |
sourceIndex
The tab index where the drag started.
|
private static java.awt.Color |
unselected |
private static int |
VALID_ACTION
Local shorthand for the actions we're accepting.
|
private ucar.unidata.idv.ui.IdvWindow |
window
The IDV window that contains this tabbed pane.
|
changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Constructor and Description |
---|
DraggableTabbedPane(ucar.unidata.idv.ui.IdvWindow win,
ucar.unidata.idv.IntegratedDataViewer idv,
McvComponentGroup group)
Mostly just registers that this component should listen for drag and
drop operations.
|
Modifier and Type | Method and Description |
---|---|
void |
addTab(java.lang.String title,
java.awt.Component component) |
void |
addTab(java.lang.String title,
java.awt.Component component,
javax.swing.Icon extraIcon) |
void |
doDrop(int srcIdx,
int dstIdx)
Moves a component to its new index within the component group.
|
void |
dragDropEnd(java.awt.dnd.DragSourceDropEvent e)
Handles what happens at the very end of a drag and drop.
|
void |
dragEnter(java.awt.dnd.DragSourceDragEvent e) |
void |
dragEnter(java.awt.dnd.DropTargetDragEvent e)
Triggered when the user drags into
dropTarget . |
void |
dragExit(java.awt.dnd.DragSourceEvent e) |
void |
dragExit(java.awt.dnd.DropTargetEvent e)
Triggered when the user drags out of
dropTarget . |
void |
dragGestureRecognized(java.awt.dnd.DragGestureEvent e)
Triggered when the user does a (platform-dependent) drag initiating
gesture.
|
void |
dragOver(java.awt.dnd.DragSourceDragEvent e) |
void |
dragOver(java.awt.dnd.DropTargetDragEvent e)
Triggered continually while the user is dragging over
dropTarget . |
void |
drop(java.awt.dnd.DropTargetDropEvent e)
Triggered when a drop has happened over
dropTarget . |
void |
dropActionChanged(java.awt.dnd.DragSourceDragEvent e) |
void |
dropActionChanged(java.awt.dnd.DropTargetDragEvent e) |
void |
mouseClicked(java.awt.event.MouseEvent e) |
void |
mouseDragged(java.awt.event.MouseEvent e) |
void |
mouseEntered(java.awt.event.MouseEvent e) |
void |
mouseExited(java.awt.event.MouseEvent e) |
void |
mouseMoved(java.awt.event.MouseEvent e) |
void |
mousePressed(java.awt.event.MouseEvent e) |
void |
mouseReleased(java.awt.event.MouseEvent e) |
private void |
newWindowDrag(ucar.unidata.ui.ComponentHolder dragged,
java.awt.Point drop)
Handle the user dropping a tab outside of a McV window.
|
void |
paint(java.awt.Graphics g)
Overridden so that McIDAS-V can draw an indicator of a dragged tab's
possible new position.
|
private void |
processMouseEvents(java.awt.event.MouseEvent e) |
private ucar.unidata.ui.ComponentHolder |
removeDragged()
"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,
javax.swing.JTabbedPane tabbedPane) |
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
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
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
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, 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
private static final long serialVersionUID
private static final org.slf4j.Logger logger
private static final int VALID_ACTION
private static final java.lang.String IDX_ICON
private static final java.awt.Color unselected
private static final java.awt.Color selected
private static final java.lang.String INDEX_COLOR_METAL
private static final java.lang.String INDEX_COLOR_UGLY_TABS
private final java.awt.Image INDICATOR
private static final java.lang.String ICON_DEFAULT
private static final java.lang.String ICON_PRESSED
private static final java.lang.String ICON_ROLLOVER
protected static boolean outsideDrag
private int sourceIndex
private int overIndex
private int draggedAtX
private int draggedAtY
private java.awt.dnd.DragSource dragSource
private java.awt.dnd.DropTarget dropTarget
private McvComponentGroup group
private ucar.unidata.idv.ui.IdvWindow window
private ucar.unidata.idv.IntegratedDataViewer idv
private java.lang.String currentTabColor
public DraggableTabbedPane(ucar.unidata.idv.ui.IdvWindow win, ucar.unidata.idv.IntegratedDataViewer idv, McvComponentGroup group)
win
- The IDV window containing this tabbed pane.idv
- The main IDV instance.group
- The McvComponentGroup
that holds this component's tabs.public void dragGestureRecognized(java.awt.dnd.DragGestureEvent e)
dragGestureRecognized
in interface java.awt.dnd.DragGestureListener
public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
dropTarget
.dragEnter
in interface java.awt.dnd.DropTargetListener
public void dragExit(java.awt.dnd.DropTargetEvent e)
dropTarget
.dragExit
in interface java.awt.dnd.DropTargetListener
public void dragOver(java.awt.dnd.DropTargetDragEvent e)
dropTarget
. McIDAS-V uses this to draw the index indicator.dragOver
in interface java.awt.dnd.DropTargetListener
e
- Information about the current state of the drag.public void drop(java.awt.dnd.DropTargetDropEvent e)
dropTarget
.drop
in interface java.awt.dnd.DropTargetListener
e
- State that we'll need in order to handle the drop.private ucar.unidata.ui.ComponentHolder removeDragged()
public void doDrop(int srcIdx, int dstIdx)
srcIdx
- The old index of the component.dstIdx
- The new index of the component.public void paint(java.awt.Graphics g)
paint
in class javax.swing.JComponent
public void setSelectedIndex(int index)
setSelectedIndex
in class javax.swing.JTabbedPane
private void newWindowDrag(ucar.unidata.ui.ComponentHolder dragged, java.awt.Point drop)
dragged
- The ComponentHolder that's being dragged around.drop
- The x- and y-coordinates where the user dropped the tab.public void dragDropEnd(java.awt.dnd.DragSourceDropEvent e)
dragDropEnd
in interface java.awt.dnd.DragSourceListener
public void dragEnter(java.awt.dnd.DragSourceDragEvent e)
dragEnter
in interface java.awt.dnd.DragSourceListener
public void dragExit(java.awt.dnd.DragSourceEvent e)
dragExit
in interface java.awt.dnd.DragSourceListener
public void dragOver(java.awt.dnd.DragSourceDragEvent e)
dragOver
in interface java.awt.dnd.DragSourceListener
public void dropActionChanged(java.awt.dnd.DragSourceDragEvent e)
dropActionChanged
in interface java.awt.dnd.DragSourceListener
public void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
dropActionChanged
in interface java.awt.dnd.DropTargetListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
private void processMouseEvents(java.awt.event.MouseEvent e)
public void addTab(java.lang.String title, java.awt.Component component)
addTab
in class javax.swing.JTabbedPane
public void addTab(java.lang.String title, java.awt.Component component, javax.swing.Icon extraIcon)
public static boolean showTabArea(McvComponentGroup mcvCompGroup, javax.swing.JTabbedPane tabbedPane)