use of com.centurylink.mdw.plugin.designer.DesignerProxy 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.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method rename.
public void rename(WorkflowElement element) {
RenameDialog renameDialog = new RenameDialog(getShell(), element);
renameDialog.setTitle("Rename " + element.getTitle());
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
String lbl = "'" + processVersion.getLabel() + "'";
IEditorPart editor = findOpenEditor(processVersion);
if (editor != null) {
String message = lbl + " is currently open in an editor.\nPlease save and close before renaming.";
MessageDialog.openError(getShell(), "Process Explorer", message);
return;
}
if (processVersion.getLockingUser() != null && !processVersion.isLockedToUser()) {
String message = lbl + " is currently locked to " + processVersion.getLockingUser() + ", so it cannot be renamed";
MessageDialog.openError(getShell(), "Process Explorer", message);
return;
}
} else if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
if (asset.getFileEditor() != null) {
IEditorPart assetEditor = findOpenEditor(asset.getFileEditor().getEditorInput());
if (assetEditor != null) {
String message = "'" + asset.getName() + "' is currently open in an editor.\nPlease save and close before renaming.";
MessageDialog.openError(getShell(), "Process Explorer", message);
return;
}
}
} else if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (!workflowProject.isRemote()) {
if (workflowProject.isCloudProject())
MessageDialog.openWarning(getShell(), "Cloud Project", "Please rename the underlying Java Project in Package Explorer and then refresh the Process Explorer view.");
return;
}
}
int result = renameDialog.open();
if (result == Dialog.OK) {
String newName = renameDialog.getNewName();
if (element instanceof WorkflowProject) {
WorkflowProject workflowProject = (WorkflowProject) element;
if (!workflowProject.isRemote())
return;
WorkflowProjectManager.renameRemoteProject(workflowProject, newName);
workflowProject.fireElementChangeEvent(ChangeType.RENAME, null);
} else {
WorkflowProject workflowProject = element.getProject();
DesignerProxy designerProxy = workflowProject.getDesignerProxy();
if (element instanceof WorkflowProcess) {
WorkflowProcess processVersion = (WorkflowProcess) element;
designerProxy.renameProcess(processVersion, newName);
} else if (element instanceof WorkflowPackage) {
WorkflowPackage packageVersion = (WorkflowPackage) element;
designerProxy.renamePackage(packageVersion, newName);
} else if (element instanceof WorkflowAsset) {
WorkflowAsset asset = (WorkflowAsset) element;
designerProxy.renameWorkflowAsset(asset, newName);
}
element.fireElementChangeEvent(ChangeType.RENAME, element.getName());
}
}
}
use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class WorkflowElementActionHandler method launchSwing.
public void launchSwing(final WorkflowProject project, final String title, final String formName, String dataInit) {
try {
if (title.equals("Java VisualVM")) {
String javaVersion = System.getProperty("java.version");
String badVersionMsg = "Cannot launch Java VisualVM.\nRequires Java version >= 1.6.0_07.\nRunning version: " + javaVersion + ".";
if (!javaVersion.startsWith("1.6") && !javaVersion.startsWith("1.7") && !javaVersion.startsWith("1.8")) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
return;
} else if (javaVersion.startsWith("1.6")) {
// check minor version
String minorVer = javaVersion.substring(javaVersion.indexOf('_') + 1);
if (Integer.parseInt(minorVer) < 7) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", badVersionMsg);
return;
}
}
String jdkBin = PluginUtil.getJdkBin();
File exe = new File(jdkBin + File.separator + "jvisualvm.exe");
if (!exe.exists()) {
MessageDialog.openError(getShell(), "Launch Java VisualVM", "Executable not found: '" + exe + "'");
return;
}
String[] cmdArr = new String[] { exe.getAbsolutePath() };
if (project.isRemote()) {
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openjmx", project.getServerSettings().getHost() + ":" + project.getJmxPort() });
} else {
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { "--openid", String.valueOf(project.getVisualVmId()) });
}
new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
} else if (title.equals("JConsole")) {
String jdkBin = PluginUtil.getJdkBin();
File exe = new File(jdkBin + File.separator + "jconsole.exe");
if (!exe.exists()) {
MessageDialog.openError(getShell(), "Launch JConsole", "Executable not found: '" + exe + "'");
return;
}
String[] cmdArr = new String[] { exe.getAbsolutePath() };
if (project.isRemote())
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { project.getServerSettings().getHost() + ":" + project.getJmxPort() });
else {
String serverProcId = project.getServerSettings().getServerProcessId();
if (serverProcId != null)
cmdArr = (String[]) PluginUtil.appendArrays(cmdArr, new String[] { serverProcId });
}
new ProcessConsoleRunner(getShell().getDisplay(), cmdArr).start();
} else {
String request = null;
if (dataInit != null) {
FormDataDocument datadoc = new FormDataDocument();
datadoc.setAttribute(FormDataDocument.ATTR_ACTION, dataInit);
request = datadoc.format();
}
final String response = dataInit == null ? null : project.getDesignerProxy().getDesignerDataAccess().engineCall(request);
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DesignerProxy designerProxy = project.getDesignerProxy();
JFrame propmgr_frame = new JFrame(title);
FormPanel mainform = new FormPanel(propmgr_frame, designerProxy.getDesignerDataAccess(), designerProxy.getPluginDataAccess().getPrivileges());
mainform.setData(formName, response);
propmgr_frame.setVisible(true);
} catch (final Exception ex) {
if (getShell() == null) {
PluginMessages.log(ex);
} else {
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
if (ex.getCause() instanceof ConnectException)
MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
else
PluginMessages.uiError(ex, "Launch " + title, project);
}
});
}
}
}
});
}
} catch (Exception ex) {
if (ex.getCause() instanceof ConnectException)
MessageDialog.openError(getShell(), "Launch " + title, ex.getCause().getMessage());
else
PluginMessages.uiError(ex, "Launch " + title, project);
}
}
use of com.centurylink.mdw.plugin.designer.DesignerProxy 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;
}
}
use of com.centurylink.mdw.plugin.designer.DesignerProxy in project mdw-designer by CenturyLinkCloud.
the class NewProcessWizard method performFinish.
@Override
public boolean performFinish() {
DesignerProxy designerProxy = process.getProject().getDesignerProxy();
designerProxy.createNewProcess(process);
if (designerProxy.getRunnerStatus().equals(RunnerStatus.SUCCESS)) {
process.sync();
process.addElementChangeListener(process.getProject());
process.fireElementChangeEvent(ChangeType.ELEMENT_CREATE, process);
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.openEditor(process, "mdw.editors.process");
DesignerPerspective.promptForShowPerspective(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), process);
return true;
} catch (Exception ex) {
PluginMessages.uiError(getShell(), ex, "Open Process", process.getProject());
return false;
}
} else {
return false;
}
}
Aggregations