Search in sources :

Example 31 with SQLEditorBase

use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.

the class SQLEditorHandlerExpandCollapseAllFoldings method execute.

@Override
public Object execute(ExecutionEvent event) {
    IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    if (activeEditor == null) {
        return null;
    }
    SQLEditorBase sqlEditor = activeEditor.getAdapter(SQLEditorBase.class);
    if (sqlEditor == null || !sqlEditor.isFoldingEnabled()) {
        return null;
    }
    ProjectionAnnotationModel model = sqlEditor.getAnnotationModel();
    if (model == null) {
        return null;
    }
    IDocument document = sqlEditor.getDocument();
    if (document == null) {
        return null;
    }
    int length = sqlEditor.getDocument().getLength();
    String commandId = event.getCommand().getId();
    if (EXPAND_COMMAND_ID.equals(commandId)) {
        model.expandAll(0, length);
    } else if (COLLAPSE_COMMAND_ID.equals(commandId)) {
        model.collapseAll(0, length);
    }
    return null;
}
Also used : ProjectionAnnotationModel(org.eclipse.jface.text.source.projection.ProjectionAnnotationModel) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) IEditorPart(org.eclipse.ui.IEditorPart) IDocument(org.eclipse.jface.text.IDocument)

Example 32 with SQLEditorBase

use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.

the class SQLEditorHandlerNavigateObject 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;
}
Also used : SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) IHyperlink(org.eclipse.jface.text.hyperlink.IHyperlink) IEditorPart(org.eclipse.ui.IEditorPart) IRegion(org.eclipse.jface.text.IRegion) TextViewer(org.eclipse.jface.text.TextViewer)

Example 33 with SQLEditorBase

use of org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase in project dbeaver by dbeaver.

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;
}
Also used : OracleProcedurePackaged(org.jkiss.dbeaver.ext.oracle.model.OracleProcedurePackaged) OraclePackage(org.jkiss.dbeaver.ext.oracle.model.OraclePackage) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

SQLEditorBase (org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase)33 IEditorPart (org.eclipse.ui.IEditorPart)20 StyledText (org.eclipse.swt.custom.StyledText)8 FillLayout (org.eclipse.swt.layout.FillLayout)8 GridData (org.eclipse.swt.layout.GridData)8 Composite (org.eclipse.swt.widgets.Composite)6 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)6 InputStream (java.io.InputStream)4 IRegion (org.eclipse.jface.text.IRegion)4 IHyperlink (org.eclipse.jface.text.hyperlink.IHyperlink)4 DisposeEvent (org.eclipse.swt.events.DisposeEvent)4 DisposeListener (org.eclipse.swt.events.DisposeListener)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 IEditorSite (org.eclipse.ui.IEditorSite)4 IContextService (org.eclipse.ui.contexts.IContextService)4 NotNull (org.jkiss.code.NotNull)4 OraclePackage (org.jkiss.dbeaver.ext.oracle.model.OraclePackage)4 OracleProcedurePackaged (org.jkiss.dbeaver.ext.oracle.model.OracleProcedurePackaged)4 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)4