Search in sources :

Example 1 with MdwInputDialog

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

the class PackageConfigurationSection method createButtons.

private void createButtons(Composite parent) {
    buttonComposite = new Composite(parent, SWT.NONE);
    GridLayout gl = new GridLayout();
    gl.numColumns = 1;
    buttonComposite.setLayout(gl);
    GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    buttonComposite.setLayoutData(gd);
    Group propBtnGroup = new Group(buttonComposite, SWT.NONE);
    propBtnGroup.setText("Properties");
    gl = new GridLayout();
    propBtnGroup.setLayout(gl);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    gd.verticalIndent = 15;
    propBtnGroup.setLayoutData(gd);
    // add prop
    Button addButton = new Button(propBtnGroup, SWT.PUSH | SWT.CENTER);
    addButton.setText("Add");
    GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    gridData.widthHint = 60;
    gridData.horizontalIndent = 3;
    addButton.setLayoutData(gridData);
    addButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            propertyRows.add(new PropertyRow("new.property"));
            if (// first property added
            propertyRows.size() == 1)
                propertyRows.get(0).envValues.put("", "");
            tableViewer.setInput(propertyRows);
            updateModel();
            if (// first property added
            propertyRows.size() == 1)
                setSelection(workflowPackage);
        }
    });
    // delete prop
    Button deleteButton = new Button(propBtnGroup, SWT.PUSH | SWT.CENTER);
    deleteButton.setText("Delete");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    gridData.widthHint = 60;
    gridData.horizontalIndent = 3;
    deleteButton.setLayoutData(gridData);
    deleteButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            PropertyRow row = (PropertyRow) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
            if (row != null)
                propertyRows.remove(row);
            tableViewer.setInput(propertyRows);
            updateModel();
        }
    });
    if (!workflowPackage.getProject().checkRequiredVersion(6)) {
        Group envBtnGroup = new Group(buttonComposite, SWT.NONE);
        envBtnGroup.setText("Environments");
        gl = new GridLayout();
        envBtnGroup.setLayout(gl);
        gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
        gd.verticalIndent = 10;
        envBtnGroup.setLayoutData(gd);
        // add env
        Button newEnvButton = new Button(envBtnGroup, SWT.PUSH | SWT.CENTER);
        newEnvButton.setText("Add...");
        gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
        gridData.widthHint = 60;
        gridData.horizontalIndent = 3;
        newEnvButton.setLayoutData(gridData);
        newEnvButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                MdwInputDialog inputDlg = new MdwInputDialog(getShell(), "Environment Name", false);
                inputDlg.setTitle("New Environment");
                if (inputDlg.open() == Dialog.OK) {
                    if (propertyRows.isEmpty())
                        propertyRows.add(new PropertyRow("new.property"));
                    propertyRows.get(0).envValues.put(inputDlg.getInput(), "");
                    tableViewer.setInput(propertyRows);
                    updateModel();
                    setSelection(workflowPackage);
                }
            }
        });
        // delete env
        Button deleteEnvButton = new Button(envBtnGroup, SWT.PUSH | SWT.CENTER);
        deleteEnvButton.setText("Delete...");
        gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
        gridData.widthHint = 60;
        gridData.horizontalIndent = 3;
        deleteEnvButton.setLayoutData(gridData);
        deleteEnvButton.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                List<String> envs = new ArrayList<>();
                for (PropertyRow propRow : propertyRows) {
                    for (String env : propRow.envValues.keySet()) {
                        if (!envs.contains(env))
                            envs.add(env);
                    }
                }
                MdwChoiceDialog choiceDlg = new MdwChoiceDialog(getShell(), "Environment to Remove", envs.toArray(new String[0]));
                choiceDlg.setTitle("Remove Environment");
                int res = choiceDlg.open();
                if (res != MdwChoiceDialog.CANCEL && !envs.isEmpty()) {
                    String choice = envs.get(res);
                    for (PropertyRow propRow : propertyRows) {
                        propRow.envValues.remove(choice);
                    }
                    updateModel();
                    setSelection(workflowPackage);
                }
            }
        });
    }
    // save
    saveButton = new Button(buttonComposite, SWT.PUSH | SWT.CENTER);
    saveButton.setText("Save");
    gridData = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
    gridData.widthHint = 60;
    gridData.verticalIndent = 15;
    saveButton.setLayoutData(gridData);
    saveButton.setEnabled(dirty);
    saveButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            saveMetaContent();
        }
    });
}
Also used : PropertyGroup(com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) MdwChoiceDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwChoiceDialog) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) MdwInputDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwInputDialog)

Example 2 with MdwInputDialog

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

the class Page method run.

public void run() {
    boolean is55 = getProject().checkRequiredVersion(5, 5);
    String urlPath;
    if (isTaskInstancePage()) {
        MdwInputDialog dlg = new MdwInputDialog(MdwPlugin.getShell(), "Task Instance ID", false);
        if (dlg.open() != Dialog.OK)
            return;
        try {
            Long taskInstanceId = new Long(dlg.getInput());
            urlPath = getProject().getTaskInstancePath(taskInstanceId);
        } catch (NumberFormatException ex) {
            MessageDialog.openError(MdwPlugin.getShell(), "Invalid Input", "Invalid task instance ID: " + dlg.getInput());
            return;
        }
    } else {
        // TODO: why does new path format not work?
        // if (is55)
        // urlPath = TaskAttributeConstant.PAGE_PATH + getName();
        // else
        urlPath = TaskAttributeConstant.PAGE_COMPATIBILITY_PATH + getName();
    }
    WebApp webapp = is55 ? WebApp.MdwHub : WebApp.TaskManager;
    WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(getProject(), webapp);
    launchAction.launch(getPackage(), urlPath);
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) MdwInputDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwInputDialog) WebApp(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebApp)

Example 3 with MdwInputDialog

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

the class ActivityImplSection method launchImplClassNameDialog.

private void launchImplClassNameDialog() {
    MdwInputDialog classNameDialog = new MdwInputDialog(getShell(), "Fully-Qualified Implementor Class Name", false);
    classNameDialog.setTitle("Activity Implementor");
    classNameDialog.setWidth(300);
    classNameDialog.setInput(activityImpl.getImplClassName());
    if (classNameDialog.open() == Dialog.OK) {
        final String newClassName = classNameDialog.getInput().trim();
        if (newClassName.length() > 0) {
            BusyIndicator.showWhile(getShell().getDisplay(), new Runnable() {

                public void run() {
                    activityImpl.setImplClassName(newClassName);
                    activityImpl.getProject().getDesignerProxy().saveActivityImpl(activityImpl);
                    activityImpl.getProject().setActivityImplClass(activityImpl.getImplClassName(), activityImpl);
                    setSelection(activityImpl);
                }
            });
        }
    }
}
Also used : MdwInputDialog(com.centurylink.mdw.plugin.designer.dialogs.MdwInputDialog)

Aggregations

MdwInputDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwInputDialog)3 PropertyGroup (com.centurylink.mdw.bpm.PropertyGroupDocument.PropertyGroup)1 WebApp (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebApp)1 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)1 MdwChoiceDialog (com.centurylink.mdw.plugin.designer.dialogs.MdwChoiceDialog)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Group (org.eclipse.swt.widgets.Group)1