com.jbbres.lib.actions.tools.elements
Class ResourceBundleElementDescription<T extends Element>

java.lang.Object
  extended by com.jbbres.lib.actions.tools.elements.ResourceBundleElementDescription<T>
All Implemented Interfaces:
ElementDescription<T>, com.jbbres.lib.search.Searchable, java.lang.Comparable<ElementDescription<?>>
Direct Known Subclasses:
AbstractElementDescription, ResourceBundleActionDescription, ResourceBundleVariableDescription

public abstract class ResourceBundleElementDescription<T extends Element>
extends java.lang.Object
implements ElementDescription<T>

Provides information regarding the element, such as its name, a short description, its version number etc.

This abstract class provides the description of an element by extracting the content of an element properties file (.properties).
A properties file is a simple text file. You can create and maintain a properties file with just about any text editor.
The name of this file begins with the base name of your element, but start with a lower case, and ends with the .properties suffix. For example, if you are creating an action whom class base name is MyAction, Therefore the properties file is called myAction.properties. This file contains the following lines:

# This is the default myAction.properties file
type=action
description.title=Add Text To File Name
description.summary=This action add a text before or after\
the names of the files or folders passed into it.
description.icon=icon.png
description.categories=#FilesCategory
description.company.name=Acme
description.company.website=http://www.acme.com/
description.company.support=http://www.acme.com/
description.version=1.0
description.copyright=© 2009-2010 Acme

Amoung other usages, The properties are used by Action(s) to displays the description in its lower-left view whenever the user selects the element. The description briefly describes what the element does and tells users anything else they should know about the action.
Because the description fits into a relatively small area of the Action(s) window, you should make it as concise and brief as possible. Ideally the user should not have to scroll the description view to see all of the text.

A description has several parts:

A description’s icon, title, summary, input and ouput are required or strongly recommended.

ResourceBundleElementDescription serves as a commun basis for ResourceBundleActionDescription and ResourceBundleVariableDescription. Actions and variables willing to use an element information property file (.properties) as a description can extends these two classes. You may not have to create a subclass of ResourceBundleElementDescription directly.

Since:
1.0.0
Version:
1.0.0
Author:
Jean-Baptiste Bres

Field Summary
 
Fields inherited from interface com.jbbres.lib.actions.elements.ElementDescription
CATEGORY_SEPARATOR, DESCRIPTION_CATEGORIES, DESCRIPTION_COMPANY_NAME, DESCRIPTION_COMPANY_SUPPORT, DESCRIPTION_COMPANY_WEBSITE, DESCRIPTION_COPYRIGHT, DESCRIPTION_ICON, DESCRIPTION_SUMMARY, DESCRIPTION_TITLE, DESCRIPTION_VERSION, TYPE
 
Constructor Summary
ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz)
          Instantiates a new ResourceBundleElementDescription describing the given Element class.
ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz, java.util.ResourceBundle resourceBundle)
          Instantiates a new resource bundle element description.
ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz, java.lang.String baseName)
          Instantiates a new ResourceBundleElementDescription describing the given Element class.
 
Method Summary
 void addElementDescriptionChangeListener(ElementDescriptionChangeListener listener)
          Adds a element description change listener.
 int compareTo(ElementDescription<?> properties)
           
abstract  javax.swing.ImageIcon defaultIcon()
          Returns the element default icon.
 void fireElementDesccriptionChange(java.lang.String descriptionKey, java.lang.String oldValue)
          Fire element desccription change.
 Category[] getCategories()
          Returns the categories associated to the element.
 java.lang.String getDescription(java.lang.String key)
          Returns the information associated to the given key.
 java.lang.Class<? extends Element> getElementClass()
          Returns the element class.
static ElementDescription<?> getElementDescription(java.lang.Class<? extends Element> clazz)
          Extracts the element description object associated to a given Element class.
 javax.swing.ImageIcon getIcon()
          Returns the icon associated to the element.
 java.lang.Object getSearchableValue(com.jbbres.lib.search.SearchField<?> field)
           
 Element newElementInstance(Workflow workflow)
          Creates and returns a new instance of the element described.
 void removeElementDescriptionChangeListener(ElementDescriptionChangeListener listener)
          Removes a element description change listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceBundleElementDescription

public ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz)
                                 throws java.io.IOException
Instantiates a new ResourceBundleElementDescription describing the given Element class.

Resource bundles belong to families whose members share a common base name, but whose names also have additional components that identify their locales. If you use this constructor, Action(s) will define the base name based on the element class name but with lower case letter instead of the upper case describing the class. So, for example, if your element class is MyAction, the associated base name will be myAction.

The resource details should be stored in properties files associated to the base name. The family should have a default resource bundle properties file which simply has the same name as its family - "myAction.properties" - and will be used as the bundle of last resort if a specific locale is not supported. The family can then provide as many locale-specific members as needed, for example a French one named "myResources_fr.properties".
Each resource bundle in a family contains the same items, but the items have been translated for the locale represented by that resource bundle. For example, both "myAction.properties" and "myAction_fr.properties" should have a String that's used to define the title of the element. In "myAction.properties" the String may contain "My Action" and in "myAction_fr.properties" it may contain "Mon Action".
If there are different resources for different countries, you can make specializations: for example, "MyResources_fr_CH" contains objects for the French language (fr) in Switzerland (CH). If you want to only modify some of the resources in the specialization, you can do so.

Parameters:
elementClazz - - the element clazz
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

ResourceBundleElementDescription

public ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz,
                                        java.lang.String baseName)
                                 throws java.io.IOException
Instantiates a new ResourceBundleElementDescription describing the given Element class. The description is extracted from the ressource bundle associated to the given base name.

Resource bundles belong to families whose members share a common base name, but whose names also have additional components that identify their locales. For example, the base name of a family of resource bundles might be "MyResources". The family should have a default resource bundle which simply has the same name as its family - "MyResources" - and will be used as the bundle of last resort if a specific locale is not supported. The family can then provide as many locale-specific members as needed, for example a German one named "MyResources_de".
Each resource bundle in a family contains the same items, but the items have been translated for the locale represented by that resource bundle. For example, both "MyResources" and "MyResources_de" may have a String that's used on a button for canceling operations. In "MyResources" the String may contain "Cancel" and in "MyResources_de" it may contain "Abbrechen".
If there are different resources for different countries, you can make specializations: for example, "MyResources_de_CH" contains objects for the German language (de) in Switzerland (CH). If you want to only modify some of the resources in the specialization, you can do so.

Parameters:
elementClazz - - the element clazz
baseName - - the resource bundle base name
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

ResourceBundleElementDescription

public ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz,
                                        java.util.ResourceBundle resourceBundle)
Instantiates a new resource bundle element description.

Parameters:
elementClazz - the element clazz
resourceBundle - the resource bundle
Method Detail

getElementDescription

public static ElementDescription<?> getElementDescription(java.lang.Class<? extends Element> clazz)
                                                   throws java.io.IOException
Extracts the element description object associated to a given Element class.

Parameters:
clazz - - the Element class
Returns:
the element description
Throws:
java.io.IOException - Signals that an I/O exception has occurred.

defaultIcon

public abstract javax.swing.ImageIcon defaultIcon()
Returns the element default icon.

Returns:
the image icon

getCategories

public Category[] getCategories()
Description copied from interface: ElementDescription
Returns the categories associated to the element.

Specified by:
getCategories in interface ElementDescription<T extends Element>
Returns:
the categories associated to the element

getDescription

public java.lang.String getDescription(java.lang.String key)
Description copied from interface: ElementDescription
Returns the information associated to the given key.

Specified by:
getDescription in interface ElementDescription<T extends Element>
Parameters:
key - - the key
Returns:
the information associated to the given key.

getIcon

public javax.swing.ImageIcon getIcon()
Description copied from interface: ElementDescription
Returns the icon associated to the element.

Specified by:
getIcon in interface ElementDescription<T extends Element>
Returns:
the icon associated to the element

getElementClass

public java.lang.Class<? extends Element> getElementClass()
Returns the element class.

Returns:
the elementClazz

newElementInstance

public Element newElementInstance(Workflow workflow)
Description copied from interface: ElementDescription
Creates and returns a new instance of the element described.

This methods should not add the new element to the given workflow. Action(s) takes care of calling the appropried Workflow.add(Element) method.

Specified by:
newElementInstance in interface ElementDescription<T extends Element>
Parameters:
workflow - - the workflow that will own the element
Returns:
a new instance of the element described.

addElementDescriptionChangeListener

public void addElementDescriptionChangeListener(ElementDescriptionChangeListener listener)
Description copied from interface: ElementDescription
Adds a element description change listener.

Specified by:
addElementDescriptionChangeListener in interface ElementDescription<T extends Element>
Parameters:
listener - - the listener
See Also:
ElementDescriptionChangeListener

removeElementDescriptionChangeListener

public void removeElementDescriptionChangeListener(ElementDescriptionChangeListener listener)
Removes a element description change listener.

Specified by:
removeElementDescriptionChangeListener in interface ElementDescription<T extends Element>
Parameters:
listener - - the listener
See Also:
ElementDescriptionChangeListener

fireElementDesccriptionChange

public void fireElementDesccriptionChange(java.lang.String descriptionKey,
                                          java.lang.String oldValue)
Fire element desccription change.

Parameters:
descriptionKey - the description key
oldValue - the old value

getSearchableValue

public java.lang.Object getSearchableValue(com.jbbres.lib.search.SearchField<?> field)
Specified by:
getSearchableValue in interface com.jbbres.lib.search.Searchable

compareTo

public int compareTo(ElementDescription<?> properties)
Specified by:
compareTo in interface java.lang.Comparable<ElementDescription<?>>


To file bugs or suggest feature enhancements, visit the app.jbbres.com Bug Reporter website.

Additional documentation available online at http://app.jbbres.com/actions/developers.

Copyright � 2009-2011 app.jbbres.com. All Rights Reserved.