Search in sources :

Example 61 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.

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)

Example 62 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.

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 63 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by serge-rider.

the class UIServiceSQLImpl method createSQLPanel.

@Override
public Object createSQLPanel(Object site, Object parent, DBPContextProvider contextProvider, String panelName, boolean showVerticalBar, String sqlText) throws DBException {
    IWorkbenchPartSite partSite = (IWorkbenchPartSite) site;
    Composite editorPH = (Composite) parent;
    final SQLEditorBase editor = new SQLEditorBase() {

        @Nullable
        @Override
        public DBCExecutionContext getExecutionContext() {
            return contextProvider.getExecutionContext();
        }

        @Override
        public void createPartControl(Composite parent) {
            super.createPartControl(parent);
            getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES).setEnabled(false);
        }

        @Override
        public boolean isFoldingEnabled() {
            return false;
        }
    };
    editor.setHasVerticalRuler(showVerticalBar);
    try {
        editor.init(new SubEditorSite(partSite), new StringEditorInput(panelName, sqlText, true, GeneralUtils.getDefaultFileEncoding()));
    } catch (PartInitException e) {
        throw new DBException("Error initializing SQL panel", e);
    }
    editor.createPartControl(editorPH);
    editor.reloadSyntaxRules();
    TextViewer textViewer = editor.getTextViewer();
    textViewer.setData("editor", editor);
    TextEditorUtils.enableHostEditorKeyBindingsSupport(partSite, textViewer.getTextWidget());
    return textViewer;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) SubEditorSite(org.jkiss.dbeaver.ui.editors.SubEditorSite) DBException(org.jkiss.dbeaver.DBException) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) StringEditorInput(org.jkiss.dbeaver.ui.editors.StringEditorInput) TextViewer(org.eclipse.jface.text.TextViewer)

Example 64 with IWorkbenchPartSite

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

the class ResultSetHandlerCopyAs method fillCopyAsMenu.

public static void fillCopyAsMenu(ResultSetViewer viewer, IContributionManager copyAsMenu) {
    IWorkbenchPartSite site = viewer.getSite();
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_SPECIAL));
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_COLUMN_NAMES));
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_COPY_ROW_NAMES));
    // Add copy commands for different formats
    copyAsMenu.add(new Separator());
    ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
    ResultSetDataContainer dataContainer = new ResultSetDataContainer(viewer, options);
    List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
    for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
        for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
            if (processor.isBinaryFormat()) {
                continue;
            }
            appProcessors.add(processor);
        }
    }
    appProcessors.sort(Comparator.comparing(DataTransferProcessorDescriptor::getName));
    for (DataTransferProcessorDescriptor processor : appProcessors) {
        CommandContributionItemParameter params = new CommandContributionItemParameter(site, processor.getId(), ResultSetHandlerCopyAs.CMD_COPY_AS, CommandContributionItem.STYLE_PUSH);
        params.label = processor.getName();
        if (processor.getIcon() != null) {
            params.icon = DBeaverIcons.getImageDescriptor(processor.getIcon());
        }
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(ResultSetHandlerCopyAs.PARAM_PROCESSOR_ID, processor.getFullId());
        params.parameters = parameters;
        copyAsMenu.add(new CommandContributionItem(params));
    }
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 65 with IWorkbenchPartSite

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

the class UIServiceSQLImpl method createSQLPanel.

@Override
public Object createSQLPanel(Object site, Object parent, DBPContextProvider contextProvider, String panelName, boolean showVerticalBar, String sqlText) throws DBException {
    IWorkbenchPartSite partSite = (IWorkbenchPartSite) site;
    Composite editorPH = (Composite) parent;
    final SQLEditorBase editor = new SQLEditorBase() {

        @Nullable
        @Override
        public DBCExecutionContext getExecutionContext() {
            return contextProvider.getExecutionContext();
        }

        @Override
        public void createPartControl(Composite parent) {
            super.createPartControl(parent);
            getAction(ITextEditorActionConstants.CONTEXT_PREFERENCES).setEnabled(false);
        }

        @Override
        public boolean isFoldingEnabled() {
            return false;
        }
    };
    editor.setHasVerticalRuler(showVerticalBar);
    try {
        editor.init(new SubEditorSite(partSite), new StringEditorInput(panelName, sqlText, true, GeneralUtils.getDefaultFileEncoding()));
    } catch (PartInitException e) {
        throw new DBException("Error initializing SQL panel", e);
    }
    editor.createPartControl(editorPH);
    editor.reloadSyntaxRules();
    TextViewer textViewer = editor.getTextViewer();
    textViewer.setData("editor", editor);
    TextEditorUtils.enableHostEditorKeyBindingsSupport(partSite, textViewer.getTextWidget());
    return textViewer;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) SubEditorSite(org.jkiss.dbeaver.ui.editors.SubEditorSite) DBException(org.jkiss.dbeaver.DBException) Composite(org.eclipse.swt.widgets.Composite) PartInitException(org.eclipse.ui.PartInitException) StringEditorInput(org.jkiss.dbeaver.ui.editors.StringEditorInput) TextViewer(org.eclipse.jface.text.TextViewer)

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