Search in sources :

Example 31 with ColumnSpec

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

the class ActivityInstanceSection method createColumnSpecs.

private List<ColumnSpec> createColumnSpecs() {
    List<ColumnSpec> colSpecs = new ArrayList<>();
    ColumnSpec instanceIdColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Instance ID", "instanceId");
    instanceIdColSpec.width = 100;
    colSpecs.add(instanceIdColSpec);
    ColumnSpec statusColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Status", "status");
    statusColSpec.width = 100;
    colSpecs.add(statusColSpec);
    ColumnSpec statusMessageColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Completion Code / Status Message", "statusMessage");
    statusMessageColSpec.width = 200;
    colSpecs.add(statusMessageColSpec);
    ColumnSpec startDateColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Start", "startDate");
    startDateColSpec.width = 150;
    colSpecs.add(startDateColSpec);
    ColumnSpec endDateColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "End", "endDate");
    endDateColSpec.width = 150;
    colSpecs.add(endDateColSpec);
    return colSpecs;
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ArrayList(java.util.ArrayList)

Example 32 with ColumnSpec

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

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

the class VariablesSection method createColumnSpecs.

private List<ColumnSpec> createColumnSpecs() {
    List<ColumnSpec> columnSpecs = new ArrayList<ColumnSpec>();
    ColumnSpec nameColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Variable Name", "name");
    nameColSpec.width = 150;
    columnSpecs.add(nameColSpec);
    ColumnSpec typeColSpec = new ColumnSpec(PropertyEditor.TYPE_COMBO, "Type", "type");
    typeColSpec.width = 200;
    typeColSpec.readOnly = true;
    typeColSpec.options = getVariableTypeNames();
    columnSpecs.add(typeColSpec);
    ColumnSpec modeColSpec = new ColumnSpec(PropertyEditor.TYPE_COMBO, "Mode", "mode");
    modeColSpec.width = 85;
    modeColSpec.readOnly = true;
    modeColSpec.options = VariableVO.VariableCategories;
    columnSpecs.add(modeColSpec);
    ColumnSpec labelColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "UI Label", "label");
    labelColSpec.width = 100;
    columnSpecs.add(labelColSpec);
    ColumnSpec displayColSpec = new ColumnSpec(PropertyEditor.TYPE_COMBO, "UI Display", "display");
    displayColSpec.width = 100;
    displayColSpec.readOnly = true;
    displayColSpec.options = new String[Display.values().length + 1];
    displayColSpec.options[0] = "";
    for (int i = 0; i < Display.values().length; i++) displayColSpec.options[i + 1] = Display.values()[i].toString();
    columnSpecs.add(displayColSpec);
    ColumnSpec sequenceColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Sequence", "sequenceNumber");
    sequenceColSpec.width = 65;
    columnSpecs.add(sequenceColSpec);
    return columnSpecs;
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ArrayList(java.util.ArrayList)

Example 34 with ColumnSpec

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

the class AttributesSection method drawWidgets.

@Override
public void drawWidgets(Composite composite, WorkflowElement selection) {
    this.element = selection;
    tableEditor = new TableEditor(element, TableEditor.TYPE_TABLE);
    List<ColumnSpec> columnSpecs = new ArrayList<>();
    columnSpecs.add(new ColumnSpec(PropertyEditor.TYPE_TEXT, "Attribute Name", "name"));
    columnSpecs.add(new ColumnSpec(PropertyEditor.TYPE_TEXT, "Value", "value"));
    tableEditor.setColumnSpecs(columnSpecs);
    tableEditor.setReadOnly(true);
    tableEditor.setContentProvider(new AttributeContentProvider());
    tableEditor.setLabelProvider(new AttributeLabelProvider());
    tableEditor.render(composite);
    tableEditor.getTable().addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            AttributeVO attributeVO = (AttributeVO) e.item.getData();
            AttributeDialog dialog = new AttributeDialog(getShell(), attributeVO);
            dialog.open();
        }
    });
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) AttributeVO(com.centurylink.mdw.model.value.attribute.AttributeVO) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ArrayList(java.util.ArrayList) SelectionEvent(org.eclipse.swt.events.SelectionEvent) AttributeDialog(com.centurylink.mdw.plugin.designer.dialogs.AttributeDialog) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)

Example 35 with ColumnSpec

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

the class LoadTestLaunchTab method createTableViewer.

protected void createTableViewer() {
    testCasesTableViewer = new TableViewer(testCasesTable);
    testCasesTableViewer.setUseHashlookup(true);
    testCasesTableViewer.setColumnProperties(testCasesColumnProps);
    CellEditor[] editors = new CellEditor[testCasesColumnSpecs.size()];
    for (int i = 0; i < testCasesColumnSpecs.size(); i++) {
        ColumnSpec colSpec = testCasesColumnSpecs.get(i);
        CellEditor cellEditor = null;
        if (colSpec.type.equals(PropertyEditor.TYPE_TEXT)) {
            if (i == 1)
                cellEditor = new TextCellEditor(testCasesTable);
            else {
                // Text with digits only for 3rd column
                cellEditor = new TextCellEditor(testCasesTable);
                ((Text) cellEditor.getControl()).addVerifyListener(new VerifyListener() {

                    public void verifyText(VerifyEvent e) {
                        e.doit = "0123456789".indexOf(e.text) >= 0;
                    }
                });
            }
        } else if (colSpec.type.equals(PropertyEditor.TYPE_CHECKBOX)) {
            cellEditor = new CheckboxCellEditor(testCasesTable);
        }
        editors[i] = cellEditor;
    }
    testCasesTableViewer.setCellEditors(editors);
    testCasesTableViewer.setCellModifier(new TestCaseCellModifier());
    testCasesTableViewer.setLabelProvider(new TestCaseLabelProvider());
    testCasesTableViewer.setContentProvider(new TestCaseContentProvider());
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) VerifyListener(org.eclipse.swt.events.VerifyListener) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Text(org.eclipse.swt.widgets.Text) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Aggregations

ColumnSpec (com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec)36 ArrayList (java.util.ArrayList)22 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)6 GridData (org.eclipse.swt.layout.GridData)6 CellEditor (org.eclipse.jface.viewers.CellEditor)5 Table (org.eclipse.swt.widgets.Table)5 TableColumn (org.eclipse.swt.widgets.TableColumn)5 List (java.util.List)4 TableViewer (org.eclipse.jface.viewers.TableViewer)4 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 DefaultRowImpl (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl)3 TableModelUpdater (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.TableModelUpdater)3 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)3 ControlAdapter (org.eclipse.swt.events.ControlAdapter)3 ControlEvent (org.eclipse.swt.events.ControlEvent)3 ElementChangeEvent (com.centurylink.mdw.plugin.designer.model.ElementChangeEvent)2