|
||||||||||
| 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.JTree
ucar.unidata.ui.XmlTree
public class XmlTree
A generic JTree that displays an xml document. Can be configured in a variety of ways to show or not show certain tags, etc.
| Nested Class Summary | |
|---|---|
class |
XmlTree.MyRenderer
Class MyRenderer is used to return the correct image icon for certain jtree nodes |
static class |
XmlTree.XlinkTreeNode
Class XlinkTreeNode. |
static class |
XmlTree.XmlTreeNode
Class XmlTreeNode |
| Nested classes/interfaces inherited from class javax.swing.JTree |
|---|
JTree.AccessibleJTree, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirector |
| 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.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
static String |
ATTR_LABEL
xml attribute |
static String |
ATTR_NAME
xml attribute |
static String |
ATTR_XLINKHREF
xml attribute |
static String |
NULL_STRING
the null string |
| 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 | |
|---|---|
XmlTree(Element xmlRoot)
ctor |
|
XmlTree(Element xmlRoot,
boolean openFirstLevel)
ctor |
|
XmlTree(Element xmlRoot,
boolean openFirstLevel,
String basePath)
ctor |
|
| Method Summary | |
|---|---|
void |
addTagsToNotProcess(List tags)
Define the set of tags we should NOT process |
void |
addTagsToNotProcessButRecurse(List tags)
Define the set of tags that we don't want to add to the jtree but do want to recurse |
void |
addTagsToNotRecurse(List tags)
Define the set of tags whose children we should NOT process |
void |
addTagsToProcess(List tags)
Define the set of tags who we should process |
void |
addTagsToRecurse(List tags)
Define the set of tags whose child elements we should process |
void |
addTagToNotProcess(String tag)
Define a tag we should NOT process |
void |
addTagToNotRecurse(String tag)
Define a tag whose children we should NOT process |
void |
addTagToProcess(String tag)
Define a tag who we should process |
void |
addTagToRecurse(String tag)
Define a tag whose child elements we should process |
void |
addXlinkTag(String tagName)
Define a tag name that holds xlink references to other xml files |
void |
defineLabelAttr(String tagName,
String attrName)
Define the name of the attribute to use for a label for elements with the given tag name |
void |
defineLabelChild(String tagName,
String childTag)
Where do we get the label for the tag |
void |
defineTooltipChild(String tagName,
String childTag)
Where do we get the tooltip text |
void |
doClick(XmlTree tree,
Element element)
tree node was clicked |
void |
doClick(XmlTree tree,
XmlTree.XmlTreeNode node,
Element element)
tree node was clicked |
void |
doDoubleClick(XmlTree tree,
Element element)
Gets called when an Xml Element has been double clicked. |
void |
doDoubleClick(XmlTree tree,
XmlTree.XmlTreeNode node,
Element element)
Gets called when an Xml Element has been double clicked. |
void |
doRightClick(XmlTree tree,
Element element,
MouseEvent event)
Handle right click |
void |
doRightClick(XmlTree tree,
XmlTree.XmlTreeNode node,
Element element,
MouseEvent event)
Handle right click |
String |
expandRelativeUrl(String href)
Utility to expand a relative url wrt to a base url |
static String |
expandRelativeUrl(String href,
String baseUrlPath)
Utility to expand a relative url wrt to a base url |
protected void |
expandXlink(XmlTree.XlinkTreeNode node,
String href)
expand the xlink node |
void |
fireTreeWillExpand(TreePath treePath)
Fire the event |
Component |
getContents()
Return the gui component. |
protected ImageIcon |
getIcon(Element xmlNode,
boolean isLeaf)
Get the icon used for the node |
boolean |
getIncludeAttributes()
Get the IncludeAttributes property. |
String |
getLabel(Element n)
Return the String used for the JTree node. |
JScrollPane |
getScroller()
Get the scrollpane the xmltree is in |
Element |
getSelectedElement()
Find the xml element that corresponds to the selected jtree node |
List |
getSelectedElements()
Return a list of the xml Element nodes that have been selected. |
String |
getToolTipText(Element n)
A hook to allow subclasses to get tooltip text for a particular xml element |
String |
getToolTipText(MouseEvent event)
Get the tooltip at the mouse |
boolean |
getUseTagNameAsLabel()
Get the UseTagNameAsLabel property. |
protected int |
getXlinkImportLevel()
When we load in an xlinked document how far down do we go before we start displaying the nodes |
Element |
getXmlElement(TreeNode treeNode)
Return the xml Element that corresponds to the given tree node |
Element |
getXmlNodeAt(int x,
int y)
Return the xml Element located at the given position |
protected Element |
getXmlNodeAtPath(TreePath path)
Return the xml Element located at the given position |
Element |
getXmlRoot()
Return the root element of the xml dom |
XmlTree.XmlTreeNode |
getXmlTreeNodeAt(int x,
int y)
Return the xml tree node located at the given position |
protected XmlTree.XmlTreeNode |
getXmlTreeNodeAtPath(TreePath path)
Return the xml tree node located at the given position |
protected boolean |
initXlinkRoot(Element root,
Document doc,
String url)
Allows derived classes to initialize the xlink loaded xml |
void |
loadTree()
Reload the xml into the jtree |
static void |
main(String[] args)
Test |
protected void |
process(XmlTree.XmlTreeNode parentTreeNode,
Element xmlNode)
Walk the xml tree at the given xmlNode and create the JTree |
protected Document |
readXlinkXml(String href)
Process the xlink href |
void |
selectElement(Element element)
Select in the jtree the node that corresponds to the given xml element |
void |
setIconForTag(ImageIcon icon,
String tagName)
Associate the icon with the tag |
void |
setIncludeAttributes(boolean value)
Set the IncludeAttributes property. |
void |
setMultipleSelect(boolean v)
Set tree select mode |
void |
setUseTagNameAsLabel(boolean value)
Set the UseTagNameAsLabel property. |
void |
setXmlRoot(Element newRoot)
Set the root and reinitialize |
protected boolean |
shouldProcess(Element xmlNode)
Should we show the given xml Element |
protected boolean |
shouldRecurse(Element xmlNode)
Should we recursiely descend the children of the given xml Element |
protected void |
treeClick(MouseEvent event)
Gets called when the tree is clicked. |