|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.binding.value.support.AbstractPropertyChangePublisher
org.springframework.richclient.command.AbstractCommand
public abstract class AbstractCommand
Base class for commands. Extend this class by implementing the
ActionCommandExecutor.execute()
method.
Most (if not all) commands result in a UI component. Several methods are
provided here to deliver abstractButtons or menuItems. Configuring this
visual aspect of the command is done by a number of
CommandFaceDescriptor
s. One of these will be registered as the
default while others can be used to create a different look by providing a
faceDescriptorId.
CommandFaceDescriptor
Field Summary | |
---|---|
static String |
ENABLED_PROPERTY_NAME
Property used to notify changes in the enabled state. |
static String |
VISIBLE_PROPERTY_NAME
Property used to notify changes in the visible state. |
Fields inherited from class org.springframework.binding.value.support.AbstractPropertyChangePublisher |
---|
logger |
Fields inherited from interface org.springframework.richclient.core.Authorizable |
---|
AUTHORIZED_PROPERTY |
Constructor Summary | |
---|---|
protected |
AbstractCommand()
Default constructor. |
protected |
AbstractCommand(String id)
Constructor providing an id for configuration. |
protected |
AbstractCommand(String id,
CommandFaceDescriptor faceDescriptor)
Constructor providing an id and the default FaceDescriptor. |
protected |
AbstractCommand(String id,
Map faceDescriptors)
Constructor providing an id and a number of FaceDescriptors. |
protected |
AbstractCommand(String id,
String encodedLabel)
Constructor providing id and encodedLabel. |
protected |
AbstractCommand(String id,
String encodedLabel,
Icon icon,
String caption)
Constructor providing id and a number of parameters to create a default CommandFaceDescriptor . |
Method Summary | |
---|---|
void |
addEnabledListener(PropertyChangeListener listener)
Adds the given listener to the collection of listeners that will be notified when the command executor's enabled state changes. |
void |
afterPropertiesSet()
Performs initialisation and validation of this instance after its dependencies have been set. |
void |
attach(AbstractButton button)
Attach and configure the button to the default faceDescriptor using the default configurer. |
void |
attach(AbstractButton button,
CommandButtonConfigurer configurer)
Attach and configure the button to the default faceDescriptor using the given configurer. |
void |
attach(AbstractButton button,
String faceDescriptorId,
CommandButtonConfigurer configurer)
Attach and configure the button to the faceDescriptorId using the configurer. |
protected Iterator |
buttonIterator()
Returns an iterator over all buttons by traversing each CommandFaceButtonManager . |
AbstractButton |
createButton()
Create a button using the defaults for faceDescriptorId, buttonFactory and buttonConfigurer. |
AbstractButton |
createButton(ButtonFactory buttonFactory)
Create a button using the defaults for faceDescriptorId and buttonConfigurer. |
AbstractButton |
createButton(ButtonFactory buttonFactory,
CommandButtonConfigurer buttonConfigurer)
Create a button using the default buttonFactory. |
AbstractButton |
createButton(String faceDescriptorId)
Create a button using the defaults for buttonFactory and buttonConfigurer. |
AbstractButton |
createButton(String faceDescriptorId,
ButtonFactory buttonFactory)
Create a button using the default buttonConfigurer. |
AbstractButton |
createButton(String faceDescriptorId,
ButtonFactory buttonFactory,
CommandButtonConfigurer buttonConfigurer)
Creates a button using the provided id, factory and configurer. |
JMenuItem |
createMenuItem()
Create a menuItem using the defaults for faceDescriptorId, menuFactory and menuItemButtonConfigurer. |
JMenuItem |
createMenuItem(MenuFactory menuFactory)
Create a menuItem using the defaults for faceDescriptorId and menuItemButtonConfigurer. |
JMenuItem |
createMenuItem(MenuFactory menuFactory,
CommandButtonConfigurer buttonConfigurer)
Create a menuItem using the default faceDescriptorId. |
JMenuItem |
createMenuItem(String faceDescriptorId)
Create a menuItem using the defaults for menuFactory and menuItemButtonConfigurer. |
JMenuItem |
createMenuItem(String faceDescriptorId,
MenuFactory menuFactory)
Create a menuItem using the default and menuItemButtonConfigurer. |
JMenuItem |
createMenuItem(String faceDescriptorId,
MenuFactory menuFactory,
CommandButtonConfigurer buttonConfigurer)
Create a menuItem using the provided id, factory and configurer. |
protected Iterator |
defaultButtonIterator()
Returns an iterator over all buttons in the default CommandFaceButtonManager . |
void |
detach(AbstractButton button)
Detach the button from the CommandFaceButtonManager . |
KeyStroke |
getAccelerator()
Returns the accelerator from the default faceDescriptor or the default accelerator of the CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getAccelerator() . |
protected ButtonFactory |
getButtonFactory()
|
AbstractButton |
getButtonIn(Container container)
Search for the first button of this command that is a child component of the given container. |
protected CommandServices |
getCommandServices()
Returns the CommandServices for this AbstractCommand . |
protected ComponentFactory |
getComponentFactory()
|
protected CommandButtonConfigurer |
getDefaultButtonConfigurer()
|
String |
getDefaultFaceDescriptorId()
Returns the default faceDescriptorId. |
protected CommandFaceDescriptor |
getFaceDescriptor()
Returns the default faceDescriptor. |
CommandFaceDescriptorRegistry |
getFaceDescriptorRegistry()
Returns the CommandFaceDescriptorRegistry of this
AbstractCommand which holds all face descriptors. |
Icon |
getIcon()
Returns the icon from the default faceDescriptor or null
if no faceDescriptor is available. |
String |
getId()
|
protected MenuFactory |
getMenuFactory()
|
protected CommandButtonConfigurer |
getMenuItemButtonConfigurer()
|
int |
getMnemonic()
Returns the mnemonic from the default faceDescriptor or the default mnemonic of the CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getMnemonic() . |
int |
getMnemonicIndex()
Returns the mnemonicIndex from the default faceDescriptor or the default mnemonicIndex of the CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getMnemonicIndex() . |
String |
getSecurityControllerId()
Get the id (bean name) of the security controller that should manage this object. |
String |
getText()
Returns the text from the default faceDescriptor or the default text of the CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getText() . |
protected CommandButtonConfigurer |
getToolBarButtonConfigurer()
|
protected ButtonFactory |
getToolBarButtonFactory()
|
boolean |
isAnonymous()
Returns true if this command doesn't have an Id. |
boolean |
isAttached(AbstractButton b)
Returns true if the provided button is attached to the
default CommandFaceButtonManager . |
boolean |
isAuthorized()
Returns true if the command is authorized. |
boolean |
isEnabled()
Returns true if the command is enabled and
isAuthorized() . |
boolean |
isFaceConfigured()
Returns true if this command has a default faceDescriptor. |
boolean |
isVisible()
Returns true if the command is visible. |
protected void |
onButtonAttached(AbstractButton button)
Additional code to execute when attaching a button. |
protected void |
onButtonDetached()
Implement this to add custom code executed when detaching a button. |
void |
removeEnabledListener(PropertyChangeListener listener)
Removes the given listener from the collection of listeners that will be notified when the command executor's enabled state changes. |
boolean |
requestFocusIn(Container container)
Search for a button representing this command in the provided container and let it request the focus. |
void |
setAuthorized(boolean authorized)
Set the authorized state. |
void |
setBeanName(String name)
|
void |
setCaption(String shortDescription)
Set the provided description on the default CommandFaceDescriptor . |
void |
setCommandServices(CommandServices services)
Set the CommandServices . |
void |
setDefaultFaceDescriptorId(String defaultFaceDescriptorId)
Change the default FaceDescriptor. |
void |
setEnabled(boolean enabled)
Set the enabled state of this command. |
void |
setFaceDescriptor(CommandFaceDescriptor faceDescriptor)
Set the default faceDescriptor to use for this command. |
void |
setFaceDescriptor(String faceDescriptorId,
CommandFaceDescriptor faceDescriptor)
Add an additional CommandFaceDescriptor . |
void |
setFaceDescriptorRegistry(CommandFaceDescriptorRegistry faceDescriptorRegistry)
Set the CommandFaceDescriptorRegistry to use when
registering/looking up CommandFaceDescriptor s. |
void |
setFaceDescriptors(Map faceDescriptors)
Add a number of CommandFaceDescriptor s to this Command. |
void |
setIcon(Icon icon)
Set the provided icon on the default CommandFaceDescriptor . |
void |
setIconInfo(CommandButtonIconInfo iconInfo)
Set the provided iconInfo on the default CommandFaceDescriptor . |
protected void |
setId(String id)
Set the id. |
void |
setLabel(CommandButtonLabelInfo label)
Set the provided label on the default CommandFaceDescriptor . |
void |
setLabel(String encodedLabel)
Set the provided label on the default CommandFaceDescriptor . |
void |
setSecurityControllerId(String controllerId)
Set the Id of the security controller that should manage this object. |
void |
setVisible(boolean value)
Set this command visible and update all associated buttons. |
String |
toString()
|
protected void |
updatedEnabledState()
This method is called when any predicate for enabled state has changed. |
protected void |
updatedVisibleState()
This method is called when any predicate for visible state has changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.springframework.richclient.command.ActionCommandExecutor |
---|
execute |
Field Detail |
---|
public static final String ENABLED_PROPERTY_NAME
public static final String VISIBLE_PROPERTY_NAME
Constructor Detail |
---|
protected AbstractCommand()
BeanNameAware
protected AbstractCommand(String id)
id
- protected AbstractCommand(String id, String encodedLabel)
id
- encodedLabel
- label to use when creating the default
CommandFaceDescriptor
.protected AbstractCommand(String id, String encodedLabel, Icon icon, String caption)
CommandFaceDescriptor
.
id
- encodedLabel
- label for the default CommandFaceDescriptor
.icon
- icon for the default CommandFaceDescriptor
.caption
- caption for the default CommandFaceDescriptor
.protected AbstractCommand(String id, CommandFaceDescriptor faceDescriptor)
id
- faceDescriptor
- the default FaceDescriptor to use.protected AbstractCommand(String id, Map faceDescriptors)
id
- faceDescriptors
- a map which contains <faceDescriptorId,
faceDescriptor> pairs.Method Detail |
---|
public String getId()
protected void setId(String id)
id
- public void setBeanName(String name)
setBeanName
in interface BeanNameAware
public void setFaceDescriptor(CommandFaceDescriptor faceDescriptor)
faceDescriptor
- the CommandFaceDescriptor
to use as
default.public void setFaceDescriptor(String faceDescriptorId, CommandFaceDescriptor faceDescriptor)
CommandFaceDescriptor
.
faceDescriptorId
- key to identify and use this faceDescriptor.faceDescriptor
- additional CommandFaceDescriptor
.public void setFaceDescriptors(Map faceDescriptors)
CommandFaceDescriptor
s to this Command.
faceDescriptors
- a Map
which contains <faceDescriptorId,
CommandFaceDescriptor> pairs.public void setDefaultFaceDescriptorId(String defaultFaceDescriptorId)
defaultFaceDescriptorId
- the id of the faceDescriptor to be used as
default.public void setFaceDescriptorRegistry(CommandFaceDescriptorRegistry faceDescriptorRegistry)
CommandFaceDescriptorRegistry
to use when
registering/looking up CommandFaceDescriptor
s.
faceDescriptorRegistry
- registry to use for the
CommandFaceDescriptor
s.public void setCommandServices(CommandServices services)
CommandServices
.
public void setLabel(String encodedLabel)
CommandFaceDescriptor
.
CommandFaceDescriptor.setButtonLabelInfo(String)
public void setLabel(CommandButtonLabelInfo label)
CommandFaceDescriptor
.
CommandFaceDescriptor#setLabelInfo(String)
public void setCaption(String shortDescription)
CommandFaceDescriptor
.
CommandFaceDescriptor.setCaption(String)
public void setIcon(Icon icon)
CommandFaceDescriptor
.
CommandFaceDescriptor.setIcon(Icon)
public void setIconInfo(CommandButtonIconInfo iconInfo)
CommandFaceDescriptor
.
CommandFaceDescriptor.setIconInfo(CommandButtonIconInfo)
public void afterPropertiesSet()
super.afterPropertiesSet()
.
afterPropertiesSet
in interface InitializingBean
public String getDefaultFaceDescriptorId()
protected CommandFaceDescriptor getFaceDescriptor()
public boolean isFaceConfigured()
true
if this command has a default faceDescriptor.
public Icon getIcon()
null
if no faceDescriptor is available.
public String getText()
CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getText()
.
public int getMnemonic()
CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getMnemonic()
.
public int getMnemonicIndex()
CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getMnemonicIndex()
.
public KeyStroke getAccelerator()
CommandButtonLabelInfo#BLANK_BUTTON_LABEL#getAccelerator()
.
public CommandFaceDescriptorRegistry getFaceDescriptorRegistry()
CommandFaceDescriptorRegistry
of this
AbstractCommand
which holds all face descriptors.
protected CommandServices getCommandServices()
CommandServices
for this AbstractCommand
.
public void setSecurityControllerId(String controllerId)
setSecurityControllerId
in interface SecurityControllable
controllerId
- Id (bean name) of the security controllerpublic String getSecurityControllerId()
getSecurityControllerId
in interface SecurityControllable
public void setAuthorized(boolean authorized)
setEnabled(boolean)
. As long as this object is
unauthorized, it can not be enabled.
setAuthorized
in interface Authorizable
authorized
- Pass true
if the object is to be
authorizedpublic boolean isAuthorized()
true
if the command is authorized.
isAuthorized
in interface Authorizable
public boolean isEnabled()
true
if the command is enabled and
isAuthorized()
.
isEnabled
in interface Guarded
isAuthorized()
protected void updatedEnabledState()
isEnabled()
has changed.
Subclasses which have an additional predicate to enabled state must call this method if the state of the predicate changes.
public void setEnabled(boolean enabled)
setEnabled
in interface Guarded
enabled
- statepublic void addEnabledListener(PropertyChangeListener listener)
addEnabledListener
in interface GuardedActionCommandExecutor
listener
- The listener to be added.public void removeEnabledListener(PropertyChangeListener listener)
removeEnabledListener
in interface GuardedActionCommandExecutor
listener
- The listener to be removed.protected final Iterator defaultButtonIterator()
Returns an iterator over all buttons in the default
CommandFaceButtonManager
.
To traverse all buttons of all CommandFaceButtonManager
s see
buttonIterator()
.
protected final Iterator buttonIterator()
CommandFaceButtonManager
.
public boolean isAnonymous()
true
if this command doesn't have an Id.
public boolean isVisible()
true
if the command is visible.
public void setVisible(boolean value)
protected void updatedVisibleState()
This method is called when any predicate for visible state has changed.
This implementation fires the visible changed event if the return value
of isVisible()
has changed.
Subclasses which have an additional predicate to visible state must call this method if the state of the predicate changes.
public final AbstractButton createButton()
createButton(String, ButtonFactory, CommandButtonConfigurer)
public final AbstractButton createButton(String faceDescriptorId)
createButton(String, ButtonFactory, CommandButtonConfigurer)
public final AbstractButton createButton(ButtonFactory buttonFactory)
createButton(String, ButtonFactory, CommandButtonConfigurer)
public final AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory)
createButton(String, ButtonFactory, CommandButtonConfigurer)
public final AbstractButton createButton(ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer)
createButton(String, ButtonFactory, CommandButtonConfigurer)
public AbstractButton createButton(String faceDescriptorId, ButtonFactory buttonFactory, CommandButtonConfigurer buttonConfigurer)
faceDescriptorId
- id of the faceDescriptor used to configure the
button.buttonFactory
- factory that delivers the button.buttonConfigurer
- configurer mapping the faceDescriptor on the
button.
public final JMenuItem createMenuItem()
createMenuItem(String, MenuFactory, CommandButtonConfigurer)
public final JMenuItem createMenuItem(String faceDescriptorId)
createMenuItem(String, MenuFactory, CommandButtonConfigurer)
public final JMenuItem createMenuItem(MenuFactory menuFactory)
createMenuItem(String, MenuFactory, CommandButtonConfigurer)
public final JMenuItem createMenuItem(String faceDescriptorId, MenuFactory menuFactory)
createMenuItem(String, MenuFactory, CommandButtonConfigurer)
public final JMenuItem createMenuItem(MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer)
createMenuItem(String, MenuFactory, CommandButtonConfigurer)
public JMenuItem createMenuItem(String faceDescriptorId, MenuFactory menuFactory, CommandButtonConfigurer buttonConfigurer)
faceDescriptorId
- id of the faceDescriptor used to configure the
button.menuFactory
- factory that delivers the menuItem.buttonConfigurer
- configurer mapping the faceDescriptor on the
button.
public void attach(AbstractButton button)
attach(AbstractButton, String, CommandButtonConfigurer)
public void attach(AbstractButton button, CommandButtonConfigurer configurer)
attach(AbstractButton, String, CommandButtonConfigurer)
public void attach(AbstractButton button, String faceDescriptorId, CommandButtonConfigurer configurer)
button
- the button to attach and configure.faceDescriptorId
- the id of the faceDescriptor.configurer
- that maps the faceDescriptor on the button.protected void onButtonAttached(AbstractButton button)
button
- the button that has been attached.public void detach(AbstractButton button)
CommandFaceButtonManager
.
button
- the button to detach.public boolean isAttached(AbstractButton b)
true
if the provided button is attached to the
default CommandFaceButtonManager
.
b
- the button to check.
true
if b is attached to the default
CommandFaceButtonManager
.protected void onButtonDetached()
protected CommandButtonConfigurer getDefaultButtonConfigurer()
CommandServices.getDefaultButtonConfigurer()
protected CommandButtonConfigurer getToolBarButtonConfigurer()
CommandServices.getToolBarButtonConfigurer()
protected ButtonFactory getToolBarButtonFactory()
CommandServices.getToolBarButtonFactory()
protected CommandButtonConfigurer getMenuItemButtonConfigurer()
CommandServices.getMenuItemButtonConfigurer()
protected ComponentFactory getComponentFactory()
CommandServices.getComponentFactory()
protected ButtonFactory getButtonFactory()
CommandServices.getButtonFactory()
protected MenuFactory getMenuFactory()
CommandServices.getMenuFactory()
public boolean requestFocusIn(Container container)
container
- the container which holds the command button.
true
if the focus request is likely to succeed.getButtonIn(Container)
,
JComponent.requestFocusInWindow()
public AbstractButton getButtonIn(Container container)
container
- the container to be searched.
AbstractButton
representing this command that is
embedded in the container or null
if none was found.public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |