Search in sources :

Example 11 with WorkflowElementActionHandler

use of com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceListView method createContextMenu.

private Menu createContextMenu(Shell shell) {
    Menu menu = new Menu(shell, SWT.POP_UP);
    final StructuredSelection selection = (StructuredSelection) getTableViewer().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
        final ProcessInstanceVO processInstanceInfo = (ProcessInstanceVO) selection.getFirstElement();
        // open instance
        MenuItem openItem = new MenuItem(menu, SWT.PUSH);
        openItem.setText("Open");
        ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
        openItem.setImage(openImageDesc.createImage());
        openItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleOpen(processInstanceInfo);
            }
        });
        // owning document
        if (OwnerType.DOCUMENT.equals(processInstanceInfo.getOwner()) || OwnerType.TESTER.equals(processInstanceInfo.getOwner())) {
            MenuItem docItem = new MenuItem(menu, SWT.PUSH);
            docItem.setText("View Owning Document");
            ImageDescriptor docImageDesc = MdwPlugin.getImageDescriptor("icons/doc.gif");
            docItem.setImage(docImageDesc.createImage());
            docItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    IStorage storage = new DocumentStorage(workflowProject, new DocumentReference(processInstanceInfo.getOwnerId(), null));
                    final IStorageEditorInput input = new StorageEditorInput(storage);
                    final IWorkbenchPage page = MdwPlugin.getActivePage();
                    if (page != null) {
                        BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {

                            public void run() {
                                try {
                                    page.openEditor(input, "org.eclipse.ui.DefaultTextEditor");
                                } catch (PartInitException ex) {
                                    PluginMessages.uiError(ex, "View Document", workflowProject);
                                }
                            }
                        });
                    }
                }
            });
        }
        // instance hierarchy
        MenuItem hierarchyItem = new MenuItem(menu, SWT.PUSH);
        hierarchyItem.setText("Instance Hierarchy");
        ImageDescriptor hierarchyImageDesc = MdwPlugin.getImageDescriptor("icons/hierarchy.gif");
        hierarchyItem.setImage(hierarchyImageDesc.createImage());
        hierarchyItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                WorkflowProcess pv = new WorkflowProcess(processVersion);
                pv.setProcessVO(processVersion.getProcessVO());
                pv.setProcessInstance(processInstanceInfo);
                new WorkflowElementActionHandler().showHierarchy(pv);
            }
        });
    }
    // delete
    if (!selection.isEmpty() && !processVersion.getProject().isProduction() && processVersion.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION)) {
        MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
        deleteItem.setText("Delete...");
        ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
        deleteItem.setImage(deleteImageDesc.createImage());
        deleteItem.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (selection.size() == 1 && selection.getFirstElement() instanceof ProcessInstanceVO) {
                    ProcessInstanceVO pii = (ProcessInstanceVO) selection.getFirstElement();
                    if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete process instance ID: " + pii.getId() + " for workflow project '" + processVersion.getProject().getName() + "'?")) {
                        List<ProcessInstanceVO> instances = new ArrayList<>();
                        instances.add((ProcessInstanceVO) selection.getFirstElement());
                        handleDelete(instances);
                    }
                } else {
                    if (MessageDialog.openConfirm(getSite().getShell(), "Confirm Delete", "Delete selected process instances for workflow project '" + processVersion.getProject().getName() + "'?")) {
                        List<ProcessInstanceVO> instances = new ArrayList<>();
                        for (Object instance : selection.toArray()) {
                            if (instance instanceof ProcessInstanceVO)
                                instances.add((ProcessInstanceVO) instance);
                        }
                        handleDelete(instances);
                    }
                }
            }
        });
    }
    return menu;
}
Also used : DocumentStorage(com.centurylink.mdw.plugin.designer.storage.DocumentStorage) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) MenuItem(org.eclipse.swt.widgets.MenuItem) IStorage(org.eclipse.core.resources.IStorage) WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) StorageEditorInput(com.centurylink.mdw.plugin.designer.storage.StorageEditorInput) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) List(java.util.List) ArrayList(java.util.ArrayList) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) DocumentReference(com.centurylink.mdw.model.value.variable.DocumentReference)

Example 12 with WorkflowElementActionHandler

use of com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler in project mdw-designer by CenturyLinkCloud.

the class ToolboxView method handleDelete.

public void handleDelete() {
    ActivityImpl activityImpl = getSelection();
    if (activityImpl == null) {
        MessageDialog.openWarning(getSite().getShell(), "No Selection", "Please select an Activity Implementor To Delete");
        return;
    }
    if (isDirty()) {
        MessageDialog.openWarning(getSite().getShell(), MSG_SAVE, "Please save or abandon outstanding changes before deleting");
        return;
    } else {
        new WorkflowElementActionHandler().delete(new WorkflowElement[] { activityImpl });
        toolboxWrapper.update();
        dirtyStateChanged(false);
        actionGroup.getDeleteAction().setEnabled(false);
    }
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl)

Example 13 with WorkflowElementActionHandler

use of com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler in project mdw-designer by CenturyLinkCloud.

the class ProcessVersionsSection method createContextMenu.

private Menu createContextMenu(Shell shell) {
    Menu menu = new Menu(shell, SWT.POP_UP);
    final StructuredSelection selection = (StructuredSelection) tableEditor.getTableViewer().getSelection();
    if (selection.size() == 1 && selection.getFirstElement() instanceof WorkflowProcess) {
        final WorkflowProcess processVer = (WorkflowProcess) selection.getFirstElement();
        MenuItem openItem = new MenuItem(menu, SWT.PUSH);
        openItem.setText("Open");
        ImageDescriptor openImageDesc = MdwPlugin.getImageDescriptor("icons/process.gif");
        openItem.setImage(openImageDesc.createImage());
        openItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                openProcess(processVer);
            }
        });
    }
    // delete
    if (!selection.isEmpty() && !process.getProject().isProduction() && process.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION) && (selection.size() == 1 && ((WorkflowProcess) selection.getFirstElement()).isLatest()) || MdwPlugin.getSettings().isAllowDeleteArchivedProcesses()) {
        MenuItem deleteItem = new MenuItem(menu, SWT.PUSH);
        deleteItem.setText("Delete...");
        ImageDescriptor deleteImageDesc = MdwPlugin.getImageDescriptor("icons/delete.gif");
        deleteItem.setImage(deleteImageDesc.createImage());
        deleteItem.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                if (selection.size() >= 1 && selection.getFirstElement() instanceof WorkflowProcess) {
                    WorkflowProcess[] processVers = new WorkflowProcess[selection.size()];
                    int idx = 0;
                    for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
                        processVers[idx] = (WorkflowProcess) iter.next();
                        idx++;
                    }
                    WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
                    actionHandler.delete(processVers);
                    boolean removedSelected = false;
                    for (WorkflowProcess pv : processVers) {
                        if (pv.equals(process))
                            removedSelected = true;
                        else
                            process.remove(pv);
                    }
                    if (removedSelected) {
                        WorkflowProcess sel = null;
                        for (WorkflowProcess toSel : process.getAllProcessVersions()) {
                            if (!toSel.equals(process)) {
                                sel = toSel;
                                break;
                            }
                        }
                        setSelection(sel);
                    } else {
                        // just force refresh
                        setSelection(process);
                    }
                }
            }
        });
    }
    return menu;
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) MenuItem(org.eclipse.swt.widgets.MenuItem) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Menu(org.eclipse.swt.widgets.Menu) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Example 14 with WorkflowElementActionHandler

use of com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler in project mdw-designer by CenturyLinkCloud.

the class ProcessLaunchMainTab method openProcess.

private void openProcess(WorkflowProcess processVersion) {
    WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
    actionHandler.open(processVersion);
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler)

Example 15 with WorkflowElementActionHandler

use of com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler in project mdw-designer by CenturyLinkCloud.

the class ServerConnectionsPropertyPage method createServerStartupControls.

private void createServerStartupControls(Composite parent) {
    Composite composite = createComposite(parent, 3);
    GridData gd = null;
    if (!workingCopy.isOsgi()) {
        startServerButton = new Button(composite, SWT.PUSH);
        gd = new GridData(GridData.BEGINNING);
        gd.horizontalSpan = 2;
        startServerButton.setLayoutData(gd);
        startServerButton.setText("Start Server");
        startServerButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                // save settings to workflowProject
                performOk();
                WorkflowElementActionHandler actionHandler = new WorkflowElementActionHandler();
                actionHandler.run(getProject());
            }
        });
        new Label(composite, SWT.NONE).setText("  (Using MDW Server Runner)");
    }
    serverStatusLabel = new Label(composite, SWT.NONE);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    serverStatusLabel.setLayoutData(gd);
    serverStatusLabel.setVisible(false);
    serverStatusLabel.setImage(serverWaitImage);
    serverMessageLabel = new Label(composite, SWT.NONE);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL);
    gd.heightHint = 20;
    gd.widthHint = 350;
    gd.horizontalSpan = 2;
    serverMessageLabel.setLayoutData(gd);
    serverMessageLabel.setVisible(false);
    serverMessageLabel.setText("Server status has not been determined yet.");
}
Also used : WorkflowElementActionHandler(com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Label(org.eclipse.swt.widgets.Label)

Aggregations

WorkflowElementActionHandler (com.centurylink.mdw.plugin.actions.WorkflowElementActionHandler)15 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)3 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)3 Menu (org.eclipse.swt.widgets.Menu)3 MenuItem (org.eclipse.swt.widgets.MenuItem)3 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)2 Iterator (java.util.Iterator)2 CoreException (org.eclipse.core.runtime.CoreException)2 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 DocumentReference (com.centurylink.mdw.model.value.variable.DocumentReference)1 Activity (com.centurylink.mdw.plugin.designer.model.Activity)1 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)1 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)1 PropertyEditor (com.centurylink.mdw.plugin.designer.properties.editor.PropertyEditor)1 ValueChangeListener (com.centurylink.mdw.plugin.designer.properties.editor.ValueChangeListener)1 DocumentStorage (com.centurylink.mdw.plugin.designer.storage.DocumentStorage)1 StorageEditorInput (com.centurylink.mdw.plugin.designer.storage.StorageEditorInput)1