Search in sources :

Example 16 with IServiceLocator

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

the class ApplicationActionBarAdvisor method createFileMenu.

private IMenuManager createFileMenu() {
    MenuManager menu = new MenuManager(Messages.applicationActionBarAdvisor_Menu_File, IWorkbenchActionConstants.M_FILE);
    IServiceLocator serviceLocator = PlatformUI.getWorkbench();
    // $NON-NLS-1$
    menu.add(new MenuManager(Messages.applicationActionBarAdvisor_Menu_New_File, "newfile"));
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START));
    menu.add(new Separator());
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_CLOSE));
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_CLOSE_ALL));
    menu.add(new Separator());
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_SAVE));
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_SAVE_AS));
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_SAVE_ALL));
    menu.add(new Separator());
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_PRINT));
    menu.add(ContributionItemFactory.REOPEN_EDITORS.create(window));
    menu.add(new GroupMarker(IWorkbenchActionConstants.MRU));
    menu.add(new Separator());
    menu.add(createContributionItem(serviceLocator, null, IWorkbenchCommandConstants.FILE_EXIT));
    menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END));
    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) GroupMarker(org.eclipse.jface.action.GroupMarker) Separator(org.eclipse.jface.action.Separator)

Example 17 with IServiceLocator

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

the class RecordPropertyTester method test.

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    final IServiceLocator locator = (IServiceLocator) receiver;
    final ICommandService commandService = (ICommandService) locator.getService(ICommandService.class);
    // $NON-NLS-1$
    final Command command = commandService.getCommand("org.jcryptool.actions.recordCommand");
    // $NON-NLS-1$
    return (Boolean) command.getState("org.jcryptool.actions.recordCommand.toggleState").getValue();
}
Also used : Command(org.eclipse.core.commands.Command) IServiceLocator(org.eclipse.ui.services.IServiceLocator) ICommandService(org.eclipse.ui.commands.ICommandService)

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