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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
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());
}
}
}
}
Aggregations