Search in sources :

Example 1 with DefaultRowImpl

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

the class ExtensionModulesTable method create.

public TableEditor create() {
    tableEditor = new TableEditor(null, TableEditor.TYPE_TABLE);
    // colspecs
    List<ColumnSpec> colSpecs = new ArrayList<ColumnSpec>();
    ColumnSpec selectionColSpec = new ColumnSpec(PropertyEditor.TYPE_CHECKBOX, "", "import");
    selectionColSpec.width = 80;
    colSpecs.add(selectionColSpec);
    ColumnSpec extensionColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Extension", "extension");
    extensionColSpec.width = 150;
    extensionColSpec.readOnly = true;
    colSpecs.add(extensionColSpec);
    ColumnSpec descriptionColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Description", "description");
    descriptionColSpec.readOnly = true;
    descriptionColSpec.width = 350;
    colSpecs.add(descriptionColSpec);
    tableEditor.setColumnSpecs(colSpecs);
    tableEditor.setFillWidth(true);
    tableEditor.setModelUpdater(new TableModelUpdater() {

        public Object create() {
            return null;
        }

        @SuppressWarnings("rawtypes")
        public void updateModelValue(List tableValue) {
            selectedModules = new ArrayList<ExtensionModule>();
            for (ExtensionModule module : WorkflowProjectManager.getInstance().getAvailableExtensions(workflowProject)) {
                for (Object rowObj : tableValue) {
                    DefaultRowImpl row = (DefaultRowImpl) rowObj;
                    if (module.getName().equals(row.getColumnValue(1))) {
                        if (((Boolean) row.getColumnValue(0)).booleanValue())
                            selectedModules.add(module);
                        else
                            selectedModules.remove(module);
                    }
                }
            }
        }
    });
    return tableEditor;
}
Also used : DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) TableModelUpdater(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.TableModelUpdater) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)

Example 2 with DefaultRowImpl

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

the class PreferencesSection method createNoticesTable.

private void createNoticesTable() {
    noticesEditor = new TableEditor(null, TableEditor.TYPE_TABLE);
    noticesEditor.setLabel("Desktop Notices");
    // colspecs
    List<ColumnSpec> colSpecs = new ArrayList<ColumnSpec>();
    ColumnSpec selectionColSpec = new ColumnSpec(PropertyEditor.TYPE_CHECKBOX, "", "selected");
    selectionColSpec.width = 50;
    colSpecs.add(selectionColSpec);
    ColumnSpec extensionColSpec = new ColumnSpec(PropertyEditor.TYPE_TEXT, "Task Outcome", "outcome");
    extensionColSpec.width = 150;
    extensionColSpec.readOnly = true;
    colSpecs.add(extensionColSpec);
    noticesEditor.setColumnSpecs(colSpecs);
    noticesEditor.setHorizontalSpan(3);
    noticesEditor.setWidth(300);
    noticesEditor.setModelUpdater(new TableModelUpdater() {

        public Object create() {
            return null;
        }

        @SuppressWarnings("rawtypes")
        public void updateModelValue(List tableValue) {
            List<String> selectedNotices = new ArrayList<String>();
            for (Action outcome : UserActionVO.NOTIFIABLE_TASK_ACTIONS) {
                for (Object rowObj : tableValue) {
                    DefaultRowImpl row = (DefaultRowImpl) rowObj;
                    if (outcome.toString().equals(row.getColumnValue(1))) {
                        if (((Boolean) row.getColumnValue(0)).booleanValue())
                            selectedNotices.add(outcome.toString());
                        else
                            selectedNotices.remove(outcome.toString());
                    }
                }
            }
            project.setNoticeChecks(selectedNotices);
        }
    });
}
Also used : Action(com.centurylink.mdw.model.value.user.UserActionVO.Action) DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) ColumnSpec(com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec) TableModelUpdater(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.TableModelUpdater) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)

Example 3 with DefaultRowImpl

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

the class PreferencesSection method getSelectedNoticeRows.

private List<DefaultRowImpl> getSelectedNoticeRows(List<String> selectedNotices) {
    List<DefaultRowImpl> tableRows = new ArrayList<DefaultRowImpl>();
    for (Action outcome : UserActionVO.NOTIFIABLE_TASK_ACTIONS) {
        String[] rowData = new String[2];
        if (selectedNotices.contains(outcome.toString()))
            rowData[0] = "true";
        else
            rowData[0] = "false";
        rowData[1] = outcome.toString();
        DefaultRowImpl row = noticesEditor.new DefaultRowImpl(rowData);
        tableRows.add(row);
    }
    return tableRows;
}
Also used : DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) Action(com.centurylink.mdw.model.value.user.UserActionVO.Action) ArrayList(java.util.ArrayList)

Example 4 with DefaultRowImpl

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

the class OsgiAdapterDesignSection method getParamsTableValue.

private List<DefaultRowImpl> getParamsTableValue() {
    List<DefaultRowImpl> rows = new ArrayList<DefaultRowImpl>();
    String methodSig = methodDropdown.getValue();
    if (methodSig != null && !methodSig.isEmpty()) {
        int parenOpen = methodSig.indexOf('(');
        String params = methodSig.substring(parenOpen + 1, methodSig.length() - 1);
        for (String p : params.split(",")) {
            p = p.trim();
            int space = p.indexOf(' ');
            String paramName = p.substring(space + 1);
            String paramType = p.substring(0, space);
            String[] colVals = new String[2];
            colVals[0] = paramName + " (" + paramType + ")";
            colVals[1] = "";
            DefaultRowImpl row = paramsTable.new DefaultRowImpl(colVals);
            rows.add(row);
        }
    }
    return rows;
}
Also used : DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) ArrayList(java.util.ArrayList)

Example 5 with DefaultRowImpl

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

the class TaskTemplateEditor method addPage.

private void addPage(String section) {
    ScrolledComposite scrolledComposite = new ScrolledComposite(getContainer(), SWT.V_SCROLL);
    scrolledComposite.setLayout(new GridLayout());
    scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    scrolledComposite.setAlwaysShowScrollBars(true);
    Composite composite = new Composite(scrolledComposite, SWT.NONE);
    composite.setLayout(new FillLayout());
    // create the grid layout
    GridLayout gl = new GridLayout();
    gl.numColumns = PropertyEditor.COLUMNS;
    gl.marginTop = 6;
    gl.marginLeft = 3;
    composite.setLayout(gl);
    for (PropertyEditor propertyEditor : propertyEditors) {
        boolean belongs;
        if (section == null)
            belongs = propertyEditor.getSection() == null;
        else
            belongs = section.equals(propertyEditor.getSection());
        if (belongs) {
            if ("Notices".equals(propertyEditor.getName())) {
                // special handling for notices
                String attrVal = taskTemplate.getAttribute(TaskAttributeConstant.NOTICES);
                if (StringHelper.isEmpty(attrVal) || attrVal.equals("$DefaultNotices"))
                    taskTemplate.setAttribute(TaskAttributeConstant.NOTICES, TaskVO.getDefaultNotices());
                if (noticesValueChangeListener != null)
                    taskTemplate.removeAttributeValueChangeListener(noticesValueChangeListener);
                noticesValueChangeListener = new NoticesValueChangeListener(propertyEditor);
                taskTemplate.addAttributeValueChangeListener(noticesValueChangeListener);
                propertyEditor.render(composite);
            } else if ("Variables".equals(propertyEditor.getName())) {
                // special handling for variables
                TableEditor tableEditor = (TableEditor) propertyEditor;
                // support for value expressions
                tableEditor.setCellModifier(tableEditor.new DefaultCellModifier() {

                    @Override
                    public boolean canModify(Object element, String property) {
                        boolean editable = super.canModify(element, property);
                        if (editable && getColumnIndex(property) == 1) {
                            for (VariableVO var : getProcessVariables()) {
                                if (var.getName().equals(getValue(element, property)))
                                    // can't edit process var rows
                                    return false;
                            }
                        }
                        return editable;
                    }
                });
                tableEditor.setHorizontalSpan(4);
                propertyEditor.render(composite);
                tableEditor.getAddButton().setText("Expression");
                GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
                gridData.widthHint = 80;
                tableEditor.getAddButton().setLayoutData(gridData);
                final Button deleteBtn = tableEditor.getDeleteButton();
                tableEditor.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {

                    public void selectionChanged(SelectionChangedEvent event) {
                        IStructuredSelection sel = (IStructuredSelection) event.getSelection();
                        if (sel.getFirstElement() instanceof DefaultRowImpl) {
                            DefaultRowImpl row = (DefaultRowImpl) sel.getFirstElement();
                            for (VariableVO var : getProcessVariables()) {
                                if (var.getName().equals(row.getColumnValue(1))) {
                                    deleteBtn.setEnabled(false);
                                    return;
                                }
                            }
                            deleteBtn.setEnabled(true);
                        } else {
                            deleteBtn.setEnabled(false);
                        }
                    }
                });
            } else {
                propertyEditor.render(composite);
            }
            propertyEditor.setValue(taskTemplate);
            if (!propertyEditor.getType().equals(PropertyEditor.TYPE_LINK)) {
                propertyEditor.setEditable(!(propertyEditor.isReadOnly() || taskTemplate.isReadOnly()));
            }
        }
    }
    scrolledComposite.setContent(composite);
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    String pageName = section == null ? "General" : section;
    setPageText(addPage(scrolledComposite), pageName);
    pages.put(pageName, scrolledComposite);
}
Also used : DefaultRowImpl(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl) Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FillLayout(org.eclipse.swt.layout.FillLayout) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TableEditor(com.centurylink.mdw.plugin.designer.properties.editor.TableEditor) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) PropertyEditor(com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor) VariableVO(com.centurylink.mdw.model.value.variable.VariableVO) JSONObject(org.json.JSONObject)

Aggregations

DefaultRowImpl (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.DefaultRowImpl)9 ArrayList (java.util.ArrayList)8 TableEditor (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor)4 ColumnSpec (com.centurylink.mdw.plugin.designer.properties.editor.ColumnSpec)3 TableModelUpdater (com.centurylink.mdw.plugin.designer.properties.editor.TableEditor.TableModelUpdater)3 List (java.util.List)3 GridData (org.eclipse.swt.layout.GridData)3 Action (com.centurylink.mdw.model.value.user.UserActionVO.Action)2 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Button (org.eclipse.swt.widgets.Button)2 Composite (org.eclipse.swt.widgets.Composite)2 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)1 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 IProject (org.eclipse.core.resources.IProject)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1