org.riotfamily.riot.list.command.core
Class AbstractCommand

java.lang.Object
  extended by org.riotfamily.riot.list.command.core.AbstractCommand
All Implemented Interfaces:
Command, RiotRuntimeAware, BeanNameAware
Direct Known Subclasses:
AddCommand, ChooseCommand, CopyCommand, CutCommand, DeleteCommand, DeletePageCommand, DescendCommand, DialogCommand, DiscardPageCommand, EditCommand, ExportCommand, PasteCommand, PopupCommand, PublishPageCommand, RefreshCommand, StepIntoCommand, SwapCommand, UnpublishPageCommand

public abstract class AbstractCommand
extends Object
implements Command, BeanNameAware, RiotRuntimeAware

Abstract base class for commands.


Field Summary
protected  RiotLog log
           
 
Constructor Summary
AbstractCommand()
           
 
Method Summary
 String getAction()
          Returns the command's id.
 String getConfirmationMessage(CommandContext context)
          Returns a localized message that is displayed to the user asking for a confirmation.
protected  Object[] getDefaultMessageArgs(CommandContext context)
           
 String getId()
          Returns a unique identifier used to reference the command.
 String getItemStyleClass(CommandContext context)
          Returns a CSS class that is added to the list of class names of the whole item/row. The default implementation always returns null.
 String getLabel(MessageResolver messageResolver)
          
protected  RiotRuntime getRuntime()
           
 String getStyleClass()
          Returns the CSS class that is assigned to command's HTML element and therefore defines which icon is displayed. If no class is set, the default implementation will return the action instead.
 boolean isEnabled(CommandContext context)
          Implementors may inspect the given context to decide whether the command should be enabled. The default implementation always returns true.
 boolean isShowOnForm()
          Returns whether the command should be shown beside the form.
 void setBeanName(String beanName)
          Implementation of the BeanNameAware interface.
 void setId(String id)
          Sets the commandId.
 void setRiotRuntime(RiotRuntime runtime)
          Implementation of the RiotRuntimeAware interface.
 void setShowOnForm(boolean showOnForm)
           
 void setStyleClass(String styleClass)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.riotfamily.riot.list.command.Command
execute
 

Field Detail

log

protected RiotLog log
Constructor Detail

AbstractCommand

public AbstractCommand()
Method Detail

getId

public String getId()
Returns a unique identifier used to reference the command.

Specified by:
getId in interface Command

setId

public void setId(String id)
Sets the commandId. If no value is set the bean name will be used by default.

Specified by:
setId in interface Command
See Also:
setBeanName(String)

setBeanName

public void setBeanName(String beanName)
Implementation of the BeanNameAware interface. If no command id is explicitly set, the bean name will be used instead. Note that if the name ends with the suffix "Command" it will be removed from the id.

Specified by:
setBeanName in interface BeanNameAware

setRiotRuntime

public void setRiotRuntime(RiotRuntime runtime)
Implementation of the RiotRuntimeAware interface. Allows subclasses to call #getRiotServletPrefix().

Specified by:
setRiotRuntime in interface RiotRuntimeAware

getRuntime

protected RiotRuntime getRuntime()

getConfirmationMessage

public String getConfirmationMessage(CommandContext context)
Description copied from interface: Command
Returns a localized message that is displayed to the user asking for a confirmation. Implementors may return null if no confirmation is needed. Otherwise a dialog containing an Ok and a Cancel button is displayed. If the user clicks Ok the command is executed otherwise no action takes place.

Specified by:
getConfirmationMessage in interface Command

getDefaultMessageArgs

protected Object[] getDefaultMessageArgs(CommandContext context)

isShowOnForm

public boolean isShowOnForm()
Returns whether the command should be shown beside the form.

Specified by:
isShowOnForm in interface Command

setShowOnForm

public void setShowOnForm(boolean showOnForm)

getAction

public String getAction()
Returns the command's id.

Specified by:
getAction in interface Command

getLabel

public String getLabel(MessageResolver messageResolver)

Specified by:
getLabel in interface Command

setStyleClass

public void setStyleClass(String styleClass)

getStyleClass

public String getStyleClass()
Returns the CSS class that is assigned to command's HTML element and therefore defines which icon is displayed. If no class is set, the default implementation will return the action instead. If no class is set, the default implementation will return the action instead.

Specified by:
getStyleClass in interface Command

getItemStyleClass

public String getItemStyleClass(CommandContext context)
Returns a CSS class that is added to the list of class names of the whole item/row. The default implementation always returns null. Subclasses may override this method to highlight a list item depending on the context. The default implementation always returns null.

Specified by:
getItemStyleClass in interface Command

isEnabled

public boolean isEnabled(CommandContext context)
Implementors may inspect the given context to decide whether the command should be enabled. Commands don't need to check the policy since commands will be automatically disabled if the action returned by Command.getAction() is denied. The default implementation always returns true.

Specified by:
isEnabled in interface Command