use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class AssistTemplatesHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor instanceof SQLEditorBase) {
SQLEditorBase editor = (SQLEditorBase) activeEditor;
boolean oldValue = SQLCompletionProcessor.isLookupTemplates();
SQLCompletionProcessor.setLookupTemplates(true);
try {
editor.getTextViewer().doOperation(SourceViewer.CONTENTASSIST_PROPOSALS);
} finally {
SQLCompletionProcessor.setLookupTemplates(oldValue);
}
}
return null;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class NavigateObjectHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor != null) {
SQLEditorBase sqlEditor = DBUtils.getAdapter(SQLEditorBase.class, activeEditor);
if (sqlEditor != null) {
IHyperlink hyperlink = getCurrentHyperlink(sqlEditor);
if (hyperlink != null) {
IRegion selRegion2 = hyperlink.getHyperlinkRegion();
TextViewer textViewer = sqlEditor.getTextViewer();
if (textViewer != null) {
textViewer.setSelectedRange(selRegion2.getOffset(), selRegion2.getLength());
}
hyperlink.open();
}
}
}
return null;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.
the class NavigateQueryHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (!(activeEditor instanceof SQLEditorBase)) {
return null;
}
SQLEditorBase editor = (SQLEditorBase) activeEditor;
String actionId = event.getCommand().getId();
SQLScriptElement nextQuery;
switch(actionId) {
case CoreCommands.CMD_SQL_QUERY_NEXT:
nextQuery = editor.extractNextQuery(true);
break;
case CoreCommands.CMD_SQL_QUERY_PREV:
nextQuery = editor.extractNextQuery(false);
break;
default:
nextQuery = null;
break;
}
if (nextQuery != null) {
editor.selectAndReveal(nextQuery.getOffset(), nextQuery.getLength());
}
return null;
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by serge-rider.
the class WorkbenchContextListener method activatePartContexts.
void activatePartContexts(IWorkbenchPart part) {
IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
if (contextService == null) {
return;
}
try {
contextService.deferUpdates(true);
if (part instanceof INavigatorModelView) {
// We check for instanceof (do not use adapter) because otherwise it become active
// for all entity editor and clashes with SQL editor and other complex stuff.
// if (activationNavigator != null) {
// //log.debug("Double activation of navigator context");
// contextService.deactivateContext(activationNavigator);
// }
// activationNavigator = contextService.activateContext(INavigatorModelView.NAVIGATOR_CONTEXT_ID);
}
if (part instanceof SQLEditorBase || part.getAdapter(SQLEditorBase.class) != null) {
if (activationSQL != null) {
// log.debug("Double activation of SQL context");
contextService.deactivateContext(activationSQL);
}
activationSQL = contextService.activateContext(SQLEditorContributions.SQL_EDITOR_CONTEXT);
}
if (part.getAdapter(ResultSetViewer.class) != null || (part instanceof SQLEditor) || (part instanceof EntityEditor && ((EntityEditor) part).getDatabaseObject() instanceof DBSDataContainer)) {
if (activationResults != null) {
contextService.deactivateContext(activationResults);
}
activationResults = contextService.activateContext(RESULTS_CONTEXT_ID);
}
// Refresh auto-commit element state (#3315)
// Refresh OpenSeparateConnection
ActionUtils.fireCommandRefresh(ConnectionCommands.CMD_TOGGLE_AUTOCOMMIT, SQLEditorCommands.CMD_TOGGLE_SEPARATE_CONNECTION);
} finally {
contextService.deferUpdates(false);
}
}
use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by serge-rider.
the class PackageNavigateHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final OracleProcedurePackaged procedure = getSelectedProcedure(event);
if (procedure != null) {
OraclePackage procPackage = procedure.getParentObject();
IEditorPart entityEditor = NavigatorHandlerObjectOpen.openEntityEditor(procPackage);
if (entityEditor instanceof EntityEditor) {
((EntityEditor) entityEditor).switchFolder("source.definition");
SQLEditorBase sqlEditor = entityEditor.getAdapter(SQLEditorBase.class);
if (sqlEditor != null) {
new NavigateJob(procedure, sqlEditor).schedule();
}
}
}
return null;
}
Aggregations