org.ceryle.ui.search
Class SearchTree
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTree
org.ceryle.ui.search.SearchTree
- All Implemented Interfaces:
- ImageObserver, MenuContainer, Serializable, Accessible, Scrollable
public class SearchTree
- extends JTree
Extends JTree providing a tree view of available search domains as well as
search results. This may come potentially from database XNodeCollections
and their nodes/documents as well as the filesystem.
Note: after instantiation, the method setRoot() must be called
to initialize the root.
- Since:
- JDK1.4
- Version:
- $Id: SearchTree.java,v 1.16 2007-06-20 04:41:24 altheim Exp $
- Author:
- Murray Altheim
- See Also:
- Serialized Form
| Fields 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, treeModel, treeModelListener, VISIBLE_ROW_COUNT_PROPERTY, visibleRowCount |
|
Method Summary |
DefaultMutableTreeNode |
addCollection(XNodeCollection collection,
int index,
boolean show)
Add the XNodeCollection with ID cid at position index of the tree,
returning the created DefaultMutableTreeNode. |
DefaultMutableTreeNode |
addDirectory(File dir,
int index,
boolean show)
Add the directory (File) at position index of the tree, returning
the created DefaultMutableTreeNode. |
DefaultMutableTreeNode |
addDocument(DefaultMutableTreeNode colNode,
String nid,
int index)
Add the Document with nid to the provided XNodeCollection's
DefaultMutableTreeNode, at the location index. |
DefaultMutableTreeNode |
addXNode(XNodeID xid)
Add the Document specified by the XNodeID xid to the tree. |
Set |
getAllCollections()
Return the Set of XNodeCollections comprising all collections in the tree,
empty if none are set. |
Set |
getAllDirectories()
Return the Set of URLs comprising all directories in the tree, empty if
none are set. |
int |
getCollectionCount()
Return the count of all collections in the tree. |
int |
getDirectoryCount()
Return the count of all directories in the tree. |
Iterator |
getSelectedCollectionIDs()
Returns an Iterator over the IDs of the selected collections of this SearchTree,
in the order they occur within the current list. |
Set |
getSelectedCollections()
Returns a Set containing the selected directories of this SearchTree. |
Set |
getSelectedDirectories()
Returns a Set containing the selected directories of this SearchTree. |
int[] |
getSelectionInfo()
Returns an int array containing:
[0] the current number of selected XNodeCollections;
[1] the total number of collections;
[2] the number of selected directories; and
[3] the total number of directories. |
void |
initialDisplay()
Set initial display state, showing and unexpanded database and any directories. |
void |
populateCollection(DefaultMutableTreeNode colNode,
String cid)
Populate the provided XNodeCollection with its Documents. |
void |
populateTree(boolean includeDocuments)
Populate the tree from its root. |
Iterator |
removeSelectedDirectories()
Removes the selected directories from this SearchTree, returning
true if any were removed. |
void |
reset()
Clear the list, resetting the root. |
void |
selectDBRoot()
Select the database root node. |
void |
setExpandedStateAll(boolean state)
Expands all Collections. |
protected void |
setRoot()
Create the tree root, and add the database root to it. |
| 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, 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, 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, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, transferFocusBackward, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, transferFocusUpCycle |
includeEmptyCollections
public static boolean includeEmptyCollections
- When true (the default), empty collections are included in the list.
rootTitle
protected String rootTitle
- The optional root node title. When null, the root node is not displayed.
m_rootNode
protected DefaultMutableTreeNode m_rootNode
m_dbRootNode
protected DefaultMutableTreeNode m_dbRootNode
m_dbRootPath
protected TreePath m_dbRootPath
SearchTree
public SearchTree(FindReplaceDialog parent,
String title)
- Constructor for a dialog box for entering an XML Name. The supplied
options can be either be a List of Strings, a List of String[] or
Object[], the latter if the first two Objects are Strings (any more
than the first two are ignored).
- Parameters:
title - the optional title for the root node (if null the root will not be shown)
reset
public void reset()
throws SearchException
- Clear the list, resetting the root.
- Throws:
SearchException - if unable to set the root collection.
setRoot
protected void setRoot()
throws SearchException
- Create the tree root, and add the database root to it.
This will fail if there are no XNodeCollections.
- Throws:
SearchException
initialDisplay
public void initialDisplay()
- Set initial display state, showing and unexpanded database and any directories.
selectDBRoot
public void selectDBRoot()
- Select the database root node.
setExpandedStateAll
public void setExpandedStateAll(boolean state)
- Expands all Collections.
addXNode
public DefaultMutableTreeNode addXNode(XNodeID xid)
throws XNodeException
- Add the Document specified by the XNodeID xid to the tree.
The Document is added at the end of its respective XNodeCollection's list
of children, and if the XNodeCollection does not exist, it is added at
the end of the list of XNodeCollections.
is thrown.
- Returns:
- the DefaultMutableTreeNode for the Document
- Throws:
XNodeException - if the XNodeCollection ID does not exist or any
problem occurs in creating the tree node.
addCollection
public DefaultMutableTreeNode addCollection(XNodeCollection collection,
int index,
boolean show)
throws XNodeException
- Add the XNodeCollection with ID cid at position index of the tree,
returning the created DefaultMutableTreeNode. If this already exists, it is
returned. If the provided index is -1, the XNodeCollection will be added at the end.
- Parameters:
collection - the XNodeCollection to be added to the treeindex - the location at which to insert the XNodeCollection in the list (-1 will be at end)show - if true, the XNodeCollection will be made explicitly visible
- Returns:
- the created or already existing DefaultMutableTreeNode
- Throws:
XNodeException
addDocument
public DefaultMutableTreeNode addDocument(DefaultMutableTreeNode colNode,
String nid,
int index)
throws XNodeException
- Add the Document with nid to the provided XNodeCollection's
DefaultMutableTreeNode, at the location index. If the index
is -1, the Document is added at the end of the list of children.
- Returns:
- the DefaultMutableTreeNode for the Document
- Throws:
XNodeException
getAllCollections
public Set getAllCollections()
- Return the Set of XNodeCollections comprising all collections in the tree,
empty if none are set.
getCollectionCount
public int getCollectionCount()
- Return the count of all collections in the tree.
This does not include the DB root.
getSelectedCollections
public Set getSelectedCollections()
- Returns a Set containing the selected directories of this SearchTree.
The order within the Set is not guaranteed to match that of the tree.
getSelectedCollectionIDs
public Iterator getSelectedCollectionIDs()
- Returns an Iterator over the IDs of the selected collections of this SearchTree,
in the order they occur within the current list.
getAllDirectories
public Set getAllDirectories()
- Return the Set of URLs comprising all directories in the tree, empty if
none are set.
getDirectoryCount
public int getDirectoryCount()
- Return the count of all directories in the tree.
getSelectedDirectories
public Set getSelectedDirectories()
- Returns a Set containing the selected directories of this SearchTree.
The order within the Set is not guaranteed to match that of the tree.
addDirectory
public DefaultMutableTreeNode addDirectory(File dir,
int index,
boolean show)
throws IOException
- Add the directory (File) at position index of the tree, returning
the created DefaultMutableTreeNode. If this already exists, it is returned.
If the provided index is -1, the directory will be added at the end.
Note that the directory is actually added as a URL.
- Parameters:
dir - the directory to be added to the treeindex - the location at which to insert the XNodeCollection in the list (-1 will be at end)show - if true, the directory will be made explicitly visible
- Returns:
- the created or already existing DefaultMutableTreeNode
- Throws:
IOException - if any problem occurs adding it to the tree, or if the directory does not exist.
removeSelectedDirectories
public Iterator removeSelectedDirectories()
- Removes the selected directories from this SearchTree, returning
true if any were removed. Returns an iterator over the removed
directories (as File objects). If none are removed, returns an
empty Iterator, not null.
populateTree
public void populateTree(boolean includeDocuments)
- Populate the tree from its root. If includeDocuments is
true, this will include all XNodeCollections and Documents.
populateCollection
public void populateCollection(DefaultMutableTreeNode colNode,
String cid)
throws XNodeException
- Populate the provided XNodeCollection with its Documents.
- Throws:
XNodeException
getSelectionInfo
public int[] getSelectionInfo()
- Returns an int array containing:
[0] the current number of selected XNodeCollections;
[1] the total number of collections;
[2] the number of selected directories; and
[3] the total number of directories.
Returns an empty array on failure.
The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.