Search in sources :

Example 56 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project liferay-ide by liferay.

the class IDEFormEditor method setSelection.

public void setSelection(ISelection selection) {
    IWorkbenchPartSite site = getSite();
    site.getSelectionProvider().setSelection(selection);
    getContributor().updateSelectableActions(selection);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite)

Example 57 with IWorkbenchPartSite

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

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

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

the class ResultSetHandlerToggleMode method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    if (element.getServiceLocator() instanceof IWorkbenchPartSite) {
        IWorkbenchPartSite partSite = (IWorkbenchPartSite) element.getServiceLocator();
        if (partSite.getPart() instanceof IResultSetContainer) {
            IResultSetController rsv = ((IResultSetContainer) partSite.getPart()).getResultSetController();
            if (rsv != null) {
                if (!rsv.isRecordMode()) {
                    element.setText("Switch to record mode");
                    element.setChecked(true);
                } else {
                    element.setText("Switch to grid mode");
                    element.setChecked(false);
                }
            }
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IResultSetContainer(org.jkiss.dbeaver.ui.controls.resultset.IResultSetContainer) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)

Example 59 with IWorkbenchPartSite

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

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

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

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)

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