Search in sources :

Example 61 with WorkflowPackage

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

the class CodeGenWizard method init.

public void init(IWorkbench workbench, IStructuredSelection selection, Code codeElement) {
    this.workbench = workbench;
    this.selection = selection;
    this.codeElement = codeElement;
    setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
    setNeedsProgressMonitor(true);
    if (selection != null) {
        if (selection.getFirstElement() instanceof WorkflowPackage) {
            WorkflowPackage workflowPackage = (WorkflowPackage) selection.getFirstElement();
            getCodeElement().setProject(workflowPackage.getProject());
            getCodeElement().setPackage(workflowPackage);
        } else if (selection.getFirstElement() instanceof WorkflowElement) {
            WorkflowElement workflowElement = ((WorkflowElement) selection.getFirstElement());
            getCodeElement().setProject(workflowElement.getProject());
            getCodeElement().setPackage(workflowElement.getPackage());
        } else if (selection.getFirstElement() instanceof IResource) {
            IResource resource = (IResource) selection.getFirstElement();
            if (resource.getProject() != null) {
                WorkflowProject workflowProject = WorkflowProjectManager.getInstance().getWorkflowProject(resource.getProject());
                if (workflowProject != null)
                    getCodeElement().setProject(workflowProject);
            }
        }
    }
    if (getCodeElement().getProject() == null) {
        // choose any available workflow project
        List<WorkflowProject> workflowProjects = WorkflowProjectManager.getInstance().getWorkflowProjects();
        if (workflowProjects == null || workflowProjects.size() == 0)
            MessageDialog.openError(getShell(), "Error", "No MDW projects found");
        else
            getCodeElement().setProject(workflowProjects.get(0));
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) IResource(org.eclipse.core.resources.IResource)

Example 62 with WorkflowPackage

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

the class ProcessExplorerActionGroup method isSomethingToPaste.

public boolean isSomethingToPaste(IStructuredSelection selection) {
    if (selection.getFirstElement() instanceof WorkflowElement) {
        WorkflowElement element = (WorkflowElement) selection.getFirstElement();
        WorkflowPackage destPackage = element.getPackage();
        if (destPackage != null) {
            Object clipboardContents = view.getClipboard().getContents(TextTransfer.getInstance());
            if (clipboardContents instanceof String) {
                String clipString = (String) clipboardContents;
                if (clipString.startsWith("Process~") || clipString.startsWith("ExternalEvent~") || clipString.startsWith("WorkflowAsset~")) {
                    ProcessExplorerDropTarget dropTarget = view.getDropTarget();
                    return (dropTarget != null && dropTarget.isValidDrop(clipString, destPackage, DND.DROP_COPY));
                }
            }
        }
    }
    return false;
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 63 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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 64 with WorkflowPackage

use of com.centurylink.mdw.plugin.designer.model.WorkflowPackage 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 65 with WorkflowPackage

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

Aggregations

WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)85 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)31 ArrayList (java.util.ArrayList)27 WorkflowElement (com.centurylink.mdw.plugin.designer.model.WorkflowElement)25 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)21 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)17 AutomatedTestCase (com.centurylink.mdw.plugin.designer.model.AutomatedTestCase)11 GridData (org.eclipse.swt.layout.GridData)11 CoreException (org.eclipse.core.runtime.CoreException)9 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)9 SelectionEvent (org.eclipse.swt.events.SelectionEvent)9 DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)8 List (java.util.List)8 Label (org.eclipse.swt.widgets.Label)8 JSONException (org.json.JSONException)8 PackageVO (com.centurylink.mdw.model.value.process.PackageVO)7 ExternalEvent (com.centurylink.mdw.plugin.designer.model.ExternalEvent)7 Folder (com.centurylink.mdw.plugin.designer.model.Folder)7 IOException (java.io.IOException)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7