dsto.dfc.swt.viewers
Class AbstractCreateItemCommand

java.lang.Object
  extended by dsto.dfc.util.BasicPropertyEventSource
      extended by dsto.dfc.swt.commands.AbstractCommand
          extended by dsto.dfc.swt.viewers.AbstractCreateItemCommand
All Implemented Interfaces:
Command, Copyable, JavaBean, PropertyEventSource, Serializable, Cloneable

public abstract class AbstractCreateItemCommand
extends AbstractCommand

Abstract base class for commands that create new items in a collection being viewed by a JFace StructuredViewer. Handles common behaviour of creating then selecting new items. Subclasses can simply implement createItem().

Version:
$Revision$
Author:
mpp
See Also:
Serialized Form

Field Summary
protected  Collection items
           
protected  org.eclipse.jface.viewers.StructuredViewer view
           
 
Fields inherited from class dsto.dfc.swt.commands.AbstractCommand
NO_ICON
 
Constructor Summary
AbstractCreateItemCommand(org.eclipse.jface.viewers.StructuredViewer view)
           
AbstractCreateItemCommand(org.eclipse.jface.viewers.StructuredViewer view, Collection items)
          Create a new instance.
 
Method Summary
protected  void addItem(Object item)
           
protected abstract  Object createItem()
          Subclasses should implement this to create a new item.
 void execute()
          Execute the command.
 Collection getItems()
           
 org.eclipse.jface.viewers.StructuredViewer getView()
           
 
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
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dsto.dfc.util.PropertyEventSource
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

view

protected org.eclipse.jface.viewers.StructuredViewer view

items

protected Collection items
Constructor Detail

AbstractCreateItemCommand

public AbstractCreateItemCommand(org.eclipse.jface.viewers.StructuredViewer view)

AbstractCreateItemCommand

public AbstractCreateItemCommand(org.eclipse.jface.viewers.StructuredViewer view,
                                 Collection items)
Create a new instance.

Parameters:
view - The viewer that is showing the groups.
items - The collection to add new items to. It is assumed that the viewer is listening for changes.
Method Detail

getView

public org.eclipse.jface.viewers.StructuredViewer getView()

getItems

public Collection getItems()

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

addItem

protected void addItem(Object item)

createItem

protected abstract Object createItem()
Subclasses should implement this to create a new item.

Returns:
The new item, or null if no item to be added (eg dialog was cancelled).


Copyright © 2008 Commonwealth of Australia