use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class QueryTunerRunAction method getDatabaseWithSelection.
/**
* get the schema information.
*
* @return schemaInfo
*/
private CubridDatabase getDatabaseWithSelection() {
// FIXME extract to module
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (null == window) {
return null;
}
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor == null) {
return null;
}
if (!(editor instanceof QueryEditorPart)) {
return null;
}
QueryEditorPart queryEditorPart = (QueryEditorPart) editor;
CubridDatabase db = queryEditorPart.getSelectedDatabase();
if (db == null || !db.isLogined()) {
return null;
}
return db;
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class QueryPropertyComposite method save.
/**
*
* Save query options
*/
public void save() {
ServerInfo serverInfo = server == null ? null : server.getServerInfo();
boolean isAutocommit = autocommitBtn.getSelection();
boolean isEnableSearchUnit = searchUnitBtn.getSelection();
int unitCount = unitCountSpinner.getSelection();
int pageUnitCount = pageUnitCountSpinner.getSelection();
int loadSize = loadSizeSpinner.getSelection();
boolean isKeywordLowercase = keywordLowerBtn.getSelection();
boolean isNoAutoUppercaseKeyword = autoNoUppercaseKeywordBtn.getSelection();
boolean isWithoutPromptSave = withoutPromptSaveBtn.getSelection();
boolean isShowMultiPageConfirm = multiPageConfirmBtn.getSelection();
boolean isUseScientificNotation = useScientificNotationBtn.getSelection();
QueryOptions.setAutoCommit(serverInfo, isAutocommit);
QueryOptions.setEnableSearchUnit(serverInfo, isEnableSearchUnit);
QueryOptions.setSearchUnitCount(serverInfo, unitCount);
QueryOptions.setPageLimit(serverInfo, pageUnitCount);
QueryOptions.setKeywordLowercase(serverInfo, isKeywordLowercase);
QueryOptions.setNoAutoUppercaseKeyword(serverInfo, isNoAutoUppercaseKeyword);
QueryOptions.setWithoutPromptSave(serverInfo, isWithoutPromptSave);
QueryOptions.setFontColorRed(serverInfo, fontColorRed);
QueryOptions.setFontColorGreen(serverInfo, fontColorGreen);
QueryOptions.setFontColorBlue(serverInfo, fontColorBlue);
QueryOptions.setFontString(serverInfo, fontString);
QueryOptions.setShowStyle(serverInfo, true);
QueryOptions.setUseScientificNotation(serverInfo, isUseScientificNotation);
QueryOptions.setLobLoadSize(serverInfo, loadSize);
QueryOptions.setMultiPageConfirm(isShowMultiPageConfirm);
QueryOptions.savePref();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (page != null) {
IEditorReference[] editorRefs = page.getEditorReferences();
for (IEditorReference ref : editorRefs) {
IEditorPart editor = ref.getEditor(true);
if (editor instanceof QueryEditorPart) {
QueryEditorPart part = (QueryEditorPart) editor;
part.refreshQueryOptions();
}
}
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class PstmtSQLDialog method showResultSet.
/**
* Open the query editor and show result set
*
* @param parameterList List<PstmtParameter>
*/
private void showResultSet(List<PstmtParameter> parameterList) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String querySql = sqlTxt.getText();
IEditorPart editor = window.getActivePage().findEditor(editorInput);
if (editor == null) {
try {
editor = window.getActivePage().openEditor(editorInput, QueryEditorPart.ID);
} catch (PartInitException e) {
editor = null;
}
}
if (editor != null) {
window.getActivePage().bringToTop(editor);
QueryEditorPart queryEditor = ((QueryEditorPart) editor);
if (!queryEditor.isConnected() && database != null) {
queryEditor.connect(database);
}
String allInputSql = getCommentSqlValue(parameterList) + querySql;
List<List<PstmtParameter>> rowParameterList = new ArrayList<List<PstmtParameter>>();
rowParameterList.add(parameterList);
if (queryEditor.isConnected()) {
queryEditor.setQuery(allInputSql, querySql, rowParameterList, true, true, false);
} else {
queryEditor.setQuery(allInputSql, true, false, false);
}
}
close();
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart 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);
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method openSelectQuery.
public void openSelectQuery(ISelection selection) {
final Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ISchemaNode table = (ISchemaNode) obj;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
boolean existsEditor = false;
QueryEditorPart editor = null;
QueryUnit input = new QueryUnit();
input.setDatabase(table.getDatabase());
try {
IEditorPart editorPart = window.getActivePage().getActiveEditor();
if (editorPart != null && editorPart instanceof QueryEditorPart) {
QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
if (queryEditorPart.getSelectedDatabase() == input.getDatabase()) {
editor = (QueryEditorPart) editorPart;
existsEditor = true;
}
}
if (editor == null) {
editor = (QueryEditorPart) window.getActivePage().openEditor(input, QueryEditorPart.ID);
editor.connect(table.getDatabase());
}
DefaultSchemaNode tableNode = (DefaultSchemaNode) obj;
String sql = getStmtSQL(tableNode) + StringUtil.NEWLINE + StringUtil.NEWLINE;
if (existsEditor) {
editor.newQueryTab(sql, true);
} else {
editor.setQuery(sql, false, true, false);
}
} catch (Exception e) {
LOGGER.error("", e);
}
}
Aggregations