Search in sources :

Example 1 with VariableValueDialog

use of com.centurylink.mdw.plugin.designer.dialogs.VariableValueDialog in project mdw-designer by CenturyLinkCloud.

the class VariableInstancesSection method openDialog.

private void openDialog(VariableInstanceInfo variableInstanceInfo) {
    Integer processStatus = process.getProcessInstance().getStatusCode();
    VariableTypeVO varType = getType(variableInstanceInfo);
    boolean readOnly = WorkStatus.STATUS_COMPLETED.equals(processStatus) || WorkStatus.STATUS_CANCELLED.equals(processStatus);
    if (varType.isJavaObjectType()) {
        try {
            // update based on object instance or from server
            varType = getDesignerProxy().getVariableInfo(variableInstanceInfo);
            if (!varType.isUpdateable())
                readOnly = true;
        } catch (Exception ex) {
            PluginMessages.log(ex);
        }
    }
    try {
        String varValue = getDesignerProxy().getVariableValue(getShell(), variableInstanceInfo, true);
        VariableValueDialog variableValueDialog = new VariableValueDialog(getShell(), variableInstanceInfo, varType, varValue, readOnly);
        if (variableValueDialog.open() == Dialog.OK) {
            DesignerProxy designerProxy = process.getProject().getDesignerProxy();
            designerProxy.updateVariableValue(process, variableInstanceInfo, variableValueDialog.getVariableValue().getValue());
            List<VariableInstanceInfo> variables = process.getProcessInstance().getVariables();
            List<VariableInstanceInfo> uninitializedVariables = getTheUninitializedVariables();
            variables.addAll(uninitializedVariables);
            tableEditor.setValue(variables);
        }
    } catch (Exception ex) {
        PluginMessages.uiMessage(ex, "Retrieve Variable", process.getProject(), PluginMessages.VALIDATION_MESSAGE);
        return;
    }
}
Also used : VariableTypeVO(com.centurylink.mdw.model.value.variable.VariableTypeVO) VariableValueDialog(com.centurylink.mdw.plugin.designer.dialogs.VariableValueDialog) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) VariableInstanceInfo(com.centurylink.mdw.model.value.variable.VariableInstanceInfo)

Example 2 with VariableValueDialog

use of com.centurylink.mdw.plugin.designer.dialogs.VariableValueDialog in project mdw-designer by CenturyLinkCloud.

the class VariableValuesTableContainer method createTable.

private void createTable(Composite parent) {
    int style = SWT.SINGLE | 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 = 2;
    gridData.verticalIndent = 3;
    gridData.verticalAlignment = SWT.FILL;
    gridData.heightHint = 150;
    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);
    }
    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 - 5);
                cumulative += tableColumns[i].getWidth();
            }
        }
    });
    table.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            VariableValue varVal = (VariableValue) e.item.getData();
            String originalValue = varVal.getValue();
            VariableValueDialog varValDlg = new VariableValueDialog(getShell(), varVal);
            varValDlg.setHelpAvailable(false);
            if (varValDlg.open() == Dialog.OK && !originalValue.equals(varVal.getValue())) {
                varVal.setValue(varValDlg.getVariableValue().getValue());
                tableViewer.update(varVal, null);
                fireDirtyStateChange(true);
            } else {
                varVal.setValue(originalValue);
            }
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) ControlAdapter(org.eclipse.swt.events.ControlAdapter) VariableValue(com.centurylink.mdw.plugin.designer.model.VariableValue) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) VariableValueDialog(com.centurylink.mdw.plugin.designer.dialogs.VariableValueDialog) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlEvent(org.eclipse.swt.events.ControlEvent)

Aggregations

VariableValueDialog (com.centurylink.mdw.plugin.designer.dialogs.VariableValueDialog)2 VariableInstanceInfo (com.centurylink.mdw.model.value.variable.VariableInstanceInfo)1 VariableTypeVO (com.centurylink.mdw.model.value.variable.VariableTypeVO)1 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)1 VariableValue (com.centurylink.mdw.plugin.designer.model.VariableValue)1 ColumnSpec (com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec)1 ControlAdapter (org.eclipse.swt.events.ControlAdapter)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1