Creating fields
The "PBoxDescription" class provides basic auxiliary window item creation services. These services are methods, all of which send back an object whose basic class is "PBoxItem".
The "PBoxDescription" class has two relationships:
· "MainItem", which is the element to be put in the auxiliary window. A matrix created with the element is generally affected to it.
· "Object" is the edited model element. This relationship is not needed by the user, as "this" is already directed to it.
Note: For an overview of the "PBoxDescription" metaclass, please see "Overview of auxiliary window services".
Creating a simple text entry field
To create a simply text entry field,
the following service should be used.
createEditField (inout Object object,
in string attributeName,
string title)
return PBoxEditField;
For example:
item = box.createEditField(this,"TypeConstraint",
"label_string_size");
This method is used to create a new editing field for an attribute named "attributeName" which belongs to an "object" object. The "title" field is used to define the label preceding the text entry zone.
Note: For all field titles, the auxiliary window will look for the translation of the "title" message in the <MDACName>Ihmlabel.us resource file. This is the case for all fields in the auxiliary window.
The associated graphic depends on the nature of the attribute:
· for a String type attribute, the field is a simple text entry field
· for an enumerate attribute, the field is a combobox which automatically contains all possible values for the enumerate
If a non-existent attribute name is entered, the following J methods are used:
String get<attributeName>;
to initialize the graphic, and
boolean set<attributeName> (in string content);
to save information at user model level.
Note: The return value must indicate whether or not processing has been correctly carried out.
The associated graphic is then a simple text zone.
For example:
void Class:initMatrix(inout PBoxDescription box,
inout PBoxMatrix matrix)
{
PBoxItem item;
item = box.createEditField(this,"theName","label_theName");
matrix.pushInto(0, matrix.NbRows(), item);
}
String Class:gettheName()
{
return Name;
}
boolean Class:settheName (in string content),
{
if (content.findLast(“ “)== -1)
{
// names should not contain spaces
return false ;
}
else
{
sessionBegin(“Change name”,true);
// a session must be opened
setName(content);
return sessionEnd();
// the best method is to send back if the session
is valid
}
}
If the attribute is an enumerate, the following service is used:
setRadio (in boolean mode);
When the "mode" parameter is true, this service is used to graphically represent the attribute in the form of radio buttons. By default, or if the "mode" parameter is false, the attribute is represented by a combobox.
Note: This is only true where the attribute represented is an enumerate. In other cases, this method has no effect on the graphic object (a text field, for example).
Creating a single-line gadget field to enter an integer
PBoxGadgetIntegerField createGadgetIntegerField
(inout Object object,
in string commandJ ,
in string title);
This method allows the definition of an editing zone for integers. Please see the "createEditField" methods for further information.
Creating a stereotype selection field
createEditStereotype(inout ModelElement modelElement,
in string title )
return PBoxEditStereotype;
This method is used to create a selection field, associated with a "modelElement" stereotype. The "title" field allows the label preceding the field to be defined.
The associated field can be a combobox or radio buttons. By default, the field is a combobox, but this can be changed using the following method:
setRadio (in boolean mode);
When the "mode" parameter is true, this method is used to graphically represent the attribute in the form of radio buttons. By default, or if the "mode" parameter is false, the attribute is represented by a combobox.
append (in string stereotypeName);
This service is used to add the "stereotypeName" stereotype to the field stereotype list.
appendAll();
This service is used to add all the possible values to the list of stereotypes.
For example:
void Class :initMatrix(inout PBoxDescription box,
inout PBoxMatrix matrix)
{
PBoxItem item;
item = box.createEditStereotype
(this,"label_Stereotype");
item.setRadio(true);
if (isInPhysicalModel())
// a method specific to the MDAC
{
item.append("table");
}
item.append("sqlView");
item.append("procedureClass");
matrix.pushInto(0, matrix.NbRows(), item);
}
Creating an editing field for a tagged value
PBoxEditTag createEditTag (inout ModelElement
modelElement,
in string tagTypeName,
in string title );
This method is used to create an editing field for a tagged value named "tagTypeName" which belongs to a "modelElement" element, and its parameters. The "title" field defines the label preceding the text entry zone.
Graphically, the field is presented in the form of a tickbox, indicating the name of the tagged value ("tagTypeName") and the name of a text field containing the parameter(s) of the tagged value.
Note: Objecteering does not handle mistakes in the name of the tagged value type!
For example:
// Addition of the management of a tagged value type
item = box.createEditTag
(this,"sqlName","label_SQL_Name");
matrix.pushInto(0, matrix.NbRows(), item);
Creating a multi-line editing field
PBoxEditText createEditText (inout Object object,
in string attributeName,
in string title);
This method is used to create a new editing field for an attribute named "attributeName" belonging to an "object" object. The "title" field is used to define the label preceding the text entry zone.
The associated graphic is automatically a multi-line zone.
createGraphicLabel (in string title )
return PBoxGraphicLabel;
This method is used to create a label. This element will be translated in the auxiliary window by a non-modifiable text string.
Adding a bitmap
createGraphicBitmap
(in string bitmapFileName)
return PBoxGraphicBitmap;
This method is used to create a bitmap.
Adding a separation line
createGraphicSeparator ()
return PBoxGraphicSeparator;
This method is used to create a horizontal separation line.
createGadgetButton
(inout Object object,
in string commandJ,
in string title)
return PBoxGadgetButton;
This method is used to create a button. The J callback associated with the button's action is defined in the "commandJ" field. This method is run on the "object" object, and "title" is the button's label.
createGadgetBitmapButton
(inout Object object,
in string commandJ,
in string bitmapFileName )
return PBoxGadgetBitmapButton;
This method provides exactly the same service as the previous method. However, instead of having a label on the button, a bitmap whose file is indicated in "bitmapFileName" appears.
Note 1: In the J callback, the current MDAC is not known! As a consequence, the "getCurrentModuleParameterValue" and "getMulMessage" services do not function.
Note 2: "bitmapFileName" must be the name of a file located in the $(OBJING_PATH)/res/bmp directory.
For example:
void Class :initMatrix(inout PBoxDescription box,
inout PBoxMatrix matrix)
{
PBoxItem item;
PBoxMatrix m3;
// The auxiliary window only accepts bitmaps which are
// located in $objing/res/bmp/.
// Providing a path serves no purpose.
item = box.createGadgetBitmapButton
(this, "selectInBrowser",
"loupe.gif");
m3.pushInto(0, m3.NbRows(), item);
//
// Label for physical model on the same line
//
item=box.createGraphicLabel
(ihmMsg1("Physical_model_x1",Name));
// Here, the second item is placed on the last occupied
// line of the matrix in the second column
m3.pushInto(1, m3.NbRows()-1, item);
// My m3 matrix is positioned in the initial matrix.
matrix.pushInto(0, m3.NbRows(), item);
}
Adding a combobox or radio buttons
PBoxGadgetChoice createGadgetChoice
(inout Object object,
in string commandJ ,
in string title );
This method is used to create a selected field associated with an "object" object. "title" is used to define the label preceding the field. "commandJ" is used to define the basis of function names which will be called to initialize the graphic gadget and save information.
To initialize the graphic, the following service is used:
string get<commandJ> ();
To save information at user model level, the following service is used:
boolean set<commandJ> (in string content);
The return value must indicate whether or not processing has been correctly carried out.
These methods are run on the "object" object. The associated graphic can be a combobox or radio buttons.
Services provided by the "PBoxGadgetChoice" class
setRadio(in boolean mode) ;
When the "mode" parameter is true, this service is used to graphically represent the attribute in the form of radio buttons. By default, or if the "mode" parameter is false, the attribute is represented by a combobox.
appendLabel(in string label);
This service is used to add the "label" string to the list of attribute values.
For example:
// Addition of a set of radio buttons
item = box.createGadgetChoice(this,"Persistence",
"label_Persistence" );
item.setRadio(true);
// true => radio buttons, false ==> combobox
item.appendLabel("label_Transient");
item.appendLabel("label_Persistent");
item.appendLabel("label_Undefined");
// Addition of the item at the bottom of the matrix
matrix.pushInto(0, matrix.NbRows(), item);
PBoxGadgetToggle createGadgetToggle
(inout Object object,
in string commandJ ,
in string title );
This method is used to define an editing zone for tickboxes. "title" is used to define the label preceding the field. "commandJ" is used to define the basis for function names which will be called to initialize the graphic field and save information.
To initialize the field, the following service is used:
boolean get<commandJ> ();
To save information at user model, the following service is used:
boolean set<commandJ> (in boolean content);
The return value must indicate whether or not processing has been correctly carried out.
These methods are run on the "object" object.
The associated field can be a combobox or radio buttons. By default, the field is a combobox, but this can be changed using the following method:
setRadio(in boolean mode) ;
When the "mode" parameter is true, this is used to graphically represent the attribute in the form of radio buttons. By default, or if the "mode" parameter is false, the attribute is represented by a combobox.