Package com.iizigo.prop
Class PropertyEditorSetup
- java.lang.Object
- com.iizigo.prop.PropertyEditorSetup
public class PropertyEditorSetup extends java.lang.Object
Class holding information in a plug-in of the Property Classes and how to set up their Editors.- Author:
- Christopher Mindus, Mikael Andersson
Field Summary
Fields Modifier and Type Field Description java.lang.ClassLoader
classLoader
Get the resource bundle.
Constructor Summary
Constructors Constructor Description PropertyEditorSetup(java.util.ResourceBundle resourceBundle)
Constructor.PropertyEditorSetup(java.util.ResourceBundle resourceBundle, java.lang.ClassLoader classLoader)
Constructor.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
assignBundleContext(org.osgi.framework.BundleContext bundleContext)
Assigns the bundle.boolean
equalsMultiEdit(PropertyEditorSetup setup)
Checks if two instances are "multi-edit-equals", i.e.java.lang.Class<?>
forName(java.lang.String cn)
Loads a class using the appropriate class loader.java.lang.String
getBundleSymbolicName()
Gets the bundle symbolic name.java.lang.String
getDefaultPropertyValue(java.lang.String name)
Gets a default value for a property.java.lang.String[]
getEditOptions(java.lang.String name)
Gets a String for the IEditProperty for a property.PropCnrEditorProperties
getEditProperties(PropCnr pc)
Gets the name mapping from a class to another, e.g.PropCnrEditorProperties
getEditProperties(PropCnr pc, boolean logError)
Gets the name mapping from a class to another, e.g.PropCnrEditorProperties
getEditProperties(PropCnr pc, boolean logError, java.lang.Throwable prev)
Gets the name mapping from a class to another, e.g.IEditedPropertyEntry<?,?>
getEditProperty(java.lang.String name)
Gets an IEditProperty for a property.java.lang.String
getGroup(java.lang.String name)
Gets the group for a property name.IGroupTextFormatter
getGroupFormatter(java.lang.String group)
Gets an group formatter for a group.PropertyEditorGroupInfo
getGroupInfo(java.lang.String group)
Gets the group information to use.java.lang.String
getGroupTextPrompt(java.lang.String group)
Get a group text prompt.java.lang.String
getGroupToolTipText(java.lang.String group)
Get a group tooltip text.java.lang.String
getParentProperty(java.lang.String name)
Gets parent property name.boolean
getPrivate(java.lang.String name)
Gets the text prompt for a property name.java.lang.Class<GProp<?>>
getPropertyClass(java.lang.String name)
Gets the class for the property.java.lang.String
getString(java.lang.String key)
Gets the localized string from a resource bundle.java.lang.String
getTextPrompt(java.lang.String name)
Gets the text prompt for a property name.java.lang.String
getToolTipText(java.lang.String name)
Gets the tooltip text for a property name.IEntryValidator
getValidator(java.lang.String name)
Gets an entry/property validator.boolean
hasAtLeastOnePropertyInGroup(PropertyEditorInfo[] infos, java.lang.String[] names)
Helper to check for at least one property in group.boolean
hasNonEmptyString(java.lang.String key)
Checks if string is present.java.lang.String
verifyPropertiesPresentInGroup(PropertyEditorInfo[] infos, java.lang.String[] names)
Helper to verify properties are present for a group.
Constructor Detail
PropertyEditorSetup
public PropertyEditorSetup(java.util.ResourceBundle resourceBundle)
Constructor.- Parameters:
resourceBundle
- Resource bundle.
PropertyEditorSetup
public PropertyEditorSetup(java.util.ResourceBundle resourceBundle, java.lang.ClassLoader classLoader)
Constructor.- Parameters:
resourceBundle
- Resource bundle.classLoader
- The class loader or null for default.
Method Detail
assignBundleContext
public void assignBundleContext(org.osgi.framework.BundleContext bundleContext)
Assigns the bundle.- Parameters:
bundleContext
- The bundle context.
getBundleSymbolicName
public java.lang.String getBundleSymbolicName()
Gets the bundle symbolic name.- Returns:
- The symbolic name of the bundle.
forName
public java.lang.Class<?> forName(java.lang.String cn) throws java.lang.ClassNotFoundException
Loads a class using the appropriate class loader.- Parameters:
cn
- The class name to load.- Throws:
java.lang.ClassNotFoundException
- For class loader errors.
getString
public java.lang.String getString(java.lang.String key)
Gets the localized string from a resource bundle.- Parameters:
key
- The key for the localized message.- Returns:
- The string matching a key, or
"?<i>key</i>?"
if not found.
hasNonEmptyString
public boolean hasNonEmptyString(java.lang.String key)
Checks if string is present.- Parameters:
key
- The key to verify.- Returns:
- true if the key is present and is has a non-empty value String.
getPrivate
public boolean getPrivate(java.lang.String name)
Gets the text prompt for a property name.- Parameters:
name
- The property name.- Returns:
- true If the key
<i>name</i>.private
equals to (String) "true
".
getTextPrompt
public java.lang.String getTextPrompt(java.lang.String name)
Gets the text prompt for a property name.- Parameters:
name
- The property name.- Returns:
- The text prompt for the key, or
"?<i>name</i>.p?"
if not found.
getToolTipText
public java.lang.String getToolTipText(java.lang.String name)
Gets the tooltip text for a property name.- Parameters:
name
- The property name.- Returns:
- The text prompt for the key, or
"?<i>name</i>.t?"
if not found.
getGroup
public java.lang.String getGroup(java.lang.String name)
Gets the group for a property name.- Parameters:
name
- The property name.- Returns:
- The text prompt for the key, or
"?<i>name</i>.g?"
if not found.
getGroupTextPrompt
public java.lang.String getGroupTextPrompt(java.lang.String group)
Get a group text prompt.- Parameters:
group
- The group name.- Returns:
- The group text prompt for the key, or
"?_<i>group</i>.g?"
if not found.
getGroupToolTipText
public java.lang.String getGroupToolTipText(java.lang.String group)
Get a group tooltip text.- Parameters:
group
- The group name.- Returns:
- The group tooltip text for the key, or
"?_<i>group</i>.t?"
if not found.
getGroupInfo
public PropertyEditorGroupInfo getGroupInfo(java.lang.String group)
Gets the group information to use.- Parameters:
group
- The group name.- Returns:
- The PropertyEditorGroupInfo instance, or
null
if not found.
getPropertyClass
public java.lang.Class<GProp<?>> getPropertyClass(java.lang.String name)
Gets the class for the property. An InternalError is thrown in case the class is not found.- Parameters:
name
- The property class name to find.- Returns:
- The class, or
null
if thename
ends with "$" or starts with '%'. - Throws:
java.lang.InternalError
- If the class is not found.
getParentProperty
public java.lang.String getParentProperty(java.lang.String name)
Gets parent property name.- Parameters:
name
- The name of the property.- Returns:
- null if not specified.
getEditProperty
public IEditedPropertyEntry<?,?> getEditProperty(java.lang.String name)
Gets an IEditProperty for a property. An InternalError is thrown if the instance cannot be created.- Parameters:
name
- The name of the property.- Returns:
- The IEditedPropertyEntry interface.
- Throws:
java.lang.InternalError
- If IEditedPropertyEntry interface is not found.
getDefaultPropertyValue
public java.lang.String getDefaultPropertyValue(java.lang.String name)
Gets a default value for a property.- Parameters:
name
- The name of the property.- Returns:
- The description string of the name property, or empty string if not found.
getEditOptions
public java.lang.String[] getEditOptions(java.lang.String name)
Gets a String for the IEditProperty for a property.- Parameters:
name
- The name of the property.- Returns:
- null for none.
getGroupFormatter
public IGroupTextFormatter getGroupFormatter(java.lang.String group)
Gets an group formatter for a group. If no group formatter is defined, null is returned.- Parameters:
group
- The group name of the property.- Throws:
java.lang.InternalError
- If the instance cannot be created.
verifyPropertiesPresentInGroup
public java.lang.String verifyPropertiesPresentInGroup(PropertyEditorInfo[] infos, java.lang.String[] names)
Helper to verify properties are present for a group.- Parameters:
infos
- The array of edit's for the property.names
- The names to verify.- Returns:
- null for no error, otherwise the missing name(s) (comma separated preceeded with "missing property name:").
hasAtLeastOnePropertyInGroup
public boolean hasAtLeastOnePropertyInGroup(PropertyEditorInfo[] infos, java.lang.String[] names)
Helper to check for at least one property in group.- Parameters:
infos
- The array of edit's for the property.names
- The names to verify.- Returns:
- null for no error, otherwise the missing name(s) (comma separated preceeded with "missing property name:").
getEditProperties
public PropCnrEditorProperties getEditProperties(PropCnr pc)
Gets the name mapping from a class to another, e.g. UILabel to EUILabel (in different packages). The method throws an InternalError in case of error.- Parameters:
pc
- The instance of the class.- Returns:
- The edit properties for the property container.
getEditProperties
public PropCnrEditorProperties getEditProperties(PropCnr pc, boolean logError)
Gets the name mapping from a class to another, e.g. UILabel to EUILabel (in different packages). The method throws an InternalError in case of error.- Parameters:
pc
- The instance of the class.- Returns:
- The edit properties for the property container.
getEditProperties
public PropCnrEditorProperties getEditProperties(PropCnr pc, boolean logError, java.lang.Throwable prev)
Gets the name mapping from a class to another, e.g. UILabel to EUILabel (in different packages). The method throws an InternalError in case of error.- Parameters:
pc
- The instance of the class.logError
- Flag to log the error.prev
- Previous exception thrown.- Returns:
- The edit properties for the property container.
getValidator
public IEntryValidator getValidator(java.lang.String name)
Gets an entry/property validator. If no group formatter is defined, null is returned.- Parameters:
name
- The validator name.- Returns:
- The validator, or
null
for none. - Throws:
java.lang.InternalError
- If the instance cannot be created.
equalsMultiEdit
public boolean equalsMultiEdit(PropertyEditorSetup setup)
Checks if two instances are "multi-edit-equals", i.e. same definition name in the same bundle.- Parameters:
setup
- Another setup to verify.- Returns:
- The equality flag.