public class DraggableTabbedPane extends JTabbedPane implements DragGestureListener, DragSourceListener, DropTargetListener, MouseListener, 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.
|
JTabbedPane.AccessibleJTabbedPane, JTabbedPane.ModelListener
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private String |
currentTabColor
RGB string for the color of the current tab.
|
private int |
draggedAtX |
private int |
draggedAtY |
private DragSource |
dragSource
Used for starting the dragging process.
|
private DropTarget |
dropTarget
Used for signaling that we'll accept drops (registers listeners).
|
private McvComponentGroup |
group
The component group holding our components.
|
private static String |
ICON_DEFAULT
Path to icon that represents the default button state.
|
private static String |
ICON_PRESSED
Path to icon that represents the pressed button state.
|
private static String |
ICON_ROLLOVER
Path to icon that represents the rollover button state.
|
private IntegratedDataViewer |
idv
Keep around this reference so that we can access the UI Manager.
|
private static String |
IDX_ICON
Path to the icon we'll use as an index indicator.
|
private static String |
INDEX_COLOR_METAL |
private static String |
INDEX_COLOR_UGLY_TABS |
private 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 Color |
selected |
private static long |
serialVersionUID |
private int |
sourceIndex
The tab index where the drag started.
|
private static Color |
unselected |
private static int |
VALID_ACTION
Local shorthand for the actions we're accepting.
|
private 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
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
DraggableTabbedPane(IdvWindow win,
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(String title,
Component component) |
void |
addTab(String title,
Component component,
Icon extraIcon) |
void |
doDrop(int srcIdx,
int dstIdx)
Moves a component to its new index within the component group.
|
void |
dragDropEnd(DragSourceDropEvent e)
Handles what happens at the very end of a drag and drop.
|
void |
dragEnter(DragSourceDragEvent e) |
void |
dragEnter(DropTargetDragEvent e)
Triggered when the user drags into
dropTarget . |
void |
dragExit(DragSourceEvent e) |
void |
dragExit(DropTargetEvent e)
Triggered when the user drags out of
dropTarget . |
void |
dragGestureRecognized(DragGestureEvent e)
Triggered when the user does a (platform-dependent) drag initiating
gesture.
|
void |
dragOver(DragSourceDragEvent e) |
void |
dragOver(DropTargetDragEvent e)
Triggered continually while the user is dragging over
dropTarget . |
void |
drop(DropTargetDropEvent e)
Triggered when a drop has happened over
dropTarget . |
void |
dropActionChanged(DragSourceDragEvent e) |
void |
dropActionChanged(DropTargetDragEvent e) |
void |
mouseClicked(MouseEvent e) |
void |
mouseDragged(MouseEvent e) |
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e) |
void |
mouseMoved(MouseEvent e) |
void |
mousePressed(MouseEvent e) |
void |
mouseReleased(MouseEvent e) |
private void |
newWindowDrag(ComponentHolder dragged,
Point drop)
Handle the user dropping a tab outside of a McV window.
|
void |
paint(Graphics g)
Overridden so that McIDAS-V can draw an indicator of a dragged tab's
possible new position.
|
private void |
processMouseEvents(MouseEvent e) |
private 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,
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 String IDX_ICON
private static final Color unselected
private static final String INDEX_COLOR_METAL
private static final String INDEX_COLOR_UGLY_TABS
private final Image INDICATOR
private static final String ICON_DEFAULT
private static final String ICON_PRESSED
private static final String ICON_ROLLOVER
protected static boolean outsideDrag
private int sourceIndex
private int overIndex
private int draggedAtX
private int draggedAtY
private DragSource dragSource
private DropTarget dropTarget
private McvComponentGroup group
private IntegratedDataViewer idv
private String currentTabColor
public DraggableTabbedPane(IdvWindow win, 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(DragGestureEvent e)
dragGestureRecognized
in interface DragGestureListener
public void dragEnter(DropTargetDragEvent e)
dropTarget
.dragEnter
in interface DropTargetListener
public void dragExit(DropTargetEvent e)
dropTarget
.dragExit
in interface DropTargetListener
public void dragOver(DropTargetDragEvent e)
dropTarget
. McIDAS-V uses this to draw the index indicator.dragOver
in interface DropTargetListener
e
- Information about the current state of the drag.public void drop(DropTargetDropEvent e)
dropTarget
.drop
in interface DropTargetListener
e
- State that we'll need in order to handle the drop.private 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(Graphics g)
paint
in class JComponent
public void setSelectedIndex(int index)
setSelectedIndex
in class JTabbedPane
private void newWindowDrag(ComponentHolder dragged, 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(DragSourceDropEvent e)
dragDropEnd
in interface DragSourceListener
public void dragEnter(DragSourceDragEvent e)
dragEnter
in interface DragSourceListener
public void dragExit(DragSourceEvent e)
dragExit
in interface DragSourceListener
public void dragOver(DragSourceDragEvent e)
dragOver
in interface DragSourceListener
public void dropActionChanged(DragSourceDragEvent e)
dropActionChanged
in interface DragSourceListener
public void dropActionChanged(DropTargetDragEvent e)
dropActionChanged
in interface DropTargetListener
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
private void processMouseEvents(MouseEvent e)
public void addTab(String title, Component component)
addTab
in class JTabbedPane
public static boolean showTabArea(McvComponentGroup mcvCompGroup, JTabbedPane tabbedPane)