|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.gui.component.AttributeEditorProperties
The AttributeEditorProperties class maintains the properties of
an AttributeTable, such as hidden Attributes and Enumerations.
Use the methods of this class to determine whether Attributes should be hidden,
mark certain attributes to be hidden, retrieve all predefined enumerations or
store newly created ones. Basically this class encapsulates a simple
properties file.
This class is usually created by the AttributeEditor itself and can then
be retrieved by calling the AttributeEditor.getEditorProperties() method.
This class is used to set up the behavior of an AttributeEditor.
It controls the sorting, visibility and mutability of attributes.
It also contains a map of generic settings that can be freely defined by an
AttributeEditor implementation.
All settings are stored in a properties file if persistence is not deactivated
(e.g. by calling the constructor with null as the filename value).
An AttributeEditor using this class may support the following
configuration settings listed in the constants. Implementations of the
AttributeEditor interface should list the supported properties
in the JavaDoc.
PROPERTYNAME_SHOWCATEGORIESPROPERTYNAME_USEEXACTMATCHINGPROPERTYNAME_AUTOEXPANDCATEGORIESPROPERTYNAME_RENAMINGALLOWEDPROPERTYNAME_ENABLE_WRITEPROTECTIONPROPERTYNAME_MERGEELEMENTTYPESPROPERTYNAME_DYNAMICROWHEIGHT
The visibility of an Attribute can be queried and set by calling
the following methods.
boolean isVisible(String)void setVisible(String, boolean)
The mutability of an Attribute can be queried and set by calling
the following methods.
Note: You should not make an Attribute mutable in the editor if
it has been returned immutable from the AttributableOnSet.
boolean isMutable(String)void setMutable(String, boolean)
The following methods control the persistence of the properties and other
configurations stored in an AttributeEditorProperties
instance:
void readProperties()void writeProperties()void enablePropertyPersistence()void disablePropertyPersistence()boolean isPropertyPersistenceEnabled()It is possible to specify new attribute display names with the following methods:
String getName(String)void renameAttribute(String, String)
The following methods can be used to retrieve or set the properties that
define the AttributeEditor behavior. Which properties are
supported depends on the AttributeEditor that is used. A basic
list of properties is shown in the usage documentation.
Object getPropery(String)void setProperty(String, Object)void assertProperty(String, Object)boolean getBoolean(String, boolean)
To manage the sort order in the AttributeEditor you should
use these methods:
int getSortMode()void setSortMode(int)Comparator getSortComparator()
| Nested Class Summary | |
static class |
AttributeEditorProperties.Enum
Class Enum encapsulates a Constraint instance and a String. |
| Field Summary | |
static java.lang.String |
DEFAULT_FILENAME
Default filename for the properties file is set to attributeEditor.properties. |
static java.lang.String |
PROPERTYNAME_AUTOEXPANDCATEGORIES
If this value is true, all categories will be expanded when showing the AttributeTree for the first time. |
static java.lang.String |
PROPERTYNAME_DYNAMICROWHEIGHT
Set this property to true in order to enable different row heights. |
static java.lang.String |
PROPERTYNAME_ENABLE_WRITEPROTECTION
The method isMutable(String) is called to determine the mutable
state of an Attribute when this property is enabled. |
static java.lang.String |
PROPERTYNAME_MERGEELEMENTTYPES
Use this property to merge the element types so that Attributes
from different types of AttributableOnSets can be edited in
a multi-selection, even though the root element of the structure - which
usually represents the name of the type - is different.
|
static java.lang.String |
PROPERTYNAME_RENAMINGALLOWED
Set this property to true if the user should be able to rename attributes in the tree, for example by pressing F2 or clicking in the first column of a selected line. |
static java.lang.String |
PROPERTYNAME_SHOWCATEGORIES
If this property is set to false, all category elements in the tree are hidden. |
static java.lang.String |
PROPERTYNAME_USEEXACTMATCHING
If this property is set to true, attribute editor states will exactly match the selected AttributableOnSet instance.
|
static int |
SORTMODE_ASCENDING
Sort mode: ascending |
static int |
SORTMODE_DESCENDING
Sort mode: descending |
static int |
SORTMODE_NONE
Sort mode: ascending |
| Constructor Summary | |
AttributeEditorProperties(AttributeEditor editor)
Creates a new AttributeEditorProperties instance. |
|
AttributeEditorProperties(AttributeEditor editor,
java.lang.String filename)
Creates a new AttributeEditorProperties instance based on
the given properties file specified by the parameter filename. |
|
| Method Summary | |
void |
addChangeListener(AttributeEditorPropertiesListener aepl)
Adds a listener that will be notified if one ore more of the properties changed. |
void |
addFilter(java.lang.String filter)
Adds a filter to the list that is used to determine the visibility of attributes. |
void |
addNamedConstraint(AttributeEditorProperties.Enum enm)
Method addEnum adds the given enum constraint to the internal list and updates the property file. |
void |
addNamedConstraint(Constraint constraint,
java.lang.String name)
This method adds the given constraint and updates the property file. |
void |
assertProperty(java.lang.String propertyName,
java.lang.Object value)
Asserts the existence of the property with the given name and creates it with the value provided if it does not already exist. |
boolean |
checkAgainstFilters(java.lang.String attributePath)
Checks if an attribute should be visible in the editor according to the list of filters. |
void |
clearFilters()
Removes all filters from the list, so all attributes (that are not part of the hidden attributes list) are shown in the editor. |
boolean |
containsCustomName(java.lang.String pathName)
Returns true if the custom rename map for attribute names contains the given path name. |
boolean |
containsEnum(java.lang.String enumTitle)
Returns true, if the given enumTitle parameter can be found
in the internal list of enumerations. |
void |
disablePropertyPersistence()
Disables property persistence. |
void |
enablePropertyPersistence()
Enables property persistence. |
AttributeEditorTranslator |
getAttributeEditorTranslator()
Returns the attribute editor translator that is used for translation of attribute names to a localized string. |
boolean |
getBoolean(java.lang.String name,
boolean defValue)
Returns the boolean value of the specified property name. |
java.util.Collection |
getHiddenAttributes()
This method returns a Collection of strings which represent the names of all hidden attributes. |
java.lang.String |
getName(java.lang.String pathName)
Returns the user-defined name or localization for the given set or category name. |
java.lang.String |
getName(java.lang.String pathName,
boolean useCustomNames)
Returns the user-defined name or localization for the given set or category name. |
java.util.List |
getNamedConstraints()
This method returns a List of all named constraints. |
java.lang.Object |
getPropery(java.lang.String name)
Returns a generic object stored as a property in this instance using the given name. |
java.util.Collection |
getShowFilters()
This method returns a Collection of strings which represent the filters for all attributes to show. |
java.util.Comparator |
getSortComparator()
Returns the sort comparator that can be used to sort the items in the edited AttributeSet. |
int |
getSortMode()
Returns the currently used sort mode. |
java.lang.String |
getValue(java.lang.String pathName,
java.lang.String value)
Returns the user-defined value for the given set or category name. |
void |
hideAttribute(java.lang.String name)
Deprecated. use setVisible(String, boolean) instead! |
boolean |
isHidden(java.lang.String name)
Deprecated. use isVisible(String) instead. |
boolean |
isHidingEnabled()
Returns true if the overall hiding mechanism is enabled, otherwise false. |
boolean |
isMutable(java.lang.String name)
Returns the mutable state of the specified editor attribute. |
boolean |
isPropertyPersistenceEnabled()
Returns a boolean that indicates whether the settings of
the AttributeEditorProperties instance are automatically
stored inside a file or not. |
boolean |
isUsingFilters()
Returns true, if the visibility is determined using a list of filters. |
boolean |
isVisible(java.lang.String name)
Returns true if the given name is in the list of
hiddenAttributeNames, otherwise false. |
protected void |
propertiesChanged()
Called whenever a property or setting changed, so the table can be notified and the values can be stored to the file. |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
|
void |
readProperties()
Loads the property file if one exists and initializes the internal hiddenAttributesNames list. |
void |
removeChangeListener(AttributeEditorPropertiesListener aepl)
Removes a listener that will be notified if one ore more of the properties changed. |
void |
removeFilter(java.lang.String filter)
Removes a previously added filter from the list. |
void |
removeNamedConstraint(AttributeEditorProperties.Enum enm)
Method removeNamedConstraint removes a given constraint from the internal List. |
void |
renameAttribute(java.lang.String pathName,
java.lang.String newName)
Adds a rename entry for the given full path name of a category. |
void |
renameAttribute(java.lang.String pathName,
java.lang.String newName,
java.util.Locale locale)
Adds a rename entry for the given full path name of a category. |
void |
setAttributeEditorTranslator(AttributeEditorTranslator attributeEditorTranslator)
Assigns the attribute editor translator to use for translation of attribute names to a localized string. |
void |
setHidingEnabled(boolean enabled)
Method setEnabled allows users to turn off the hiding-mechanism of attributes, which are marked as hidden through this Properties class. |
void |
setMutable(java.lang.String name,
boolean mutable)
Sets the mutable state of an Attribute for the editor.
|
void |
setProperty(java.lang.String name,
java.lang.Object value)
Call this method to store additional editor configuration attributes. |
void |
setSortMode(int sortMode)
Sets the sort mode that should be used. |
void |
setVisible(java.lang.String name,
boolean visible)
Sets the visibility of an Attribute for the corresponding
editor and updates the properties file. |
void |
showAttribute(java.lang.String name)
Deprecated. use setVisible(String, boolean) instead! |
void |
updateNamedConstraint(AttributeEditorProperties.Enum enm)
Updates an enumeration entry in the internal list, by removing the element and then adding it. |
void |
writeProperties()
If a valid PropertiesFile is available and the persistence
is enabled this method writes out all information containing the states
of the attributes (visibility, mutability), the rename map and all
generic properties that have been set using the
setProperty(String, Object) method. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String PROPERTYNAME_SHOWCATEGORIES
Boolean.TRUE
public static final java.lang.String PROPERTYNAME_USEEXACTMATCHING
AttributableOnSet instance.
Default = Boolean.TRUE
public static final java.lang.String PROPERTYNAME_MERGEELEMENTTYPES
Attributes
from different types of AttributableOnSets can be edited in
a multi-selection, even though the root element of the structure - which
usually represents the name of the type - is different.
Default =Boolean.FALSE
public static final java.lang.String PROPERTYNAME_RENAMINGALLOWED
Boolean.TRUE
public static final java.lang.String PROPERTYNAME_ENABLE_WRITEPROTECTION
isMutable(String) is called to determine the mutable
state of an Attribute when this property is enabled.AttributableOnSet
should not be set to mutable by the editor. Only mutable attributes may be
changed to immutable to prevent the user from editing. Default =
Boolean.FALSE
public static final java.lang.String PROPERTYNAME_DYNAMICROWHEIGHT
Boolean.FALSE
public static final java.lang.String PROPERTYNAME_AUTOEXPANDCATEGORIES
AttributeTree for the first time. Additionally, no stored tree
state is available for the current element type. Default =
Boolean.FALSE
public static final int SORTMODE_NONE
public static final int SORTMODE_ASCENDING
public static final int SORTMODE_DESCENDING
public static final java.lang.String DEFAULT_FILENAME
attributeEditor.properties.
| Constructor Detail |
public AttributeEditorProperties(AttributeEditor editor)
AttributeEditorProperties instance.
editor - The editor these settings apply to
public AttributeEditorProperties(AttributeEditor editor,
java.lang.String filename)
AttributeEditorProperties instance based on
the given properties file specified by the parameter filename.
editor - The editor this instance will belong tofilename - The name of the properties file for this class.| Method Detail |
public void readProperties()
public boolean isHidden(java.lang.String name)
isVisible(String) instead.
name - the attribute to check.
public void setMutable(java.lang.String name,
boolean mutable)
Attribute for the editor.
Note that you cannot turn an immutable Attribute returned
from an AttributableOnSet into a mutable one for the editor.
name - The full path name of the attributemutable - false, to write protect the attribute in the editor
true, to remove the name from the map and use the
mutable state returned by the AttributableOnSetpublic boolean isMutable(java.lang.String name)
Attribute may still be
immutable even thought this method returns true.
name - The full path name of the attribute
public boolean isVisible(java.lang.String name)
true if the given name is in the list of
hiddenAttributeNames, otherwise false.
name - the attribute to check.
public void setVisible(java.lang.String name,
boolean visible)
Attribute for the corresponding
editor and updates the properties file.
name - the name of the attribute which visibility should be changes.visible - true, to show the attribute and false to hide itpublic void addFilter(java.lang.String filter)
removeFilter(String) or
clearFilters().
filter - The filter string to addremoveFilter(String),
clearFilters(),
checkAgainstFilters(String)public void removeFilter(java.lang.String filter)
filter - the filter to removeaddFilter(String),
clearFilters(),
checkAgainstFilters(String)public void clearFilters()
addFilter(String),
removeFilter(String)public boolean isUsingFilters()
public boolean checkAgainstFilters(java.lang.String attributePath)
attributePath - The pathname to check
public boolean isPropertyPersistenceEnabled()
boolean that indicates whether the settings of
the AttributeEditorProperties instance are automatically
stored inside a file or not.
public void enablePropertyPersistence()
AttributeEditorProperties are automatically stored
inside a file.
public void disablePropertyPersistence()
AttributeEditorProperties will not be automatically
stored inside a file.
Notice: an existing AttributeEditorProperties file will not
be deleted when disabling property persistence.
public void writeProperties()
throws java.io.IOException
PropertiesFile is available and the persistence
is enabled this method writes out all information containing the states
of the attributes (visibility, mutability), the rename map and all
generic properties that have been set using the
setProperty(String, Object) method.
java.io.IOException - When there is an io error while writing datapublic java.util.Collection getHiddenAttributes()
public java.util.Collection getShowFilters()
public void setHidingEnabled(boolean enabled)
enabled - true to enable the property driven hiding mechanism, false to
turn that off.public boolean isHidingEnabled()
public java.util.List getNamedConstraints()
List of all named constraints.
public void addNamedConstraint(Constraint constraint,
java.lang.String name)
constraint - The Constraint instance describing the enumeration.name - A human readable name for the given enumeration.public boolean containsEnum(java.lang.String enumTitle)
true, if the given enumTitle parameter can be found
in the internal list of enumerations.
enumTitle - the title to look for.
public void addNamedConstraint(AttributeEditorProperties.Enum enm)
public void removeNamedConstraint(AttributeEditorProperties.Enum enm)
public void updateNamedConstraint(AttributeEditorProperties.Enum enm)
public void renameAttribute(java.lang.String pathName,
java.lang.String newName)
pathName - The full path name of the category or attribute to renamenewName - The new name of the item (only the name, not the full path)
public void renameAttribute(java.lang.String pathName,
java.lang.String newName,
java.util.Locale locale)
pathName - The full path name of the category or attribute to
renamenewName - The new name of the item (only the name, not the
full path)locale - The locale to add set custom name forpublic boolean containsCustomName(java.lang.String pathName)
pathName - The path name of the attribute to look for
public java.lang.String getName(java.lang.String pathName)
pathName - The full path name of the category or attribute
public java.lang.String getName(java.lang.String pathName,
boolean useCustomNames)
pathName - The full path name of the category or attributeuseCustomNames - If this parameter is true the custom names map
is used. Otherwise only the language resources are
used to find a localized name.
public java.lang.String getValue(java.lang.String pathName,
java.lang.String value)
pathName - The full path name of the category or attributevalue - The value
public void setProperty(java.lang.String name,
java.lang.Object value)
name - The name of the propertyvalue - The value of the property
public boolean getBoolean(java.lang.String name,
boolean defValue)
name - The name of the property to checkdefValue - The default value to return instead
public void assertProperty(java.lang.String propertyName,
java.lang.Object value)
propertyName - The name of the property to assertvalue - The value to use, if it doesn't existpublic java.lang.Object getPropery(java.lang.String name)
name - The name of the property to retrieve
public java.util.Comparator getSortComparator()
AttributeSet. The comparator returned
depends on the sort mode, so you will have to call this method again
after the sort mode changed.
public void setSortMode(int sortMode)
sortMode - The sort mode to use.public int getSortMode()
protected void propertiesChanged()
public void hideAttribute(java.lang.String name)
setVisible(String, boolean) instead!
name - the name of the attribute which should be hidden.public void showAttribute(java.lang.String name)
setVisible(String, boolean) instead!
name - the name of the attribute which should no longer be hidden.public void addChangeListener(AttributeEditorPropertiesListener aepl)
aepl - The listener to addpublic void removeChangeListener(AttributeEditorPropertiesListener aepl)
aepl - The listener to removepublic void setAttributeEditorTranslator(AttributeEditorTranslator attributeEditorTranslator)
attributeEditorTranslator - The translator to setpublic AttributeEditorTranslator getAttributeEditorTranslator()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange in interface java.beans.PropertyChangeListener
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||