Search in sources :

Example 16 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project erlide_eclipse by erlang.

the class ErlangFileActionProvider method init.

@Override
public void init(final ICommonActionExtensionSite aSite) {
    final ICommonViewerSite viewSite = aSite.getViewSite();
    if (viewSite instanceof ICommonViewerWorkbenchSite) {
        final ICommonViewerWorkbenchSite workbenchSite = (ICommonViewerWorkbenchSite) viewSite;
        final IWorkbenchPartSite site = workbenchSite.getSite();
        openAction = new OpenErlangAction(aSite, workbenchSite.getSelectionProvider());
        searchActionGroup = new ErlangSearchActionGroup(site);
        final IContextService service = site.getService(IContextService.class);
        if (service != null) {
            service.activateContext("org.erlide.ui.erlangOutlineAndNavigatorScope");
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ErlangSearchActionGroup(org.erlide.ui.actions.ErlangSearchActionGroup) ICommonViewerSite(org.eclipse.ui.navigator.ICommonViewerSite) IContextService(org.eclipse.ui.contexts.IContextService) ICommonViewerWorkbenchSite(org.eclipse.ui.navigator.ICommonViewerWorkbenchSite)

Example 17 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.

the class NavigatorHandlerConnectionFilter method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
    if (partSite != null && partSite.getPart() instanceof DatabaseNavigatorView) {
        DatabaseNavigatorTree navigatorTree = ((DatabaseNavigatorView) partSite.getPart()).getNavigatorTree();
        element.setIcon(DBeaverIcons.getImageDescriptor(navigatorTree.isFilterShowConnected() ? UIIcon.FILTER_RESET : UIIcon.FILTER_APPLY));
        String actionName = navigatorTree.isFilterShowConnected() ? "Show all" : "Show connected only";
        element.setText(actionName);
        element.setTooltip(actionName);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) DatabaseNavigatorView(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorView) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree)

Example 18 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.

the class OracleTaskHandler method getOracleSourceObjects.

protected List<OracleSourceObject> getOracleSourceObjects(UIElement element) {
    List<OracleSourceObject> objects = new ArrayList<>();
    IWorkbenchPartSite partSite = UIUtils.getWorkbenchPartSite(element.getServiceLocator());
    if (partSite != null) {
        final ISelectionProvider selectionProvider = partSite.getSelectionProvider();
        if (selectionProvider != null) {
            ISelection selection = selectionProvider.getSelection();
            if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
                for (Iterator<?> iter = ((IStructuredSelection) selection).iterator(); iter.hasNext(); ) {
                    final Object item = iter.next();
                    final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(item, OracleSourceObject.class);
                    if (sourceObject != null) {
                        objects.add(sourceObject);
                    }
                }
            }
        }
        if (objects.isEmpty()) {
            final IWorkbenchPart activePart = partSite.getPart();
            final OracleSourceObject sourceObject = RuntimeUtils.getObjectAdapter(activePart, OracleSourceObject.class);
            if (sourceObject != null) {
                objects.add(sourceObject);
            }
        }
    }
    return objects;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ArrayList(java.util.ArrayList) ISelection(org.eclipse.jface.viewers.ISelection) OracleStatefulObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleStatefulObject) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject)

Example 19 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.

the class ResultSetStatListener method handleResultSetSelectionChange.

@Override
public void handleResultSetSelectionChange(SelectionChangedEvent event) {
    IResultSetSelection selection = viewer.getSelection();
    IWorkbenchPartSite site = viewer.getSite();
    if (site instanceof IEditorSite) {
        // Use job with 100ms delay to avoid event spam
        if (this.updateJob == null) {
            this.updateJob = new SLUpdateJob();
        }
        this.updateJob.schedule(100);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IEditorSite(org.eclipse.ui.IEditorSite)

Example 20 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.

the class AbstractPresentation method trackPresentationControl.

protected void trackPresentationControl() {
    final Control control = getControl();
    final IWorkbenchPartSite site = controller.getSite();
    UIUtils.addFocusTracker(site, PRESENTATION_CONTROL_ID, control);
    // RSV control context
    EditorUtils.trackControlContext(site, control, RESULTS_CONTROL_CONTEXT_ID);
    // Enable horizontal scrolling
    control.addMouseWheelListener(e -> {
        boolean shift = ((e.stateMask & SWT.MOD2) != 0);
        if (shift) {
            performHorizontalScroll(e.count);
        }
    });
    // Register DnD handlers for this presentation
    controller.getDecorator().registerDragAndDrop(this);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) Control(org.eclipse.swt.widgets.Control)

Aggregations

IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)73 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ISelection (org.eclipse.jface.viewers.ISelection)12 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)10 MenuManager (org.eclipse.jface.action.MenuManager)9 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Composite (org.eclipse.swt.widgets.Composite)9 Display (org.eclipse.swt.widgets.Display)9 Shell (org.eclipse.swt.widgets.Shell)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 Menu (org.eclipse.swt.widgets.Menu)7 IEditorSite (org.eclipse.ui.IEditorSite)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 SWT (org.eclipse.swt.SWT)6 PartInitException (org.eclipse.ui.PartInitException)6 List (java.util.List)5 IToolBarManager (org.eclipse.jface.action.IToolBarManager)4 Separator (org.eclipse.jface.action.Separator)4