public class PdoTree extends FormTree implements TreeWillExpandListener, DragSourceListener, DragGestureListener, DropTargetListener
FormTree that implements object navigation,
drag and drop, clipboard functionality for PersistentDomainObjects,
and provides a context-sensitive popup menu,JTree.AccessibleJTree, JTree.DropLocation, JTree.DynamicUtilTreeNode, JTree.EmptySelectionModel, JTree.TreeModelHandler, JTree.TreeSelectionRedirectorJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
protected JMenuItem |
collapseItem |
protected JMenuItem |
copyItem |
protected JMenuItem |
deleteItem |
protected JMenuItem |
editItem |
protected JMenuItem |
expandItem |
protected JMenuItem[] |
extraItems
additional popup menu items from TreeExtension.
|
protected JSeparator |
extraSeparator
!= null if sep.
|
protected GuiProvider |
guiProvider
current GUI provider.
|
protected JMenuItem |
insertItem |
protected JMenuItem |
makeTableItem |
protected Runnable |
openEditor
!= null if object provides special editor.
|
protected JMenuItem |
openItem |
protected JPopupMenu |
popupMenu |
protected DefaultMutableTreeNode |
popupNode
current node for popup.
|
protected PersistentDomainObject |
popupObject
current object for popup.
|
protected TreePath |
popupPath
current path for popup.
|
protected JMenuItem |
selectAllItem |
protected JMenuItem |
showItem |
protected JMenuItem |
subTreeItem |
protected JMenuItem[] |
toggleItems
optional togglenode menu items.
|
protected JSeparator |
toggleSeparator
!= null if sep.
|
protected JMenuItem |
usageMenuItem
!= null if usage menu item available.
|
protected PdoTreeExtensionUsageToggleNode |
usageToggleNode
!= null if usage toggle node available.
|
CLICK_ACTION, ENTER_ACTIONANCHOR_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, visibleRowCountlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWaccessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
PdoTree()
Creates an empty tree.
|
PdoTree(Collection<?> objects)
Creates a tree.
If the given object is a Collection the objects of the collection
will be shown in the tree. |
PdoTree(Object object)
Creates a tree.
If the given object is a Collection the objects of the collection
will be shown in the tree. |
| Modifier and Type | Method and Description |
|---|---|
void |
buildTree(Collection<?> col)
Builds the tree from a collection of objects.
|
void |
collapseAll()
Collapses all childnodes of the root.
|
String |
convertValueToText(Object value,
boolean selected,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) |
TreeCellRenderer |
createDefaultRenderer()
Creates the default tree cell renderer.
The default implementation returns a PdoTreeCellRenderer. |
void |
doCollapsePath(TreePath path)
Collapses a given path.
The method invokes collapsePath and set expanded=false
in all PdoTreeObject-nodes. |
void |
doExpandPath(int level,
int maxLevel,
PersistentDomainObject<?> stopObject,
TreePath path)
Recursively expands the path.
|
void |
dragDropEnd(DragSourceDropEvent event) |
void |
dragEnter(DragSourceDragEvent event) |
void |
dragEnter(DropTargetDragEvent dtde) |
void |
dragExit(DragSourceEvent event) |
void |
dragExit(DropTargetEvent dte) |
void |
dragGestureRecognized(DragGestureEvent event) |
void |
dragOver(DragSourceDragEvent event) |
void |
dragOver(DropTargetDragEvent dtde) |
void |
drop(DropTargetDropEvent dtde) |
void |
dropActionChanged(DragSourceDragEvent event) |
void |
dropActionChanged(DropTargetDragEvent dtde) |
void |
expandTree()
Expands all items in this tree, unlimited.
|
void |
expandTree(int maxLevel)
Expands all items in this tree.
|
DefaultMutableTreeNode |
findNodeInCollection(Object object)
Finds the treenode for an object which is part of the displayed collection.
|
TreePath |
findPathInCollection(Object object)
Find the treepath for an object which is part of the displayed collection.
|
int |
getMaxDepthForExtractPath()
Gets the maximum treepath depth up to which the "extract path"-button
is displayed in the popupmenu.
|
static Object |
getObjectInParentNode(DefaultMutableTreeNode node)
Helper method for applications to get the object of the parent node.
|
Collection<?> |
getObjects()
Gets the objects (first level) of this tree.
|
boolean |
isObjectAppendable(Object childObject)
Checks whether the given object is appendable.
An object is appendable if it is not null, not an PersistentDomainObject or an PersistentDomainObject with granted read permission. |
boolean |
isObjectInChilds(Object childObject,
DefaultMutableTreeNode node)
Checks whether given object is in some of the child paths down to the leafs.
Used to detect recursion loops. |
boolean |
isObjectInParents(Object childObject,
DefaultMutableTreeNode node)
Checks whether given object is in path (parents to root) or not.
Used to detect recursion loops. |
boolean |
isPopupEnabled()
Returns whether popup-menu for nodes are enabled.
|
boolean |
pathConsistsOfPdos(TreePath path)
Checks whether a path contains only
PersistentDomainObjects. |
void |
refreshCurrentNode()
Refreshes the view of the current node.
|
void |
requestFocusForFirstItem()
Transfer the focus to the first item in tree.
|
void |
setMaxDepthForExtractPath(int maxDepth)
Sets the maximum treepath depth up to which the "extract path"-button
is displayed in the popupmenu.
|
void |
setPopupEnabled(boolean enabled)
Enables/disables the popup-menu for nodes.
|
void |
showPopup()
Shows the popup menu at current selection.
|
void |
treeWillCollapse(TreeExpansionEvent e) |
void |
treeWillExpand(TreeExpansionEvent e) |
addActionListener, fireActionPerformed, getClickCount, removeActionListeneraddSelectionInterval, addSelectionPath, addSelectionPaths, addSelectionRow, addSelectionRows, addTreeExpansionListener, addTreeSelectionListener, addTreeWillExpandListener, cancelEditing, clearSelection, clearToggledPaths, collapsePath, collapseRow, 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, updateUIaddAncestorListener, 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, updateadd, 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, validateTreeaction, 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, 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, transferFocusBackward, transferFocusUpCycleprotected PersistentDomainObject popupObject
protected GuiProvider guiProvider
protected DefaultMutableTreeNode popupNode
protected TreePath popupPath
protected Runnable openEditor
protected PdoTreeExtensionUsageToggleNode usageToggleNode
protected JMenuItem usageMenuItem
protected JMenuItem[] toggleItems
protected JSeparator toggleSeparator
protected JMenuItem[] extraItems
protected JSeparator extraSeparator
protected JMenuItem collapseItem
protected JMenuItem copyItem
protected JMenuItem deleteItem
protected JMenuItem editItem
protected JMenuItem expandItem
protected JMenuItem insertItem
protected JMenuItem makeTableItem
protected JMenuItem openItem
protected JPopupMenu popupMenu
protected JMenuItem selectAllItem
protected JMenuItem showItem
protected JMenuItem subTreeItem
public PdoTree(Collection<?> objects)
Collection the objects of the collection
will be shown in the tree. If it is some other object, only that
object is shown.PersistentDomainObjects.objects - the objects, null if empty treepublic PdoTree(Object object)
Collection the objects of the collection
will be shown in the tree. If it is some other object, only that
object is shown.PersistentDomainObjects.object - the object or collection of objects, null if empty treepublic PdoTree()
public static Object getObjectInParentNode(DefaultMutableTreeNode node)
node - the child nodepublic Collection<?> getObjects()
public TreeCellRenderer createDefaultRenderer()
PdoTreeCellRenderer.public String convertValueToText(Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus)
Overridden to render the domainkey if value is a PDO.
Useful if the toString() method, for whatever reason, does not return
the domain key.
convertValueToText in class JTreepublic void setPopupEnabled(boolean enabled)
enabled - true to enable popup menus (default)public boolean isPopupEnabled()
public void setMaxDepthForExtractPath(int maxDepth)
maxDepth - the maximum path depthpublic int getMaxDepthForExtractPath()
public void showPopup()
public void buildTree(Collection<?> col)
col - the collection, null to set the empty collectionpublic void expandTree(int maxLevel)
maxLevel - is the maximum number of levels to expand, 0 = allpublic void expandTree()
public void requestFocusForFirstItem()
public boolean isObjectAppendable(Object childObject)
childObject - the object to appendpublic boolean isObjectInParents(Object childObject, DefaultMutableTreeNode node)
childObject - the object to checknode - the node to start the search up to the rootpublic boolean isObjectInChilds(Object childObject, DefaultMutableTreeNode node)
childObject - the object to checknode - the node to start the search up to the rootpublic void doExpandPath(int level,
int maxLevel,
PersistentDomainObject<?> stopObject,
TreePath path)
level - is the current tree level, 0 = topmaxLevel - is the maximum level not to exceed, 0 = unlimitedstopObject - stops expansion if object met, null = unlimitedpath - is the path to expandpublic void doCollapsePath(TreePath path)
collapsePath and set expanded=false
in all PdoTreeObject-nodes. Furthermore, all nodes
referring to PdoTreeToggleNodeObjects will get their childs removed.
Tentackle applications should not use collapsePath directly.path - the tree path to collapseJTree.collapsePath(javax.swing.tree.TreePath)public boolean pathConsistsOfPdos(TreePath path)
PersistentDomainObjects.path - the tree pathPersistentDomainObjects.public void treeWillExpand(TreeExpansionEvent e) throws ExpandVetoException
Loads child objects from the database.
treeWillExpand in interface TreeWillExpandListenere - the expansion eventExpandVetoException - if expanding not allowedpublic void treeWillCollapse(TreeExpansionEvent e)
The default implementation does nothing. Applications may override.
treeWillCollapse in interface TreeWillExpandListenere - the expansion eventpublic void dragGestureRecognized(DragGestureEvent event)
The default implementation creates the transferable and starts the drag
if the node refers to an PersistentDomainObject or PdoTreeExtension.
dragGestureRecognized in interface DragGestureListenerevent - the gesture eventpublic void dragEnter(DragSourceDragEvent event)
The default implementation does nothing. Provided to be overridden.
dragEnter in interface DragSourceListenerevent - the drag source eventpublic void dragOver(DragSourceDragEvent event)
The default implementation does nothing. Provided to be overridden.
dragOver in interface DragSourceListenerevent - the drag source eventpublic void dragExit(DragSourceEvent event)
The default implementation does nothing. Provided to be overridden.
dragExit in interface DragSourceListenerevent - the drag source eventpublic void dropActionChanged(DragSourceDragEvent event)
The default implementation does nothing. Provided to be overridden.
dropActionChanged in interface DragSourceListenerevent - the drag source eventpublic void dragDropEnd(DragSourceDropEvent event)
The default implementation does nothing. Provided to be overridden.
dragDropEnd in interface DragSourceListenerevent - the drag source eventpublic void dragEnter(DropTargetDragEvent dtde)
The default implementation does nothing. Provided to be overridden.
dragEnter in interface DropTargetListenerdtde - the drop target drag eventpublic void dragOver(DropTargetDragEvent dtde)
Overridden to check whether to accept the drag or not.
dragOver in interface DropTargetListenerdtde - the drop target drag eventpublic void dropActionChanged(DropTargetDragEvent dtde)
The default implementation does nothing. Provided to be overridden.
dropActionChanged in interface DropTargetListenerdtde - the drop target drag eventpublic void dragExit(DropTargetEvent dte)
The default implementation does nothing. Provided to be overridden.
dragExit in interface DropTargetListenerdte - the drop target eventpublic void drop(DropTargetDropEvent dtde)
Overridden to insert the object.
drop in interface DropTargetListenerdtde - the drop target drop eventGuiProvider.dropTransferable(java.awt.datatransfer.Transferable)public DefaultMutableTreeNode findNodeInCollection(Object object)
object - the objectpublic TreePath findPathInCollection(Object object)
object - the objectpublic void collapseAll()
public void refreshCurrentNode()
Tentackle - distributed, domain- and model-driven