Search in sources :

Example 1 with ListConverter

use of com.centurylink.mdw.plugin.designer.properties.convert.ListConverter in project mdw-designer by CenturyLinkCloud.

the class WorkflowAssetCustomSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    workflowAsset = (WorkflowAsset) selection;
    // attr definition text area
    customAttrsPropEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_TEXT);
    customAttrsPropEditor.setLabel("Custom Attr Definition\n(Pagelet Syntax)");
    customAttrsPropEditor.setMultiLine(true);
    customAttrsPropEditor.setWidth(475);
    customAttrsPropEditor.setHeight(80);
    customAttrsPropEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            String def = newValue == null || ((String) newValue).length() == 0 ? null : (String) newValue;
            if (customAttribute == null)
                customAttribute = new CustomAttributeVO("RULE_SET", workflowAsset.getLanguage());
            customAttribute.setDefinition(def);
        }
    });
    customAttrsPropEditor.render(composite);
    // roles picklist
    rolesPropertyEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_PICKLIST);
    rolesPropertyEditor.setValueConverter(new ListConverter());
    rolesPropertyEditor.setLabel("Custom Attr Edit Roles:Unselected~Permitted");
    PluginDataAccess dataAccess = workflowAsset.getProject().getDataAccess();
    rolesPropertyEditor.setValueOptions(dataAccess.getRoleNames(false));
    rolesPropertyEditor.addValueChangeListener(new ValueChangeListener() {

        @SuppressWarnings("unchecked")
        public void propertyValueChanged(Object newValue) {
            if (customAttribute == null)
                customAttribute = new CustomAttributeVO("RULE_SET", workflowAsset.getLanguage());
            if (newValue == null)
                customAttribute.setRoles(null);
            else
                customAttribute.setRoles((List<String>) newValue);
        }
    });
    rolesPropertyEditor.render(composite);
    rolesPropertyEditor.setValue("");
    // save button
    savePropertyEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_BUTTON);
    savePropertyEditor.setLabel("Save");
    savePropertyEditor.setComment("Save Custom Attrs:");
    savePropertyEditor.setWidth(65);
    savePropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            saveCustomAttribute();
        }
    });
    savePropertyEditor.render(composite);
    // help link
    helpLinkPropertyEditor = new PropertyEditor(workflowAsset, PropertyEditor.TYPE_LINK);
    helpLinkPropertyEditor.setLabel("Custom Attributes Help");
    helpLinkPropertyEditor.render(composite);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) CustomAttributeVO(com.centurylink.mdw.model.value.attribute.CustomAttributeVO) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) ListConverter(com.centurylink.mdw.plugin.designer.properties.convert.ListConverter) PluginDataAccess(com.centurylink.mdw.plugin.designer.PluginDataAccess)

Aggregations

CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)1 PluginDataAccess (com.centurylink.mdw.plugin.designer.PluginDataAccess)1 ListConverter (com.centurylink.mdw.plugin.designer.properties.convert.ListConverter)1 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1