Package noaa.coastwatch.gui.open
Class XMLTree
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
noaa.coastwatch.gui.open.XMLTree
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,Accessible
,Scrollable
A JTree that displays an xml document.
- Since:
- 3.3.0
- Author:
- Xiaoming Liu
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Class XmlNodeListclass
Class XmlTreeNodeNested classes/interfaces inherited from class javax.swing.JTree
JTree.AccessibleJTree, JTree.DropLocation, 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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
xml attributestatic final String
xml attributestatic final String
the null stringFields inherited from class javax.swing.JTree
ANCHOR_SELECTION_PATH_PROPERTY, CELL_EDITOR_PROPERTY, CELL_RENDERER_PROPERTY, cellEditor, cellRenderer, editable, EDITABLE_PROPERTY, EXPANDS_SELECTED_PATHS_PROPERTY, INVOKES_STOP_CELL_EDITING_PROPERTY, invokesStopCellEditing, LARGE_MODEL_PROPERTY, largeModel, LEAD_SELECTION_PATH_PROPERTY, ROOT_VISIBLE_PROPERTY, rootVisible, ROW_HEIGHT_PROPERTY, rowHeight, SCROLLS_ON_EXPAND_PROPERTY, scrollsOnExpand, SELECTION_MODEL_PROPERTY, selectionModel, selectionRedirector, SHOWS_ROOT_HANDLES_PROPERTY, showsRootHandles, TOGGLE_CLICK_COUNT_PROPERTY, toggleClickCount, TREE_MODEL_PROPERTY, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addTagsToProcess
(List tags) Define the set of tags who we should processboolean
getAttribute
(NamedNodeMap attrs, String name, String dflt) Get the given name-d attribute from the given attrs map.getAttribute
(Node element, String name, String dflt) Get the given name-d attribute from the given element.getChildText
(Node parent) Concatenates the node values (grom getNodeValue) of the children of the given parent Node.getElement
(Element parent, String tagName) Get the first Element children of the given parent Element with the given tagName.getElements
(Element parent) Get all children of the given parent Element who are instances of the Element class.getElements
(Element parent, String tagName) Get all Element children of the given parent Element with the given tagName.static NodeList
getElements
(Element parent, XMLTree.XmlNodeList nodeList) Get all children of the given parent Element who are instances of the Element class.Return the String used for the JTree node.getLocalName
(Node element) Get the non qualified tag namegetXmlTreeNodeAt
(int x, int y) Return the xml tree node located at the given positionprotected XMLTree.XmlTreeNode
getXmlTreeNodeAtPath
(TreePath path) Return the xml tree node located at the given positionboolean
Checks if the tag name of the given node matches the given name.void
loadDocument
(Element xmlRoot, String basePath) loadDocumentprotected void
process
(XMLTree.XmlTreeNode parentTreeNode, Element xmlNode) Walk the xml tree at the given xmlNode and create the JTreevoid
setMultipleSelect
(boolean v) Set tree select modeprotected boolean
shouldProcess
(Element xmlNode) Should we show the given xml Elementprotected boolean
shouldRecurse
(Element xmlNode) Should we recursiely descend the children of the given xml Elementprotected void
treeClick
(MouseEvent event) Gets called when the tree is clicked.Methods inherited from class javax.swing.JTree
addSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, convertValueToText, createTreeModel, createTreeModelListener, expandPath, expandRow, fireTreeCollapsed, fireTreeExpanded, fireTreeWillCollapse, fireTreeWillExpand, fireValueChanged, getAccessibleContext, getAnchorSelectionPath, getCellEditor, getCellRenderer, getClosestPathForLocation, getClosestRowForLocation, getDefaultTreeModel, getDescendantToggledPaths, getDragEnabled, getDropLocation, getDropMode, getEditingPath, getExpandedDescendants, getExpandsSelectedPaths, getInvokesStopCellEditing, getLastSelectedPathComponent, getLeadSelectionPath, getLeadSelectionRow, getMaxSelectionRow, getMinSelectionRow, getModel, getNextMatch, getPathBetweenRows, getPathBounds, getPathForLocation, getPathForRow, getPreferredScrollableViewportSize, getRowBounds, getRowCount, getRowForLocation, getRowForPath, getRowHeight, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getScrollsOnExpand, getSelectionCount, getSelectionModel, getSelectionPath, getSelectionPaths, getSelectionRows, getShowsRootHandles, getToggleClickCount, getToolTipText, getTreeExpansionListeners, getTreeSelectionListeners, getTreeWillExpandListeners, getUI, getUIClassID, getVisibleRowCount, hasBeenExpanded, isCollapsed, isCollapsed, isEditable, isEditing, isExpanded, isExpanded, isFixedRowHeight, isLargeModel, isPathEditable, isPathSelected, isRootVisible, isRowSelected, isSelectionEmpty, isVisible, makeVisible, paramString, removeDescendantSelectedPaths, removeDescendantToggledPaths, removeSelectionInterval, removeSelectionPath, removeSelectionPaths, removeSelectionRow, removeSelectionRows, removeTreeExpansionListener, removeTreeSelectionListener, removeTreeWillExpandListener, scrollPathToVisible, scrollRowToVisible, setAnchorSelectionPath, setCellEditor, setCellRenderer, setDragEnabled, setDropMode, setEditable, setExpandedState, setExpandsSelectedPaths, setInvokesStopCellEditing, setLargeModel, setLeadSelectionPath, setModel, setRootVisible, setRowHeight, setScrollsOnExpand, setSelectionInterval, setSelectionModel, setSelectionPath, setSelectionPaths, setSelectionRow, setSelectionRows, setShowsRootHandles, setToggleClickCount, setUI, setVisibleRowCount, startEditingAtPath, stopEditing, treeDidChange, 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, 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
-
ATTR_NAME
xml attribute- See Also:
-
ATTR_LABEL
xml attribute- See Also:
-
NULL_STRING
the null string
-
-
Constructor Details
-
XMLTree
ctor- Parameters:
xmlRoot
- The root of the xml dom treebasePath
- Where the xml came from
-
-
Method Details
-
loadDocument
loadDocument- Parameters:
xmlRoot
- The root of the xml dom treebasePath
- Where the xml came from
-
treeClick
Gets called when the tree is clicked.- Parameters:
event
- Mouse event
-
addTagsToProcess
Define the set of tags who we should process- Parameters:
tags
- List of tag names
-
shouldProcess
Should we show the given xml Element- Parameters:
xmlNode
-- Returns:
- Should we look at this node and turn it into a jtree node
-
process
Walk the xml tree at the given xmlNode and create the JTree- Parameters:
parentTreeNode
- The parent jtree nodexmlNode
- The xml node to process
-
shouldRecurse
Should we recursiely descend the children of the given xml Element- Parameters:
xmlNode
- The xml node- Returns:
- Should we recurse down
-
getLabel
Return the String used for the JTree node. This first looks in the tagNameToLabelAttr hashtable for an attribute name to fetch the label. If not found we try the attributes "label" and "name".- Parameters:
n
- The node- Returns:
- Its label
-
getXmlTreeNodeAt
Return the xml tree node located at the given position- Parameters:
x
- xy
- y- Returns:
- The node or null
-
getXmlTreeNodeAtPath
Return the xml tree node located at the given position- Parameters:
path
- The tree path- Returns:
- The node or null
-
setMultipleSelect
public void setMultipleSelect(boolean v) Set tree select mode- Parameters:
v
- Do multiples?
-
getLocalName
Get the non qualified tag name- Parameters:
element
- element- Returns:
- tag name
-
getAttribute
Get the given name-d attribute from the given element.- Parameters:
element
- The xml element to look within.name
- The attribute name.dflt
- The default value.- Returns:
- The attribute value or the dflt if not found.
-
getAttribute
Get the given name-d attribute from the given attrs map. If not found then return the dflt argument.- Parameters:
attrs
- The xml attribute map.name
- The name of the attribute.dflt
- The default value- Returns:
- The attribute valueif found, else the dflt argument.
-
getChildText
Concatenates the node values (grom getNodeValue) of the children of the given parent Node.- Parameters:
parent
- The xml node to search its chidlren.- Returns:
- The text values contained by the children of the given parent.
-
getElement
Get the first Element children of the given parent Element with the given tagName.- Parameters:
parent
- The xml node to search its children.tagName
- The tag to match.- Returns:
- The first Element child that matches the given tag name.
-
getElements
Get all children of the given parent Element who are instances of the Element class.- Parameters:
parent
- The xml node to search its chidlren.- Returns:
- All Element children of the given parent.
-
getElements
Get all Element children of the given parent Element with the given tagName.- Parameters:
parent
- The xml node to search its children.tagName
- The tag to match.- Returns:
- The Element children of the given parent node whose tags match the given tagName.
-
getElements
Get all children of the given parent Element who are instances of the Element class.- Parameters:
parent
- The xml node to search its chidlren.nodeList
- list to add to- Returns:
- All Element children of the given parent.
-
isTag
Checks if the tag name of the given node matches the given name. If the given name is fully qualified (e.g., namespace:tagname) then check if it matches the full name of the node. If the node name is fully qualified and the name isn't then strip off the namespace of the node and compare else just compare the 2- Parameters:
node
- the xml nodename
- name- Returns:
- is non qualified tag name the same
-
equals
-