Search in sources :

Example 46 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method debugApplies.

public boolean debugApplies(IStructuredSelection selection) {
    if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
        return false;
    WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
    if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
        WorkflowProject prj = workflowElement.getProject();
        if (prj == null || !prj.checkRequiredVersion(6, 0) || !prj.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION))
            return false;
        WorkflowPackage pkg = workflowElement.getPackage();
        if (pkg != null && !pkg.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION))
            return false;
        try {
            AutomatedTestView testView = (AutomatedTestView) MdwPlugin.getActivePage().showView("mdw.views.launch.automatedTest");
            return !testView.isLocked();
        } catch (PartInitException ex) {
            PluginMessages.uiError(ex, "Menu", workflowElement.getProject());
        }
    }
    if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent)
        return !MdwPlugin.isRcp() && workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
    else
        return false;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) PartInitException(org.eclipse.ui.PartInitException) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

Example 47 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createImportActionGroup.

private ActionGroup createImportActionGroup() {
    importMenu = new MenuManager("Import", MdwPlugin.getImageDescriptor("icons/import.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import");
    return new ActionGroup() {

        @Override
        public void fillContextMenu(IMenuManager menu) {
            importMenu.removeAll();
            IStructuredSelection selection = getSelection();
            WorkflowElement element = (WorkflowElement) selection.getFirstElement();
            if (!importMenuApplies(selection))
                return;
            if (importProjectApplies())
                importMenu.add(importProjectAction);
            if (importPackageApplies(selection))
                importMenu.add(importPackageAction);
            if (importVcsApplies(selection))
                importMenu.add(importVcsAction);
            if (importProcessApplies(selection)) {
                if (element instanceof WorkflowProcess) {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.process.version");
                    importProcessAction.setText("New Process Version...");
                } else {
                    importProcessAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.process");
                    importProcessAction.setText(PROCESS_DOT);
                }
                importMenu.add(importProcessAction);
            }
            if (importWorkflowAssetApplies(selection)) {
                if (element instanceof WorkflowAsset) {
                    WorkflowAsset asset = (WorkflowAsset) element;
                    // menu item text and icon are dynamic
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.new.asset.version");
                    importWorkflowAssetAction.setText("New " + asset.getTitle() + " Version...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICONS + asset.getIcon()));
                } else {
                    importWorkflowAssetAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.asset");
                    importWorkflowAssetAction.setText("Asset...");
                    importWorkflowAssetAction.setImageDescriptor(MdwPlugin.getImageDescriptor(ICON_DOC_GIF));
                }
                importMenu.add(importWorkflowAssetAction);
            }
            if (importAttributesApplies(selection)) {
                List<IAction> importAttrsActions = getImportAttributeActions(selection);
                if (!importAttrsActions.isEmpty()) {
                    MenuManager attributesMenu = new MenuManager("Attributes", MdwPlugin.getImageDescriptor("icons/attribute.gif"), MdwMenuManager.MDW_MENU_PREFIX + "menu.import.attributes");
                    attributesMenu.removeAll();
                    for (IAction action : importAttrsActions) attributesMenu.add(action);
                    importMenu.add(attributesMenu);
                }
            }
            if (importTaskTemplateApplies(selection))
                importMenu.add(importTaskTemplateAction);
            importMenu.add(new Separator(OTHER));
            IWorkbenchAction otherAction = ActionFactory.IMPORT.create(getViewSite().getWorkbenchWindow());
            otherAction.setId(MdwMenuManager.MDW_MENU_PREFIX + "import.other");
            otherAction.setText(OTHER_DOT);
            importMenu.add(otherAction);
        }
    };
}
Also used : IAction(org.eclipse.jface.action.IAction) ActionGroup(org.eclipse.ui.actions.ActionGroup) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) MdwMenuManager(com.centurylink.mdw.plugin.actions.MdwMenuManager) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) IMenuManager(org.eclipse.jface.action.IMenuManager) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) Separator(org.eclipse.jface.action.Separator)

Example 48 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method getExportAttributeActions.

private List<IAction> getExportAttributeActions(IStructuredSelection selection) {
    List<IAction> exportAttributesActions = new ArrayList<>();
    if (selection != null && selection.getFirstElement() instanceof WorkflowElement) {
        // bam
        IAction action = new Action() {

            @Override
            public void run() {
                if (!exportAttributesApplies(getSelection()))
                    return;
                view.setFocus();
                actionHandler.exportAttributes(WorkAttributeConstant.BAM_ATTR_PREFIX, (WorkflowElement) getSelection().getFirstElement());
            }
        };
        action.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.monitoring");
        action.setText("Monitoring...");
        exportAttributesActions.add(action);
        // simulation
        action = new Action() {

            @Override
            public void run() {
                if (!exportAttributesApplies(getSelection()))
                    return;
                view.setFocus();
                actionHandler.exportAttributes(WorkAttributeConstant.SIMULATION_ATTR_PREFIX, (WorkflowElement) getSelection().getFirstElement());
            }
        };
        action.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.simulation");
        action.setText("Simulation...");
        exportAttributesActions.add(action);
        // pagelet-driven attributes
        WorkflowProject project = ((WorkflowElement) selection.getFirstElement()).getProject();
        List<PageletTab> pageletTabs = project.getPageletTabs();
        if (pageletTabs != null) {
            for (PageletTab pageletTab : pageletTabs) {
                final String prefix = pageletTab.getOverrideAttributePrefix();
                action = new Action() {

                    @Override
                    public void run() {
                        if (!exportAttributesApplies(getSelection()))
                            return;
                        view.setFocus();
                        actionHandler.exportAttributes(prefix, (WorkflowElement) getSelection().getFirstElement());
                    }
                };
                action.setId(MdwMenuManager.MDW_MENU_PREFIX + "export.attributes." + prefix);
                action.setText(pageletTab.getLabel() + "...");
                exportAttributesActions.add(action);
            }
        }
    }
    return exportAttributesActions;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) PageletTab(com.centurylink.mdw.plugin.designer.properties.PageletTab) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 49 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createDeleteAction.

private IAction createDeleteAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            if (!deleteApplies(getSelection()))
                return;
            view.setFocus();
            Object[] items = getSelection().toArray();
            WorkflowElement[] elements = new WorkflowElement[items.length];
            boolean includesArchived = false;
            for (int i = 0; i < items.length; i++) {
                elements[i] = (WorkflowElement) items[i];
                if (elements[i].isArchived())
                    includesArchived = true;
            }
            actionHandler.delete(elements);
            view.select(null);
            getContext().setSelection(new StructuredSelection());
            if (// TODO archived elements are not being
            includesArchived)
                // listened to
                view.refreshItem(elements[0].getProject());
        }
    };
    ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
    action.setImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
    action.setActionDefinitionId("org.eclipse.ui.edit.delete");
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "delete");
    action.setText("Delete");
    getActionBars().setGlobalActionHandler(ActionFactory.DELETE.getId(), action);
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) ISharedImages(org.eclipse.ui.ISharedImages) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 50 with WorkflowElement

use of com.centurylink.mdw.plugin.designer.model.WorkflowElement in project mdw-designer by CenturyLinkCloud.

the class ProcessExplorerActionGroup method createSetVersionAction.

private IAction createSetVersionAction() {
    IAction action = new Action() {

        @Override
        public void run() {
            if (setVersionApplies(getSelection()))
                actionHandler.setVersion((WorkflowElement) getSelection().getFirstElement());
            view.setFocus();
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "set.version");
    action.setText("Set Version");
    return action;
}
Also used : WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) IAction(org.eclipse.jface.action.IAction) IWorkbenchAction(org.eclipse.ui.actions.ActionFactory.IWorkbenchAction) Action(org.eclipse.jface.action.Action) IAction(org.eclipse.jface.action.IAction) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Aggregations

WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)65 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)25 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)25 IAction (org.eclipse.jface.action.IAction)22 Action (org.eclipse.jface.action.Action)21 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)21 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)19 ArrayList (java.util.ArrayList)17 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)14 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)11 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 IFile (org.eclipse.core.resources.IFile)8 AutomatedTestSuite (com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 LegacyExpectedResults (com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults)7 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)7 PartInitException (org.eclipse.ui.PartInitException)7 AutomatedTestResults (com.centurylink.mdw.plugin.designer.model.AutomatedTestResults)5 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)5