com.sas.swing.visuals.dualselector
Class JListDualSelectorAdapter

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

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

JListDualSelectorAdapter is a class that supports using a JList in a dual selector.

Since:
3.1

Field Summary
protected  javax.swing.JList component
          The JList component that's being adapted
protected  javax.swing.JScrollPane containerComponent
          a scrollpane for the JList 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
 
Constructor Summary
JListDualSelectorAdapter(javax.swing.JComponent parent)
          Default constructor.
JListDualSelectorAdapter(javax.swing.JList list, javax.swing.JComponent parent)
          Constructor method that takes a JList 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 in the component.
 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 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 selected items in the component.
 int[] getSelectedIndices()
          Returns the indices of the selected items.
 java.util.List getSelectedItems()
          Returns the user selected items.
 boolean isInAdapter(java.lang.Object item)
          Returns true if the item is a member of the adapter model.
 boolean isSelectedIndex(int index)
          Returns whether the supplied index is selected.
 void moveItems(int[] selectedIndices, int offset)
          Performs the actual movement of the items within the list.
 void removeItems(java.util.List removeItems)
          Removes the items from the component.
 void setSelectedIndex(int index)
          Selects the item at the specified index.
 

Field Detail

component

protected javax.swing.JList component
The JList component that's being adapted


containerComponent

protected javax.swing.JScrollPane containerComponent
a scrollpane for the JList component


parentSelector

protected javax.swing.JComponent parentSelector
the parent component


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

JListDualSelectorAdapter

public JListDualSelectorAdapter(javax.swing.JComponent parent)
Default constructor. Allows specification of the parent component.

Parameters:
parent - this class' parent component

JListDualSelectorAdapter

public JListDualSelectorAdapter(javax.swing.JList list,
                                javax.swing.JComponent parent)
Constructor method that takes a JList instance for use in the component.

Parameters:
list - a JList instance
parent - this class' parent component
Method Detail

clearSelections

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

Specified by:
clearSelections in interface DualSelectorInterface

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

getSelectedCount

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

Specified by:
getSelectedCount in interface DualSelectorInterface
Returns:
the number of selected items

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

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

getComponent

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

Specified by:
getComponent in interface DualSelectorInterface
Returns:
the component

getContainerComponent

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

Specified by:
getContainerComponent in interface DualSelectorInterface
Returns:
the container component.

getSelectedItems

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

Specified by:
getSelectedItems in interface DualSelectorInterface
Returns:
the selected items

getAllItems

public java.util.List getAllItems()
Returns all items in the component.

Specified by:
getAllItems in interface DualSelectorInterface
Returns:
all items

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

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.

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

isInAdapter

public boolean isInAdapter(java.lang.Object item)
Returns true if the item is a member of the adapter model.

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

getSelectedIndices

public int[] getSelectedIndices()
Returns the indices of the selected items.

Specified by:
getSelectedIndices in interface DualSelectorUpDownInterface
Returns:
an array containing the selected indices

moveItems

public void moveItems(int[] selectedIndices,
                      int offset)
Performs the actual movement of the items within the list. (This method may be replaced.)

Specified by:
moveItems in interface DualSelectorUpDownInterface
Parameters:
selectedIndices - the indices of the selected items
offset - the direction to move items. 1 is up and -1 is down.

isSelectedIndex

public boolean isSelectedIndex(int index)
Returns whether the supplied index is selected.

Specified by:
isSelectedIndex in interface DualSelectorUpDownInterface
Parameters:
index - the item index to check
Returns:
whether the item is selected

canMove

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

Specified by:
canMove in interface DualSelectorUpDownInterface
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 - the drag event

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 - the drop event

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 - the drag event

drop

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

Specified by:
drop in interface java.awt.dnd.DropTargetListener
Parameters:
event - the drop event

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

dragGestureRecognized

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

Specified by:
dragGestureRecognized in interface java.awt.dnd.DragGestureListener

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

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

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

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

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



Copyright © 2009 SAS Institute Inc. All Rights Reserved.