use of org.jkiss.dbeaver.model.edit.DBEObjectRenamer in project dbeaver by serge-rider.
the class NavigatorHandlerObjectRename method renameDatabaseObject.
public static boolean renameDatabaseObject(IWorkbenchWindow workbenchWindow, DBNDatabaseNode node, String newName) {
try {
if (node.getParentNode() instanceof DBNContainer) {
final DBNContainer container = (DBNContainer) node.getParentNode();
DBSObject object = node.getObject();
if (object != null) {
DBEObjectRenamer objectRenamer = EntityEditorsRegistry.getInstance().getObjectManager(object.getClass(), DBEObjectRenamer.class);
if (objectRenamer != null) {
CommandTarget commandTarget = getCommandTarget(workbenchWindow, container, object.getClass(), false);
objectRenamer.renameObject(commandTarget.getContext(), object, newName);
if (object.isPersisted() && commandTarget.getEditor() == null) {
if (!showScript(workbenchWindow, commandTarget.getContext(), "Rename script")) {
commandTarget.getContext().resetChanges();
return false;
} else {
ObjectSaver renamer = new ObjectSaver(commandTarget.getContext());
TasksJob.runTask("Rename object '" + object.getName() + "'", renamer);
}
} else {
for (DBECommand command : commandTarget.getContext().getFinalCommands()) {
//System.out.println(command);
}
}
return true;
}
}
}
} catch (Throwable e) {
UIUtils.showErrorDialog(workbenchWindow.getShell(), "Rename object", "Can't rename object '" + node.getNodeName() + "'", e);
return false;
}
return false;
}
Aggregations