use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class StopBrokerEnvAction method run.
/**
* Override the run method in order to complete stopping broker environment
*/
public void run() {
if (!CommonUITool.openConfirmBox(CONFIRM_CONTENT)) {
return;
}
final Object[] obj = this.getSelectedObj();
CubridBrokerFolder selection = (CubridBrokerFolder) obj[0];
if (null == selection) {
return;
}
ServerInfo serverInfo = selection.getServer().getServerInfo();
StopBrokerEnvTask task = new StopBrokerEnvTask(serverInfo);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.stopBrokerEnvTaskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
selection.setRunning(false);
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection);
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class MultiDatabaseLoginFailedDialog method editHost.
public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
if (multiDatabaseloginFailedInfo == null) {
return;
}
CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
//if login ,can't edit
if (database.isLogined()) {
return;
}
// CubridDatabase oldDatabase = null;
// try {
// oldDatabase = database.clone();
// } catch (CloneNotSupportedException e) {
// //Ignore
// }
LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
int returnVal = dialog.open();
if (returnVal == IDialogConstants.OK_ID) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
/*Save the data*/
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (editorConfig == null) {
editorConfig = new DatabaseEditorConfig();
}
editorConfig.setBackGround(dialog.getSelectedColor());
CMDBNodePersistManager.getInstance().addDatabase(database, editorConfig);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
multiDatabaseloginFailedInfo.setErrMsg("");
}
databaseTable.refresh();
}
use of org.eclipse.jface.viewers.TreeViewer 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 org.eclipse.jface.viewers.TreeViewer 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 org.eclipse.jface.viewers.TreeViewer 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