Search in sources :

Example 1 with RenameDialog

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());
        }
    }
}
Also used : WorkflowPackage(com.centurylink.mdw.plugin.designer.model.WorkflowPackage) RenameDialog(com.centurylink.mdw.plugin.designer.dialogs.RenameDialog) DesignerProxy(com.centurylink.mdw.plugin.designer.DesignerProxy) WorkflowAsset(com.centurylink.mdw.plugin.designer.model.WorkflowAsset) WorkflowProject(com.centurylink.mdw.plugin.project.model.WorkflowProject) IEditorPart(org.eclipse.ui.IEditorPart) WorkflowProcess(com.centurylink.mdw.plugin.designer.model.WorkflowProcess)

Aggregations

DesignerProxy (com.centurylink.mdw.plugin.designer.DesignerProxy)1 RenameDialog (com.centurylink.mdw.plugin.designer.dialogs.RenameDialog)1 WorkflowAsset (com.centurylink.mdw.plugin.designer.model.WorkflowAsset)1 WorkflowPackage (com.centurylink.mdw.plugin.designer.model.WorkflowPackage)1 WorkflowProcess (com.centurylink.mdw.plugin.designer.model.WorkflowProcess)1 WorkflowProject (com.centurylink.mdw.plugin.project.model.WorkflowProject)1 IEditorPart (org.eclipse.ui.IEditorPart)1