|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jbbres.lib.actions.tools.elements.ResourceBundleElementDescription<T>
public abstract class ResourceBundleElementDescription<T extends Element>
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:
description.icon
: a 32 x 32 pixel image displayed in the
upper-left corner of the description. In the properties file you should
provide the relative path of the image within the package. Accepted format
are PNG, JPEG, GIF and BMP.description.title
: the name of the element.description.summary
: a sentence or two directly under the
title that succinctly states what the element does.
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.
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 |
---|
public ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz) throws java.io.IOException
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.
elementClazz
- - the element clazz
java.io.IOException
- Signals that an I/O exception has occurred.public ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz, java.lang.String baseName) throws java.io.IOException
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.
elementClazz
- - the element clazzbaseName
- - the resource bundle base name
java.io.IOException
- Signals that an I/O exception has occurred.public ResourceBundleElementDescription(java.lang.Class<? extends Element> elementClazz, java.util.ResourceBundle resourceBundle)
elementClazz
- the element clazzresourceBundle
- the resource bundleMethod Detail |
---|
public static ElementDescription<?> getElementDescription(java.lang.Class<? extends Element> clazz) throws java.io.IOException
Element
class.
clazz
- - the Element
class
java.io.IOException
- Signals that an I/O exception has occurred.public abstract javax.swing.ImageIcon defaultIcon()
public Category[] getCategories()
ElementDescription
getCategories
in interface ElementDescription<T extends Element>
public java.lang.String getDescription(java.lang.String key)
ElementDescription
getDescription
in interface ElementDescription<T extends Element>
key
- - the key
public javax.swing.ImageIcon getIcon()
ElementDescription
getIcon
in interface ElementDescription<T extends Element>
public java.lang.Class<? extends Element> getElementClass()
public Element newElementInstance(Workflow workflow)
ElementDescription
This methods should not add the new element to the given workflow.
Action(s) takes care of calling the appropried
Workflow.add(Element)
method.
newElementInstance
in interface ElementDescription<T extends Element>
workflow
- - the workflow that will own the element
public void addElementDescriptionChangeListener(ElementDescriptionChangeListener listener)
ElementDescription
addElementDescriptionChangeListener
in interface ElementDescription<T extends Element>
listener
- - the listenerElementDescriptionChangeListener
public void removeElementDescriptionChangeListener(ElementDescriptionChangeListener listener)
removeElementDescriptionChangeListener
in interface ElementDescription<T extends Element>
listener
- - the listenerElementDescriptionChangeListener
public void fireElementDesccriptionChange(java.lang.String descriptionKey, java.lang.String oldValue)
descriptionKey
- the description keyoldValue
- the old valuepublic java.lang.Object getSearchableValue(com.jbbres.lib.search.SearchField<?> field)
getSearchableValue
in interface com.jbbres.lib.search.Searchable
public int compareTo(ElementDescription<?> properties)
compareTo
in interface java.lang.Comparable<ElementDescription<?>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |