use of com.cubrid.cubridmanager.ui.common.dialog.LoginQueryEditDialog in project cubrid-manager by CUBRID.
the class QueryNewCustomAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
Object[] selected = getSelectedObj();
LoginQueryEditDialog dialog = new LoginQueryEditDialog(getShell());
if (selected != null && selected.length == 1 && selected[0] instanceof ISchemaNode) {
dialog.setSelServerName(((ISchemaNode) selected[0]).getServer().getServerName());
dialog.setSelDatabaseName(((ISchemaNode) selected[0]).getDatabase().getName());
} else if (selected != null && selected.length == 1 && selected[0] instanceof CubridServer) {
dialog.setSelServerName(((CubridServer) selected[0]).getName());
} else {
dialog.setSelServerName(DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL);
}
if (dialog.open() == IDialogConstants.OK_ID) {
try {
IEditorInput input = new QueryUnit();
IEditorPart editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
((QueryEditorPart) editor).connect(DatabaseNavigatorMenu.SELF_DATABASE);
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
}
use of com.cubrid.cubridmanager.ui.common.dialog.LoginQueryEditDialog in project cubrid-manager by CUBRID.
the class CMDatabaseNavigatorMenu method handleWithSelfConn.
/**
*
* When click self-connection menu item, handle with this event
*
* @param dbItem DatabaseMenuItem
* @return boolean
*/
public boolean handleWithSelfConn(DatabaseMenuItem dbItem) {
LoginQueryEditDialog dialog = new LoginQueryEditDialog(parent.getShell());
dialog.setSelServerName(DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL);
if (DatabaseNavigatorMenu.SELF_DATABASE.getDatabaseInfo() != null) {
dialog.setSelDatabaseName(DatabaseNavigatorMenu.SELF_DATABASE.getDatabaseInfo().getDbName());
}
if (dialog.open() == IDialogConstants.OK_ID) {
return true;
} else {
dbItem.setSelection(false);
return false;
}
}
use of com.cubrid.cubridmanager.ui.common.dialog.LoginQueryEditDialog in project cubrid-manager by CUBRID.
the class QueryNewAction method openQueryEditor.
/**
* Open new query editor.
*
* @param database of query editor.
* @throws PartInitException when open editor error.
*/
private void openQueryEditor(CubridDatabase database) throws PartInitException {
IWorkbenchPage page = LayoutUtil.getActivePage();
if (page == null) {
return;
}
if (database == null) {
page.openEditor(new QueryUnit(), QueryEditorPart.ID);
return;
}
if (database != null && database.getRunningType() != DbRunningType.CS) {
CommonUITool.openErrorBox(Messages.bind(Messages.msgStartDb, database.getLabel()));
return;
}
CubridDatabase cdb = database;
if (database == null || !database.isLogined()) {
LoginQueryEditDialog dialog = new LoginQueryEditDialog(getShell());
dialog.setSelServerName(getInitConnectionName(getSelectedSever()));
dialog.setSelDatabaseName(getInitDatabaseName(database));
if (dialog.open() == IDialogConstants.OK_ID) {
cdb = DatabaseNavigatorMenu.SELF_DATABASE;
} else {
return;
}
}
QueryUnit input = new QueryUnit();
input.setDatabase(cdb);
IEditorPart editor = page.openEditor(input, QueryEditorPart.ID);
if (editor != null) {
((QueryEditorPart) editor).connect(cdb);
}
}
Aggregations