Creating a property page

 

When you create commands, you can choose to make them accessible through a specific property page or a dedicated contextual menu or both.

 

To add a property page, carry out the following steps shown in Figure 183 below:

1.      In the explorer, select the "GUI extensions" folder and click on the  "Create a property page" button.

2.      In the "Property page" window that then appears, give the property page a name, a tab label and an icon.

3.      Define the Java class that will be in charge of managing the property box. The provided class must inherit from the AbstractMdacPropertyPage class and an implementation for the update() method.

4.      Drag and drop the created commands (in the desired order).

 

 

Figure 183. Defining a property page

 

Key:

·         "Name": This field defines the “logical” name of the property page. This name is not visible to the end-user and is only used internally as an identifier.

·         "Tab": This field defines the visible label of the tab of the property page. Leave empty if none.

·         "Icon": This field defines the visible icon of the tab of the property page.  Icons must be in “.bmp” or “.png” format.  We recommend that the size of these icons be 16*16 pixels. Leave empty if none. 

·         "Java class to activate": This field defines the Java class that will be activated to manage the property page. This class must properly implement a specific interface to be suitable for this purpose. The user can:

o        Either drag and drop an existing class from the model with the mandatory condition that this class must inherit from AbstractMdacPropertyPage and must belong to the component.

o        Or enter the name of a new class. In this case, the class will be automatically created by MDA Modeler along with default code for its methods (empty code).

o        Or select the class in the UML explorer by clicking on the  icon.

·         "Commands displayed in the toolbar": Commands dragged from the "GUI extensions" folder of the MDA component model into this list will appear as toolbar buttons in the property box. Filtering criteria applied are those of the command, exactly as for contextual menus.  The following is an example of the JUnitPropertyPage class contents:

 

package junit;

class JUnitPropertyPage extends AbstractMdacPropertyPage

{

    // Simply add one property (the Name of the currently selected element)

    public void update(ObList<ObElement> elements, MdacPropertyTable table)

    {

        ObModelElement modelElement = ((ObModelElement)elements.get(0));

        table.addProperty ("Name", modelElement.getName());

    }

 

    // This method is called when a value has been edited

    // in the property box in the row ‘row’

    // Here we simply have to update the currently selected element name

          // Note the use of a Transaction to modify the model.

    public void changeProperty(ObList<ObElement> elements, int row, String value)

    {

        Transaction t = Objecteering.getInstance().getModelingSession().

                        createTransaction("Change a property");

         

        for ( ObElement element : elements )

        {

            if ( element instanceof ObModelElement )

            {

                ObModelElement modelElement = (ObModelElement)element;

                switch (row)

                {

                    case 0: // Name

                        modelElement.setName (value);

                        break;

                }

            }

        }

 

        Objecteering.getInstance().getModelingSession().commit(t);

    }

}