Back to Tutorials Index... ## How to show the parameters of a extension in the property editor VSM supports to list all the parameters(properties) of a plugin in the property editor, which makes it convenient for users to set the values of required parameters. <br/> In this tutorial we will use the plugin "ReetiExecutor" as an example to introduce how to achieve this function.<br/><br/> The interface ExportableProperties contains the methods to provide the properties of the decive and the properties of the agent, which needs to be implemented by our plugin.<br/> ``` public interface ExportableProperties { // return properties of the decive Map<ProjectProperty, ProjectValueProperty> getExportableProperties(); // return properties of the agent Map<ProjectProperty, ProjectValueProperty> getExportableAgentProperties(); } ``` ProjectProperty is used to store the name of a property. ``` public class ProjectProperty { // description of the current property private final String description; // name of the current property String name; // specify whether the property is necessary or not boolean required; public ProjectProperty(String name, boolean required){ this.name = name; this.required = required; this.description = ""; } public ProjectProperty(String name ){ this.name = name; this.required = false; this.description = ""; } public ProjectProperty(String name, String description){ this.name = name; this.description = description; this.required = false; } public ProjectProperty(String name, boolean required, String description){ this.name = name; this.description = description; this.required = required; } ... } ``` ProjectValueProperty is used to store the default value of a property. ``` public class ProjectValueProperty implements PropertyValue { ... // used by SelectableRenderer private final ArrayList<String> options; // type of the value: STRING, LIST, BOOLEAN, NUMERIC, FILEPATH ValueTYPE type; // the defalut value Object defaultValue; // specify different input forms ValueRenderable renderer; ... public ProjectValueProperty(ValueTYPE type, Object defaultValue, ValueRenderable renderer){ this.type = type; this.defaultValue = defaultValue; this.renderer = renderer; this.required = false; this.options = new ArrayList<>(); this.renderer.setValueProperty(this); } public ProjectValueProperty(ValueTYPE type, Object defaultValue, ValueRenderable renderer, boolean required){ this.type = type; this.defaultValue = defaultValue; this.renderer = renderer; this.required = required; this.options = new ArrayList<>(); this.renderer.setValueProperty(this); } public ProjectValueProperty(ValueTYPE type, Object defaultValue, ValueRenderable renderer, boolean required, ArrayList<String> options){ this.type = type; this.defaultValue = defaultValue; this.renderer = renderer; this.required = required; this.renderer.setValueProperty(this); this.options = options; } ... } ``` In this example, we implement ExportableProperties and override the methods getExportableProperties() and getExportableAgentProperties() using ReetiExecutor.java. ``` public class ReetiExecutor extends ActivityExecutor implements ExportableProperties { ... private ReetiProjectProperty reetiProjectProperty = new ReetiProjectProperty(); ... @Override public Map<ProjectProperty, ProjectValueProperty> getExportableProperties() { return reetiProjectProperty.getExportableProperties(); } @Override public Map<ProjectProperty, ProjectValueProperty> getExportableAgentProperties() { return reetiProjectProperty.getExportableAgentProperties(); } } ``` The class ReetiProjectProperty.java is used to input the values of ProjectProperty and ProjectValueProperty in the map. We add "lhost" for the device into the following code. ``` public class ReetiProjectProperty implements ExportableProperties { HashMap<ProjectProperty, ProjectValueProperty> exportableProperties = new HashMap<>(); public ReetiProjectProperty(){ ProjectProperty lhost = new ProjectProperty("lhost", true, "The address of the computer running VSM "); ProjectValueProperty lhostVP = new ProjectValueProperty(ValueTYPE.STRING, "127.0.0.1", new StringRender()); exportableProperties.put(lhost, lhostVP); } @Override public Map<ProjectProperty, ProjectValueProperty> getExportableProperties() { return exportableProperties; } @Override public Map<ProjectProperty, ProjectValueProperty> getExportableAgentProperties() { return null; } } ``` After that, we can find "lhost" in the list of the combobox. <img src="../../images/tutorials/lhostInCombobox.png" width="600" height="660"/>
Back to Tutorials Index...