use of org.talend.mdm.repository.ui.dialogs.RenameViewDialog in project tmdm-studio-se by Talend.
the class RenameViewAction method renameViewObject.
private void renameViewObject(IRepositoryViewObject viewObj) {
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
MDMServerObject serverObject = item.getMDMServerObject();
IProxyRepositoryFactory factory = getFactory();
try {
if (serverObject != null) {
String oldName = serverObject.getName();
RenameViewDialog dialog = getRenameDialog(oldName);
int returnCode = dialog.open();
if (returnCode == IDialogConstants.OK_ID) {
String newName = dialog.getValue();
if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
newName = PREFIX_VIEW_UPPER + newName;
} else {
if (newName.startsWith(PREFIX_VIEW_UPPER)) {
viewTypeChanged = true;
item.getState().setPath(IPath.SEPARATOR + PATH_WEBFILTER);
}
}
if (newName != null && factory.isEditableAndLockIfPossible(item)) {
serverObject.setName(newName);
viewObj.getProperty().setLabel(newName);
viewObj.getProperty().setDisplayName(newName);
factory.save(viewObj.getProperty().getItem(), false);
MDMServerDef lastServerDef = RepositoryResourceUtil.getLastServerDef(viewObj);
if (lastServerDef != null) {
CommandManager.getInstance().pushCommand(ICommand.CMD_RENAME, viewObj.getId(), new String[] { oldName, newName });
}
}
commonViewer.refresh(viewObj);
}
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} finally {
try {
factory.unlock(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
use of org.talend.mdm.repository.ui.dialogs.RenameViewDialog in project tmdm-studio-se by Talend.
the class RenameViewAction method getRenameDialog.
private RenameViewDialog getRenameDialog(String oldName) {
RenameViewDialog dialog = null;
IWorkbenchPartSite site = commonViewer.getCommonNavigator().getSite();
if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
dialog = new RenameViewDialog(getShell(), Messages.RenameObjectAction_rename, Messages.Common_rename, oldName.substring(PREFIX_VIEW_UPPER.length()), getInputValidator(), site);
} else {
dialog = new RenameViewDialog2(getShell(), Messages.RenameObjectAction_rename, Messages.Common_rename, oldName, getInputValidator(), site);
}
return dialog;
}
Aggregations