use of com.cubrid.cubridquery.ui.common.action.ShortSetEditorConfigAction in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method processDoubleClickNavigatorEvent.
/**
* @see
* WorkbenchContrItem.processDoubleClickNavigatorEvent(DoubleClickEvent)
* @param event DoubleClickEvent
*/
public void processDoubleClickNavigatorEvent(DoubleClickEvent event) {
ISelection selection = event.getSelection();
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj;
if (NodeType.DATABASE.equals(cubridNode.getType())) {
CubridDatabase database = (CubridDatabase) cubridNode;
if (!database.isLogined() && database.isAutoSavePassword()) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
if (EditorConstance.isNeedSetBackground(editorConfig)) {
new ShortSetEditorConfigAction(database).run();
}
}
if (database.isLogined()) {
ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
} else if (database.isAutoSavePassword() && connectDatabase(database.getDatabaseInfo())) {
try {
CommonUITool.openQueryEditor(database, true);
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
CQBGroupNodePersistManager.getInstance().fix();
database.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
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));
} else {
ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
}
}
if (cubridNode.getType() == NodeType.TABLE_FOLDER || cubridNode.getType() == NodeType.TABLE_FOLDER || cubridNode.getType() == NodeType.VIEW_FOLDER || cubridNode.getType() == NodeType.TRIGGER_FOLDER || cubridNode.getType() == NodeType.SERIAL_FOLDER || cubridNode.getType() == NodeType.USER_FOLDER) {
CubridDatabase database = (CubridDatabase) cubridNode.getParent();
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (cubridNode.getType() == NodeType.TABLE_FOLDER) {
if (!treeViewer.getExpandedState(cubridNode)) {
treeViewer.expandToLevel(cubridNode, 1);
int sleepCount = 0;
while (cubridNode.getChildren().size() == 0) {
try {
Thread.sleep(500);
sleepCount++;
if (sleepCount > 5) {
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
openTablesDetailInfoPart(database);
} else if (cubridNode.getType() == NodeType.VIEW_FOLDER) {
//if not open child node ,edit serial from dashboard can not open edit dialog
if (!treeViewer.getExpandedState(cubridNode)) {
treeViewer.expandToLevel(cubridNode, 1);
}
openViewsDetailInfoPart(database);
} else if (cubridNode.getType() == NodeType.TRIGGER_FOLDER) {
//if not open child node ,edit serial from dashboard can not open edit dialog
if (!treeViewer.getExpandedState(cubridNode)) {
treeViewer.expandToLevel(cubridNode, 1);
}
openTriggersDetailInfoPart(database);
} else if (cubridNode.getType() == NodeType.SERIAL_FOLDER) {
//if not open child node ,edit trigger from dashboard can not open edit dialog
if (!treeViewer.getExpandedState(cubridNode)) {
treeViewer.expandToLevel(cubridNode, 1);
}
openSerialsDetailInfoPart(database);
} else if (StringUtil.isEqual(cubridNode.getType(), NodeType.USER_FOLDER)) {
if (!treeViewer.getExpandedState(cubridNode)) {
treeViewer.expandToLevel(cubridNode, 1);
}
openUsersDetailInfoPart(database);
}
}
if (cubridNode.getType() == NodeType.SERIAL) {
CubridDatabase database = (CubridDatabase) cubridNode.getParent().getParent();
openSerialsDetailInfoPart(database, cubridNode.getName());
}
if (!LayoutManager.getInstance().isUseClickOnce()) {
if (ActionSupportUtil.isSupportMultiSelection(obj, new String[] { NodeType.USER_TABLE, NodeType.USER_VIEW, NodeType.SYSTEM_TABLE, NodeType.SYSTEM_VIEW, NodeType.USER_PARTITIONED_TABLE_FOLDER }, false)) {
openSelectQuery(selection);
} else {
openEditorOrView(cubridNode);
}
}
}
use of com.cubrid.cubridquery.ui.common.action.ShortSetEditorConfigAction in project cubrid-manager by CUBRID.
the class OpenQueryConnAction method run.
/**
* Open the query connection
*/
public void run() {
// TODO remove later
CQBGroupNodePersistManager.getInstance().fix();
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISelectionProvider provider = getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
CubridDatabase[] cubridDatabases = handleSelectionObj(obj);
if (cubridDatabases.length > 1) {
List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
for (CubridDatabase object : cubridDatabases) {
CubridDatabase database = (CubridDatabase) object;
String errMsg = null;
if (database.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo());
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
database.getLoader().setLoaded(false);
database.setLogined(true);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
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));
} else {
failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
}
}
if (failedDatabaseList.size() > 0) {
MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
dialog.open();
}
return;
}
CubridDatabase database = cubridDatabases[0];
if (!database.isLogined() && database.isAutoSavePassword()) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
if (EditorConstance.isNeedSetBackground(editorConfig)) {
new ShortSetEditorConfigAction(database).run();
}
}
if (database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo())) {
database.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
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));
} else {
ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
}
}
Aggregations