use of com.cubrid.cubridmanager.ui.host.dialog.RenameHostDialog in project cubrid-manager by CUBRID.
the class RenameHostAction method doRun.
private void doRun(CubridServer server) {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
RenameHostDialog dlg = new RenameHostDialog(shell, server);
int ret = dlg.open();
if (ret == IDialogConstants.OK_ID) {
server.setLabel(dlg.getNewName());
server.getServerInfo().setServerName(dlg.getNewName());
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
LOGGER.error("Error: Can't find the navigator view:" + CubridHostNavigatorView.ID);
return;
}
// Fire all the databases which are in the server logout
List<ICubridNode> children = server.getChildren();
if (children != null) {
for (ICubridNode child : children) {
if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
continue;
}
List<ICubridNode> childList = child.getChildren();
if (childList == null) {
continue;
}
for (ICubridNode node : childList) {
if (!NodeType.DATABASE.equals(node.getType())) {
continue;
}
CubridDatabase database = (CubridDatabase) node;
database.setLogined(false);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
}
}
// Refresh the tree view
server.removeAllChild();
if (server.getLoader() != null) {
server.getLoader().setLoaded(false);
}
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(null, true);
treeViewer.setSelection(new StructuredSelection(server), true);
setEnabled(false);
// Save the data
CMHostNodePersistManager.getInstance().addServer(server.getServerInfo().getHostAddress(), server.getServerInfo().getHostMonPort(), server.getServerInfo().getUserName(), server.getServerInfo());
QueryOptions.removePref(server.getServerInfo());
BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
CMHostNodePersistManager.getInstance().saveServers();
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
}
Aggregations