Search in sources :

Example 41 with ValueChangeListener

use of com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener in project mdw-designer by CenturyLinkCloud.

the class VariableValueDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);
    composite.getShell().setText("Variable Value");
    Label nameLabel = new Label(composite, SWT.NONE);
    nameLabel.setFont(new Font(nameLabel.getDisplay(), new FontData("Tahoma", 8, SWT.BOLD)));
    nameLabel.setText(variableValue.getName());
    final String type = variableValue.getType() == null ? "Unknown" : variableValue.getType().getVariableType();
    new Label(composite, SWT.NONE).setText("(" + type + ")");
    if (type.equals("java.lang.Boolean")) {
        valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_CHECKBOX);
    } else if (type.equals("java.util.Date")) {
        valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_DATE_PICKER);
        valueEditor.setWidth(100);
    } else if (type.equals("java.lang.Integer") || type.equals("java.lang.Long")) {
        valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_TEXT);
        valueEditor.setWidth(250);
        valueEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                String stringValue = (String) newValue;
                try {
                    long val = type.equals("java.lang.Long") ? Long.parseLong(stringValue) : Integer.parseInt(stringValue);
                    variableValue.setValue(String.valueOf(val));
                } catch (NumberFormatException ex) {
                    String oldValue = variableValue.getValue();
                    valueEditor.setValue(oldValue);
                }
            }
        });
    } else if (type.equals("java.net.URI")) {
        valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_TEXT);
        valueEditor.setWidth(450);
        valueEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                try {
                    new URI((String) newValue);
                    valueEditor.setLabel("");
                } catch (URISyntaxException ex) {
                    valueEditor.setLabel(ex.getMessage());
                }
            }
        });
    } else if (type.equals("java.lang.Integer[]") || type.equals("java.lang.Long[]") || type.equals("java.lang.String[]")) {
        valueEditor = new TableEditor(null, TableEditor.TYPE_TABLE);
        TableEditor tableEditor = (TableEditor) valueEditor;
        List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
        ColumnSpec valueColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, type.substring(type.lastIndexOf('.') + 1, type.length() - 2) + " Values", type);
        columnSpecs.add(valueColSpec);
        tableEditor.setColumnSpecs(columnSpecs);
        tableEditor.setFillWidth(true);
        tableEditor.setRowDelimiter(ROW_DELIMITER);
        tableEditor.setModelUpdater(new CollectionModelUpdater(tableEditor));
    } else if (type.equals("java.util.Map")) {
        valueEditor = new MappingEditor(null);
        MappingEditor mappingEditor = (MappingEditor) valueEditor;
        List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
        ColumnSpec keyColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Key", "key");
        keyColSpec.width = 150;
        columnSpecs.add(keyColSpec);
        ColumnSpec valColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Value", "value");
        valColSpec.width = 150;
        columnSpecs.add(valColSpec);
        mappingEditor.setColumnSpecs(columnSpecs);
        mappingEditor.setHeight(150);
        mappingEditor.setFillWidth(true);
        mappingEditor.setRowDelimiter(ROW_DELIMITER);
        mappingEditor.setColumnDelimiter(COLUMN_DELIMITER);
        mappingEditor.setContentProvider(mappingEditor.new DefaultContentProvider());
        mappingEditor.setLabelProvider(((TableEditor) mappingEditor).new DefaultLabelProvider());
        mappingEditor.setCellModifier(((TableEditor) mappingEditor).new DefaultCellModifier());
        mappingEditor.setModelUpdater(new CollectionModelUpdater(mappingEditor));
    } else {
        valueEditor = new PropertyEditor(null, PropertyEditor.TYPE_TEXT);
        valueEditor.setMultiLine(true);
        valueEditor.setWidth(500);
        valueEditor.setHeight(500);
    }
    valueEditor.setReadOnly(variableValue.isReadOnly());
    valueEditor.render(composite);
    valueEditor.setValue(variableValue.getValue());
    if (!variableValue.isReadOnly()) {
        valueEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                Button okButton = getButton(Dialog.OK);
                if (// else not editable
                okButton != null)
                    okButton.setEnabled(true);
            }
        });
    }
    if (isCollectionType(type))
        tentativeValueForCollection = variableValue.getValue();
    if (type.equals("java.lang.Boolean"))
        ((Button) valueEditor.getWidget()).setText("(checked = true)");
    else if (type.equals("java.lang.Object"))
        valueEditor.setValue(variableValue.getValue() == null ? null : variableValue.getValue().toString());
    else if (type.equals("java.lang.Integer[]") || type.equals("java.lang.Long[]")) {
        if (!variableValue.isReadOnly()) {
            TableEditor tableEditor = (TableEditor) valueEditor;
            final CellEditor cellEditor = tableEditor.getTableViewer().getCellEditors()[0];
            cellEditor.setValidator(new ICellEditorValidator() {

                private String oldValue = "";

                public String isValid(Object value) {
                    String message = validateValue((String) value, variableValue.getType().getVariableType());
                    if (message != null)
                        cellEditor.setValue(oldValue);
                    else
                        oldValue = (String) value;
                    return null;
                }
            });
        }
    } else if (type.equals("java.util.Map")) {
        if (!variableValue.isReadOnly()) {
            MappingEditor mappingEditor = (MappingEditor) valueEditor;
            final CellEditor valueCellEditor = mappingEditor.getTableViewer().getCellEditors()[1];
            valueCellEditor.setValidator(new ICellEditorValidator() {

                public String isValid(Object value) {
                    String message = validateValue((String) value, variableValue.getType().getVariableType());
                    if (message != null)
                        getButton(Dialog.OK).setEnabled(false);
                    return null;
                }
            });
        }
    }
    return composite;
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) CellEditor(org.eclipse.jface.viewers.CellEditor) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) Font(org.eclipse.swt.graphics.Font) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) Button(org.eclipse.swt.widgets.Button) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) FontData(org.eclipse.swt.graphics.FontData) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor) MappingEditor(com.centurylink.mdw.plugin.designer.properties.editor.MappingEditor) ICellEditorValidator(org.eclipse.jface.viewers.ICellEditorValidator) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 42 with ValueChangeListener

use of com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener in project mdw-designer by CenturyLinkCloud.

the class TransformSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    activity = (Activity) selection;
    // artifact editor
    artifactEditor = new ArtifactEditor(activity, new TransformEditorValueProvider(activity), null);
    artifactEditor.render(composite);
    // input document combo
    inputDocumentEditor = new PropertyEditor(activity, PropertyEditor.TYPE_COMBO);
    inputDocumentEditor.setLabel("Input Document");
    inputDocumentEditor.setWidth(150);
    inputDocumentEditor.setReadOnly(true);
    inputDocumentEditor.setValueOptions(activity.getProcess().getDocRefVariableNames());
    inputDocumentEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activity.setAttribute("Input Documents", (String) newValue);
        }
    });
    inputDocumentEditor.render(composite);
    // output document combo
    outputDocumentEditor = new PropertyEditor(activity, PropertyEditor.TYPE_COMBO);
    outputDocumentEditor.setLabel("Output Document");
    outputDocumentEditor.setWidth(150);
    outputDocumentEditor.setReadOnly(true);
    outputDocumentEditor.setValueOptions(activity.getProcess().getDocRefVariableNames());
    outputDocumentEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activity.setAttribute("Output Documents", (String) newValue);
        }
    });
    outputDocumentEditor.render(composite);
    // help link
    helpPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_LINK);
    helpPropertyEditor.setLabel("Transform Activity Help");
    helpPropertyEditor.render(composite);
}
Also used : ArtifactEditor(com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) TransformEditorValueProvider(com.centurylink.mdw.plugin.designer.properties.value.TransformEditorValueProvider)

Example 43 with ValueChangeListener

use of com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener in project mdw-designer by CenturyLinkCloud.

the class ActivityImplSection method drawWidgets.

@Override
public void drawWidgets(Composite composite, WorkflowElement selection) {
    activityImpl = (ActivityImpl) selection;
    // id text field
    idField = new PropertyEditor(activityImpl, PropertyEditor.TYPE_TEXT);
    idField.setLabel("ID");
    idField.setWidth(150);
    idField.setReadOnly(true);
    idField.render(composite);
    // impl class name link
    implClassLink = new PropertyEditor(activityImpl, PropertyEditor.TYPE_LINK);
    implClassLink.setWidth(600);
    implClassLink.setHeight(17);
    implClassLink.setFont(new FontData("Tahoma", 8, SWT.BOLD));
    implClassLink.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activityImpl.getProject().viewSource(activityImpl.getImplClassName());
        }
    });
    implClassLink.render(composite);
    // impl class button
    implClassButton = new PropertyEditor(activityImpl, PropertyEditor.TYPE_BUTTON);
    implClassButton.setLabel("Change...");
    implClassButton.setVerticalIndent(-3);
    implClassButton.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            launchImplClassNameDialog();
        }
    });
    implClassButton.render(composite);
    // label text field
    labelField = new PropertyEditor(activityImpl, PropertyEditor.TYPE_TEXT);
    labelField.setLabel("Label");
    labelField.setWidth(200);
    labelField.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activityImpl.setLabel((String) newValue);
        }
    });
    labelField.render(composite);
    // icon text field
    iconField = new PropertyEditor(activityImpl, PropertyEditor.TYPE_TEXT);
    iconField.setLabel("Icon");
    iconField.setWidth(200);
    iconField.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activityImpl.setIconName((String) newValue);
        }
    });
    iconField.render(composite);
    // implementor help link
    helpLink = new PropertyEditor(activityImpl, PropertyEditor.TYPE_LINK);
    helpLink.setLabel("Activity Implementor Help");
    helpLink.render(composite);
}
Also used : ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) FontData(org.eclipse.swt.graphics.FontData) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)

Example 44 with ValueChangeListener

use of com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener in project mdw-designer by CenturyLinkCloud.

the class ActivitySection method drawWidgets.

@Override
public void drawWidgets(Composite composite, WorkflowElement selection) {
    activity = (Activity) selection;
    // id text field
    idPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_TEXT);
    idPropertyEditor.setLabel("ID");
    idPropertyEditor.setWidth(150);
    idPropertyEditor.setReadOnly(true);
    idPropertyEditor.render(composite);
    // logical id text field
    logicalIdPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_TEXT);
    logicalIdPropertyEditor.setLabel("Logical ID");
    logicalIdPropertyEditor.setWidth(150);
    logicalIdPropertyEditor.setReadOnly(true);
    logicalIdPropertyEditor.render(composite);
    // name text field
    namePropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_TEXT);
    namePropertyEditor.setLabel("Label");
    namePropertyEditor.setMultiLine(true);
    namePropertyEditor.setWidth(475);
    namePropertyEditor.setHeight(30);
    namePropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activity.setName((String) newValue);
        }
    });
    namePropertyEditor.render(composite);
    // implementor combo
    implementorPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_COMBO);
    implementorPropertyEditor.setLabel("Implementor");
    implementorPropertyEditor.setWidth(475);
    List<String> implementorNames = new ArrayList<>();
    for (ActivityImplementorVO implVo : getDataAccess().getActivityImplementors(false)) implementorNames.add(implVo.getImplementorClassName());
    implementorPropertyEditor.setValueOptions(implementorNames);
    implementorPropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activity.setActivityImpl(activity.getProject().getActivityImpl((String) newValue));
        }
    });
    implementorPropertyEditor.render(composite);
    ((Combo) implementorPropertyEditor.getWidget()).setVisibleItemCount(10);
    // implementor link
    linkPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_LINK);
    linkPropertyEditor.setLabel("Open Implementor Source Code");
    linkPropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activity.getProject().viewSource(activity.getActivityImpl().getImplClassName());
        }
    });
    linkPropertyEditor.render(composite);
    // description text area
    descriptionPropertyEditor = new PropertyEditor(activity, PropertyEditor.TYPE_TEXT);
    descriptionPropertyEditor.setLabel("Description");
    descriptionPropertyEditor.setWidth(475);
    descriptionPropertyEditor.setHeight(70);
    descriptionPropertyEditor.setMultiLine(true);
    descriptionPropertyEditor.setTextLimit(1000);
    descriptionPropertyEditor.addValueChangeListener(new ValueChangeListener() {

        public void propertyValueChanged(Object newValue) {
            activity.setDescription((String) newValue);
        }
    });
    descriptionPropertyEditor.render(composite);
}
Also used : ActivityImplementorVO(com.centurylink.mdw.model.value.activity.ActivityImplementorVO) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) ArrayList(java.util.ArrayList) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) Combo(org.eclipse.swt.widgets.Combo)

Aggregations

ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)44 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)36 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)9 ArrayList (java.util.ArrayList)8 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 ArtifactEditor (com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor)5 Event (org.eclipse.swt.widgets.Event)5 Label (org.eclipse.swt.widgets.Label)5 Listener (org.eclipse.swt.widgets.Listener)5 DateConverter (com.centurylink.mdw.plugin.designer.properties.convert.DateConverter)4 ColumnSpec (com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec)3 PropertyEditorList (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList)3 FontData (org.eclipse.swt.graphics.FontData)3 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)2 ElementChangeEvent (com.centurylink.mdw.plugin.designer.model.ElementChangeEvent)2 ElementChangeListener (com.centurylink.mdw.plugin.designer.model.ElementChangeListener)2 EmbeddedSubProcess (com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess)2 TimeInterval (com.centurylink.mdw.plugin.designer.properties.editor.TimeInterval)2 WorkflowAssetEditor (com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor)2 MarkdownRenderer (com.centurylink.mdw.designer.utils.MarkdownRenderer)1