dsto.dfc.swt.viewers
Class CmdMoveItem
java.lang.Object
dsto.dfc.util.BasicPropertyEventSource
dsto.dfc.swt.commands.AbstractCommand
dsto.dfc.swt.viewers.CmdMoveItem
- All Implemented Interfaces:
- CollectionListener, DfcMonitoredListListener, Command, Copyable, JavaBean, PropertyEventSource, Serializable, Cloneable, EventListener, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.swt.events.DisposeListener, org.eclipse.swt.internal.SWTEventListener
public class CmdMoveItem
- extends AbstractCommand
- implements org.eclipse.jface.viewers.ISelectionChangedListener, DfcMonitoredListListener, org.eclipse.swt.events.DisposeListener
Generic command to move items up/down in a viewer that is displaying a
java.util.List. If the list is a DfcMonitoredList (which supports in-place
movement of items) move () is used rather than remove/add.
- See Also:
- Serialized Form
Constructor Summary |
CmdMoveItem(org.eclipse.jface.viewers.Viewer viewer,
int direction)
Create a new instance. |
Methods inherited from class dsto.dfc.swt.commands.AbstractCommand |
addCommandListener, clone, createDefaultDisplayName, fireCommandExecuted, fireCommandExecuted, getAccelerator, getContextMenuGroup, getDescription, getDisplayName, getGroupInView, getIcon, getLogString, getMainMenuGroup, getMnemonic, getName, getToolbarGroup, isEnabled, isInteractive, removeCommandListener, setAccelerator, setContextMenuGroup, setDescription, setDisplayName, setEnabled, setIcon, setInteractive, setMainMenuGroup, setMnemonic, setName, setToolbarGroup |
Methods inherited from class dsto.dfc.util.BasicPropertyEventSource |
addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeSource, removePropertyChangeListener, setPropertyChangeSource |
UP
public static final int UP
- See Also:
- Constant Field Values
DOWN
public static final int DOWN
- See Also:
- Constant Field Values
viewer
protected org.eclipse.jface.viewers.Viewer viewer
items
protected List items
direction
protected int direction
CmdMoveItem
public CmdMoveItem(org.eclipse.jface.viewers.Viewer viewer,
int direction)
- Create a new instance.
- Parameters:
viewer
- The viewer.direction
- The direction to move the entries (MOVE_UP or
MOVE_DOWN).- See Also:
setInput(List)
dispose
public void dispose()
setInput
public void setInput(List newItems)
- Notify the command that the input to the viewer has changed (there is no
automatic way to do this). If the items list also implements
MonitoredCollection
it is tracked and the
command will be correctly enabled/disabled depending on the current
context.
inputChanged
protected void inputChanged(List oldInput,
List newInput)
execute
public void execute()
- Description copied from interface:
Command
- Execute the command. Commands should fire
CommandListener.commandExecuted(CommandEvent)
when executed.
- Specified by:
execute
in interface Command
- Specified by:
execute
in class AbstractCommand
moveItem
protected void moveItem(int oldIndex,
int newIndex)
updateEnabled
protected void updateEnabled()
- Update the enabled status of the command given the current selected items.
Default is to be enabled when items is not empty and canMove () is true.
canMove
protected boolean canMove(List toMove)
selectionChanged
public void selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent e)
- Specified by:
selectionChanged
in interface org.eclipse.jface.viewers.ISelectionChangedListener
elementsAdded
public void elementsAdded(CollectionEvent e)
- Specified by:
elementsAdded
in interface CollectionListener
elementsRemoved
public void elementsRemoved(CollectionEvent e)
- Specified by:
elementsRemoved
in interface CollectionListener
elementMoved
public void elementMoved(CollectionEvent e)
- Description copied from interface:
DfcMonitoredListListener
- Fired when an element in the list has moved (changed indexes).
- Specified by:
elementMoved
in interface DfcMonitoredListListener
- Parameters:
e
- The move event. startIndex is the element's old index,
endIndex is the new index.
widgetDisposed
public void widgetDisposed(org.eclipse.swt.events.DisposeEvent e)
- Specified by:
widgetDisposed
in interface org.eclipse.swt.events.DisposeListener
Copyright © 2008 Commonwealth of Australia