|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectdsto.dfc.util.BasicPropertyEventSource
dsto.dfc.swt.commands.AbstractCommand
public abstract class AbstractCommand
Base class for most commands. Subclasses only have to implement
execute()
.
Field Summary | |
---|---|
static Icon |
NO_ICON
Value to use when a command has no icon. |
Constructor Summary | |
---|---|
AbstractCommand(String name,
Icon icon,
String group,
String description,
boolean interactive)
Create a new instance. |
|
AbstractCommand(String name,
Icon icon,
String group,
String description,
boolean interactive,
char mnemonic,
int accelerator)
Create a new instance. |
|
AbstractCommand(String name,
String iconName,
String group,
String description,
boolean interactive)
Create a new instance. |
|
AbstractCommand(String name,
String iconName,
String group,
String description,
boolean interactive,
char mnemonic,
int accelerator)
Create a new instance. |
Method Summary | |
---|---|
void |
addCommandListener(CommandListener l)
|
Object |
clone()
Create a completely separate copy of this object and any mutable objects owned by the object. |
protected String |
createDefaultDisplayName()
Generates a display name based on the last component of the command name. |
abstract void |
execute()
Execute the command. |
void |
fireCommandExecuted()
|
void |
fireCommandExecuted(Object data)
|
int |
getAccelerator()
eg SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2 |
String |
getContextMenuGroup()
|
String |
getDescription()
A short description of the command, suitable for a tooltip or use in a status panel. |
String |
getDisplayName()
The name of the command as it should be displayed (eg on a menu). |
String |
getGroupInView(String viewName)
Get the preferred group that this command should appear in for a given view. |
Icon |
getIcon()
The symbolic icon for the command. |
String |
getLogString()
Simply returns the command name followed by empty brackets. |
String |
getMainMenuGroup()
|
char |
getMnemonic()
Get a character shortcut for the command (eg for use on a menu). |
String |
getName()
The formal identifying name for this command (eg edit.Copy, file.Open). |
String |
getToolbarGroup()
|
boolean |
isEnabled()
True if the command is enabled, ie able to execute in the current context. |
boolean |
isInteractive()
True if this command will interact with the user when execute () is called. |
void |
removeCommandListener(CommandListener l)
|
void |
setAccelerator(int newAccelerator)
Sets the accelerator. |
void |
setContextMenuGroup(String newContextMenuGroup)
Sets the contextMenuGroup. |
void |
setDescription(String newDescription)
Sets the description. |
void |
setDisplayName(String newDisplayName)
|
void |
setEnabled(boolean newValue)
|
void |
setIcon(Icon newIcon)
|
void |
setInteractive(boolean newInteractive)
Sets the interactive. |
void |
setMainMenuGroup(String newMainMenuGroup)
Sets the mainMenuGroup. |
void |
setMnemonic(char newMnemonic)
Sets the mnemonic. |
void |
setName(String newName)
Sets the name. |
void |
setToolbarGroup(String newToolbarGroup)
Sets the toolbarGroup. |
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 |
---|
public static final Icon NO_ICON
Constructor Detail |
---|
public AbstractCommand(String name, Icon icon, String group, String description, boolean interactive)
name
- The command name.icon
- The icon resource name (passed to Images
).group
- The base group for the command. This is used for the default
context and toolbar groups. The main menu group is also derived from this.description
- A tooltip-length description of the command.interactive
- True of the command will interact with the user when
executed.public AbstractCommand(String name, String iconName, String group, String description, boolean interactive)
name
- The command name.iconName
- The icon resource name (passed to Images
).group
- The base group for the command. This is used for the default
context and toolbar groups. The main menu group is also derived from this.description
- A tooltip-length description of the command.interactive
- True of the command will interact with the user when
executed.public AbstractCommand(String name, String iconName, String group, String description, boolean interactive, char mnemonic, int accelerator)
name
- The command name.iconName
- The icon resource name (passed to Images
).group
- The base group for the command. This is used for the default
context and toolbar groups. The main menu group is also derived from this.description
- A tooltip-length description of the command.interactive
- True of the command will interact with the user when
executed.mnemonic
- A menu mnemonic for the command.accelerator
- The global accelerator key for the command.public AbstractCommand(String name, Icon icon, String group, String description, boolean interactive, char mnemonic, int accelerator)
name
- The command name.icon
- The command icon.group
- The base group for the command. This is used for the default
context and toolbar groups. The main menu group is also derived from this.description
- A tooltip-length description of the command.interactive
- True of the command will interact with the user when
executed.mnemonic
- A menu mnemonic for the command.accelerator
- The global accelerator key for the command.Method Detail |
---|
public Object clone() throws CloneNotSupportedException
Copyable
NOTE: subclasses should not remove the CloneNotSupportedException throws clause if they themselves support subclassing: removing the CloneNotSupportedException declaration stops subclasses from indicating that a clone was not possible.
clone
in interface Copyable
clone
in class BasicPropertyEventSource
CloneNotSupportedException
- if the clone failed or is not
possible.public abstract void execute()
Command
CommandListener.commandExecuted(CommandEvent)
when executed.
execute
in interface Command
public void addCommandListener(CommandListener l)
addCommandListener
in interface Command
public void removeCommandListener(CommandListener l)
removeCommandListener
in interface Command
public String getGroupInView(String viewName)
Command
NOTE: groups may be overridden by a setting in the CommandRegistry.
If the command changes its group it should generate a property change event with the property name the name of the view, the old value set to the old group and the new value set to the new group.
getGroupInView
in interface Command
viewName
- The name of the view.
public Icon getIcon()
Command
getIcon
in interface Command
public void setIcon(Icon newIcon)
setIcon
in interface Command
public String getName()
Command
getName
in interface Command
public String getDescription()
Command
getDescription
in interface Command
public boolean isInteractive()
Command
isInteractive
in interface Command
public String getMainMenuGroup()
public String getContextMenuGroup()
public String getToolbarGroup()
public char getMnemonic()
Command
getMnemonic
in interface Command
public int getAccelerator()
getAccelerator
in interface Command
public String getDisplayName()
Command
getDisplayName
in interface Command
public void setDisplayName(String newDisplayName)
setDisplayName
in interface Command
protected String createDefaultDisplayName()
public String getLogString()
getLogString
in interface Command
public boolean isEnabled()
Command
isEnabled
in interface Command
public void setEnabled(boolean newValue)
setEnabled
in interface Command
public void setAccelerator(int newAccelerator)
setAccelerator
in interface Command
newAccelerator
- The accelerator to setpublic void setContextMenuGroup(String newContextMenuGroup)
setContextMenuGroup
in interface Command
newContextMenuGroup
- The contextMenuGroup to setCommand.getGroupInView(String)
public void setDescription(String newDescription)
setDescription
in interface Command
newDescription
- The description to setpublic void setInteractive(boolean newInteractive)
newInteractive
- The interactive to setpublic void setMainMenuGroup(String newMainMenuGroup)
setMainMenuGroup
in interface Command
newMainMenuGroup
- The mainMenuGroup to setCommand.getGroupInView(String)
public void setMnemonic(char newMnemonic)
setMnemonic
in interface Command
newMnemonic
- The mnemonic to setpublic void setName(String newName)
newName
- The name to setpublic void setToolbarGroup(String newToolbarGroup)
setToolbarGroup
in interface Command
newToolbarGroup
- The toolbarGroup to setCommand.getGroupInView(String)
public void fireCommandExecuted()
public void fireCommandExecuted(Object data)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |