Package edu.wisc.ssec.mcidasv.util
Class TreePanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.wisc.ssec.mcidasv.util.TreePanel
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,TreeSelectionListener
This class shows a tree on the left and a card panel on the right.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
TreeNode extensions that allows us to associate an icon with this node.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
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 TypeFieldDescription_more_static final String
private final Map
<String, DefaultMutableTreeNode> Maps categories to tree node.private final Map
<Component, DefaultMutableTreeNode> Maps components to tree node.private final JPanel
_more_private boolean
Whether or not it is okay to save.private boolean
Okay to respond to selection changes.private GuiUtils.CardLayoutPanel
The panel.private final DefaultMutableTreeNode
The root.private final JTree
The tree.private final DefaultTreeModel
The model.private final JScrollPane
The scroller.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
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCategoryComponent
(String cat, JComponent comp) _more_void
addComponent
(JComponent component, String category, String label, ImageIcon icon) Add the component to the panel.void
closeAll()
Close all tree paths.static TreePath
findByName
(JTree tree, List<String> names) static DefaultMutableTreeNode
findNodeByPath
(JTree tree, String path) static String
private static TreePath
getPathToFirstLeaf
(TreePath searchPath) private String
void
openAll()
Open all tree paths.void
removeComponent
(JComponent component) _more_private void
private static TreePath
searchTree
(TreePath parent, List<String> nodes, int depth) void
Associate an icon with a component.void
Show the givencomponent
.void
Show the tree node that corresponds to the component.void
Attempts to select the path from a previous McIDAS-V session.tokenizePath
(String path) private void
void
Handle tree selection changed.Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, 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
Methods inherited from class java.awt.Container
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
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
-
CATEGORY_DELIMITER
- See Also:
-
root
The root. -
treeModel
The model. -
tree
The tree. -
treeView
The scroller. -
panel
The panel. -
emptyPanel
_more_ -
catComponents
_more_ -
catToNode
Maps categories to tree node. -
compToNode
Maps components to tree node. -
okToUpdateTree
Okay to respond to selection changes. -
okToSave
Whether or not it is okay to save.
-
-
Constructor Details
-
TreePanel
public TreePanel()Default constructor. CallsTreePanel(boolean, int)
withuseSplitPane
set totrue
andtreeWidth
set to-1
. -
TreePanel
Constructor that actually does the work.- Parameters:
useSplitPane
- Whether or not to use a split pane.treeWidth
- Width of the component containing the tree.
-
-
Method Details
-
getVisibleComponent
-
valueChanged
Handle tree selection changed.- Specified by:
valueChanged
in interfaceTreeSelectionListener
- Parameters:
e
- Event to handle. Cannot benull
.
-
setIcon
Associate an icon with a component.- Parameters:
comp
- Component to associate withicon
.icon
- Icon to associate withcomp
. Should not benull
.
-
addComponent
Add the component to the panel.- Parameters:
component
- componentcategory
- tree category. May be null.label
- Tree node labelicon
- Node icon. May be null.
-
treeChanged
-
addCategoryComponent
_more_- Parameters:
cat
- _more_comp
- _more_
-
removeComponent
_more_- Parameters:
component
- _more_
-
show
Show the givencomponent
.- Parameters:
component
- Component to show. Should not benull
.
-
showPath
Show the tree node that corresponds to the component.- Parameters:
component
- Component whose corresponding tree node to show. Should not benull
.
-
openAll
Open all tree paths. -
closeAll
Close all tree paths. -
showPersistedSelection
Attempts to select the path from a previous McIDAS-V session. If no path was persisted, the method attempts to use the "first" non-leaf node.This method also sets
okToSave
totrue
, so that user selections can be captured after this method quits. -
saveCurrentPath
-
loadSavedPath
-
tokenizePath
-
getPath
-
findNodeByPath
-
findByName
-
searchTree
-
getPathToFirstLeaf
-