Search in sources :

Example 36 with WorkflowElement

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

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

the class ProcessExplorerActionGroup method createCompareResultsAction.

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

        @SuppressWarnings("restriction")
        @Override
        public void run() {
            if (compareResultsApplies(getSelection())) {
                WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
                try {
                    project.getProjectFolder(project.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST)).refreshLocal(IResource.DEPTH_INFINITE, null);
                    Object[] items = new Object[2];
                    if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
                        AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
                        if (project.isFilePersist()) {
                            items[0] = project.getProjectFile(expectedResults.getVcsAssetPath());
                        } else {
                            expectedResults.openTempFile(new NullProgressMonitor());
                            items[0] = expectedResults.getTempFile(expectedResults.getTempFolder());
                        }
                        String actualResultsPath = expectedResults.getPackage().getName() + "/" + expectedResults.getName();
                        items[1] = project.getProjectFile(project.getTestResultsPath(AutomatedTestCase.FUNCTION_TEST) + "/" + actualResultsPath);
                    } else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
                        LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
                        items[0] = expectedResult.getExpectedResult();
                        items[1] = expectedResult.getActualResult();
                    }
                    if (items[1] == null || !((IFile) items[1]).exists()) {
                        MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file: " + ((IFile) items[1]).getLocation().toString());
                        return;
                    }
                    StructuredSelection compareSelection = new StructuredSelection(items);
                    ResultsCompareAction compareAction = new ResultsCompareAction(compareSelection);
                    compareAction.run(compareSelection);
                } catch (Exception ex) {
                    PluginMessages.uiError(ex, "Compare Test Results", project);
                }
            }
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "compare.results");
    action.setText("Compare Results");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/compare.gif");
    action.setImageDescriptor(imageDesc);
    return action;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) 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) IFile(org.eclipse.core.resources.IFile) IAction(org.eclipse.jface.action.IAction) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) AutomatedTestResults(com.centurylink.mdw.plugin.designer.model.AutomatedTestResults) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 38 with WorkflowElement

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

the class ProcessExplorerActionGroup method createRunAction.

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

        @Override
        public void run() {
            if (!runApplies(getSelection()))
                return;
            try {
                WorkflowElement element = (WorkflowElement) getSelection().getFirstElement();
                WorkflowProject project = element.getProject();
                restServer = ((RestfulServer) project.getDesignerDataAccess().getCurrentServer());
                restServer.getAppSummary();
                refreshRolePermissions(project);
                if (!isAuthorized(element)) {
                    MessageDialog.openError(getViewSite().getShell(), RUN_ACTION, "You are not authorized to run " + element.getName());
                    return;
                }
                view.setFocus();
                if (element instanceof AutomatedTestSuite || element instanceof AutomatedTestCase)
                    actionHandler.test(getSelection());
                else
                    actionHandler.run((WorkflowElement) element);
            } catch (ConnectException ex) {
                PluginMessages.log(ex);
                MessageDialog.openError(MdwPlugin.getShell(), RUN_ACTION, "Server appears to be offline: " + restServer.getServerUrl());
            } catch (Exception ex) {
                PluginMessages.log(ex);
                MessageDialog.openError(MdwPlugin.getShell(), RUN_ACTION, ex.getMessage());
            }
        }
    };
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_RUN_GIF);
    action.setImageDescriptor(imageDesc);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "run");
    action.setText("Run...");
    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) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) RestfulServer(com.centurylink.mdw.designer.utils.RestfulServer) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite) PartInitException(org.eclipse.ui.PartInitException) ConnectException(java.net.ConnectException) NamingException(javax.naming.NamingException) DataAccessException(com.centurylink.mdw.common.exception.DataAccessException) RemoteException(java.rmi.RemoteException) ConnectException(java.net.ConnectException)

Example 39 with WorkflowElement

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

the class ProcessExplorerActionGroup method createSearchAction.

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

        @Override
        public void run() {
            if (!searchApplies(getSelection()))
                return;
            Object[] items = getSelection().toArray();
            WorkflowElement[] elements = new WorkflowElement[items.length];
            for (int i = 0; i < items.length; i++) elements[i] = (WorkflowElement) items[i];
            actionHandler.search(elements);
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "search");
    action.setText("Search");
    ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor("icons/search.gif");
    action.setImageDescriptor(imageDesc);
    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) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 40 with WorkflowElement

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

the class ProcessExplorerActionGroup method renameApplies.

public boolean renameApplies(IStructuredSelection selection) {
    if (selection.size() != 1)
        return false;
    Object element = selection.getFirstElement();
    if (!(element instanceof WorkflowElement) || ((WorkflowElement) element).isArchived())
        return false;
    WorkflowElement workflowElement = (WorkflowElement) element;
    if (element instanceof Folder || element instanceof AutomatedTestSuite)
        return false;
    if (element instanceof AutomatedTestCase)
        return !((AutomatedTestCase) element).isLegacy();
    if (element instanceof File || element instanceof LegacyExpectedResults)
        return false;
    return workflowElement.isUserAuthorized(UserRoleVO.ASSET_DESIGN);
}
Also used : LegacyExpectedResults(com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) Folder(com.centurylink.mdw.plugin.designer.model.Folder) IFile(org.eclipse.core.resources.IFile) TestFile(com.centurylink.mdw.designer.testing.TestFile) File(com.centurylink.mdw.plugin.designer.model.File) JarFile(com.centurylink.mdw.plugin.designer.model.JarFile) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) AutomatedTestSuite(com.centurylink.mdw.plugin.designer.model.AutomatedTestSuite)

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