Search in sources :

Example 6 with CTreeComboItem

use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.

the class ParameterizedCombo method setParamValue.

public void setParamValue(String value) {
    if (paramText != null && !paramText.isDisposed()) {
        paramText.setText(value);
    }
    if (paramCombo != null && !paramCombo.isDisposed()) {
        paramAsset = assetFromAttr(value);
        if (paramAsset != null) {
            CTreeComboItem selItem = null;
            for (CTreeComboItem pkgItem : paramCombo.getItems()) {
                if (pkgItem.getText().equals(paramAsset.getPackage().getName())) {
                    for (CTreeComboItem assetItem : pkgItem.getItems()) {
                        if (assetItem.getText().equals(paramAsset.getName())) {
                            selItem = assetItem;
                            break;
                        }
                    }
                    break;
                }
            }
            paramCombo.setSelection(selItem == null ? new CTreeComboItem[0] : new CTreeComboItem[] { selItem });
        } else {
            paramCombo.setText(value == null ? "" : value);
        }
        paramLink.setText(getParamLinkLabel());
        paramLink.setVisible(paramAsset != null || !workflowElement.isReadOnly());
    }
}
Also used : CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem)

Example 7 with CTreeComboItem

use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.

the class WorkflowAssetEditor method setValue.

@Override
public void setValue(String value) {
    String attrVal = value;
    String versionAttr = readVersionAttribute();
    if (!this.isProcess())
        // currently version not supported for assets
        versionAttr = null;
    if (versionAttr != null && attrVal != null && !attrVal.isEmpty()) {
        if (// special
        !versionAttr.equals(AssetVersionSpec.VERSION_LATEST)) // case
        {
            try {
                // old style
                versionAttr = RuleSetVO.formatVersion(Integer.parseInt(versionAttr));
            } catch (NumberFormatException ex) {
            // new style -- no formatting needed
            }
        }
        attrVal += " v" + versionAttr;
    }
    // ** display asset
    AssetLocator assetLocator = new AssetLocator(getElement(), getLocatorType());
    workflowAsset = assetLocator.assetFromAttr(attrVal);
    // AssetDrivenActivityCustomSection.determineCustomAttr()
    if (treeCombo != null) {
        if (workflowAsset != null) {
            CTreeComboItem selItem = null;
            for (CTreeComboItem pkgItem : treeCombo.getItems()) {
                if (((pkgItem.getText().isEmpty() || pkgItem.getText().equals(PackageVO.DEFAULT_PACKAGE_NAME)) && workflowAsset.getPackage() == null) || pkgItem.getText().equals(workflowAsset.getPackage().getName())) {
                    for (CTreeComboItem assetItem : pkgItem.getItems()) {
                        if (assetItem.getText().equals(workflowAsset.getName()) || assetItem.getText().equals(workflowAsset.getLabel())) {
                            selItem = assetItem;
                            break;
                        }
                    }
                    break;
                }
            }
            // suppress attribute update
            suppressFire = true;
            treeCombo.setSelection(selItem == null ? new CTreeComboItem[0] : new CTreeComboItem[] { selItem });
            suppressFire = false;
        } else {
            treeCombo.setText(attrVal == null ? "" : attrVal);
        }
    }
    if (link != null) {
        link.setText(getLinkLabel());
        link.setVisible(workflowAsset != null || link.getText().equals("<A>New...</A>"));
    }
}
Also used : CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem)

Example 8 with CTreeComboItem

use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.

the class TableEditor method createTableViewer.

private TableViewer createTableViewer(Table table) {
    TableViewer lTableViewer = new TableViewer(table);
    lTableViewer.setUseHashlookup(true);
    lTableViewer.setColumnProperties(columnProps);
    if (!isReadOnly()) {
        CellEditor[] cellEditors = new CellEditor[columnSpecs.size()];
        for (int i = 0; i < columnSpecs.size(); i++) {
            ColumnSpec colSpec = columnSpecs.get(i);
            CellEditor cellEditor = null;
            if (!colSpec.hidden) {
                if (colSpec.type.equals(TYPE_TEXT)) {
                    if (colSpec.style != 0)
                        cellEditor = new TextCellEditor(table, colSpec.style);
                    else
                        cellEditor = new TextCellEditor(table);
                } else if (colSpec.type.equals(TYPE_CHECKBOX)) {
                    cellEditor = new CheckboxCellEditor(table);
                } else if (colSpec.type.equals(TYPE_COMBO)) {
                    int style = SWT.None;
                    if (colSpec.readOnly)
                        style = style | SWT.READ_ONLY;
                    cellEditor = new ComboBoxCellEditor(table, colSpec.options, style);
                    if (!colSpec.readOnly)
                        cellEditor.addListener(new EditableComboCellEditorListener((ComboBoxCellEditor) cellEditor, i));
                } else if (colSpec.type.equals(WorkflowAssetEditor.TYPE_ASSET)) {
                    int style = SWT.None;
                    if (colSpec.readOnly)
                        style = style | SWT.READ_ONLY;
                    cellEditor = new TreeComboCellEditor(table, style) {

                        @Override
                        protected void doSetValue(Object value) {
                            Object val = getValue();
                            if (val instanceof CTreeComboItem) {
                                CTreeComboItem selItem = (CTreeComboItem) getValue();
                                if (selItem != null) {
                                    super.doSetValue(selItem.getText());
                                    return;
                                }
                            }
                            if (value instanceof String) {
                                String strVal = (String) value;
                                if (strVal.indexOf('/') > -1) {
                                    super.doSetValue(strVal.substring(strVal.indexOf('/') + 1));
                                    return;
                                }
                            }
                            super.doSetValue(value);
                        }
                    };
                    ((TreeComboCellEditor) cellEditor).setSelectionModifier(new SelectionModifier() {

                        public String modify(CTreeComboItem selection) {
                            if (selection.getParentItem() != null) {
                                WorkflowPackage pkg = getProject().getPackage(selection.getParentItem().getText());
                                if (pkg == null || pkg.isDefaultPackage())
                                    return selection.getText();
                                else
                                    return pkg.getName() + "/" + selection.getText();
                            } else {
                                // ignore packages
                                return null;
                            }
                        }
                    });
                    // populate the treecombo
                    if (colSpec.source.equals(PROCESS)) {
                        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
                        for (WorkflowPackage pkg : packages) {
                            CTreeComboItem packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkg.getName());
                            packageItem.setText(pkg.getName());
                            packageItem.setImage(pkg.getIconImage());
                            for (WorkflowProcess process : pkg.getProcesses()) {
                                CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
                                processItem.setText(process.getLabel());
                                processItem.setImage(process.getIconImage());
                            }
                        }
                    } else {
                        List<WorkflowAsset> assets = getProject().getAssetList(Arrays.asList(colSpec.assetTypes));
                        Map<String, CTreeComboItem> packageItems = new HashMap<>();
                        for (WorkflowAsset asset : assets) {
                            String pkgName = asset.getPackage().getName();
                            CTreeComboItem packageItem = packageItems.get(pkgName);
                            if (packageItem == null) {
                                packageItem = ((TreeComboCellEditor) cellEditor).addItem(pkgName);
                                packageItem.setImage(asset.getPackage().getIconImage());
                                packageItems.put(pkgName, packageItem);
                            }
                            CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
                            assetItem.setText(asset.getLabel());
                            assetItem.setImage(asset.getIconImage());
                        }
                    }
                }
                if (colSpec.listener != null && cellEditor != null)
                    cellEditor.addListener(colSpec.listener);
                cellEditors[i] = cellEditor;
            }
        }
        lTableViewer.setCellEditors(cellEditors);
        lTableViewer.setCellModifier(cellModifier);
    }
    return lTableViewer;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) CellEditor(org.eclipse.jface.viewers.CellEditor) CheckboxCellEditor(org.eclipse.jface.viewers.CheckboxCellEditor) TreeComboCellEditor(com.centurylink.jface.viewers.TreeComboCellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) ComboBoxCellEditor(org.eclipse.jface.viewers.ComboBoxCellEditor) SelectionModifier(com.centurylink.jface.viewers.TreeComboCellEditor.SelectionModifier) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) TreeComboCellEditor(com.centurylink.jface.viewers.TreeComboCellEditor) List(java.util.List) ArrayList(java.util.ArrayList) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) TableViewer(org.eclipse.jface.viewers.TableViewer) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) HashMap(java.util.HashMap)

Example 9 with CTreeComboItem

use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.

the class ViewLayoutEditAttributeDialog method createDialogArea.

protected Control createDialogArea(Composite parent) {
    Composite dialogArea = baseCreateDialogArea(parent);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_ATTRIBUTE_DIALOG);
    Composite composite = new Composite(dialogArea, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    Label attributeNameLabel = new Label(composite, SWT.NONE);
    attributeNameLabel.setText(XMLUIMessages._UI_LABEL_NAME_COLON);
    attributeNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 300;
    attributeNameField.setLayoutData(gd);
    attributeNameField.setText(getDisplayValue(attribute != null ? attribute.getName() : ""));
    attributeNameField.addModifyListener(this);
    Label attributeValueLabel = new Label(composite, SWT.NONE);
    attributeValueLabel.setText(XMLUIMessages._UI_LABEL_VALUE_COLON);
    String value = attribute != null ? attribute.getValue() : "";
    int style = SWT.SINGLE | SWT.BORDER;
    if (value.indexOf("\n") != -1) {
        style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
    }
    String[] attrOptions = viewLayout.getAttributeOptions(attribute);
    if (attrOptions != null) {
        attributeValueCombo = new CTreeCombo(composite, style);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.widthHint = 300;
        gd.heightHint = 16;
        attributeValueCombo.setLayoutData(gd);
        for (String option : attrOptions) {
            CTreeComboItem item = new CTreeComboItem(attributeValueCombo);
            item.setText(option);
            if (option.equals(ViewLayout.VARIABLES_ATTRIBUTE_OPTION)) {
                Map<String, List<String>> vars = viewLayout.getVariables(attribute, option);
                for (String task : vars.keySet()) {
                    CTreeComboItem taskItem = new CTreeComboItem(item);
                    taskItem.setText(task);
                    for (String var : vars.get(task)) {
                        CTreeComboItem varItem = new CTreeComboItem(taskItem);
                        varItem.setText(var);
                    }
                }
            }
        }
        attributeValueCombo.setText(getDisplayValue(attribute != null ? attribute.getValue() : ""));
        attributeValueCombo.addListener(SWT.Selection, new Listener() {

            public void handleEvent(Event event) {
                CTreeComboItem[] selItems = attributeValueCombo.getSelection();
                if (selItems.length == 1) {
                    CTreeComboItem selItem = selItems[0];
                    if (selItem.getItemCount() != 0) {
                        // ignore non-node selection
                        attributeValueCombo.setSelection(new CTreeComboItem[0]);
                    } else {
                        if (hasVariablesParent(selItem))
                            attributeValueCombo.setText("$" + selItem.getText());
                        try {
                            Thread.sleep(200);
                        } catch (InterruptedException ex) {
                        }
                        attributeValueCombo.dropDown(false);
                    }
                }
            }
        });
    } else {
        attributeValueField = new Text(composite, style);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.widthHint = 300;
        attributeValueField.setLayoutData(gd);
        attributeValueField.setText(getDisplayValue(attribute != null ? attribute.getValue() : ""));
    }
    // error message
    Composite message = new Composite(composite, SWT.NONE);
    layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    message.setLayout(layout);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    message.setLayoutData(gd);
    errorMessageIcon = new Label(message, SWT.NONE);
    gd = new GridData();
    gd.horizontalSpan = 1;
    gd.verticalAlignment = SWT.TOP;
    errorMessageIcon.setLayoutData(gd);
    errorMessageIcon.setImage(null);
    errorMessageLabel = new Label(message, SWT.WRAP);
    errorMessageLabel.setText(XMLUIMessages.error_message_goes_here);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 200;
    gd.heightHint = Math.max(30, errorMessageLabel.computeSize(0, 0, false).y * 2);
    gd.horizontalSpan = 1;
    gd.verticalAlignment = SWT.TOP;
    errorMessageLabel.setLayoutData(gd);
    return dialogArea;
}
Also used : Listener(org.eclipse.swt.widgets.Listener) Composite(org.eclipse.swt.widgets.Composite) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) CTreeCombo(com.centurylink.swt.widgets.CTreeCombo) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) Event(org.eclipse.swt.widgets.Event) List(java.util.List)

Example 10 with CTreeComboItem

use of com.centurylink.swt.widgets.CTreeComboItem in project mdw-designer by CenturyLinkCloud.

the class EventHandlerPage method fillProcessTreeCombo.

private void fillProcessTreeCombo() {
    processTreeCombo.removeAll();
    List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
    for (WorkflowPackage pkg : packages) {
        CTreeComboItem packageItem = new CTreeComboItem(processTreeCombo, SWT.NONE);
        packageItem.setText(pkg.getName());
        packageItem.setImage(pkg.getIconImage());
        for (WorkflowProcess process : pkg.getProcesses()) {
            CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
            processItem.setText(process.getName());
            processItem.setImage(process.getIconImage());
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Aggregations

CTreeComboItem (com.centurylink.swt.widgets.CTreeComboItem)10 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)6 CTreeCombo (com.centurylink.swt.widgets.CTreeCombo)4 List (java.util.List)4 GridData (org.eclipse.swt.layout.GridData)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)3 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)3 ArrayList (java.util.ArrayList)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)2 Comparator (java.util.Comparator)2 Map (java.util.Map)2 TreeMap (java.util.TreeMap)2 ModifyEvent (org.eclipse.swt.events.ModifyEvent)2 ModifyListener (org.eclipse.swt.events.ModifyListener)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Label (org.eclipse.swt.widgets.Label)2