Search in sources :

Example 91 with WorkflowProject

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

the class ProcessExplorerActionGroup method runApplies.

// top-level run action
public boolean runApplies(IStructuredSelection selection) {
    if (selection.size() > 1) {
        Boolean legacy = null;
        WorkflowPackage testPkg = null;
        for (Object o : selection.toArray()) {
            if (!(o instanceof AutomatedTestCase))
                return false;
            // make sure they're all in the same package or legacy suite
            AutomatedTestCase testCase = (AutomatedTestCase) o;
            if (legacy == null)
                legacy = testCase.isLegacy();
            if (legacy.booleanValue() != testCase.isLegacy())
                return false;
            if (!testCase.isLegacy()) {
                if (testPkg == null)
                    testPkg = testCase.getPackage();
                if (!testPkg.equals(testCase.getPackage()))
                    return false;
            }
        }
        WorkflowProject workflowProject = ((AutomatedTestCase) selection.getFirstElement()).getProject();
        if (!workflowProject.isRemote())
            return true;
        return workflowProject.isUserAuthorizedInAnyGroup(UserRoleVO.PROCESS_EXECUTION);
    }
    if (selection.size() != 1 || !(selection.getFirstElement() instanceof WorkflowElement))
        return false;
    WorkflowElement workflowElement = (WorkflowElement) selection.getFirstElement();
    if (workflowElement instanceof Report)
        return true;
    if (workflowElement instanceof Page)
        return true;
    if (workflowElement instanceof Template && ((Template) workflowElement).getLanguage().equals(RuleSetVO.VELOCITY))
        return true;
    if (workflowElement instanceof WorkflowProcess || workflowElement instanceof ExternalEvent) {
        if (!workflowElement.getProject().isRemote())
            return true;
        return workflowElement.isUserAuthorized(UserRoleVO.PROCESS_EXECUTION);
    }
    if (workflowElement instanceof AutomatedTestSuite || workflowElement instanceof AutomatedTestCase) {
        if (workflowElement.getProject() == null)
            return false;
        if (workflowElement.getProject().isRemote()) {
            if (!workflowElement.getProject().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());
        }
    }
    return false;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) Report(com.centurylink.mdw.plugin.designer.model.Report) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) Page(com.centurylink.mdw.plugin.designer.model.Page) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) Template(com.centurylink.mdw.plugin.designer.model.Template) TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) ExternalEvent(com.centurylink.mdw.plugin.designer.model.ExternalEvent) 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)

Example 92 with WorkflowProject

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

the class ProcessExplorerActionGroup method createMdwHubAction.

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

        @Override
        public void run() {
            if (webLaunchApplies(getSelection())) {
                if (getSelection().getFirstElement() instanceof WorkflowProject) {
                    WorkflowProject project = (WorkflowProject) getSelection().getFirstElement();
                    WebLaunchActions.getLaunchAction(project, WebApp.MdwHub).launch(project);
                } else if (getSelection().getFirstElement() instanceof WorkflowPackage) {
                    WorkflowPackage packageVersion = (WorkflowPackage) getSelection().getFirstElement();
                    WebLaunchActions.getLaunchAction(packageVersion.getProject(), WebApp.MdwHub).launch(packageVersion);
                }
            }
        }
    };
    WebLaunchAction launchAction = WebLaunchActions.getLaunchAction(null, WebApp.MdwHub);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "launch.hub");
    action.setText(launchAction.getLabel());
    action.setImageDescriptor(launchAction.getImageDescriptor());
    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) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) IAction(org.eclipse.jface.action.IAction) WebLaunchAction(com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Example 93 with WorkflowProject

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

the class ProcessExplorerActionGroup method createUnlockAction.

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

        @Override
        public void run() {
            if (unlockApplies(getSelection())) {
                WorkflowProject project = (WorkflowProject) getSelection().getFirstElement();
                WorkflowProjectManager.getInstance().makeLocal(project);
                project.fireElementChangeEvent(ChangeType.SETTINGS_CHANGE, project.getMdwVcsRepository());
                MessageDialog.openInformation(getViewSite().getShell(), "Remote Project Unlocked", project.getName() + " has been unlocked.  Please close any open assets and refresh.");
            }
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "unlock");
    action.setText("Unlock");
    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) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject)

Example 94 with WorkflowProject

use of com.centurylink.mdw.plugin.project.model.WorkflowProject 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 95 with WorkflowProject

use of com.centurylink.mdw.plugin.project.model.WorkflowProject 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)

Aggregations

WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)128 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)31 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WebLaunchAction (com.centurylink.mdw.plugin.actions.WebLaunchActions.WebLaunchAction)22 ArrayList (java.util.ArrayList)22 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 CoreException (org.eclipse.core.runtime.CoreException)19 Action (org.eclipse.jface.action.Action)19 IAction (org.eclipse.jface.action.IAction)18 IProject (org.eclipse.core.resources.IProject)17 IFile (org.eclipse.core.resources.IFile)16 PartInitException (org.eclipse.ui.PartInitException)16 IWorkbenchAction (org.eclipse.ui.actions.ActionFactory.IWorkbenchAction)16 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)15 ImageDescriptor (org.eclipse.jface.resource.ImageDescriptor)12 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)11 IOException (java.io.IOException)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)9