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);
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class RunQueryPlanAction 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(true);
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class ShowSchemaAction method run.
/**
* @see org.eclipse.jface.action.Action#run() Override the run method in
* order to complete showing brokers status server to a broker
*/
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
showError();
return;
}
IEditorPart editor = window.getActivePage().getActiveEditor();
if (editor == null) {
showError();
return;
}
if (!(editor instanceof QueryEditorPart)) {
showError();
return;
}
QueryEditorPart queryEditorPart = (QueryEditorPart) editor;
CubridDatabase db = queryEditorPart.getSelectedDatabase();
if (db == null || !db.isLogined()) {
showError();
return;
}
String tableName = queryEditorPart.getSelectedText();
if (tableName == null) {
showError();
return;
}
DatabaseInfo databaseInfo = db.getDatabaseInfo();
if (databaseInfo == null) {
showError();
return;
}
CubridNavigatorView mainNav = CubridNavigatorView.findNavigationView();
if (mainNav != null) {
mainNav.showQuickView(databaseInfo, tableName, true);
}
}
use of com.cubrid.common.ui.query.editor.QueryEditorPart in project cubrid-manager by CUBRID.
the class QueryTunerAction method getQuery.
public String getQuery() {
// FIXME extract to utility
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;
StyledText stext = queryEditorPart.getSqlEditorWidget();
return stext.getSelectionText();
}
Aggregations