For detailed information on inspector API follow this link.
To illustrate the material of this chapter there are two examples in the installation of Together. Take the directory modules/com/togethersoft/modules/inspector/examples. In this directory you can see two manifest (.def) files declaring the examples: Page.def and Field.def.
Inside each of those files there is a line commented out. That line looks like:
# MainClassName = <Main module class name>Given that this line in file Page.def is uncommented, autorun() method of corresponding module will be executed upon next startup of Together. Then, after inspector is called on a class of a class diagram you will see additional page with three fields called "My page". Or/and 3 additional fields at the bottom of the existing page called "Properties". Those are the results of work of the modules that you just have enabled.
Now let's give a detailed look to how those modules work inside.
Creates a string property.
| config | inspector.node.element.*.Class.item.Properties.item.myStringProperty = StringField |
| Java | property = new RwiInspectorStringProperty(rwiElements, "myStringProperty"); |
Sets the name to be shown in the UI.
| config | inspector.node.element.*.Class.item.Properties.item.myStringProperty.name = "My string property" |
| Java | property.setName("My string property"); |
Creates a string property.
| config | inspector.node.element.*.Class.item.Properties.item.myStringProperty = StringField |
| Java | property = new RwiInspectorStringProperty(rwiElements, "myStringProperty"); |
Creates a boolean property
| config | inspector.node.element.*.Class.item.Properties.item.myBooleanProperty = BooleanField |
| Java | property = new RwiInspectorBooleanProperty(rwiElements, "myBooleanProperty"); |
Sets the name to be shown in the UI
| config | inspector.node.element.*.Class.item.Properties.item.myBooleanProperty.name = "My boolean property" |
| Java | property.setName("My boolean property"); |
Creates a string property
| config | inspector.node.element.*.Class.item.Properties.item.myChoiceProperty = ComboboxField( \ { \ values := { "value1", "value2", "value3" } \ } \ ) inspector.node.element.*.Class.item.Properties.item.myChoiceProperty.name = "My choice property" |
| Java |
property.setName("My choice property");
SwingComboBoxEditor editor = new SwingComboBoxEditor(
new DefaultComboBoxModel(
new String[] {"value1", "value2", "value3"}
)
);
property.setPropertyEditor(editor);
|
Creates a string property, which will be shown, when some condition is met
| config | inspector.node.element.*.Class.item.Properties.item.myConditionalProperty = StringField inspector.node.element.*.Class.item.Properties.item.myConditionalProperty.name = "My conditional property" inspector.node.element.*.Class.item.Properties.item.myConditionalProperty.condition = hasProperty("myBooleanProperty") |
| Java |
property = new RwiInspectorStringProperty(rwiElements, "myConditionalProperty");
property.setName("My conditional property");
Condition condition = new Condition() {
public boolean execute(IdeContext context) {
RwiElement[] rwiElements = RwiElementsUtil.getRwiElements(context);
return RwiElementsUtil.checkProperty(context, "myBooleanProperty", true);
}
};
propertiesPage.addProperty(property, condition);
|
Set service - class which will be used to visualize this component
| config | inspector.node.element.*.Class.item.My page.view.UI = treeTableNodeUI inspector.node.element.*.Class.item.My page.view.expandLevel = all |
| Java | page.setService(UIComponentService.class, new PropertyTableComponentUI(page)); inspector.addComponent(page, null); |
Creates a string property
| config | inspector.node.element.*.Class.item.My page.item.myStringProperty = StringField |
| Java | property = new RwiInspectorStringProperty(rwiElements, "myStringProperty"); |
sets the name to be shown in the UI
| config | inspector.node.element.*.Class.item.My page.item.myStringProperty.name = "My string property" |
| Java | property.setName("My string property"); |
creates a boolean property
| config | inspector.node.element.*.Class.item.My page.item.myBooleanProperty = BooleanField |
| Java | property = new RwiInspectorBooleanProperty(rwiElements, "myBooleanProperty"); |
sets the name to be shown in the UI
| config | inspector.node.element.*.Class.item.My page.item.myBooleanProperty.name = "My boolean property" |
| Java | property.setName("My boolean property"); page.addProperty(property, null); |
creates a string property
| config |
inspector.node.element.*.Class.item.My page.item.myChoiceProperty = ComboboxField(
\ {
\ values := { "value1", "value2", "value3" }
\ }
\ )
inspector.node.element.*.Class.item.My page.item.myChoiceProperty.name = "My choice property"
|
| Java |
property = new RwiInspectorStringProperty(rwiElements, "myChoiceProperty");
property.setName("My choice property");
SwingComboBoxEditor editor = new SwingComboBoxEditor(
new DefaultComboBoxModel(
new String[] {
"value1", "value2", "value3"
}
)
);
property.setPropertyEditor(editor);
editor.setValueEditable(true);
page.addProperty(property, null);
|
creates a string property, which will be shown, when some condition is met
| config | inspector.node.element.*.Class.item.My page.item.myConditionalProperty = StringField |
| Java | property = new RwiInspectorStringProperty(rwiElements, "myConditionalProperty"); |
sets the name to be shown in the UI
| config | inspector.node.element.*.Class.item.My page.item.myConditionalProperty.name = "My conditional property" |
| Java | property.setName("My conditional property"); |
creates a Condition class
| config | inspector.node.element.*.Class.item.My page.item.myConditionalProperty.condition = hasProperty("myBooleanProperty") |
| Java |
Condition condition = new Condition() {
public boolean execute(IdeContext context) {
RwiElement[] rwiElements = RwiElementsUtil.getRwiElements(context);
return RwiElementsUtil.checkProperty(context, "myBooleanProperty", true);
}
};
page.addProperty(property, condition);
|
###### The one, which corresponds to "AddFieldsToInspector.java":
inspector.node.element.*.Class.item.Properties.item.myStringProperty = StringField
inspector.node.element.*.Class.item.Properties.item.myStringProperty.name = "My string property"
inspector.node.element.*.Class.item.Properties.item.myBooleanProperty = BooleanField
inspector.node.element.*.Class.item.Properties.item.myBooleanProperty.name = "My boolean property"
inspector.node.element.*.Class.item.Properties.item.myChoiceProperty = ComboboxField(
\ {
\ values := { "value1", "value2", "value3" }
\ }
\ )
inspector.node.element.*.Class.item.Properties.item.myChoiceProperty.name = "My choice property"
inspector.node.element.*.Class.item.Properties.item.myConditionalProperty = StringField
inspector.node.element.*.Class.item.Properties.item.myConditionalProperty.name = "My conditional property"
inspector.node.element.*.Class.item.Properties.item.myConditionalProperty.condition = hasProperty("myBooleanProperty")
###### The one, which corresponds to "AddPageToInspector.java":
inspector.node.element.*.Class.item.My page.view.UI = treeTableNodeUI
inspector.node.element.*.Class.item.My page.view.expandLevel = all
inspector.node.element.*.Class.item.My page.item.myStringProperty = StringField
inspector.node.element.*.Class.item.My page.item.myStringProperty.name = "My string property"
inspector.node.element.*.Class.item.My page.item.myBooleanProperty = BooleanField
inspector.node.element.*.Class.item.My page.item.myBooleanProperty.name = "My boolean property"
inspector.node.element.*.Class.item.My page.item.myChoiceProperty = ComboboxField(
\ {
\ values := { "value1", "value2", "value3" }
\ }
\ )
inspector.node.element.*.Class.item.My page.item.myChoiceProperty.name = "My choice property"
inspector.node.element.*.Class.item.My page.item.myConditionalProperty = StringField
inspector.node.element.*.Class.item.My page.item.myConditionalProperty.name = "My conditional property"
inspector.node.element.*.Class.item.My page.item.myConditionalProperty.condition = hasProperty("myBooleanProperty")