Search in sources :

Example 16 with WorkflowElement

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

the class AutomatedTestLaunchShortcut method launch.

public void launch(ISelection sel, String mode) {
    StructuredSelection selection = (StructuredSelection) sel;
    Object firstElement = selection.getFirstElement();
    WorkflowProject project = null;
    try {
        if (firstElement instanceof WorkflowElement) {
            WorkflowElement element = (WorkflowElement) firstElement;
            project = element.getProject();
            boolean prevEnablement = disableBuildBeforeLaunch();
            if (selection.size() > 1 || element instanceof AutomatedTestCase) {
                List<AutomatedTestCase> testCases = new ArrayList<>();
                for (Object obj : selection.toArray()) testCases.add((AutomatedTestCase) obj);
                performLaunch(testCases, mode);
            } else {
                performLaunch(element, mode);
            }
            setBuildBeforeLaunch(prevEnablement);
        } else {
            ResourceWrapper resourceWrapper = new ResourceWrapper(firstElement);
            IFile firstFile = resourceWrapper.getFile();
            if (firstFile != null) {
                project = WorkflowProjectManager.getInstance().getWorkflowProject(firstFile.getProject());
                // test case file(s)
                List<AutomatedTestCase> testCases = new ArrayList<>();
                Object[] objArr = selection.toArray();
                if (objArr.length == 1) {
                    WorkflowPackage pkg = project.getPackage((IFolder) firstFile.getParent());
                    testCases.add((AutomatedTestCase) pkg.getAsset(firstFile));
                } else {
                    for (Object obj : objArr) {
                        IFile file = (IFile) obj;
                        WorkflowPackage pkg = project.getPackage((IFolder) file.getParent());
                        testCases.add((AutomatedTestCase) pkg.getAsset(file));
                    }
                }
                performLaunch(testCases, mode);
            } else {
                IFolder folder = resourceWrapper.getFolder();
                if (folder != null) {
                    project = WorkflowProjectManager.getInstance().getWorkflowProject(folder.getProject());
                    performLaunch(project.getPackage(folder), mode);
                } else {
                    IProject proj = resourceWrapper.getProject();
                    project = WorkflowProjectManager.getInstance().getWorkflowProject(proj);
                    performLaunch(project, mode);
                }
            }
        }
    } catch (Exception ex) {
        PluginMessages.uiError(ex, "Test Exec", project);
    }
}
Also used : ResourceWrapper(com.centurylink.mdw.plugin.ResourceWrapper) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) AutomatedTestCase(com.centurylink.mdw.plugin.designer.model.AutomatedTestCase) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) IFolder(org.eclipse.core.resources.IFolder)

Example 17 with WorkflowElement

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

the class CucumberLaunchShortcut method launch.

public void launch(ISelection sel, String mode) {
    StructuredSelection selection = (StructuredSelection) sel;
    Object firstElement = selection.getFirstElement();
    ResourceWrapper resourceWrapper = new ResourceWrapper(firstElement);
    try {
        List<CucumberTest> tests = new ArrayList<>();
        IFile file = resourceWrapper.getFile();
        if (file != null) {
            // launch gherkin feature test(s)
            for (Object obj : selection.toArray()) {
                ResourceWrapper fileWrapper = new ResourceWrapper(obj);
                tests.add(new CucumberTest(fileWrapper.getOwningProject(), fileWrapper.getFile()));
            }
            performLaunch(tests, new ResourceWrapper(file.getParent()).getFolder());
        } else {
            // package folder
            IFolder folder = resourceWrapper.getFolder();
            if (folder != null) {
                CucumberTest.findTests(folder, tests);
                performLaunch(tests, folder);
            } else {
                IProject proj = resourceWrapper.getProject();
                tests.addAll(CucumberTest.getTests(proj));
                performLaunch(tests, null);
            }
        }
    } catch (Exception ex) {
        WorkflowProject proj = firstElement instanceof WorkflowElement ? ((WorkflowElement) firstElement).getProject() : null;
        PluginMessages.uiError(ex, "Test Exec", proj);
    }
}
Also used : ResourceWrapper(com.centurylink.mdw.plugin.ResourceWrapper) CucumberTest(com.centurylink.mdw.plugin.designer.model.CucumberTest) IFile(org.eclipse.core.resources.IFile) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ArrayList(java.util.ArrayList) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement) IFolder(org.eclipse.core.resources.IFolder)

Example 18 with WorkflowElement

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

the class Discoverer method removeEmptyFolders.

private void removeEmptyFolders(Folder folder) {
    List<Folder> emptyFolders = new ArrayList<>();
    for (WorkflowElement child : folder.getChildren()) {
        if (child instanceof Folder) {
            Folder childFolder = ((Folder) child);
            if (childFolder.getChildren() == null)
                emptyFolders.add(childFolder);
        }
    }
    for (Folder emptyFolder : emptyFolders) {
        if (emptyFolder.getParent() instanceof Folder) {
            Folder parent = emptyFolder.getParent();
            parent.getChildren().remove(emptyFolder);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) Folder(com.centurylink.mdw.plugin.designer.model.Folder) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 19 with WorkflowElement

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

the class NewProcessWizard method init.

public void init(IWorkbench workbench, IStructuredSelection selection) {
    setDefaultPageImageDescriptor(MdwPlugin.getImageDescriptor("icons/mdw_wiz.png"));
    setNeedsProgressMonitor(true);
    newProcessPage = new NewProcessPage();
    process = new WorkflowProcess();
    if (selection != null && selection.getFirstElement() instanceof WorkflowPackage) {
        WorkflowPackage processPackage = (WorkflowPackage) selection.getFirstElement();
        process.setProject(processPackage.getProject());
        process.setPackage(processPackage);
    } else if (selection != null && selection.getFirstElement() instanceof WorkflowProject) {
        WorkflowProject workflowProject = (WorkflowProject) selection.getFirstElement();
        process.setProject(workflowProject);
        if (workflowProject.isShowDefaultPackage())
            process.setPackage(workflowProject.getDefaultPackage());
    } else if (selection != null && selection.getFirstElement() instanceof WorkflowElement) {
        WorkflowProject workflowProject = ((WorkflowElement) selection.getFirstElement()).getProject();
        process.setProject(workflowProject);
    } else {
        WorkflowProject workflowProject = WorkflowProjectManager.getInstance().findWorkflowProject(selection);
        if (workflowProject != null)
            process.setProject(workflowProject);
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) WorkflowElement(com.centurylink.mdw.plugin.designer.model.WorkflowElement)

Example 20 with WorkflowElement

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

the class WorkflowAssetEditor method fillTreeCombo.

private void fillTreeCombo() {
    treeCombo.removeAll();
    Comparator<WorkflowElement> comparator = new Comparator<WorkflowElement>() {

        public int compare(WorkflowElement we1, WorkflowElement we2) {
            return we1.getLabel().compareTo(we2.getLabel());
        }
    };
    if (isProcess()) {
        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
        for (WorkflowPackage pkg : packages) {
            CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
            packageItem.setText(pkg.getName());
            packageItem.setImage(pkg.getIconImage());
            for (WorkflowProcess process : pkg.getProcesses()) {
                CTreeComboItem processItem = new CTreeComboItem(packageItem, SWT.NONE);
                processItem.setText(process.getLabel());
                processItem.setImage(process.getIconImage());
            }
        }
    } else if (isTaskTemplate()) {
        List<WorkflowPackage> packages = getProject().getTopLevelUserVisiblePackages();
        for (WorkflowPackage pkg : packages) {
            List<TaskTemplate> templatesForPkg = pkg.getTaskTemplates();
            if (templatesForPkg != null && !templatesForPkg.isEmpty()) {
                CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
                packageItem.setText(pkg.getName());
                packageItem.setImage(pkg.getIconImage());
                for (TaskTemplate template : templatesForPkg) {
                    CTreeComboItem templateItem = new CTreeComboItem(packageItem, SWT.NONE);
                    templateItem.setText(template.getLabel());
                    templateItem.setImage(template.getIconImage());
                }
            }
        }
    } else {
        List<WorkflowAsset> assets = getProject().getAssetList(assetTypes);
        Map<WorkflowPackage, List<WorkflowAsset>> packageAssets = new TreeMap<>();
        for (WorkflowAsset asset : assets) {
            List<WorkflowAsset> assetsForPkg = packageAssets.get(asset.getPackage());
            if (assetsForPkg == null) {
                assetsForPkg = new ArrayList<>();
                packageAssets.put(asset.getPackage(), assetsForPkg);
            }
            assetsForPkg.add(asset);
        }
        for (Map.Entry<WorkflowPackage, List<WorkflowAsset>> pkgAssets : packageAssets.entrySet()) {
            CTreeComboItem packageItem = new CTreeComboItem(treeCombo, SWT.NONE);
            packageItem.setText(pkgAssets.getKey().getName());
            packageItem.setImage(pkgAssets.getKey().getIconImage());
            List<WorkflowAsset> assetsForPkg = pkgAssets.getValue();
            Collections.sort(assetsForPkg, comparator);
            for (WorkflowAsset assetForPkg : assetsForPkg) {
                CTreeComboItem assetItem = new CTreeComboItem(packageItem, SWT.NONE);
                assetItem.setText(assetForPkg.getLabel());
                assetItem.setImage(assetForPkg.getIconImage());
            }
        }
    }
}
Also used : TaskTemplate(com.centurylink.mdw.plugin.designer.model.TaskTemplate) WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) CTreeComboItem(com.centurylink.swt.widgets.CTreeComboItem) ArrayList(java.util.ArrayList) Comparator(java.util.Comparator) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess) Map(java.util.Map) TreeMap(java.util.TreeMap) 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