use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class JobAutoDashboardEditorPart method expandBackOrQueryPlanChildNode.
public void expandBackOrQueryPlanChildNode() {
Set<String> typeSet = new HashSet<String>();
typeSet.add(CubridNodeType.JOB_FOLDER);
ICubridNode jobFolderNode = CommonUITool.findNode(database, typeSet);
if (jobFolderNode != null) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
if (view == null) {
return;
}
TreeViewer treeViewer = view.getViewer();
for (ICubridNode backOrQueryFolderNode : jobFolderNode.getChildren()) {
//if not expand ,expand the node and wait until all children be added
if (!treeViewer.getExpandedState(backOrQueryFolderNode)) {
treeViewer.expandToLevel(backOrQueryFolderNode, 1);
}
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class JobAutoDashboardEditorPart method findAutoJobInfoNode.
/**
* find queryPlanoNode or backupPlanNode from treeView
*
* @param nodeType String
* @param nodeType id
* @return
*/
public ICubridNode findAutoJobInfoNode(String nodeType, String id) {
Set<String> typeSet = new HashSet<String>();
typeSet.add(nodeType);
ICubridNode node = CommonUITool.findNode(database, typeSet, id);
//if backupPlanNode is null,expand the backupPlanNodeFolder then find again
if (node == null) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
String childNodeFolderID = nodeType.equals(CubridNodeType.BACKUP_PLAN) ? CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID : CubridJobAutoFolderLoader.QUERY_PLAN_FOLDER_ID;
DefaultSchemaNode folderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + childNodeFolderID);
treeViewer.expandToLevel(folderNode, 1);
//wait 5 times expand the folder node
int time = 0;
while (folderNode.getChildren().size() == 0 && time++ < 5) {
try {
Thread.sleep(500);
} catch (Exception e) {
}
}
}
return CommonUITool.findNode(database, typeSet, id);
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView 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));
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class DeleteHostAction method doRun.
/**
* Perform do run
*
* @param objArr
*/
public void doRun(Object[] objArr) {
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (navigatorView == null) {
return;
}
StringBuilder hostNames = new StringBuilder();
for (int i = 0; objArr != null && i < objArr.length; i++) {
if (!isSupported(objArr[i])) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) objArr[i];
hostNames.append(node.getLabel());
if (i != objArr.length - 1) {
hostNames.append(",");
}
}
String msg = Messages.bind(Messages.msgConfirmDeleteHost, hostNames.toString());
boolean isDelete = CommonUITool.openConfirmBox(getShell(), msg);
if (!isDelete) {
return;
}
TreeViewer viewer = navigatorView.getViewer();
if (objArr == null) {
LOGGER.error("objArr is null.");
return;
}
for (int i = 0; i < objArr.length; i++) {
CubridServer server = (CubridServer) objArr[i];
boolean isContinue = HostUtils.processHostDeleted(server);
List<CubridGroupNode> groups = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
for (CubridGroupNode grp : groups) {
grp.removeChild(server);
}
if (isContinue) {
viewer.remove(server);
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class AddHostAction method run.
public void run() {
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return;
}
doRun(this.getSelectedObj());
}
Aggregations