use of com.cubrid.cubridmanager.ui.common.action.ShortSetEditorConfigAction 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);
}
}
}
}
Aggregations