|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.wisc.ssec.mcidasv.util.TreePanel
public class TreePanel
This class shows a tree on the left and a card panel on the right.
Nested Class Summary | |
---|---|
private static class |
TreePanel.MyTreeNode
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 | |
---|---|
private Map<String,Component> |
catComponents
_more_ |
static String |
CATEGORY_DELIMITER
|
private Map<String,DefaultMutableTreeNode> |
catToNode
Maps categories to tree node. |
private Map<Component,DefaultMutableTreeNode> |
compToNode
Maps components to tree node. |
private JPanel |
emptyPanel
_more_ |
private boolean |
okToSave
Whether or not it is okay to save. |
private boolean |
okToUpdateTree
Okay to respond to selection changes. |
private GuiUtils.CardLayoutPanel |
panel
The panel. |
private DefaultMutableTreeNode |
root
The root. |
private JTree |
tree
The tree. |
private DefaultTreeModel |
treeModel
The model. |
private JScrollPane |
treeView
The scroller. |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, 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 |
---|
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 | |
---|---|
TreePanel()
Default constructor. |
|
TreePanel(boolean useSplitPane,
int treeWidth)
Constructor that actually does the work. |
Method Summary | |
---|---|
void |
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 |
getPath(DefaultMutableTreeNode node)
|
private static TreePath |
getPathToFirstLeaf(TreePath searchPath)
|
Component |
getVisibleComponent()
|
private String |
loadSavedPath()
|
void |
openAll()
Open all tree paths. |
void |
removeComponent(JComponent component)
_more_ |
private void |
saveCurrentPath(DefaultMutableTreeNode node)
|
private static TreePath |
searchTree(TreePath parent,
List<String> nodes,
int depth)
|
void |
setIcon(Component comp,
ImageIcon icon)
Associate an icon with a component. |
void |
show(Component component)
Show the given component . |
void |
showPath(Component component)
Show the tree node that corresponds to the component. |
void |
showPersistedSelection()
Attempts to select the path from a previous McIDAS-V session. |
static List<String> |
tokenizePath(String path)
|
private void |
treeChanged()
|
void |
valueChanged(TreeSelectionEvent e)
Handle tree selection changed. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String CATEGORY_DELIMITER
private final DefaultMutableTreeNode root
private final DefaultTreeModel treeModel
private final JTree tree
private final JScrollPane treeView
private GuiUtils.CardLayoutPanel panel
private final JPanel emptyPanel
private final Map<String,Component> catComponents
private final Map<String,DefaultMutableTreeNode> catToNode
private final Map<Component,DefaultMutableTreeNode> compToNode
private boolean okToUpdateTree
private boolean okToSave
Constructor Detail |
---|
public TreePanel()
TreePanel(boolean, int)
with
useSplitPane
set to true
and treeWidth
set to
-1
.
public TreePanel(boolean useSplitPane, int treeWidth)
useSplitPane
- Whether or not to use a split pane.treeWidth
- Width of the component containing the tree.Method Detail |
---|
public Component getVisibleComponent()
public void valueChanged(TreeSelectionEvent e)
valueChanged
in interface TreeSelectionListener
e
- Event to handle. Cannot be null
.public void setIcon(Component comp, ImageIcon icon)
comp
- Component to associate with icon
.icon
- Icon to associate with comp
. Should not be
null
.public void addComponent(JComponent component, String category, String label, ImageIcon icon)
component
- componentcategory
- tree category. May be null.label
- Tree node labelicon
- Node icon. May be null.private void treeChanged()
public void addCategoryComponent(String cat, JComponent comp)
cat
- _more_comp
- _more_public void removeComponent(JComponent component)
component
- _more_public void show(Component component)
component
.
component
- Component to show. Should not be null
.public void showPath(Component component)
component
- Component whose corresponding tree node to show. Should not be null
.public void openAll()
public void closeAll()
public void showPersistedSelection()
This method also sets okToSave
to true
, so that
user selections can be captured after this method quits.
private void saveCurrentPath(DefaultMutableTreeNode node)
private String loadSavedPath()
public static List<String> tokenizePath(String path)
public static String getPath(DefaultMutableTreeNode node)
public static DefaultMutableTreeNode findNodeByPath(JTree tree, String path)
public static TreePath findByName(JTree tree, List<String> names)
private static TreePath searchTree(TreePath parent, List<String> nodes, int depth)
private static TreePath getPathToFirstLeaf(TreePath searchPath)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |