Variable Selector
From Skyway Wiki
Contents |
Overview
Variables are selected using the VariablePathSelectionDialog.
The VariablePathSelectionDialog is a design-time dialog that shows a list of variables that are available to a given Action or Web Page. Complex typed variables appear in the selector as expandable nodes so the user can navigate to fields and relationships inside the Complex type. The variables that appear in the selector can be programmatically filtered.
Note that the tree control in the VariablePathSelectionDialog also appears in the Variables View.
Invoking the VariablePathSelectionDialog
Integrating the VariablePathSelectionDialog into a custom step using common skyway controls
The VariablePathSelectionDialog is called automatically by the SkywayElementChooserButton if your associated SkywayCommonTextField has a datatype of SkywayType.VARIABLEPATH. For an example of how to integrate the variable selector into a step, see: com.skyway.core.steps.sendemail.sheetHeaderPropertySection.java.
It goes something like this (in your StepPropertySection):
toField = getDataBindingWidgetFactory().createVariableTextField(parent, "to"); toButton = createSkywayElementChooserButton(parent, toField); …
The DataBindingWidgetFactory methods set a DesignContext on the button and text field. In this case, the DesignContext provides the correct variables on demand. Note that the button uses the context to know which variables to show. The field uses the context to know which variables to use in content assist.
Invoking the VariablePathSelectionDialog without using the common skyway controls
If you need to use the selector without using the common button, call SkywayElementChooserFactory.createChooser() passing in SkywayType.VARIABLEPATH as the type of chooser you want.
Getting the selected Variable Path
The selection from the VariablePathSelectionDialog is always represented as a VariablePath. If you are using a combination of the SkywayCommonTextField and SkywayElementChooserButton, then the text field and chooser will work together to get the VariablePath from the variable selector. If you have called the variable selector manually, then you can get the variable path by calling dialog.getSelectedVariablePath() like this:
SelectionDialog chooser =
SkywayElementChooserFactory.createChooser(myShell, false, "", SkywayType.VARIABLE_PATH, designContext);
if (chooser instanceof VariablePathSelectionDialog && chooser.open() == SelectionDialog.OK) {
selection = ((VariablePathSelectionDialog) chooser).getSelectedVariablePath();
}
Filtering Variables
You can set filters on the VariablePathSelectionDialog. Filters are additive meaning that you can add as many as you want and only items that pass all filters will be shown in the tree.
There are currently two filters available:
1) VariableTypeFilter - Works with Primitive or Complex types. 2) VariableCardinalityFilter
You are welcome to create and use any filters you need as long as they extend org.eclipse.jface.viewers.ViewerFilter. Use the existing filters as examples.
Filtering tree contents when using SkywayCommonTextField/SkywayElementChooserButton combination
If you are using the SkywayCommonTextField, then the text field is the source of truth for what it wants from the variable picker. You can add filters to the text field and the dialog will retrieve them from the field via the SkywayElementSelectionReceiver interface.
Example:
Create the filter
PrimitiveDataType pdt = SkywayModelFactory.createInstance(PrimitiveDataType.class); pdt.setType(PrimitiveType.TEXT); VariableTypeFilter filter = new VariableTypeFilter(pdt); // Constructor takes any IType instance.
Create the text field and add the filter (you can add multiple)
SkywayCommonTextField textField = this.createSkywayCommonTextField(parent, SkywayType.VARIABLETEXT, "MyTextField"); textField.addFilter(filter);
Filtering tree contents when calling the VariablePathSelectionDialog directly
If you need to call the dialog directly without the common controls, the only trick is that you need to set your filter before you open the dialog window.
Example:
Create primitive type (in many cases this type will be derived from a prior user selection.)
PrimitiveDataType pdt = SkywayModelFactory.createInstance(PrimitiveDataType.class); pdt.setType(PrimitiveType.TEXT);
Create a list of filters.
List filters = new ArrayList<ViewerFilter>(); filters.add(new VariableTypeFilter(pdt)); filters.add(new VariableCardinalityFilter(Cardinality.ONE));
Create the chooser and add the filters before you open the window.
VariablePathSelectionDialogchooser = new VariablePathSelectionDialog(getShell(), designContext);
chooser.addFilters(filters);
if (chooser.open() == Window.OK) {
selection = ((VariablePathSelectionDialog) chooser).getSelectedVariablePath();
}
To Do
Add ability to re-select a given variable path (for subsequent opens). Content assist for variables. Add ability to type a variable path into the common text field and have it resolve to a real variable. - Is Jay doing this? Add Filter to top of screen that filters by name. Allow Selection of Inputs (inputs not implemented).

