Search in sources :

Example 11 with ColumnSpec

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

the class TestSuiteLaunchTab method createTable.

protected void createTable(Composite parent) {
    int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
    testCasesTable = new Table(parent, style);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 2;
    gridData.verticalIndent = 3;
    testCasesTable.setLayoutData(gridData);
    testCasesTable.setLinesVisible(true);
    testCasesTable.setHeaderVisible(true);
    for (int i = 0; i < testCasesColumnSpecs.size(); i++) {
        ColumnSpec colSpec = testCasesColumnSpecs.get(i);
        int styles = SWT.LEFT;
        if (colSpec.readOnly)
            style = style | SWT.READ_ONLY;
        TableColumn column = new TableColumn(testCasesTable, styles, i);
        column.setText(colSpec.label);
        column.setWidth(colSpec.width);
        column.setResizable(colSpec.resizable);
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) GridData(org.eclipse.swt.layout.GridData) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 12 with ColumnSpec

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

the class ListView method createTable.

private void createTable(Composite parent) {
    int style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION;
    table = new Table(parent, style);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.horizontalSpan = 10;
    table.setLayoutData(gridData);
    table.setLinesVisible(true);
    table.setHeaderVisible(true);
    for (int i = 0; i < columnSpecs.size(); i++) {
        ColumnSpec colSpec = columnSpecs.get(i);
        int styles = SWT.LEFT;
        if (colSpec.readOnly)
            style = style | SWT.READ_ONLY;
        TableColumn column = new TableColumn(table, styles, i);
        column.setText(colSpec.label);
        column.setWidth(colSpec.width);
        column.setResizable(colSpec.resizable);
        column.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                TableColumn sortColumn = tableViewer.getTable().getSortColumn();
                TableColumn currentColumn = (TableColumn) e.widget;
                int direction = tableViewer.getTable().getSortDirection();
                if (sortColumn == currentColumn) {
                    direction = direction == SWT.UP ? SWT.DOWN : SWT.UP;
                } else {
                    tableViewer.getTable().setSortColumn(currentColumn);
                    direction = SWT.UP;
                }
                tableViewer.getTable().setSortDirection(direction);
                // TODO handle column sort
                refreshTable();
            }
        });
    }
    // double-click
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            handleOpen(e.item.getData());
        }
    });
    // right-click menu
    table.addListener(SWT.MenuDetect, new Listener() {

        public void handleEvent(Event event) {
            table.setMenu(createContextMenu(table.getShell()));
        }
    });
    // auto-adjust column width
    table.addControlListener(new ControlAdapter() {

        @Override
        public void controlResized(ControlEvent e) {
            int tableWidth = table.getBounds().width;
            int cumulative = 0;
            TableColumn[] tableColumns = table.getColumns();
            for (int i = 0; i < tableColumns.length; i++) {
                if (i == tableColumns.length - 1)
                    tableColumns[i].setWidth(tableWidth - cumulative - 25);
                cumulative += tableColumns[i].getWidth();
            }
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) Listener(org.eclipse.swt.widgets.Listener) ControlAdapter(org.eclipse.swt.events.ControlAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 13 with ColumnSpec

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

the class VariableInstancesSection 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 instanceIdColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Instance ID", "instId");
    instanceIdColSpec.width = 80;
    columnSpecs.add(instanceIdColSpec);
    ColumnSpec valueColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Value", "value");
    valueColSpec.width = 300;
    columnSpecs.add(valueColSpec);
    ColumnSpec typeColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Type", "type");
    typeColSpec.width = 200;
    columnSpecs.add(typeColSpec);
    return columnSpecs;
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ArrayList(java.util.ArrayList)

Example 14 with ColumnSpec

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

the class SubProcessMappingSection method createColumnSpecs.

private List<ColumnSpec> createColumnSpecs() {
    List<ColumnSpec> columnSpecs = new ArrayList<>();
    ColumnSpec variableColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "SubProcess Variable", "variable");
    variableColSpec.width = 175;
    variableColSpec.readOnly = true;
    columnSpecs.add(variableColSpec);
    ColumnSpec typeColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Type", "type");
    typeColSpec.width = 200;
    typeColSpec.readOnly = true;
    columnSpecs.add(typeColSpec);
    ColumnSpec varModeColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Mode", "mode");
    varModeColSpec.width = 125;
    varModeColSpec.readOnly = true;
    columnSpecs.add(varModeColSpec);
    ColumnSpec expressionColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Binding Expression", "expression");
    expressionColSpec.width = 175;
    columnSpecs.add(expressionColSpec);
    return columnSpecs;
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ArrayList(java.util.ArrayList)

Example 15 with ColumnSpec

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

the class SubProcessMappingSection method populateVariableBindingsTable.

private void populateVariableBindingsTable() {
    mappingEditor.disposeWidget();
    mappingEditor.setOwningProcess(subProcess);
    inputOutputVariables = getInputOutputVariables();
    List<ColumnSpec> columnSpecs = createColumnSpecs();
    mappingEditor.setColumnSpecs(columnSpecs);
    mappingEditor.render(composite, false);
    if (subProcess != null) {
        Map<String, String> map = StringHelper.parseMap(activity.getAttribute("variables"));
        // clear inapplicable bindings
        List<String> inapplicableVars = new ArrayList<>();
        for (String varName : map.keySet()) {
            boolean found = false;
            for (VariableVO inputVar : subProcess.getInputOutputVariables()) {
                if (inputVar.getName().equals(varName)) {
                    found = true;
                    break;
                }
            }
            if (!found)
                inapplicableVars.add(varName);
        }
        for (String inapplicableVar : inapplicableVars) map.remove(inapplicableVar);
        if (!inapplicableVars.isEmpty()) {
            String newAttrVal = StringHelper.formatMap(map);
            activity.setAttribute("variables", newAttrVal);
            activity.fireAttributeValueChanged("variables", newAttrVal);
        }
        List<VariableBinding> variableBindings = getVariableBindings(map);
        mappingEditor.setValue(variableBindings);
    }
    composite.layout(true);
}
Also used : ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ArrayList(java.util.ArrayList) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) VariableBinding(com.centurylink.mdw.plugin.designer.model.VariableBinding)

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