use of com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults in project mdw-designer by CenturyLinkCloud.
the class AutomatedTestView method refreshOutputFromSelection.
private void refreshOutputFromSelection() {
display.asyncExec(new Runnable() {
public void run() {
String output = "";
if (selectedItem instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) selectedItem;
output = readFile(testCase.getOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
if (testCase.isPostman() && testCase.getItemName() != null)
output = readFile(testCase.getItemOutputFile()).replaceAll("\r\n", "\n").replaceAll("\n", "\r\n");
} else if (selectedItem instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) selectedItem;
output = "Results:\n--------\n" + readFile(expectedResults.getActualResults());
} else if (selectedItem instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) selectedItem;
output = "Results:\n--------\n" + readFile(expectedResult.getActualResultFile());
}
if (!outputText.getText().equals(output)) {
outputText.setText(output);
outputText.setSelection(outputText.getText().length());
}
}
});
}
use of com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method delete.
public void delete(WorkflowElement[] elements) {
boolean globalConf = false;
boolean includeInstances = false;
if (elements.length > 1) {
boolean globalConfAllowed = true;
List<WorkflowElement> lockedElems = new ArrayList<WorkflowElement>();
for (WorkflowElement element : elements) {
if ((element instanceof WorkflowProject) || (element instanceof WorkflowPackage)) {
globalConfAllowed = false;
break;
} else if (element instanceof WorkflowProcess) {
WorkflowProcess pv = (WorkflowProcess) element;
if (pv.getLockingUser() != null && !pv.isLockedToUser())
lockedElems.add(pv);
} else if (element instanceof WorkflowAsset) {
WorkflowAsset dd = (WorkflowAsset) element;
if (dd.getLockingUser() != null && !dd.isLockedToUser())
lockedElems.add(dd);
}
}
if (!lockedElems.isEmpty()) {
PluginMessages.uiList(getShell(), "Error: The following elements are locked to other users.\nPlease exclude them from your selection or have them unlocked before proceeding.", "Delete Elements", lockedElems);
return;
}
if (globalConfAllowed) {
WorkflowElementDeleteDialog multipleDeleteDialog = new WorkflowElementDeleteDialog(getShell(), Arrays.asList(elements));
int res = multipleDeleteDialog.open();
if (res == Dialog.CANCEL)
return;
else if (res == Dialog.OK) {
globalConf = true;
includeInstances = multipleDeleteDialog.isIncludeInstances();
}
}
}
for (WorkflowElement element : elements) {
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (!workflowProject.isRemote()) {
MessageDialog.openWarning(getShell(), "Delete Project", "Please delete the underlying Java Project in Package Explorer view.");
return;
}
boolean confirmed = MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete workflow project: " + workflowProject.getName() + "?");
if (confirmed) {
WorkflowProjectManager.getInstance().deleteProject(workflowProject);
workflowProject.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
} else {
return;
}
} else if (element instanceof AutomatedTestCase && ((AutomatedTestCase) element).isLegacy()) {
// still allow deletion of legacy test stuff
final AutomatedTestCase testCase = (AutomatedTestCase) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Delete Legacy Test Case", "Delete " + testCase.getLabel() + "?")) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
File tcDir = testCase.getTestCaseDirectory();
try {
PluginUtil.deleteDirectory(tcDir);
testCase.getTestSuite().getTestCases().remove(testCase);
try {
IFolder folder = testCase.getProject().getOldTestCasesFolder();
if (folder.exists())
folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException ex) {
PluginMessages.uiError(ex, "Delete Legacy Test Case", testCase.getProject());
}
testCase.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
testCase.removeElementChangeListener(testCase.getProject());
} catch (IOException ex) {
PluginMessages.uiError(ex, "Delete Test Case", testCase.getProject());
}
}
});
}
} else if (element instanceof LegacyExpectedResults) {
final LegacyExpectedResults expectedResult = (LegacyExpectedResults) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Delete Legacy Expected Result", "Delete " + expectedResult.getLabel() + "?")) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
File file = expectedResult.getExpectedResultFile();
if (file.delete()) {
expectedResult.getTestCase().getLegacyExpectedResults().remove(expectedResult);
try {
IFolder folder = expectedResult.getProject().getOldTestCasesFolder();
if (folder.exists())
folder.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
} catch (CoreException ex) {
PluginMessages.uiError(ex, "Delete Legacy Expected Result", expectedResult.getProject());
}
expectedResult.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
expectedResult.removeElementChangeListener(expectedResult.getProject());
} else {
PluginMessages.uiError("Cannot delete expected result " + expectedResult.getName(), "Delete Result", expectedResult.getProject());
}
}
});
}
} else if (element instanceof com.centurylink.mdw.plugin.designer.model.File) {
final com.centurylink.mdw.plugin.designer.model.File file = (com.centurylink.mdw.plugin.designer.model.File) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Delete File", "Delete " + file.getLabel() + "?")) {
BusyIndicator.showWhile(Display.getCurrent(), new Runnable() {
public void run() {
IFile workspaceFile = file.getWorkspaceFile();
try {
workspaceFile.delete(true, null);
WorkflowElement parent = file.getParent();
if (parent instanceof AutomatedTestCase) {
AutomatedTestCase testCase = (AutomatedTestCase) parent;
testCase.getFiles().remove(file);
}
file.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
file.removeElementChangeListener(file.getProject());
refresh(file.getProject().getLegacyTestSuite());
} catch (Exception ex) {
PluginMessages.uiError("Cannot delete file " + file.getName(), "Delete File", file.getProject());
}
}
});
}
} else {
WorkflowProject workflowProject = element.getProject();
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (element instanceof WorkflowPackage) {
WorkflowPackage packageToDelete = (WorkflowPackage) element;
PackageDeleteDialog packageDeleteDialog = new PackageDeleteDialog(getShell(), packageToDelete);
if (packageDeleteDialog.open() == Dialog.OK) {
designerProxy.deletePackage(packageToDelete);
} else {
return;
}
} else if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
if (!processVersion.getProject().isFilePersist() && processVersion.getLockingUser() != null && !processVersion.isLockedToUser()) {
MessageDialog.openError(getShell(), "Cannot Delete", "Process '" + processVersion.getLabel() + "' is locked to user '" + processVersion.getLockingUser() + "'.\nPlease have it unlocked before deleting.");
return;
}
ProcessDeleteDialog deleteDialog = new ProcessDeleteDialog(getShell(), processVersion);
if (globalConf || deleteDialog.open() == Dialog.OK) {
closeOpenEditor(processVersion, false);
includeInstances = includeInstances || deleteDialog.isIncludeInstances();
designerProxy.deleteProcess(processVersion, includeInstances);
} else {
return;
}
} else if (element instanceof TaskTemplate) {
TaskTemplate taskTemplate = (TaskTemplate) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete " + taskTemplate.getTitle() + " '" + taskTemplate.getLabel() + "'?")) {
designerProxy.deleteTaskTemplate(taskTemplate);
} else {
return;
}
} else if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
if (!asset.getProject().isFilePersist() && asset.getLockingUser() != null && !asset.isLockedToUser()) {
MessageDialog.openError(getShell(), "Cannot Delete", asset.getTitle() + " '" + asset.getLabel() + "' is locked to user '" + asset.getLockingUser() + "'.\nPlease have it unlocked before deleting");
return;
}
if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete " + asset.getTitle() + " '" + asset.getLabel() + "'?")) {
if (asset.getFileEditor() != null) {
IEditorInput editorInput = asset.getFileEditor().getEditorInput();
if (editorInput != null)
closeOpenEditor(editorInput, false);
}
WorkflowAssetFactory.deRegisterAsset(asset);
designerProxy.deleteWorkflowAsset(asset);
} else {
return;
}
} else if (element instanceof ActivityImpl) {
ActivityImpl activityImpl = (ActivityImpl) element;
ActivityImplDeleteDialog deleteDialog = new ActivityImplDeleteDialog(getShell(), activityImpl);
if (globalConf || deleteDialog.open() == Dialog.OK) {
designerProxy.deleteActivityImpl(activityImpl, deleteDialog.isIncludeActivities());
} else {
return;
}
} else if (element instanceof ExternalEvent) {
ExternalEvent externalEvent = (ExternalEvent) element;
if (globalConf || MessageDialog.openConfirm(getShell(), "Confirm Delete", "Delete Event Handler: " + externalEvent.getLabel() + "?")) {
designerProxy.deleteExternalEvent(externalEvent);
} else {
return;
}
} else if (element instanceof TaskTemplate) {
MessageDialog.openWarning(getShell(), "TODO", "Delete task template not yet implemented");
}
if (RunnerStatus.SUCCESS.equals(designerProxy.getRunnerStatus())) {
// notify listeners
element.fireElementChangeEvent(ChangeType.ELEMENT_DELETE, null);
element.removeElementChangeListener(workflowProject);
}
}
}
}
use of com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults 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.LegacyExpectedResults 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);
}
use of com.centurylink.mdw.plugin.designer.model.LegacyExpectedResults in project mdw-designer by CenturyLinkCloud.
the class ProcessExplorerActionGroup method createOpenInstanceAction.
private IAction createOpenInstanceAction() {
IAction action = new Action() {
@Override
public void run() {
if (openInstanceApplies(getSelection())) {
WorkflowProject project = ((WorkflowElement) getSelection().getFirstElement()).getProject();
try {
Long procInstId = null;
if (getSelection().getFirstElement() instanceof AutomatedTestResults) {
AutomatedTestResults expectedResults = (AutomatedTestResults) getSelection().getFirstElement();
procInstId = expectedResults.getActualProcessInstanceId();
} else if (getSelection().getFirstElement() instanceof LegacyExpectedResults) {
LegacyExpectedResults expectedResult = (LegacyExpectedResults) getSelection().getFirstElement();
java.io.File resultsFile = expectedResult.getActualResultFile();
TestFile testFile = new TestFile(null, resultsFile.getPath());
testFile.load();
TestFileLine line1 = testFile.getLines().get(0);
procInstId = new Long(line1.getWord(3));
}
if (procInstId == null) {
MessageDialog.openWarning(view.getSite().getShell(), "No Results", "Unable to locate results file.");
return;
}
ProcessInstanceVO procInst = project.getDataAccess().getProcessInstance(procInstId);
Long processId = procInst.getProcessId();
ProcessVO procVO = project.getProcess(processId).getProcessVO();
if (procVO == null)
PluginMessages.uiError("Unable to locate process: " + processId, OPEN_PROCESS_INSTANCE, project);
WorkflowProcess instance = new WorkflowProcess(project, procVO);
instance.setProcessInstance(procInst);
actionHandler.open(instance);
} catch (Exception ex) {
PluginMessages.uiError(ex, OPEN_PROCESS_INSTANCE, project);
}
}
}
};
action.setText(OPEN_PROCESS_INSTANCE);
action.setId(MdwMenuManager.MDW_MENU_PREFIX + OPEN_PROCESS_INSTANCE);
ImageDescriptor imageDesc = MdwPlugin.getImageDescriptor(ICON_PROCESS_GIF);
action.setImageDescriptor(imageDesc);
return action;
}
Aggregations