use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class OpenJobAutomationInfoAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj) || obj.length == 0) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) obj[0];
if (node.getType().equals(CubridNodeType.JOB_FOLDER)) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openJobsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
}
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class AddBackupPlanAction method run.
/**
* Creates a Dialog which is the instance of EditBackupPlanDialog to add a backup plan
*
* @param database
*/
public void run(CubridDatabase database) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
DefaultSchemaNode buckupPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID);
EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), true);
editBackupPlanDlg.setOperation(AddEditType.ADD);
editBackupPlanDlg.initPara(buckupPlanFolderNode);
if (editBackupPlanDlg.open() == Dialog.OK) {
BackupPlanInfo backupPlanInfo = editBackupPlanDlg.getBackupPlanInfo();
String newBackupId = backupPlanInfo.getBackupid();
DefaultSchemaNode newNode = new DefaultSchemaNode(newBackupId, newBackupId, ICON_PATH);
newNode.setContainer(false);
newNode.setType(CubridNodeType.BACKUP_PLAN);
newNode.setModelObj(backupPlanInfo);
buckupPlanFolderNode.addChild(newNode);
treeViewer.add(buckupPlanFolderNode, newNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
canceledTask = true;
}
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class DeleteBackupPlanAction method run.
/**
* Deletes the selected backup plan
*
*/
public void run(ISchemaNode[] nodeArray) {
List<String> nodeNames = new ArrayList<String>();
for (Object obj : nodeArray) {
ICubridNode selection = (ICubridNode) obj;
nodeNames.add(selection.getLabel());
}
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delBackupPlanConfirmContent, nodeNames))) {
return;
}
String taskName = Messages.bind(Messages.delBackupPlanTaskName, nodeNames);
CommonTaskExec taskExecutor = new CommonTaskExec(taskName);
for (Object obj : nodeArray) {
CubridDatabase database = null;
if (obj instanceof DefaultSchemaNode) {
database = ((DefaultSchemaNode) obj).getDatabase();
}
if (database == null) {
CommonUITool.openErrorBox(Messages.msgSelectDB);
return;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
DelBackupPlanTask delBackupPlanTask = new DelBackupPlanTask(serverInfo);
delBackupPlanTask.setDbname(database.getName());
String backupid = ((DefaultSchemaNode) obj).getLabel();
delBackupPlanTask.setBackupid(backupid);
taskExecutor.addTask(delBackupPlanTask);
}
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
for (Object obj : nodeArray) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
DefaultSchemaNode delNode = ((DefaultSchemaNode) obj);
ICubridNode parentNode = delNode.getParent();
parentNode.removeChild(delNode);
treeViewer.remove(delNode);
}
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class HostDialog method closeTestServerConnection.
/**
*
* Close the test server connection
*
*/
public void closeTestServerConnection() {
if (testConnServerInfo != null) {
ServerManager.getInstance().setConnected(testConnServerInfo.getHostAddress(), testConnServerInfo.getHostMonPort(), testConnServerInfo.getUserName(), false);
}
//clear and reset the tree view items of the server to avoid troublesome error prompt, for UX improvement.
if (server != null) {
CubridWorkbenchContrItem.closeAllEditorAndViewInServer(server, false);
server.removeAllChild();
TreeViewer viewer = (TreeViewer) LayoutManager.getInstance().getSelectionProvider();
viewer.refresh(server);
viewer.setSelection(null, true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
testConnServerInfo = null;
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class NewMultiHostConnectionDialog method editHost.
public void editHost(FailedHostServerInfo multiHostConnectionFailedServerInfo) {
// get selected dbdata
if (multiHostConnectionFailedServerInfo == null || multiHostConnectionFailedServerInfo.getCubridServer().isConnected()) {
return;
}
HostDialog dialog = new HostDialog(getShell(), false, false);
ServerInfo oldServerInfo = multiHostConnectionFailedServerInfo.getCubridServer().getServerInfo();
dialog.setServer(multiHostConnectionFailedServerInfo.getCubridServer());
if (dialog.open() != HostDialog.CONNECT_ID) {
return;
}
ServerInfo serverInfo = dialog.getServerInfo();
if (!serverInfo.getServerName().equals(multiHostConnectionFailedServerInfo.getCubridServer().getLabel())) {
QueryOptions.removePref(multiHostConnectionFailedServerInfo.getCubridServer().getServerInfo());
BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(multiHostConnectionFailedServerInfo.getCubridServer().getLabel());
}
if (oldServerInfo.isConnected() && !oldServerInfo.equals(serverInfo)) {
HostUtils.processHostDisconnected(multiHostConnectionFailedServerInfo.getCubridServer());
}
multiHostConnectionFailedServerInfo.getCubridServer().setId(serverInfo.getServerName());
multiHostConnectionFailedServerInfo.getCubridServer().setLabel(serverInfo.getServerName());
multiHostConnectionFailedServerInfo.getCubridServer().setServerInfo(serverInfo);
multiHostConnectionFailedServerInfo.getCubridServer().setAutoSavePassword(dialog.isSavePassword());
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(multiHostConnectionFailedServerInfo.getCubridServer(), CubridNodeChangedEventType.SERVER_CONNECTED));
multiHostConnectionFailedServerInfo.getCubridServer().getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(multiHostConnectionFailedServerInfo.getCubridServer(), true);
treeViewer.expandToLevel(multiHostConnectionFailedServerInfo.getCubridServer(), 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
multiHostConnectionFailedServerInfo.setErrConnectionMsg("");
serverTable.refresh();
}
Aggregations