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