use of com.centurylink.mdw.plugin.designer.dialogs.RenameDialog 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());
}
}
}
Aggregations