Search in sources :

Example 11 with IServiceLocator

use of org.eclipse.ui.services.IServiceLocator in project translationstudio8 by heartsome.

the class CommandsPropertyTester method test.

public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
    if (receiver instanceof IServiceLocator && args.length == 1 && args[0] instanceof String) {
        final IServiceLocator locator = (IServiceLocator) receiver;
        if (TOGGLE_PROPERTY_NAME.equals(property)) {
            final String commandId = args[0].toString();
            final ICommandService commandService = (ICommandService) locator.getService(ICommandService.class);
            final Command command = commandService.getCommand(commandId);
            final State state = command.getState(RegistryToggleState.STATE_ID);
            if (state != null) {
                return state.getValue().equals(expectedValue);
            }
        }
    }
    return false;
}
Also used : Command(org.eclipse.core.commands.Command) RegistryToggleState(org.eclipse.ui.handlers.RegistryToggleState) State(org.eclipse.core.commands.State) IServiceLocator(org.eclipse.ui.services.IServiceLocator) ICommandService(org.eclipse.ui.commands.ICommandService)

Example 12 with IServiceLocator

use of org.eclipse.ui.services.IServiceLocator in project tdq-studio-se by Talend.

the class AbstractOSGIServiceUtils method initService.

protected void initService(boolean isNeedDownload) {
    BundleContext context = CWMPlugin.getDefault().getBundleContext();
    if (context == null) {
        return;
    }
    ServiceReference serviceReference = context.getServiceReference(getServiceName());
    if (serviceReference != null) {
        setService(context, serviceReference);
    } else if (isNeedDownload) {
        if (!hasShowDownloadWizard) {
            // show download jar dialog
            IServiceLocator serviceLocator = PlatformUI.getWorkbench();
            ICommandService commandService = (ICommandService) serviceLocator.getService(ICommandService.class);
            try {
                Command command = commandService.getCommand(COMMAND_ID);
                command.executeWithChecks(new ExecutionEvent());
                hasShowDownloadWizard = true;
            } catch (Exception e) {
                log.error(e);
            }
        } else {
            log.error(Messages.getString(getMissingMessageName()));
        }
    }
}
Also used : Command(org.eclipse.core.commands.Command) ExecutionEvent(org.eclipse.core.commands.ExecutionEvent) IServiceLocator(org.eclipse.ui.services.IServiceLocator) ICommandService(org.eclipse.ui.commands.ICommandService) BundleContext(org.osgi.framework.BundleContext) ServiceReference(org.osgi.framework.ServiceReference)

Example 13 with IServiceLocator

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

the class NodeListControl method openNodeEditor.

protected void openNodeEditor(DBNNode node) {
    IServiceLocator serviceLocator = workbenchSite != null ? workbenchSite : UIUtils.getActiveWorkbenchWindow();
    NavigatorUtils.executeNodeAction(DBXTreeNodeHandler.Action.open, node, serviceLocator);
}
Also used : IServiceLocator(org.eclipse.ui.services.IServiceLocator)

Example 14 with IServiceLocator

use of org.eclipse.ui.services.IServiceLocator in project dbeaver by dbeaver.

the class NodeListControl method openNodeEditor.

protected void openNodeEditor(DBNNode node) {
    IServiceLocator serviceLocator = workbenchSite != null ? workbenchSite : UIUtils.getActiveWorkbenchWindow();
    NavigatorUtils.executeNodeAction(DBXTreeNodeHandler.Action.open, node, serviceLocator);
}
Also used : IServiceLocator(org.eclipse.ui.services.IServiceLocator)

Example 15 with IServiceLocator

use of org.eclipse.ui.services.IServiceLocator in project core by jcryptool.

the class ApplicationActionBarAdvisor method createWindowMenu.

private IMenuManager createWindowMenu() {
    MenuManager menu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_Window, IWorkbenchActionConstants.M_WINDOW);
    IServiceLocator serviceLocator = PlatformUI.getWorkbench();
    // create actions for "open perspective" menu
    perspectiveMenu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_Open_Perspective, // $NON-NLS-1$
    "openPerspective");
    perspectiveMenu.add(ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window));
    // create actions for "open view" menu
    // $NON-NLS-1$
    showViewMenu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_Show_View, "showView");
    showViewMenu.add(ContributionItemFactory.VIEWS_SHORTLIST.create(window));
    menu.add(perspectiveMenu);
    menu.add(showViewMenu);
    menu.add(new Separator());
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_CUSTOMIZE_PERSPECTIVE));
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_RESET_PERSPECTIVE));
    if (OS_MAC_OS_X.equalsIgnoreCase(OS)) {
        // hide the preferences action, Mac OS X adds this automatically
        hiddenMenu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_PREFERENCES));
    } else {
        menu.add(new Separator());
        menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.WINDOW_PREFERENCES));
    }
    menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
    return menu;
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IServiceLocator(org.eclipse.ui.services.IServiceLocator) Separator(org.eclipse.jface.action.Separator)

Aggregations

IServiceLocator (org.eclipse.ui.services.IServiceLocator)17 Command (org.eclipse.core.commands.Command)4 IMenuManager (org.eclipse.jface.action.IMenuManager)4 MenuManager (org.eclipse.jface.action.MenuManager)4 Separator (org.eclipse.jface.action.Separator)4 ICommandService (org.eclipse.ui.commands.ICommandService)4 ExecutionEvent (org.eclipse.core.commands.ExecutionEvent)3 ExecutionException (org.eclipse.core.commands.ExecutionException)3 GroupMarker (org.eclipse.jface.action.GroupMarker)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Job (org.eclipse.core.runtime.jobs.Job)2 RepositoryNode (org.eclipse.egit.ui.internal.repository.tree.RepositoryNode)2 Repository (org.eclipse.jgit.lib.Repository)2 IHandlerService (org.eclipse.ui.handlers.IHandlerService)2 IWorkbenchSiteProgressService (org.eclipse.ui.progress.IWorkbenchSiteProgressService)2 IOException (java.io.IOException)1 NotEnabledException (org.eclipse.core.commands.NotEnabledException)1 NotHandledException (org.eclipse.core.commands.NotHandledException)1 State (org.eclipse.core.commands.State)1 NotDefinedException (org.eclipse.core.commands.common.NotDefinedException)1