Search in sources :

Example 46 with PropertyEditor

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

the class DocumentationSection method setSelection.

public void setSelection(WorkflowElement selection) {
    element = selection;
    String attrVal = element.getAttribute(ATTR);
    if (attrVal != null && !attrVal.isEmpty()) {
        if (attrVal.length() >= 8) {
            byte[] first4 = RuleSetVO.decode(attrVal.substring(0, 8));
            if (first4[0] == 68 && first4[1] == 35 && first4[2] == 17 && first4[3] == 0)
                language = DocumentationEditorValueProvider.MS_WORD;
        }
    }
    if (artifactEditor != null) {
        artifactEditor.dispose();
        artifactEditor = null;
    }
    if (referenceIdEditor != null) {
        referenceIdEditor.dispose();
        referenceIdEditor = null;
    }
    if (sequenceIdEditor != null) {
        sequenceIdEditor.dispose();
        sequenceIdEditor = null;
    }
    if (webEditor != null) {
        webEditor.dispose();
        webEditor = null;
    }
    // artifact editor
    ArtifactEditorValueProvider valueProvider = new DocumentationEditorValueProvider(selection) {

        @Override
        public void languageChanged(String newLanguage) {
            super.languageChanged(newLanguage);
            boolean proceed = true;
            String attrVal = element.getAttribute(ATTR);
            if (attrVal != null && !attrVal.isEmpty() && !language.equals(newLanguage))
                proceed = MessageDialog.openConfirm(getShell(), "Confirm Format", "Proceed with switch to " + newLanguage + " format? (" + language + " formatted content will be lost.)");
            if (proceed) {
                language = newLanguage;
                element.setAttribute(getAttributeName(), " ");
                setSelection(element);
            } else {
                artifactEditor.setLanguage(language);
            }
        }

        @Override
        public String getLanguage() {
            return language;
        }
    };
    artifactEditor = new ArtifactEditor(selection, valueProvider, "Format");
    artifactEditor.render(composite);
    artifactEditor.setElement(selection);
    artifactEditor.setEditable(!selection.isReadOnly());
    artifactEditor.setLanguage(language);
    if (element instanceof Activity || element instanceof EmbeddedSubProcess) {
        // reference ID text field
        sequenceIdEditor = new PropertyEditor(element, PropertyEditor.TYPE_TEXT);
        sequenceIdEditor.setLabel("Sequence Number");
        sequenceIdEditor.setWidth(100);
        sequenceIdEditor.setVerticalIndent(5);
        sequenceIdEditor.render(composite);
        sequenceIdEditor.setElement(selection);
        sequenceIdEditor.setValue(element instanceof EmbeddedSubProcess ? ((EmbeddedSubProcess) element).getSequenceId() : ((Activity) element).getSequenceId());
        sequenceIdEditor.setEditable(false);
        // reference ID text field
        referenceIdEditor = new PropertyEditor(element, PropertyEditor.TYPE_TEXT);
        referenceIdEditor.setLabel("Reference ID");
        referenceIdEditor.setWidth(100);
        referenceIdEditor.setComment("Optional (select Reference ID element order when exporting)");
        referenceIdEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                element.setAttribute(WorkAttributeConstant.REFERENCE_ID, (String) newValue);
            }
        });
        referenceIdEditor.render(composite);
        referenceIdEditor.setElement(selection);
        referenceIdEditor.setEditable(!selection.isReadOnly());
        referenceIdEditor.setValue(element.getAttribute(WorkAttributeConstant.REFERENCE_ID));
    }
    if (DocumentationEditorValueProvider.MARKDOWN.equals(language) && element.getProject().checkRequiredVersion(6, 0)) {
        webEditor = new PropertyEditor(element, PropertyEditor.TYPE_WEB);
        webEditor.render(composite);
        webEditor.setElement(element);
        MarkdownRenderer renderer = new MarkdownRenderer(attrVal);
        webEditor.setValue(renderer.renderHtml());
        webEditor.addValueChangeListener(new ValueChangeListener() {

            public void propertyValueChanged(Object newValue) {
                MarkdownRenderer renderer = new MarkdownRenderer(newValue == null ? null : newValue.toString());
                String html = renderer.renderHtml();
                webEditor.setValue(html);
            }
        });
    }
    composite.layout(true);
}
Also used : EmbeddedSubProcess(com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess) ArtifactEditor(com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor) ValueChangeListener(com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener) DocumentationEditorValueProvider(com.centurylink.mdw.plugin.designer.properties.value.DocumentationEditorValueProvider) Activity(com.centurylink.mdw.plugin.designer.model.Activity) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) ArtifactEditorValueProvider(com.centurylink.mdw.plugin.designer.properties.value.ArtifactEditorValueProvider) MarkdownRenderer(com.centurylink.mdw.designer.utils.MarkdownRenderer)

Example 47 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor 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 48 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor 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 49 with PropertyEditor

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

the class VariablesSection method drawWidgets.

public void drawWidgets(Composite composite, WorkflowElement selection) {
    process = (WorkflowProcess) selection;
    tableEditor = new TableEditor(process, TableEditor.TYPE_TABLE);
    if (columnSpecs == null)
        columnSpecs = createColumnSpecs();
    tableEditor.setColumnSpecs(columnSpecs);
    if (contentProvider == null)
        contentProvider = new VariableContentProvider();
    tableEditor.setContentProvider(contentProvider);
    if (labelProvider == null)
        labelProvider = new VariableLabelProvider();
    tableEditor.setLabelProvider(labelProvider);
    if (cellModifier == null)
        cellModifier = new VariableCellModifier();
    tableEditor.setCellModifier(cellModifier);
    if (modelUpdater == null)
        modelUpdater = new VariableModelUpdater();
    tableEditor.setModelUpdater(modelUpdater);
    tableEditor.render(composite);
    // variables help link
    variablesHelpPropertyEditor = new PropertyEditor(process, PropertyEditor.TYPE_LINK);
    variablesHelpPropertyEditor.setLabel("Process Variables Help");
    variablesHelpPropertyEditor.render(composite);
}
Also used : PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)

Example 50 with PropertyEditor

use of com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor 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)

Aggregations

PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)51 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)36 PropertyEditorList (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditorList)11 Activity (com.centurylink.mdw.plugin.designer.model.Activity)7 ArrayList (java.util.ArrayList)6 Label (org.eclipse.swt.widgets.Label)6 ArtifactEditor (com.centurylink.mdw.plugin.designer.properties.editor.ArtifactEditor)5 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)5 DateConverter (com.centurylink.mdw.plugin.designer.properties.convert.DateConverter)4 WorkflowAssetEditor (com.centurylink.mdw.plugin.designer.properties.editor.WorkflowAssetEditor)4 CustomAttributeVO (com.centurylink.mdw.model.value.attribute.CustomAttributeVO)3 FontData (org.eclipse.swt.graphics.FontData)3 TimeInterval (com.centurylink.mdw.plugin.designer.properties.editor.TimeInterval)2 GridData (org.eclipse.swt.layout.GridData)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 MarkdownRenderer (com.centurylink.mdw.designer.utils.MarkdownRenderer)1 ActivityImplementorVO (com.centurylink.mdw.model.value.activity.ActivityImplementorVO)1 BamMessageDefinition (com.centurylink.mdw.model.value.event.BamMessageDefinition)1 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)1