com.ca.directory.jxplorer.tree
Class SmartPopupTool

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPopupMenu
                          |
                          +--com.ca.directory.jxplorer.tree.SmartPopupTool
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.MenuElement, java.io.Serializable

public class SmartPopupTool
extends javax.swing.JPopupMenu
implements java.awt.event.ActionListener

This is the small popup menu that appears when a manager left-clicks (or system-dependant-whatever-s) on the display tree, allowing them to cut/copy/paste/delete/rename tree elements

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPopupMenu
javax.swing.JPopupMenu.AccessibleJPopupMenu, javax.swing.JPopupMenu.Separator
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
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
SmartPopupTool(SmartTree owningTree)
          Constructor initialises the drop down menu and menu items, and registers 'this' component as being the listener for all the menu items.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ev)
          This handles the menu item actions.
protected  boolean checkAction(java.lang.String operationType)
          This checks to see if the 'confirm tree operations' option is on.
 void copy()
          'Copies' a subtree by registering the DN of the copied branch, which is accessed by the paste ftn
 void copy(DN copyFrom, DN copyTo)
          Copys (in the directory) the selected Dn to the new destination.
 void copyDN()
          Copies a previously selected entry (and it's children) to the new position, under the current selection.
 void cut()
          'Cuts' a subtree by registering the DN of the cut branch, which is accessed by the paste ftn. - the @paste ftn then has responsibility for moving the subtree.
 void delete()
          Deletes the currently selected entry.
 void dragCopy(DN copyFrom, DN copyTo)
          Copys (in the directory) the selected DN to the new destination.
 void dragMove(DN moveFrom, DN moveTo)
          Move the node to another location (performs a cut operation).
 DN getActiveDN()
           
 SmartNode getActiveNode()
          Returns the most recently selected tree node.
 javax.swing.tree.TreePath getActivePath()
          Returns the last set active path (e.g. the TreePath corresponding to the last highlighted tree node).
 void move(DN moveFrom, DN moveTo)
          Move the node to another location (performs a cut operation).
 void newEntry()
          Uses the tree to start the process of creating a new entry.
 void paste()
          The paste ftn either copies or moves a pre-selected subtree depending
 void pasteAlias()
          Creates an alias of the currently copied or copyDN-ed entry
 void refresh()
          Reads the directory to refresh the currently selected entry's data and it's immediate children.
 void rename()
          Starts the tree cell editor on the currently selected entry.
 void setEnabled(boolean enable)
          sets functionality on or off (i.e. sets whether the tree is or isn't modifiable).
 void setModifiable(boolean canModify)
          This sets whether the popup tool will show functions that will modify the directory.
 void setNewEntryEnabled(boolean enable)
           
 void show(java.awt.Component invoker, int x, int y)
          This displays the popup tool at the right spot.
 
Methods inherited from class javax.swing.JPopupMenu
add, add, add, addPopupMenuListener, addSeparator, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SmartPopupTool

public SmartPopupTool(SmartTree owningTree)
Constructor initialises the drop down menu and menu items, and registers 'this' component as being the listener for all the menu items.

Method Detail

show

public void show(java.awt.Component invoker,
                 int x,
                 int y)
This displays the popup tool at the right spot. Some special magic here allows us to set the state of the popup tool if we want.

Overrides:
show in class javax.swing.JPopupMenu

getActivePath

public javax.swing.tree.TreePath getActivePath()
Returns the last set active path (e.g. the TreePath corresponding to the last highlighted tree node).


getActiveNode

public SmartNode getActiveNode()
Returns the most recently selected tree node.


getActiveDN

public DN getActiveDN()

setEnabled

public void setEnabled(boolean enable)
sets functionality on or off (i.e. sets whether the tree is or isn't modifiable).

Overrides:
setEnabled in class javax.swing.JComponent
Parameters:
enable - the status to set the popuptool to.

setModifiable

public void setModifiable(boolean canModify)
This sets whether the popup tool will show functions that will modify the directory.


setNewEntryEnabled

public void setNewEntryEnabled(boolean enable)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ev)
This handles the menu item actions. They rely on 'activeDN' being set prior to this method being called (usually by setActivePath() above). Most of the action handling is simply tossing arguments to the treeDataSource, and any required tree methods to reflect the changes made.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
ev - the active event, i.e. the menu item selected

cut

public void cut()
'Cuts' a subtree by registering the DN of the cut branch, which is accessed by the paste ftn. - the @paste ftn then has responsibility for moving the subtree.


copy

public void copy()
'Copies' a subtree by registering the DN of the copied branch, which is accessed by the paste ftn. - the @paste ftn then has responsibility for copying the subtree.


checkAction

protected boolean checkAction(java.lang.String operationType)
This checks to see if the 'confirm tree operations' option is on. If it is, it sticks up an annoying dialog box to ask the user whether they actually want to do what they just asked to do.

Parameters:
operationType - the type of operation being performed e.g. delete, copy etc.

paste

public void paste()
The paste ftn either copies or moves a pre-selected subtree depending


dragMove

public void dragMove(DN moveFrom,
                     DN moveTo)
Move the node to another location (performs a cut operation). Currently this is being used by the drag functionality - the difference between this method and the move(DN moveFrom, DN moveTo) method is purely that this method does NOT show a confirmation message even if that option is set to true by the user.

Parameters:
moveFrom - the DN of the entry to be moved (or cut).
moveTo - the new DN of the entry i.e. where it will be cut to.

move

public void move(DN moveFrom,
                 DN moveTo)
Move the node to another location (performs a cut operation).

Parameters:
moveFrom - the DN of the entry to be moved (or cut).
moveTo - the new DN of the entry i.e. where it will be cut to.

dragCopy

public void dragCopy(DN copyFrom,
                     DN copyTo)
Copys (in the directory) the selected DN to the new destination. The copied entry/subtree is placed *under* the destination node. Currently this is being used by the drag functionality - the difference between this method and the copy(DN copyFrom, DN copyTo) method is purely that this method does NOT show a confirmation message even if that option is set to true by the user.

Parameters:
copyFrom - the DN of an entry or subtree apex to copy entries from
copyTo - the location to copy to.

copy

public void copy(DN copyFrom,
                 DN copyTo)
Copys (in the directory) the selected Dn to the new destination. The copied entry/subtree is placed *under* the destination node.

Parameters:
copyFrom - the DN of an entry or subtree apex to copy entries from
copyTo - the location to copy to.

delete

public void delete()
Deletes the currently selected entry.


rename

public void rename()
Starts the tree cell editor on the currently selected entry.


newEntry

public void newEntry()
Uses the tree to start the process of creating a new entry.


pasteAlias

public void pasteAlias()
Creates an alias of the currently copied or copyDN-ed entry


refresh

public void refresh()
Reads the directory to refresh the currently selected entry's data and it's immediate children.


copyDN

public void copyDN()
Copies a previously selected entry (and it's children) to the new position, under the current selection.