Sweet Home 3D 4.0

com.eteks.sweethome3d.plugin
Class PluginAction

java.lang.Object
  extended by com.eteks.sweethome3d.plugin.PluginAction

public abstract class PluginAction
extends Object

An action made available to application users through a plugin.

Author:
Emmanuel Puybaret

Nested Class Summary
static class PluginAction.Property
          Enumeration of the various properties this action may define.
 
Constructor Summary
PluginAction()
          Creates a disabled plug-in action.
PluginAction(String resourceBaseName, String actionPrefix, ClassLoader pluginClassLoader)
          Creates a disabled plug-in action with properties retrieved from a resource bundle in which key starts with actionPrefix.
PluginAction(String resourceBaseName, String actionPrefix, ClassLoader pluginClassLoader, boolean enabled)
          Creates an action with properties retrieved from a resource bundle in which key starts with actionPrefix.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds the property change listener in parameter to this plugin action.
abstract  void execute()
          Executes this action.
 Object getPropertyValue(PluginAction.Property property)
          Returns a property value of this action.
 boolean isEnabled()
          Returns the enabled state of this action.
 void putPropertyValue(PluginAction.Property property, Object value)
          Sets a property value of this action, and fires a PropertyChangeEvent if the value changed.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes the property change listener in parameter from this plugin action.
 void setEnabled(boolean enabled)
          Sets the enabled state of this action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PluginAction

public PluginAction()
Creates a disabled plug-in action.


PluginAction

public PluginAction(String resourceBaseName,
                    String actionPrefix,
                    ClassLoader pluginClassLoader)
Creates a disabled plug-in action with properties retrieved from a resource bundle in which key starts with actionPrefix.
For example, a plug-in action created by the call new PluginAction("com.mycompany.mypackage.MyResources", "EXPORT", plugin.getPluginClassLoader()) will retrieve its property values from the /com/mycompany/mypackage/MyResources.properties file bundled with the plug-in class, and this file may describe the action EXPORT with the following keys:
 EXPORT.NAME=Export
 EXPORT.SHORT_DESCRIPTION=Export home data
 EXPORT.SMALL_ICON=/com/mycompany/mypackage/resources/export.png
 EXPORT.MNEMONIC=X
 EXPORT.IN_TOOL_BAR=true
 EXPORT.MENU=File

Parameters:
resourceBaseName - the base name of a resource bundle
actionPrefix - prefix used in resource bundle to search action properties
pluginClassLoader - the class loader that will be used to search the resource bundle
Throws:
MissingResourceException - if no resource bundle could be found from resourceBaseName.

PluginAction

public PluginAction(String resourceBaseName,
                    String actionPrefix,
                    ClassLoader pluginClassLoader,
                    boolean enabled)
Creates an action with properties retrieved from a resource bundle in which key starts with actionPrefix.

Parameters:
resourceBaseName - the base name of a resource bundle
actionPrefix - prefix used in resource bundle to search action properties
pluginClassLoader - the class loader that will be used to search the resource bundle
enabled - true if the action should be enabled at creation.
Throws:
MissingResourceException - if no resource bundle could be found from resourceBaseName.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds the property change listener in parameter to this plugin action.


removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes the property change listener in parameter from this plugin action.


getPropertyValue

public Object getPropertyValue(PluginAction.Property property)
Returns a property value of this action.


putPropertyValue

public void putPropertyValue(PluginAction.Property property,
                             Object value)
Sets a property value of this action, and fires a PropertyChangeEvent if the value changed.


setEnabled

public void setEnabled(boolean enabled)
Sets the enabled state of this action. When enabled, any menu item or tool bar button associated with this object is enabled and able to call the execute method. If the value has changed, a PropertyChangeEvent is sent to listeners. By default, an action is disabled.


isEnabled

public boolean isEnabled()
Returns the enabled state of this action.

Returns:
true if this action is enabled.

execute

public abstract void execute()
Executes this action. This method will be called by application when the user wants to execute this action.


Sweet Home 3D 4.0

© Copyrights 2006-2013 eTeks - All rights reserved
Distributed under GNU General Public License