dsto.dfc.swt.commands
Interface Command

All Superinterfaces:
PropertyEventSource
All Known Subinterfaces:
CustomMenuCommand
All Known Implementing Classes:
AbstractAboutCommand, AbstractAddEntryCommand, AbstractCommand, AbstractCopyCommand, AbstractCreateItemCommand, AbstractCutCommand, AbstractDeleteCommand, AbstractPasteCommand, AbstractPropertiesCommand, BasicExitCommand, BasicToggleCommand, CmdAboutBox, CmdChangeDataObjectProperty, CmdCopyDataObjectProperties, CmdCopyObject, CmdDeleteItem, CmdMoveItem, CmdPasteObject, CmdRestartOsgi, CmdSetBeanProperty, CmdShowPanel, CmdShutdownOsgi, CmdToggleDataBeanProperty, CmdToggleWindowStyle

public interface Command
extends PropertyEventSource

Defines a command that may presented in a UI. Most commands will extend AbstractCommand.

Version:
$Revision$
See Also:
AbstractCommand

Method Summary
 void addCommandListener(CommandListener l)
           
 void execute()
          Execute the command.
 int getAccelerator()
          Get a keyboard accelerator for the command.
 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()
          A string that is suitable to describe this command and its parameters for logging purposes.
 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).
 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)
           
 void setContextMenuGroup(String newContextMenuGroup)
          Sets the group that command appears in context menus.
 void setDescription(String newDescription)
          Sets the description.
 void setDisplayName(String newDisplayName)
           
 void setEnabled(boolean newValue)
           
 void setIcon(Icon newIcon)
           
 void setMainMenuGroup(String newMainMenuGroup)
          Sets the group that command appears in the main menu.
 void setMnemonic(char newMnemonic)
          Sets the mnemonic.
 void setToolbarGroup(String newToolbarGroup)
          Sets the group that command appears in toolbars.
 
Methods inherited from interface dsto.dfc.util.PropertyEventSource
addPropertyChangeListener, removePropertyChangeListener
 

Method Detail

execute

void execute()
Execute the command. Commands should fire CommandListener.commandExecuted(CommandEvent) when executed.


getIcon

Icon getIcon()
The symbolic icon for the command. May be null.


getName

String getName()
The formal identifying name for this command (eg edit.Copy, file.Open). This must not change during the lifetime of a command instance.


getDisplayName

String getDisplayName()
The name of the command as it should be displayed (eg on a menu). May be null in which case the command name (or some derivative) will be used.


getDescription

String getDescription()
A short description of the command, suitable for a tooltip or use in a status panel.


getLogString

String getLogString()
A string that is suitable to describe this command and its parameters for logging purposes.


isEnabled

boolean isEnabled()
True if the command is enabled, ie able to execute in the current context.


isInteractive

boolean isInteractive()
True if this command will interact with the user when execute () is called.


getGroupInView

String getGroupInView(String viewName)
Get the preferred group that this command should appear in for a given view. eg "File.doc" for a main menu or "edit" for a context menu. Deeply nested groups such as "View.window.Windows.recent" will be placed in nested pullright menus.

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.

Parameters:
viewName - The name of the view.
Returns:
The group in the view, or null if this command does not appear in the given view.

getMnemonic

char getMnemonic()
Get a character shortcut for the command (eg for use on a menu). May Return 0 for no mnemonic.


getAccelerator

int getAccelerator()
Get a keyboard accelerator for the command.

Returns:
The SWT acclerator (eg SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2) or 0 for no accelerator.

setDisplayName

void setDisplayName(String newDisplayName)

setIcon

void setIcon(Icon newIcon)

setEnabled

void setEnabled(boolean newValue)

setAccelerator

void setAccelerator(int newAccelerator)

setMnemonic

void setMnemonic(char newMnemonic)
Sets the mnemonic.

Parameters:
newMnemonic - The mnemonic to set

setContextMenuGroup

void setContextMenuGroup(String newContextMenuGroup)
Sets the group that command appears in context menus.

See Also:
getGroupInView(String)

setToolbarGroup

void setToolbarGroup(String newToolbarGroup)
Sets the group that command appears in toolbars.

See Also:
getGroupInView(String)

setMainMenuGroup

void setMainMenuGroup(String newMainMenuGroup)
Sets the group that command appears in the main menu.

See Also:
getGroupInView(String)

setDescription

void setDescription(String newDescription)
Sets the description.

Parameters:
newDescription - The description to set

addCommandListener

void addCommandListener(CommandListener l)

removeCommandListener

void removeCommandListener(CommandListener l)


Copyright © 2008 Commonwealth of Australia