com.sas.swing.visuals.dualselector
Class JTreeDualSelectorAdapter

com.sas.swing.visuals.dualselector.JTreeDualSelectorAdapter
All Implemented Interfaces:
DualSelectorInterface, DualSelectorTreeInterface, com.sas.swing.visuals.dualselector.DualSelectorV2Interface, java.awt.dnd.DragGestureListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DropTargetListener, java.util.EventListener

public class JTreeDualSelectorAdapter
implements com.sas.swing.visuals.dualselector.DualSelectorV2Interface, DualSelectorTreeInterface, java.awt.dnd.DropTargetListener, java.awt.dnd.DragSourceListener, java.awt.dnd.DragGestureListener

JTreeDualSelectorAdapter is a class that supports using a JTree in a dual selector.

Since:
3.1

Field Summary
protected  javax.swing.JTree component
          the actual JTree component
protected  javax.swing.JScrollPane containerComponent
          a scroll pane used by the JTree component
 java.awt.dnd.DragSource dragSource
          enables this component to be a Drag Source
 java.awt.dnd.DropTarget dropTarget
          enables this component to be a dropTarget
protected  javax.swing.JComponent parentSelector
          the parent component
protected  java.lang.Object sourceTargetNode
          a node in the target tree used add items from the source tree
 
Constructor Summary
JTreeDualSelectorAdapter(javax.swing.JComponent parent)
          Default constructor.
JTreeDualSelectorAdapter(javax.swing.JTree tree, javax.swing.JComponent parent)
          Constructor method that takes a JTree instance for use in the component.
 
Method Summary
 void addItems(java.util.List newItems)
          Adds the items to the component.
 boolean canMove(int[] indices, int offset)
          Determines whether a particular move is allowed.
 void clearSelections()
          Clears the selections made on the component.
 void dragDropEnd(java.awt.dnd.DragSourceDropEvent event)
          this message goes to DragSourceListener, informing it that the dragging has ended
 void dragEnter(java.awt.dnd.DragSourceDragEvent event)
          this message goes to DragSourceListener, informing it that the dragging has entered the DropSite
 void dragEnter(java.awt.dnd.DropTargetDragEvent event)
          is invoked when you are dragging over the DropSite
 void dragExit(java.awt.dnd.DragSourceEvent event)
          this message goes to DragSourceListener, informing it that the dragging has exited the DropSite
 void dragExit(java.awt.dnd.DropTargetEvent event)
          is invoked when you are exit the DropSite without dropping
 void dragGestureRecognized(java.awt.dnd.DragGestureEvent event)
          a drag gesture has been initiated
 void dragOver(java.awt.dnd.DragSourceDragEvent event)
          this message goes to DragSourceListener, informing it that the dragging is currently ocurring over the DropSite
 void dragOver(java.awt.dnd.DropTargetDragEvent event)
          is invoked when a drag operation is going on
 void drop(java.awt.dnd.DropTargetDropEvent event)
          a drop has occurred
 void dropActionChanged(java.awt.dnd.DragSourceDragEvent event)
          is invoked when the user changes the dropAction
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
          is invoked if the use modifies the current drop gesture
 java.util.List getAllItems()
          Returns all items.
 java.util.List getAllMoveableItems()
          Returns all of the items that are moveable based on the status of the movement control options.
 javax.swing.JComponent getComponent()
          Returns the actual component.
 javax.swing.JComponent getContainerComponent()
          Returns the container holding a component.
 int getCount()
          Returns the number of items in the component.
 int getLastSelectedIndex()
          Returns the index of the last item selected.
 int getSelectedCount()
          Returns the number of items selected.
 java.util.List getSelectedItems()
          Returns the user selected items.
 boolean isChildNodesOnlyMoveable()
          Returns true if only the child nodes can be moved.
 boolean isInAdapter(java.lang.Object item)
          Returns true if the item is a member of the adapter model.
 boolean isParentNodeMoveable()
          Returns the true if the parents can be moved, false if not.
 boolean isParentNodeOnlyMoveable()
          Returns the value for moving parent nodes only or parents and children
 void removeItems(java.util.List removeItems)
          Removes the items from the component.
 void setChildNodesOnlyMoveable(boolean nodes)
          Sets the value allowing only child nodes to be moveable.
 void setParentNodesMoveable(boolean moveableParentNodes)
          Sets the value allowing parent nodes to be moved.
 void setParentNodesOnlyMoveable(boolean parentNodesMoveable)
          Sets the value for moving parent nodes only or parents and children
 void setSelectedIndex(int index)
          Selects the item at the specified index.
 void setSourceTargetNode(java.lang.Object sourceTargetNode)
          Sets the target node used to move items from the source component.
 

Field Detail

component

protected javax.swing.JTree component
the actual JTree component


containerComponent

protected javax.swing.JScrollPane containerComponent
a scroll pane used by the JTree component


parentSelector

protected javax.swing.JComponent parentSelector
the parent component


sourceTargetNode

protected java.lang.Object sourceTargetNode
a node in the target tree used add items from the source tree


dropTarget

public java.awt.dnd.DropTarget dropTarget
enables this component to be a dropTarget


dragSource

public java.awt.dnd.DragSource dragSource
enables this component to be a Drag Source

Constructor Detail

JTreeDualSelectorAdapter

public JTreeDualSelectorAdapter(javax.swing.JComponent parent)
Default constructor. Allows specification of a parent component.

Parameters:
parent - the parent component

JTreeDualSelectorAdapter

public JTreeDualSelectorAdapter(javax.swing.JTree tree,
                                javax.swing.JComponent parent)
Constructor method that takes a JTree instance for use in the component.

Parameters:
tree - a JTree instance
parent - the parent component
Method Detail

getCount

public int getCount()
Returns the number of items in the component.

Specified by:
getCount in interface DualSelectorInterface
Returns:
the number of items in the component
See Also:
DualSelectorInterface.getCount()

getSelectedCount

public int getSelectedCount()
Returns the number of items selected.

Specified by:
getSelectedCount in interface DualSelectorInterface
Returns:
the number of selected items
See Also:
DualSelectorInterface.getSelectedCount()

getLastSelectedIndex

public int getLastSelectedIndex()
Returns the index of the last item selected.

Specified by:
getLastSelectedIndex in interface DualSelectorInterface
Returns:
the index of the last selected item
See Also:
DualSelectorInterface.getLastSelectedIndex()

setSelectedIndex

public void setSelectedIndex(int index)
Selects the item at the specified index.

Specified by:
setSelectedIndex in interface DualSelectorInterface
Parameters:
index - the index of the item to be selected
See Also:
DualSelectorInterface.setSelectedIndex(int)

getSelectedItems

public java.util.List getSelectedItems()
Returns the user selected items.

Specified by:
getSelectedItems in interface DualSelectorInterface
Returns:
the selected items
See Also:
DualSelectorInterface.getSelectedItems()

getAllItems

public java.util.List getAllItems()
Returns all items.

Specified by:
getAllItems in interface DualSelectorInterface
Returns:
the items
See Also:
DualSelectorInterface.getAllItems()

getAllMoveableItems

public java.util.List getAllMoveableItems()
Returns all of the items that are moveable based on the status of the movement control options.

Specified by:
getAllMoveableItems in interface DualSelectorInterface
Returns:
a list of all moveable items
See Also:
DualSelectorInterface.getAllMoveableItems()

getContainerComponent

public javax.swing.JComponent getContainerComponent()
Returns the container holding a component.

Specified by:
getContainerComponent in interface DualSelectorInterface
Returns:
the container
See Also:
DualSelectorInterface.getContainerComponent()

getComponent

public javax.swing.JComponent getComponent()
Returns the actual component.

Specified by:
getComponent in interface DualSelectorInterface
Returns:
the component
See Also:
DualSelectorInterface.getComponent()

addItems

public void addItems(java.util.List newItems)
Adds the items to the component.

Specified by:
addItems in interface DualSelectorInterface
Parameters:
newItems - the items to be added.
See Also:
DualSelectorInterface.addItems(List)

setSourceTargetNode

public void setSourceTargetNode(java.lang.Object sourceTargetNode)
Sets the target node used to move items from the source component.

Specified by:
setSourceTargetNode in interface DualSelectorTreeInterface
Parameters:
sourceTargetNode - the tree node used as the target
See Also:
DualSelectorTreeInterface.setSourceTargetNode(Object)

removeItems

public void removeItems(java.util.List removeItems)
Removes the items from the component.

Specified by:
removeItems in interface DualSelectorInterface
Parameters:
removeItems - items to be removed from the component
See Also:
DualSelectorInterface.removeItems(List)

clearSelections

public void clearSelections()
Clears the selections made on the component.

Specified by:
clearSelections in interface DualSelectorInterface
See Also:
DualSelectorInterface.clearSelections()

setParentNodesOnlyMoveable

public void setParentNodesOnlyMoveable(boolean parentNodesMoveable)
Sets the value for moving parent nodes only or parents and children

Parameters:
parentNodesMoveable - set to true if only parents are to be moved.

isParentNodeOnlyMoveable

public boolean isParentNodeOnlyMoveable()
Returns the value for moving parent nodes only or parents and children

Returns:
set to true if only parents are to be moved.

setParentNodesMoveable

public void setParentNodesMoveable(boolean moveableParentNodes)
Sets the value allowing parent nodes to be moved. This setting also affects the movement of parent nodes associated with child nodes. Once a child node is moved to the other tree, it may lose it's association with it's original parent node.

Parameters:
moveableParentNodes - set to true if parents can be selected for move/copy.

isParentNodeMoveable

public boolean isParentNodeMoveable()
Returns the true if the parents can be moved, false if not.

Returns:
true if the parent nodes can be moved, false if not

setChildNodesOnlyMoveable

public void setChildNodesOnlyMoveable(boolean nodes)
Sets the value allowing only child nodes to be moveable.

Parameters:
nodes - set to true if only child nodes are moveable.
See Also:
isChildNodesOnlyMoveable()

isChildNodesOnlyMoveable

public boolean isChildNodesOnlyMoveable()
Returns true if only the child nodes can be moved.

Returns:
true if only the child nodes can be moved
See Also:
setChildNodesOnlyMoveable(boolean)

isInAdapter

public boolean isInAdapter(java.lang.Object item)
Returns true if the item is a member of the adapter model. The item must be in the form of a javax.swing.tree.TreePath object.

Specified by:
isInAdapter in interface DualSelectorInterface
Parameters:
item - the object to be checked
Returns:
true if the items is a member of the adapter model
See Also:
DualSelectorInterface.isInAdapter(Object)

canMove

public boolean canMove(int[] indices,
                       int offset)
Determines whether a particular move is allowed. Returns true if the move is allowed.

Parameters:
indices - the indices of the items to be moved
offset - the number of places to move the items
Returns:
true if the move allowed, false if not allowed

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent event)
is invoked when you are dragging over the DropSite

Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener
Parameters:
event - DropTargetDragEvent
See Also:
DropTargetListener.dragEnter(DropTargetDragEvent)

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent event)
is invoked when you are exit the DropSite without dropping

Specified by:
dragExit in interface java.awt.dnd.DropTargetListener
Parameters:
event - DropTargetEvent
See Also:
DropTargetListener.dragExit(DropTargetEvent)

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent event)
is invoked when a drag operation is going on

Specified by:
dragOver in interface java.awt.dnd.DropTargetListener
Parameters:
event - DropTargetDragEvent
See Also:
DropTargetListener.dragOver(DropTargetDragEvent)

drop

public void drop(java.awt.dnd.DropTargetDropEvent event)
a drop has occurred

Specified by:
drop in interface java.awt.dnd.DropTargetListener
Parameters:
event - DropTargetDropEvent
See Also:
DropTargetListener.drop(DropTargetDropEvent)

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent event)
is invoked if the use modifies the current drop gesture

Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener
Parameters:
event - DropTargetDragEvent
See Also:
DropTargetListener.dropActionChanged(DropTargetDragEvent)

dragGestureRecognized

public void dragGestureRecognized(java.awt.dnd.DragGestureEvent event)
a drag gesture has been initiated

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener
Parameters:
event - DragGestureEvent
See Also:
DragGestureListener.dragGestureRecognized(DragGestureEvent)

dragDropEnd

public void dragDropEnd(java.awt.dnd.DragSourceDropEvent event)
this message goes to DragSourceListener, informing it that the dragging has ended

Specified by:
dragDropEnd in interface java.awt.dnd.DragSourceListener
Parameters:
event - DragSourceDropEvent
See Also:
DragSourceListener.dragDropEnd(DragSourceDropEvent)

dragEnter

public void dragEnter(java.awt.dnd.DragSourceDragEvent event)
this message goes to DragSourceListener, informing it that the dragging has entered the DropSite

Specified by:
dragEnter in interface java.awt.dnd.DragSourceListener
Parameters:
event - DragSourceDragEvent
See Also:
DragSourceListener.dragEnter(DragSourceDragEvent)

dragExit

public void dragExit(java.awt.dnd.DragSourceEvent event)
this message goes to DragSourceListener, informing it that the dragging has exited the DropSite

Specified by:
dragExit in interface java.awt.dnd.DragSourceListener
Parameters:
event - DragSourceEvent
See Also:
DragSourceListener.dragExit(DragSourceEvent)

dragOver

public void dragOver(java.awt.dnd.DragSourceDragEvent event)
this message goes to DragSourceListener, informing it that the dragging is currently ocurring over the DropSite

Specified by:
dragOver in interface java.awt.dnd.DragSourceListener
Parameters:
event - DragSourceDragEvent
See Also:
DragSourceListener.dragOver(DragSourceDragEvent)

dropActionChanged

public void dropActionChanged(java.awt.dnd.DragSourceDragEvent event)
is invoked when the user changes the dropAction

Specified by:
dropActionChanged in interface java.awt.dnd.DragSourceListener
Parameters:
event - DragSourceDragEvent
See Also:
DragSourceListener.dropActionChanged(DragSourceDragEvent)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.