|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectARoad0.Gui1.SimplePropertyEditor
ARoad0.Gui1.StringMapPropertyEditor
public class StringMapPropertyEditor
This class is responsible for displaying, by the mean of panels, a property map of a gBase BaseObject, for which the type is a map where keys are Strings and the values are only String arrays.
The map updating is never done through a write method or a 'choiceMethodForNew' in the property descriptor, but only through 'add/remove' methods set in the property descriptor. On the other hand, 'choiceMethodForNew' is used in super.getRestrictedValues() to get the constrained keys, if any.
The keys updating may be forbidden or constrained, and if this updating is allowed, the deleting of a key is always through the call of the removing method with a null value for each key to delete. The maximal number of constrained keys is 84.
The values updating may be constrained by a specific method which declares the allowed values. A maximal value may be defined for the number of map keys, through the property 'MaxSize'. Through the property 'MaxValueSize', a maximal value may be defined for the number of values in the map. The default maximal size for the keys set is 50, and 100 for the values set.
The updating of the keys and the values handles all the exceptions in the same way, like the superclass. A message is displayed to the user from the exception, and the map is reset through the call to the current value. So, the called gBase class may set in the updating methods how the exception impacts the current value. This class complements CollectionPropertyEditor, which handles more complex types but manages maps only as collections of values.
StringTwoKeysMapPropertyEditor is a subclass for handling two-parts, structured keys. AssociationMapPropertyEditor is its subclass and it creates associations to use as scripts calling the constuctors and methods in any gBase class.
BaseObjectMapPropertyEditor is a subclass for BaseObjects or ImmutableNames in the values. RightMapPropertyEditor is a subclass for StringRights in the values.
The getCustomEditor() method is the main method. This class is specified by some BeanInfo classes in gBase, for instance in their property descriptors for ACSFactory.SpecializedTypesAndExplorerSet, ACSImpl.m_TypesAndGUIPolicy and M_ContainerPolicy. This class is called by Gui1.BeamerManager.addPropertyEditor().
The unique property type is String, both for the keys and the values, but some methods are more general and they are used by the subclasses. This class is a PropertyEditor that gets, and listens the property in the relevant gBase instance, and edits the keys and the values. It is also a custom editor that provides getCustomEditor(), and specifies the prefered size of the panel to be displayed. This instance listens actions from gBase objects when the program updates the property. So, the GUI always DISPLAYS THE RIGHT DATA which is in the base. When a string is entered in a JTextField, its length is limited to 200, to prevent any unauthorized input. A space is always added to the end of the string.
As a PropertyEditor, it must be able to register PropertyChangeListeners but this is not a feature to use so far. It uses only registration on gBase BoundBeans, that handle PropertyChangeListeners. In the same way, does not use the ActionEvents handling - add/removeActionListener() - in the JComponent property. An instance is constructed through the factory method valueOf() which calls the super valueOf() method, and it is possible to get a reusable empty instance. java.beans.PropertyEditorManager is not used. setValue(), setAsText() and getAsText() are not operational.
Field Summary | |
---|---|
protected java.lang.reflect.Method |
addMethod_
The add method if it exists, for the property. |
protected javax.swing.JComponent |
boundComponentTwo_
The values list that displays a bound property. |
protected javax.swing.JScrollPane |
keyScrollPane_
The scrollpane that displays the keys list. |
protected javax.swing.DefaultListModel |
keysModel_
The ListModel of Strings, in the JList which displays the keys |
protected boolean |
keysUpdateInMap_
True if the key list may be updated. |
protected java.lang.reflect.Method |
limitedValuesMethod_
The limited values method if it exists, for the property. |
protected int |
maxKeySize_
The maximal size which is allowed for the keys set. |
protected int |
maxValueSize_
The maximal size which is allowed for the values set. |
protected java.lang.Class |
propertyTypeInGroup_
When the property type is a map (Map |
protected java.lang.reflect.Method |
removeMethod_
The remove method if it exists, for the property If it is non null, the writeMethod in 'super' may be still non null. |
protected java.lang.Class |
selectedTypeInGroup_
When the property type is a map (Map |
protected javax.swing.JScrollPane |
valueScrollPane_
The scrollpane that displays the values list. |
protected javax.swing.DefaultListModel |
valuesModel_
The ListModel of Strings, in the JList which displays the values |
Fields inherited from class ARoad0.Gui1.SimplePropertyEditor |
---|
boundComponent_, displayName_, EMPTY_INSTANCE, EMPTY_OBJECT, INITIAL_CAPACITY, isRestrictedArgument_, listeners_, propertyDescriptor_, propertyType_, readMethod_, source_, sourceBeanInfo_, writeMethod_ |
Constructor Summary | |
---|---|
StringMapPropertyEditor()
Constructor FOR USE ONLY through the valueOf() method, EMPTY_INSTANCE and the subclasses. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent _evt)
Manages the events fired by the buttons 'New' and 'Delete' for the map keys, and 'Select', 'Remove' for the map values, in the JPanel displayed by getCustomEditor(). |
protected void |
addKeyElement()
Called by actionPerformed() when the user clicks on the button 'New' to add a new key in the map. |
protected void |
addRestrictedValueElements(java.lang.String _key)
Called when the user clicks on the button 'Select' or 'NewV' to add a new value in the map, among the constrained values given by the property limitedValuesMethod_. |
protected void |
addValueElements(java.lang.Object[] _l_values)
Adds some values in the map, from an user click on 'Select', 'NewV' or 'Prev.'. |
void |
changeDimensions()
Updates the dimensions of the key and value panels. |
private void |
deleteKeyElements(java.lang.Object[] _l_keysToRemove)
Deletes some selected keys in the map, from an user click on 'Delete'. |
void |
finalizeForProcess()
Finalizes the instance; the call is reserved to BeamerManager. |
java.lang.String |
getAsText()
Gets the property value as a string suitable for presentation to a human to edit. |
java.awt.Component |
getCustomEditor()
Return a full custom Component that edits its property value, with the relevant buttons following the property descriptor. |
protected int |
getMaximumValuesListSize()
Called by the setPanelDimension method for the subclasses. |
void |
propertyChange(java.beans.PropertyChangeEvent _evt)
Manages the events fired by the BaseObject source_, if it is a bound property and when the property value changes. |
protected void |
removeValueElements(java.lang.Object[] _l_valuesToRemove,
boolean _toConfirm)
Remove some selected values in the map, from an user click on 'Remove'. |
void |
setAsText(java.lang.String _text)
Sets the property value by parsing a given String. |
protected void |
setKeysModel()
Called by getCustomEditor(), propertyChange(), and the subclasses, to set the keys list, without database update. |
void |
setPanelDimension(boolean _keyButtons,
boolean _valueButtons)
Sets the two panels for the keys and the values lists. |
void |
setValue(java.lang.Object _value)
No use. |
protected void |
setValuesModel(java.lang.String _key)
Sets the values list in the JList of Objects, without database update. |
java.lang.String |
toString()
Get the values of variables for the instance. |
void |
valueChanged(javax.swing.event.ListSelectionEvent _e)
When a key is selected by the user in the beamer, displays the right values list. |
static CommonPropertyEditor |
valueOf(BaseObject _source,
java.beans.PropertyDescriptor _propertyDescriptor)
Factory method to use when a StringMapPropertyEditor is delegating to us. |
protected void |
viewElement()
Called by a subclass actionPerformed() method, when the user clicks on the button 'See'. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.Class propertyTypeInGroup_
protected java.lang.Class selectedTypeInGroup_
protected javax.swing.DefaultListModel keysModel_
protected javax.swing.DefaultListModel valuesModel_
protected javax.swing.JComponent boundComponentTwo_
protected javax.swing.JScrollPane keyScrollPane_
protected javax.swing.JScrollPane valueScrollPane_
protected java.lang.reflect.Method addMethod_
protected java.lang.reflect.Method removeMethod_
protected java.lang.reflect.Method limitedValuesMethod_
protected boolean keysUpdateInMap_
protected int maxKeySize_
protected int maxValueSize_
Constructor Detail |
---|
StringMapPropertyEditor()
Method Detail |
---|
public static CommonPropertyEditor valueOf(BaseObject _source, java.beans.PropertyDescriptor _propertyDescriptor) throws java.lang.NullPointerException, ProcessError
It constructs the adding and removing methods for the property, from the BeanInfo information. From the same information, it uses 'KeysUpdateInMap' to allow the updating of keys. It uses also 'limitedValuesMethod' to construct the limited-values method which defines the set of the allowed values in any map value. This is the equivalent for values, of the SimplePropertyEditor work to set the limited-keys method from the property descriptor, with 'choiceMethodForNew'. The property must be a map. These 2 'limit' methods are also used by the subclasses of this class.
Called by BeamerManager.addPropertyEditor(). Overrides the SimplePropertyEditor method and calls it.
_source
- owning the property._propertyDescriptor
- is the descriptor of the property
java.lang.NullPointerException
- if _source or _displayName is null
ProcessError
- if BeanInfo and PropertyDecriptor calls failpublic void setValue(java.lang.Object _value)
setValue
in interface java.beans.PropertyEditor
setValue
in class SimplePropertyEditor
_value
- The new target object to be edited. Note that this
object is not modified by the PropertyEditor. May be null.public java.lang.String getAsText()
getAsText
in interface java.beans.PropertyEditor
getAsText
in class SimplePropertyEditor
public void setAsText(java.lang.String _text) throws java.lang.IllegalArgumentException
setAsText
in interface java.beans.PropertyEditor
setAsText
in class SimplePropertyEditor
_text
- The string to be parsed.
java.lang.IllegalArgumentException
public java.awt.Component getCustomEditor()
getCustomEditor
in interface CommonPropertyEditor
getCustomEditor
in interface java.beans.PropertyEditor
getCustomEditor
in class SimplePropertyEditor
PropertyEditor.getCustomEditor()
public void actionPerformed(java.awt.event.ActionEvent _evt)
actionPerformed
in interface java.awt.event.ActionListener
actionPerformed
in class SimplePropertyEditor
_evt
- is the event fired by a buttonpublic void propertyChange(java.beans.PropertyChangeEvent _evt)
propertyChange
in interface java.beans.PropertyChangeListener
propertyChange
in class SimplePropertyEditor
_evt
- only source and property name in _evt are used in this methodpublic void changeDimensions()
public void valueChanged(javax.swing.event.ListSelectionEvent _e)
valueChanged
in interface javax.swing.event.ListSelectionListener
_e
- from the key listpublic void setPanelDimension(boolean _keyButtons, boolean _valueButtons)
_keyButtons
- true if there is a vertical panel for key buttons._valueButtons
- true if there is a vertical panel for value buttons.public java.lang.String toString()
toString
in class SimplePropertyEditor
public void finalizeForProcess()
finalizeForProcess
in interface CommonPropertyEditor
finalizeForProcess
in class SimplePropertyEditor
protected void setKeysModel()
protected void setValuesModel(java.lang.String _key)
_key
- is a map key for the property. Clears the values
if it is not a current key or if _key is null.protected void removeValueElements(java.lang.Object[] _l_valuesToRemove, boolean _toConfirm)
_l_valuesToRemove
- String or StringRight values to remove
for the current selected key. Never null._toConfirm
- true if the user has to confirm the removingprotected int getMaximumValuesListSize()
protected void addKeyElement()
protected void viewElement()
protected void addValueElements(java.lang.Object[] _l_values)
_l_values
- to add for the current selected key. Never null.private void deleteKeyElements(java.lang.Object[] _l_keysToRemove)
_l_keysToRemove
- map keys to remove with their associated values.protected void addRestrictedValueElements(java.lang.String _key)
_key
- current selected key
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |