use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class LoginDatabaseAction method doRun.
public void doRun(CubridDatabase[] databaseArray) {
if (databaseArray == null || databaseArray.length == 0) {
return;
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null && databaseArray.length > 0) {
final TreeViewer treeViewer = navigationView.getViewer();
if (databaseArray.length > 1) {
List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
for (CubridDatabase object : databaseArray) {
CubridDatabase database = (CubridDatabase) object;
String errMsg = null;
if (database.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo(), false);
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
database.getLoader().setLoaded(false);
database.setLogined(true);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
// open database dashboard
if (GeneralPreference.isUseDatabaseDashboard()) {
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(database);
}
} else {
failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
}
}
if (failedDatabaseList.size() > 0) {
MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
dialog.open();
}
return;
} else {
CubridDatabase database = databaseArray[0];
if (DbRunningType.STANDALONE.equals(database.getRunningType()) && ActionSupportUtil.hasAdminPermissionOnStopState(database)) {
if (CommonUITool.openConfirmBox(Messages.bind(Messages.msgWhetherStartDB, database.getName()))) {
StartDatabaseAction startDatabaseAction = (StartDatabaseAction) ActionManager.getInstance().getAction(StartDatabaseAction.ID);
startDatabaseAction.doRun(new CubridDatabase[] { database });
}
}
if (!database.isLogined() && database.isAutoSavePassword()) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (EditorConstance.isNeedSetBackground(editorConfig)) {
new ShortSetEditorConfigAction(database).run();
}
}
if (!database.isLogined() && database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo(), true)) {
database.getLoader().setLoaded(false);
database.setLogined(true);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
// open database dashboard
if (GeneralPreference.isUseDatabaseDashboard()) {
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(database);
}
} else if (!database.isLogined()) {
EditDatabaseLoginAction editDatabaseLoginAction = (EditDatabaseLoginAction) ActionManager.getInstance().getAction(EditDatabaseLoginAction.ID);
editDatabaseLoginAction.doRun(databaseArray);
}
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class EditDatabaseLoginAction method doRun.
public void doRun(CubridDatabase[] databaseArray) {
if (databaseArray == null || databaseArray.length == 0) {
return;
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null) {
final TreeViewer treeViewer = navigationView.getViewer();
CubridDatabase database = (CubridDatabase) databaseArray[0];
LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
int returnVal = dialog.open();
if (returnVal == IDialogConstants.OK_ID && provider instanceof TreeViewer) {
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
if (dialog.isFireLogoutEvent()) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
} else if (returnVal == LoginDatabaseDialog.SAVE_ID && provider instanceof TreeViewer) {
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class AddHostAction method doRun.
public void doRun(Object[] nodes) {
CubridGroupNode parent = getParentGroupNode(nodes);
if (parent == null) {
LOGGER.error("parent is null.");
return;
}
HostDialog dialog = new HostDialog(getShell(), true, false);
int returnCode = dialog.open();
if (returnCode == HostDialog.ADD_ID || returnCode == HostDialog.CONNECT_ID) {
CubridServer server = getServerNode(dialog);
if (server == null) {
LOGGER.error("server is null.");
return;
}
CMHostNodePersistManager.getInstance().addServer(server);
TreeItem item = null;
parent.addChild(server);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (navigatorView != null) {
boolean isShowGroup = navigatorView.isShowGroup();
TreeViewer treeViewer = navigatorView.getViewer();
if (isShowGroup) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(treeViewer.getTree(), SWT.NONE);
}
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
item.setText(server.getLabel());
item.setData(server);
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(new StructuredSelection(server), true);
if (returnCode == HostDialog.CONNECT_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
}
} else {
dialog.closeTestServerConnection();
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class ConnectHostAction method doRun.
public void doRun(CubridServer[] servers) {
if (servers.length == 0) {
return;
}
if (servers.length == 1) {
CubridServer server = servers[0];
if (server.isAutoSavePassword() && CubridWorkbenchContrItem.connectHost(server.getServerInfo(), true)) {
server.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (view == null) {
LOGGER.error("view is null.");
return;
}
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeChangedEvent event = new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED);
CubridNodeManager.getInstance().fireCubridNodeChanged(event);
} else {
EditHostAction editHostAction = (EditHostAction) ActionManager.getInstance().getAction(EditHostAction.ID);
if (editHostAction != null) {
editHostAction.doRun(servers, true);
}
}
} else {
List<FailedHostServerInfo> failedServerList = new ArrayList<FailedHostServerInfo>();
for (CubridServer object : servers) {
CubridServer server = (CubridServer) object;
String errMsg = null;
if (server.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectHostWithErrMsg(server.getServerInfo(), false);
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
server.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
} else {
failedServerList.add(new FailedHostServerInfo(server, errMsg));
}
}
if (failedServerList.size() > 0) {
NewMultiHostConnectionDialog dialog = new NewMultiHostConnectionDialog(getShell(), failedServerList);
dialog.open();
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class PasteHostAction method run.
/**
* Paste the host
*/
public void run() {
Object[] objs = this.getSelectedObj();
if (!isSupported(objs[0])) {
setEnabled(false);
return;
}
objs = null;
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection strSelection = (IStructuredSelection) selection;
objs = strSelection.toArray();
}
if (objs == null || objs.length == 0) {
return;
}
if (!(objs[0] instanceof CubridServer)) {
return;
}
CubridServer pastedServer = (CubridServer) objs[0];
HostDialog dialog = new HostDialog(getShell(), true, false);
dialog.setServer(pastedServer);
int returnCode = dialog.open();
if (returnCode == HostDialog.ADD_ID || returnCode == HostDialog.CONNECT_ID) {
CubridServer server = getServerNode(dialog);
CMHostNodePersistManager.getInstance().addServer(server);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return;
}
TreeItem item;
Tree tree = treeViewer.getTree();
CubridGroupNode parent = getParentGroupNode();
parent.addChild(server);
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
item.setText(server.getLabel());
item.setData(server);
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(new StructuredSelection(server), true);
if (returnCode == HostDialog.CONNECT_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
}
}
}
Aggregations