Search in sources :

Example 1 with CTreeComboItem

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

the class EventHandlerPage method createProcessLaunchNotifyControls.

protected void createProcessLaunchNotifyControls(Composite parent, boolean serviceOption, int ncol) {
    launchNotifyGroup = new Group(parent, SWT.NONE);
    launchNotifyGroup.setText("Handler Action");
    GridLayout gl = new GridLayout();
    gl.numColumns = 2;
    launchNotifyGroup.setLayout(gl);
    GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    gd.horizontalSpan = ncol;
    if (!serviceOption)
        gd.horizontalIndent = 25;
    launchNotifyGroup.setLayoutData(gd);
    launchProcessButton = new Button(launchNotifyGroup, SWT.RADIO | SWT.LEFT);
    launchProcessButton.setText("Process Launch:");
    launchProcessButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (launchProcessButton.getSelection())
                getEventHandlerWizard().setHandlerAction(HandlerAction.launchProcess);
            else
                getEventHandlerWizard().setHandlerAction(HandlerAction.notifyProcess);
            enableHandlerActionFields(getEventHandlerWizard().getHandlerAction());
        }
    });
    launchProcessButton.setSelection(true);
    // process treecombo
    processTreeCombo = new CTreeCombo(launchNotifyGroup, SWT.BORDER | SWT.FULL_SELECTION);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 250;
    gd.heightHint = 16;
    processTreeCombo.setLayoutData(gd);
    fillProcessTreeCombo();
    processTreeCombo.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            CTreeComboItem[] selItems = processTreeCombo.getSelection();
            if (selItems.length == 1) {
                CTreeComboItem selItem = selItems[0];
                if (selItem.getParentItem() == null) {
                    // ignore package selection
                    processTreeCombo.setSelection(new CTreeComboItem[0]);
                } else {
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException ex) {
                    }
                    String processPath = selItem.getText();
                    if (getProject().checkRequiredVersion(5, 2))
                        processPath = selItem.getParentItem().getText() + "/" + processPath;
                    getEventHandler().setProcess(processPath);
                    processTreeCombo.dropDown(false);
                    handleFieldChanged();
                }
            }
        }
    });
    processTreeCombo.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            if (processTreeCombo.getSelection().length == 0) {
                // triggered when something was typed in the combo instead
                // of selecting -- use it verbatim
                // note: also triggered on selection, but immediately
                // followed by SWT.Selection event, so no harm done
                getEventHandler().setProcess(processTreeCombo.getText().trim());
                handleFieldChanged();
            }
        }
    });
    if (serviceOption) {
        // synchronous checkbox
        launchSynchronousCheckbox = new Button(launchNotifyGroup, SWT.CHECK);
        gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
        gd.horizontalSpan = 2;
        gd.horizontalIndent = 25;
        launchSynchronousCheckbox.setLayoutData(gd);
        launchSynchronousCheckbox.setText("Invoke synchronously (service process)");
        launchSynchronousCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                boolean launchSync = launchSynchronousCheckbox.getSelection();
                getEventHandler().setLaunchSynchronous(launchSync);
                handleFieldChanged();
            }
        });
    }
    notifyProcessButton = new Button(launchNotifyGroup, SWT.RADIO | SWT.LEFT);
    notifyProcessButton.setText("Event Notify:");
    notifyProcessButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (notifyProcessButton.getSelection())
                getEventHandlerWizard().setHandlerAction(HandlerAction.notifyProcess);
            else
                getEventHandlerWizard().setHandlerAction(HandlerAction.launchProcess);
            enableHandlerActionFields(getEventHandlerWizard().getHandlerAction());
        }
    });
    // event text
    eventTextField = new Text(launchNotifyGroup, SWT.SINGLE | SWT.BORDER);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 250;
    eventTextField.setLayoutData(gd);
    eventTextField.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            getEventHandler().setEvent(eventTextField.getText().trim());
            handleFieldChanged();
        }
    });
    enableHandlerActionFields(getEventHandlerWizard().getHandlerAction());
}
Also used : Group(org.eclipse.swt.widgets.Group) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) CTreeCombo(com.centurylink.swt.widgets.CTreeCombo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with CTreeComboItem

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

the class WorkflowAssetEditor method fillTreeCombo.

private void fillTreeCombo() {
    treeCombo.removeAll();
    Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {

        public int compare(WorkflowElement we1, WorkflowElement we2) {
            return we1.getLabel().compareTo(we2.getLabel());
        }
    };
    if (isProcess()) {
        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
        for (WorkflowPackage pkg : packages) {
            CTreeComboItem packageItem = new CTreeComboItem(treeCombo, 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.getLabel());
                processItem.setImage(process.getIconImage());
            }
        }
    } else if (isTaskTemplate()) {
        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
        for (WorkflowPackage pkg : packages) {
            List<TaskTemplate> templatesForPkg = pkg.getTaskTemplates();
            if (templatesForPkg != null && !templatesForPkg.isEmpty()) {
                CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
                packageItem.setText(pkg.getName());
                packageItem.setImage(pkg.getIconImage());
                for (TaskTemplate template : templatesForPkg) {
                    CTreeComboItem templateItem = new CTreeComboItem(packageItem, SWT.NONE);
                    templateItem.setText(template.getLabel());
                    templateItem.setImage(template.getIconImage());
                }
            }
        }
    } else {
        List<WorkflowAsset> assets = getProject().getAssetList(assetTypes);
        Map<WorkflowPackage, List<WorkflowAsset>> packageAssets = new TreeMap<>();
        for (WorkflowAsset asset : assets) {
            List<WorkflowAsset> assetsForPkg = packageAssets.get(asset.getPackage());
            if (assetsForPkg == null) {
                assetsForPkg = new ArrayList<>();
                packageAssets.put(asset.getPackage(), assetsForPkg);
            }
            assetsForPkg.add(asset);
        }
        for (Map.Entry<WorkflowPackage, List<WorkflowAsset>> pkgAssets : packageAssets.entrySet()) {
            CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
            packageItem.setText(pkgAssets.getKey().getName());
            packageItem.setImage(pkgAssets.getKey().getIconImage());
            List<WorkflowAsset> assetsForPkg = pkgAssets.getValue();
            Collections.sort(assetsForPkg, comparator);
            for (WorkflowAsset assetForPkg : assetsForPkg) {
                CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
                assetItem.setText(assetForPkg.getLabel());
                assetItem.setImage(assetForPkg.getIconImage());
            }
        }
    }
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) TreeMap(java.util.TreeMap) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 3 with CTreeComboItem

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

the class WorkflowAssetEditor method render.

@Override
public void render(Composite parent) {
    label = new Label(parent, SWT.NONE);
    label.setText(attributeLabel + ":");
    treeCombo = new CTreeCombo(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.widthHint = comboWidth;
    gd.heightHint = 16;
    treeCombo.setLayoutData(gd);
    fillTreeCombo();
    treeCombo.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            CTreeComboItem[] selItems = treeCombo.getSelection();
            if (selItems.length == 1) {
                CTreeComboItem selItem = selItems[0];
                if (selItem.getParentItem() == null) {
                    // ignore package selection
                    treeCombo.setSelection(new CTreeComboItem[0]);
                } else {
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException ex) {
                    }
                    // ** set asset
                    WorkflowPackage pkg = getProject().getPackage(selItem.getParentItem().getText());
                    if (pkg == null) {
                        workflowAsset = null;
                    } else {
                        AssetLocator assetLocator = new AssetLocator(getElement(), getLocatorType());
                        workflowAsset = assetLocator.getAssetVersion(selItem.getText(), pkg);
                    }
                    link.setText(getLinkLabel());
                    fireValueChanged(new AssetLocator(getElement(), getLocatorType()).attrFromAsset(workflowAsset));
                    // selecting the asset also selects the version
                    updateVersionAttribute(workflowAsset);
                    treeCombo.dropDown(false);
                }
            }
        }
    });
    treeCombo.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            if (treeCombo.getSelection().length == 0 && !suppressFire) {
                // triggered when something was typed in the combo
                // instead of selecting -- use it verbatim
                // note: also triggered on selection, but immediately
                // followed by SWT.Selection event, so no harm done
                // ** set asset
                workflowAsset = null;
                link.setText("");
                AssetVersionSpec versionSpec = AssetVersionSpec.parse(treeCombo.getText().trim());
                String oldName = getElement().getAttribute(attributeName);
                String newName = versionSpec.getName();
                boolean nameChanged = oldName == null ? newName != null && newName.length() > 0 : !oldName.equals(newName);
                if (nameChanged)
                    fireValueChanged(newName);
                String oldVer = readVersionAttribute();
                String newVer = "".equals(newName) ? "" : versionSpec.getVersion();
                boolean verChanged = oldVer == null ? newVer != null && newVer.length() > 0 : !oldVer.equals(newVer);
                if (verChanged)
                    updateVersionAttribute(newVer);
            }
        }
    });
    link = new Link(parent, SWT.SINGLE);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 75;
    link.setLayoutData(gd);
    link.setText(getLinkLabel());
    link.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (workflowAsset == null) {
                workflowAsset = createWorkflowAsset();
                fillTreeCombo();
                if (workflowAsset != null) {
                    treeCombo.setText(workflowAsset.getName());
                    fireValueChanged(new AssetLocator(getElement(), getLocatorType()).attrFromAsset(workflowAsset));
                    updateVersionAttribute(workflowAsset);
                }
            } else {
                openWorkflowAsset();
            }
        }
    });
    spacer = new Label(parent, SWT.NONE);
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Listener(org.eclipse.swt.widgets.Listener) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) CTreeCombo(com.centurylink.swt.widgets.CTreeCombo) AssetVersionSpec(com.centurylink.mdw.model.value.attribute.AssetVersionSpec) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link)

Example 4 with CTreeComboItem

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

the class ParameterizedCombo method fillParamCombo.

private void fillParamCombo(String[] types) {
    paramCombo.removeAll();
    Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {

        public int compare(WorkflowElement we1, WorkflowElement we2) {
            return we1.getName().compareTo(we2.getName());
        }
    };
    List<WorkflowAsset> assets = workflowProject.getAssetList(Arrays.asList(types));
    Map<WorkflowPackage, List<WorkflowAsset>> packageAssets = new TreeMap<>();
    for (WorkflowAsset asset : assets) {
        List<WorkflowAsset> assetsForPkg = packageAssets.get(asset.getPackage());
        if (assetsForPkg == null) {
            assetsForPkg = new ArrayList<>();
            packageAssets.put(asset.getPackage(), assetsForPkg);
        }
        assetsForPkg.add(asset);
    }
    for (WorkflowPackage pkg : packageAssets.keySet()) {
        CTreeComboItem packageItem = new CTreeComboItem(paramCombo, SWT.NONE);
        packageItem.setText(pkg.getName());
        packageItem.setImage(pkg.getIconImage());
        List<WorkflowAsset> assetsForPkg = packageAssets.get(pkg);
        Collections.sort(assetsForPkg, comparator);
        for (WorkflowAsset assetForPkg : assetsForPkg) {
            CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
            assetItem.setText(assetForPkg.getName());
            assetItem.setImage(assetForPkg.getIconImage());
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList) List(java.util.List) TreeMap(java.util.TreeMap) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) Comparator(java.util.Comparator)

Example 5 with CTreeComboItem

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

the class ParameterizedCombo method createParamCombo.

private void createParamCombo() {
    paramCombo = new CTreeCombo(this, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 200;
    gd.heightHint = 16;
    paramCombo.setLayoutData(gd);
    paramCombo.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            CTreeComboItem[] selItems = paramCombo.getSelection();
            if (selItems.length == 1) {
                CTreeComboItem selItem = selItems[0];
                if (selItem.getItemCount() != 0) {
                    // ignore package selection
                    paramCombo.setSelection(new CTreeComboItem[0]);
                } else {
                    try {
                        Thread.sleep(200);
                    } catch (InterruptedException ex) {
                    }
                    // set the definition doc
                    WorkflowPackage pkg = workflowProject.getPackage(selItem.getParentItem().getText());
                    if (pkg == null) {
                        paramAsset = null;
                    } else {
                        paramAsset = pkg.getAsset(selItem.getText());
                    }
                    paramLink.setText(getParamLinkLabel());
                    fireModify(new ModifyEvent(event));
                    paramCombo.dropDown(false);
                }
            }
        }
    });
    paramCombo.addListener(SWT.Modify, new Listener() {

        public void handleEvent(Event event) {
            if (paramCombo.getSelection().length == 0) {
                // something was typed in the combo instead of selected
                paramAsset = assetFromAttr(paramCombo.getText().trim());
                paramLink.setText(getParamLinkLabel());
                String oldVal = workflowElement.getAttribute(paramLabel.getText());
                String newVal;
                if (paramCombo.getText().startsWith("$"))
                    newVal = paramCombo.getText().trim();
                else
                    newVal = paramAsset == null ? paramCombo.getText() : attrFromAsset(paramAsset, false);
                boolean changed = oldVal == null ? newVal != null && newVal.length() > 0 : !oldVal.equals(newVal);
                if (changed && !suppressFire)
                    fireModify(new ModifyEvent(event));
            }
        }
    });
    paramLink = new Link(this, SWT.SINGLE);
    gd = new GridData(GridData.BEGINNING);
    gd.widthHint = 75;
    paramLink.setLayoutData(gd);
    paramLink.setText(getParamLinkLabel());
    paramLink.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            if (paramAsset == null) {
                String[] paramTypes = valueConverter.getOptionParam(getValue()).getTypes();
                paramAsset = createParamAsset(paramTypes);
                fillParamCombo(paramTypes);
                if (paramAsset != null) {
                    paramCombo.setText(paramAsset.getName());
                    fireModify(new ModifyEvent(new Event()));
                }
            } else {
                openParamAsset();
            }
        }
    });
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) CTreeCombo(com.centurylink.swt.widgets.CTreeCombo) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Link(org.eclipse.swt.widgets.Link)

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