Search in sources :

Example 1 with CTreeCombo

use of com.centurylink.swt.widgets.CTreeCombo 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 CTreeCombo

use of com.centurylink.swt.widgets.CTreeCombo 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 3 with CTreeCombo

use of com.centurylink.swt.widgets.CTreeCombo 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)

Example 4 with CTreeCombo

use of com.centurylink.swt.widgets.CTreeCombo 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)

Aggregations

CTreeCombo (com.centurylink.swt.widgets.CTreeCombo)4 CTreeComboItem (com.centurylink.swt.widgets.CTreeComboItem)4 GridData (org.eclipse.swt.layout.GridData)4 Event (org.eclipse.swt.widgets.Event)4 Listener (org.eclipse.swt.widgets.Listener)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)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 Link (org.eclipse.swt.widgets.Link)2 Text (org.eclipse.swt.widgets.Text)2 AssetVersionSpec (com.centurylink.mdw.model.value.attribute.AssetVersionSpec)1 List (java.util.List)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1