Search in sources :

Example 86 with WorkflowProject

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

the class CodeGenWizard method createJavaAssetAndOpen.

protected JavaSource createJavaAssetAndOpen(WorkflowPackage workflowPackage, String jetFile, String targetFolder, String targetFile, IProgressMonitor monitor) throws CoreException {
    JetAccess jet = getJet(jetFile, targetFolder, targetFile);
    Generator generator = new Generator(getShell());
    IFile contentFile = generator.createFile(jet, monitor);
    WorkflowProject workflowProject = workflowPackage.getProject();
    JavaSource javaAsset = new JavaSource();
    javaAsset.setLanguage(RuleSetVO.JAVA);
    javaAsset.setName(contentFile.getName());
    javaAsset.setProject(workflowProject);
    javaAsset.setPackage(workflowPackage);
    String content = new String(PluginUtil.readFile(contentFile));
    javaAsset.setContent(content);
    contentFile.refreshLocal(IResource.DEPTH_ZERO, monitor);
    contentFile.delete(true, monitor);
    DesignerProxy designerProxy = javaAsset.getProject().getDesignerProxy();
    try {
        designerProxy.createNewWorkflowAsset(javaAsset, true);
    } catch (Exception ex) {
        PluginMessages.uiError(getShell(), ex, "New " + javaAsset.getTitle(), javaAsset.getProject());
        return null;
    }
    if (designerProxy.getRunnerStatus().equals(RunnerStatus.SUCCESS)) {
        javaAsset.openFile(new NullProgressMonitor());
        javaAsset.addElementChangeListener(javaAsset.getProject());
        javaAsset.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, javaAsset);
        WorkflowAssetFactory.registerAsset(javaAsset);
        return javaAsset;
    } else {
        return null;
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) JavaSource(com.centurylink.mdw.plugin.designer.model.JavaSource) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 87 with WorkflowProject

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

the class ProcessExplorerActionGroup method createRunTestsAction.

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

        @Override
        public void run() {
            if (!runTestsApplies(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();
                actionHandler.test(getSelection());
            } 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("icons/testrun.gif");
    action.setImageDescriptor(imageDesc);
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "run.tests");
    action.setText("Run Tests...");
    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) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) 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 88 with WorkflowProject

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

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

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

the class ProcessExplorerActionGroup method createSwingLaunchAction.

private IAction createSwingLaunchAction(final String title, final String icon, final String formName, final String dataInit) {
    IAction action = new Action() {

        @Override
        public void run() {
            if (!swingLaunchApplies(getSelection()))
                return;
            WorkflowProject workflowProject = (WorkflowProject) getSelection().getFirstElement();
            boolean is55 = workflowProject.checkRequiredVersion(5, 5);
            String handlerPkg = is55 ? "com.centurylink.mdw.listener.formaction." : "com.qwest.mdw.listener.formaction.";
            String listenerPackage = is55 ? "com.centurylink.mdw.swingtools/" : "";
            actionHandler.launchSwing(workflowProject, title, formName == null ? null : listenerPackage + formName, handlerPkg + dataInit);
        }
    };
    action.setId(MdwMenuManager.MDW_MENU_PREFIX + "swing." + title);
    action.setText(title);
    if (icon != null) {
        ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICONS + icon);
        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) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)

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