|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectARoad0.Gui1.BaseObjectHandler
public class BaseObjectHandler
This important class is responsible for creating or copying a BaseObject instance, but not an ACS nor a view. In the MVC pattern, this is the controler that handles all user dialogs to define the relevant parameters. For creating or copying, the BaseObject class methods to use are declared in the BeanInfo class (the model in the MVC pattern) which is associated to the gBase class in the gBaseBeanInfo package. User dialogs are handled by DialogBox (the View in MVC). It allows to create a base object both: - through its constructor, - through the 'add' method of another object (for example, AclEntry from Resource), - or through its copy method. The selection depends on the valueOf method which is used, among three, to build up the correct BaseObjectHandler instance. The BaseObjectHandler constructor is to be avoided.
The general logic of this class is a mix of BeamerManager and SimplePropertyEditor. The creator of the BaseObjectHandler instance has to be a NewBaseObjectListener for using a constructor or a copy method, or the subinterface AddRemoveBaseObjectListener for using an 'add' method. In the first case, a handleNewBaseObject() method is called by this instance after the new BaseObject creation or copying. In the second case, an addOneBaseObject method is called back. It handles preset, constrained, optional, uncomplete or mandatory arguments, and checks the ACS properties of an ACSObject to control the entered values.
This class is used by SimplePropertyEditor.actionPerformed(), CollectionPropertyEditor.addElement(), ActionNewResource, ActionNewEligibleParty, ActionCopy. This class displays and manages the panels which are required to enter all the parameters of the new BaseObject. The number of parameters has to be strictly inferior to 8. It allows the user to choose a parameter: - among any open base objects, through the explorer (the second-level dialog to handle is then controlled by this class), - among the allowed values, if the parameter is constrained by the ACS or the base object BeanInfo class, - or to create it, if it is a boolean, a string, a name. It does not allow to create a parameter from scratch if it is a BaseObject; this type of parameter has to be created before the call to BaseObjectHandler. When the argument is a relative name to concatenate with the name of another argument (the ACS or the directory name, for example), the root argument must be a BaseObject. The panel for a parameter may be dynamically changed in the user windows when the presence of a constraint on the values for a parameter depends on the value of the ACS, and when the ACS value is a parameter the user has to choice (example: 'Acl Rights' at the creation of the AclEntry).
Each parameter may be constrained through the ACS, with a limited set of values, including the control of a null argument. Each parameter may be optional, and then, it is not used to create the base object instance if it is null. When the parameter is an array, only one-value array is created as parameter of the constructing method. See the Copyright.
SimplePropertyEditor
,
CollectionPropertyEditor
Field Summary | |
---|---|
protected int |
argIndex_
The index in l_argumentsValues_ of the argument currently processed, between '0' and l_argumentsValues_.length - 1. |
protected NewBaseObjectListener |
caller_
This is the creator of this instance. |
protected static int |
INITIAL_CAPACITY
Default capacity for collections and maps |
protected java.lang.Class[] |
l_argumentsClass_
The classes array of the arguments to use for creating the new instance of a BaseObject. |
protected java.lang.Integer[] |
l_argumentsConcatening_
The Int array of the name arguments which are relative and are to concatenate with names from another arguments |
protected java.lang.Boolean[] |
l_argumentsFromSelect_
The Boolean array to use for selecting or not the value, from the explorer or through a special dialog. |
protected javax.swing.JComponent[] |
l_argumentsJComponent_
The JComponent (JTextField, JComboBox) array to use for displaying the arguments. |
protected javax.swing.JPanel[] |
l_argumentsJPanel_
The JPanel array to use for displaying the arguments. |
protected java.lang.String[] |
l_argumentsNames_
The names array of the arguments for the constructor of the new instance, in the same order used in l_argumentsClass_. |
protected java.lang.Object[] |
l_argumentsValues_
The arguments values array to use for creating the new instance of a BaseObject. |
protected java.lang.String[] |
l_displayNames_
The property names displayed in the panel. |
protected static java.lang.String[] |
L_INDEX
This index is used for the buttons in the creation dialog |
protected java.lang.Boolean[] |
l_nonVisibleArguments_
The Boolean array of non visible arguments. |
protected java.lang.Boolean[] |
l_nullArgumentPossible_
The Boolean array to allow or not a null argument. |
protected java.lang.Boolean[] |
l_optionalArguments_
The Boolean array of optional argument. |
protected java.lang.Boolean[] |
l_restrictedArguments_
The Boolean array of restricted argument. |
protected java.lang.String[] |
l_restrictedFromOtherArgumentMessage_
The String array of user messages for restricted arguments. |
protected static java.awt.Dimension |
NAME_DIMENSION
Name dimension for all arguments |
protected BeanInfoPattern |
newBaseObjectBeanInfo_
The beanInfo instance associated to newBaseObjectClass_ |
protected java.lang.Class |
newBaseObjectClass_
The class of the new BaseObject value to create. |
protected Copyable |
objectToCopy_
The BaseObject instance to copy. |
protected boolean |
onGoingCreationDialog_
True when getBaseObjectEditor() has called DialogBox for entering the user choices, until the call back to handleCreationDialog(). |
protected java.beans.PropertyDescriptor |
propertyDescriptor_
When it is new BaseObject to create through the call of an 'add' method, this is the descriptor of the property. |
Constructor Summary | |
---|---|
private |
BaseObjectHandler()
Constructor FOR USING ONLY through the valueOf() methods. |
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent _evt)
Manages the events fired by all the Select buttons in the JPanels which are created by getBaseObjectEditor(). |
private boolean |
checkNullArguments()
Checks in l_argumentsJComponent_ if there is a null or empty argument while it is forbidden. |
private static BaseObjectHandler |
commonValueOf(BaseObjectHandler _result,
java.lang.Class _baseObjectClass,
boolean _fromConstructor)
Sets most of the _result properties from its BeanInfo class. |
private void |
createBaseObject()
Called by handleCreationDialog() to create the base object. |
private void |
finalizeForProcess()
Sets to null all the variables of the instance |
private javax.swing.JPanel |
getArgumentEditor(javax.swing.JPanel _result,
java.lang.String _propertyName,
boolean _isSelected,
int _argIndex,
boolean _isDefined,
java.lang.Object _knownValue,
ACSRun _acs)
Gets a graphical editor for an argument or for the source, when the type is a boolean, string, name, BaseObject (including StringRight), or a String list. |
void |
getBaseObjectEditor()
Displays the arguments panels for creating the new BaseObject instance, then creates it after the user had entered all the values. |
void |
getBaseObjectEditor(java.lang.Object[] _l_knownValue)
This is the unique method to call on a BaseObjectHandler instance, which displays the arguments panels for creating the new BaseObject instance, then creates it after the user had entered all the values. |
private javax.swing.JPanel |
getBooleanEditor(javax.swing.JPanel _result,
java.lang.String _propertyName,
int _argIndex,
boolean _isDefined,
java.lang.Object _knownValue,
java.beans.PropertyDescriptor[] _l_propertyDescriptor,
int _beanInfoIndex)
Gets a graphical editor for an argument or for the source, when the type is a boolean. |
void |
handleCreationDialog(boolean _data)
After an user click on 'OK', reads the data entered by the user in the JPanels, and creates the new BaseObject. |
void |
handleSelectionDialog(java.util.Map _validatedObjectsSetMap)
Called by DialogBox.showExplorerSelectionDialog() for actionPerformed(), when an argument is a BaseObject which has to be selected in the explorer. |
private void |
removeOptionalArguments()
Removes the null arguments which are optional, to select the right constructor. |
private void |
setFinalArguments()
Sets in l_argumentsValues_ the absolute arguments to use, through an analyse of the relative names to concatenate. |
private void |
setRelativeArguments()
Sets in l_argumentsValues_, from l_argumentsJComponent_, the right arguments to use, but without handling of the absolute names. |
private void |
setRestrictedSelectedArguments()
Sets l_argumentsValues_ when an argument is a StringRight array argument in a combox, from a restricted set proposed to the user. |
static BaseObjectHandler |
valueOf(AddRemoveBaseObjectListener _caller,
java.beans.PropertyDescriptor _propertyDescriptor,
java.lang.reflect.Method _addMethod)
Second of the 3 valueOf methods, to create a new BaseObject through an 'ADD' method which is described in a property descriptor. |
static BaseObjectHandler |
valueOf(NewBaseObjectListener _caller,
java.lang.Class _baseObjectClass)
First of the 3 valueOf methods, to create a new BaseObject through its CONSTRUCTOR, as it is described in the bean descriptor in the relevant BeanInfo class. |
static BaseObjectHandler |
valueOf(NewBaseObjectListener _caller,
Copyable _toCopy,
Copyable _toCopy2)
Third of the 3 valueOf methods, to create a new BaseObject through the COPY method, as it is described in the bean descriptor of the relevant BeanInfo class. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int INITIAL_CAPACITY
protected static final java.awt.Dimension NAME_DIMENSION
protected static final java.lang.String[] L_INDEX
protected NewBaseObjectListener caller_
protected java.beans.PropertyDescriptor propertyDescriptor_
protected java.lang.Class newBaseObjectClass_
protected BeanInfoPattern newBaseObjectBeanInfo_
protected java.lang.Object[] l_argumentsValues_
protected java.lang.Class[] l_argumentsClass_
protected java.lang.String[] l_argumentsNames_
protected javax.swing.JComponent[] l_argumentsJComponent_
protected javax.swing.JPanel[] l_argumentsJPanel_
protected java.lang.Boolean[] l_argumentsFromSelect_
protected java.lang.Integer[] l_argumentsConcatening_
protected java.lang.Boolean[] l_nullArgumentPossible_
protected java.lang.Boolean[] l_optionalArguments_
protected java.lang.Boolean[] l_restrictedArguments_
protected java.lang.Boolean[] l_nonVisibleArguments_
protected java.lang.String[] l_restrictedFromOtherArgumentMessage_
protected int argIndex_
protected Copyable objectToCopy_
protected java.lang.String[] l_displayNames_
protected boolean onGoingCreationDialog_
Constructor Detail |
---|
private BaseObjectHandler()
Method Detail |
---|
public static BaseObjectHandler valueOf(NewBaseObjectListener _caller, java.lang.Class _baseObjectClass)
_caller
- of this method is a NewBaseObjectListener with a
handleNewBaseObject() method that is called back after the instance creation.
Cannot be null._baseObjectClass
- is the class of the new instance of BaseObject to create.
Used to find the right BeanInfo class. Cannot be null.
if
- _caller is null or if _baseObjectClass is not correctpublic static BaseObjectHandler valueOf(AddRemoveBaseObjectListener _caller, java.beans.PropertyDescriptor _propertyDescriptor, java.lang.reflect.Method _addMethod)
_caller
- of this method is a AddRemoveBaseObjectListener with an
handleAddBaseObject() method that is called before the instance creation.
Cannot be null._propertyDescriptor
- is the descriptor of the property
to update through an 'add' method. Cannot be null._addMethod
- is the source method to use for adding a new instance.
Cannot be null.
public static BaseObjectHandler valueOf(NewBaseObjectListener _caller, Copyable _toCopy, Copyable _toCopy2)
_caller
- of this method is a NewBaseObjectListener with a
handleNewBaseObject() method that is called when _toCopy has been copied.
Cannot be null._toCopy
- is the base object to copy. Cannot be an ACS or a ViewInBase,
nor null._toCopy2
- is not used. Only to be different to the first valueOf method.
private static BaseObjectHandler commonValueOf(BaseObjectHandler _result, java.lang.Class _baseObjectClass, boolean _fromConstructor)
_result
- is the BaseObjectHandler to set up_baseObjectClass
- is the class of the new instance of BaseObject to create.
Cannot be an ImmutableACS or an ImmutableView.
Used to find the right BeanInfo class. Cannot be null._fromConstructor
- true to build up the new object from its
constructor, and false to do it from its copy
public void actionPerformed(java.awt.event.ActionEvent _evt)
actionPerformed
in interface java.awt.event.ActionListener
_evt
- is the event fired by a JButton classpublic void handleSelectionDialog(java.util.Map _validatedObjectsSetMap)
handleSelectionDialog
in interface SelectionDialogListener
_validatedObjectsSetMap
- with one element, where
- the key is l_argumentsClass_[argIndex_],
- the value is one selected object with the right type.
May be null or empty if the user cancels the selection operation.public void getBaseObjectEditor()
public void getBaseObjectEditor(java.lang.Object[] _l_knownValue)
_l_knownValue
- array of arguments for the object creation.
They may be Booleans, Strings, ImmutableNames or BaseObjects,
as arguments which has been chosen by the user before the call of this method.
The value at the index 0 is the chosen value for the first argument, and so on.
A value in the array is null if the argument for this index is not set in the BeanInfo.
At the index equal or superior to the number of arguments,
any fixed BaseObject may be put for displaying without taking it as an argument
(typically, the source).
So, the size of _l_knownValue may be inferior, or equal,
or superior to the contructor arguments number.
4 is the number of arguments for the instance creation of most of the base objects,
excepting for actors, executables and acsrights for which there are 7 arguments.public void handleCreationDialog(boolean _data)
handleCreationDialog
in interface CreationDialogListener
_data
- true if the user has entered the data and false if the user has closed the dialogprivate javax.swing.JPanel getArgumentEditor(javax.swing.JPanel _result, java.lang.String _propertyName, boolean _isSelected, int _argIndex, boolean _isDefined, java.lang.Object _knownValue, ACSRun _acs)
_result
- is the returned JPanel._propertyName
- of the argument. Never null. Has to be inferior to 50.
If it is equals to "", returns an empty panel. This is not always the name
displayed to the user in the panel._isSelected
- true if the argument is selected in the explorer or through
another mean which needs the 'Select' button._argIndex
- is the index of the argument in all the argument list._isDefined
- true when the argument has been chosen by the user
before the call of this method._knownValue
- of argument only if the argument is a String,
an ImmutableName or a BaseObject (not Boolean),
which has been chosen by the user before the call to this class.
May be null if _isDefined is false._acs
- is null when the method is called by getBaseObjectEditor()
without knowledge of the acs,
and non null when the acs is known or when it is called
by handleSelectionDialog() after the selection of the acs by the user.
private javax.swing.JPanel getBooleanEditor(javax.swing.JPanel _result, java.lang.String _propertyName, int _argIndex, boolean _isDefined, java.lang.Object _knownValue, java.beans.PropertyDescriptor[] _l_propertyDescriptor, int _beanInfoIndex)
_result
- is the returned JPanel._propertyName
- of the argument. Never null. Has to be inferior to 50.
If it is equals to "", returns an empty panel. This is not always the name
displayed to the user in the panel._argIndex
- is the index of the argument in all the argument list._isDefined
- true when the argument has been chosen by the user
before the call of this method._knownValue
- of argument only if the argument is a String,
an ImmutableName or a BaseObject (not Boolean),
that has been chosen by the user before the call to this class.
May be null if _isDefined is false._l_propertyDescriptor
- descriptors from the BeanInfo_beanInfoIndex
- index of the right PropertyDescriptor
private boolean checkNullArguments()
private void setRestrictedSelectedArguments() throws BaseError
If there are some rights to select but without user selection, the rights array is set to null, and there is no exception from the AclEntry or the Privilege.
BaseError
- if the convertion of String to StringRight does not workprivate void setRelativeArguments() throws BaseError
BaseError
- if Convertion from String to Integer does not workprivate void setFinalArguments()
AssociateUtilityImpl.setFinalArgumentsForAssociateCreation(java.lang.Object[], java.beans.BeanDescriptor)
private void removeOptionalArguments()
private void createBaseObject()
private void finalizeForProcess()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |