use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class PstmtOneDataDialog 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();
close();
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);
}
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class ObjectInfoComposite method appendToEditor.
/**
* Append the sql to the sqlEditor and select it
*
* @param sql
*/
private void appendToEditor(String sql) {
StringBuffer queries = new StringBuffer();
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (part instanceof QueryEditorPart) {
QueryEditorPart editorPart = (QueryEditorPart) part;
SQLEditorComposite sqlEditor = editorPart.getCombinedQueryComposite().getSqlEditorComp();
queries.append(sqlEditor.getAllQueries());
int index = queries.length();
if (index > 0) {
String last = queries.substring(index - 1);
if (!(NEWLINE.equals(last) || "\n".equals(last))) {
queries.append(NEWLINE);
index += NEWLINE.length();
}
}
queries.append(sql);
sqlEditor.setQueries(queries.toString());
sqlEditor.forcusCursor(index, sql.length());
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class SqlPstmtAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor instanceof QueryEditorPart) {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
PstmtSQLDialog dialog = new PstmtSQLDialog(queryEditor.getSite().getShell(), queryEditor.getSelectedDatabase());
dialog.create();
dialog.setEditorInput((QueryUnit) queryEditor.getEditorInput());
String queries = queryEditor.getCombinedQueryComposite().getSqlEditorComp().getText().getSelectionText();
dialog.setSql(queries);
dialog.open();
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class QueryOpenAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null || window.getActivePage() == null) {
return;
}
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor != null && editor.isDirty()) {
int confirm = CommonUITool.openMsgBox(editor.getSite().getShell(), MessageDialog.WARNING, Messages.saveResource, Messages.bind(Messages.saveConfirm, editor.getTitle()), new String[] { Messages.btnYes, Messages.btnNo, Messages.cancel });
switch(confirm) {
case 0:
editor.doSave(null);
break;
case 1:
break;
default:
return;
}
}
try {
if (editor == null) {
IEditorInput input = new QueryUnit();
editor = window.getActivePage().openEditor(input, QueryEditorPart.ID);
}
} catch (PartInitException e) {
CommonUITool.openErrorBox(e.getMessage());
}
if (editor == null) {
return;
}
try {
QueryEditorPart queryEditor = (QueryEditorPart) editor;
SQLEditorComposite editorComp = queryEditor.getCombinedQueryComposite().getSqlEditorComp();
String encoding = editorComp.getDocument().getEncoding();
SetFileEncodingDialog dialog = new SetFileEncodingDialog(getShell(), encoding, true);
if (IDialogConstants.OK_ID == dialog.open()) {
editorComp.open(dialog.getFilePath(), dialog.getEncoding());
}
} catch (IOException e) {
CommonUITool.openErrorBox(e.getMessage());
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class RunQueryAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Control control = getFocusProvider();
if (!(control instanceof StyledText)) {
showNoSelectionQueryError();
return;
}
StyledText stext = (StyledText) control;
String data = stext.getSelectionText();
if (StringUtil.isEmpty(data)) {
showNoSelectionQueryError();
return;
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
showNoSelectionQueryError();
return;
}
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor == null || !(editor instanceof QueryEditorPart)) {
showNoSelectionQueryError();
return;
}
((QueryEditorPart) editor).runQuery(false);
}
Aggregations