当前位置: 首页>>代码示例>>Java>>正文


Java IServiceLocator.getService方法代码示例

本文整理汇总了Java中org.eclipse.ui.services.IServiceLocator.getService方法的典型用法代码示例。如果您正苦于以下问题:Java IServiceLocator.getService方法的具体用法?Java IServiceLocator.getService怎么用?Java IServiceLocator.getService使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.services.IServiceLocator的用法示例。


在下文中一共展示了IServiceLocator.getService方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createContributionItems

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
	IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class);
	if (menuService == null) {
		CloudFoundryPlugin
				.logError("Unable to retrieve Eclipse menu service. Cannot add Cloud Foundry context menus."); //$NON-NLS-1$
		return;
	}

	List<IAction> debugActions = getActions(menuService);
	for (IAction action : debugActions) {
		additions.addContributionItem(new ActionContributionItem(action), new Expression() {
			public EvaluationResult evaluate(IEvaluationContext context) {
				return EvaluationResult.TRUE;
			}

			public void collectExpressionInfo(ExpressionInfo info) {
			}
		});
	}
}
 
开发者ID:eclipse,项目名称:cft,代码行数:22,代码来源:AbstractMenuContributionFactory.java

示例2: createContributionItems

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
	IMenuService menuService = (IMenuService) serviceLocator.getService(IMenuService.class);
	if (menuService == null) {
		DockerFoundryPlugin
				.logError("Unable to retrieve Eclipse menu service. Cannot add Cloud Foundry context menus."); //$NON-NLS-1$
		return;
	}

	List<IAction> debugActions = getActions(menuService);
	for (IAction action : debugActions) {
		additions.addContributionItem(new ActionContributionItem(action), new Expression() {
			public EvaluationResult evaluate(IEvaluationContext context) {
				return EvaluationResult.TRUE;
			}

			public void collectExpressionInfo(ExpressionInfo info) {
			}
		});
	}
}
 
开发者ID:osswangxining,项目名称:dockerfoundry,代码行数:22,代码来源:AbstractMenuContributionFactory.java

示例3: performDrop

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public boolean performDrop(Object data) {
    IServiceLocator locator = Helper.getWB();
    ICommandService svc = (ICommandService)locator.getService(
            ICommandService.class);
    Command cmd = svc.getCommand(CMD_ID_MOVE_ENTRY);

    Map<String, String> params = new HashMap<>();

    params.put("source", data.toString());

    TreeNode en = (TreeNode)getCurrentTarget();
    EntryData ed = EntryData.of(en);
    params.put("target", String.valueOf(ed.entryID()));

    try {
        cmd.executeWithChecks(
        		new ExecutionEvent(cmd, params, getCurrentEvent(), null));
    } catch (ExecutionException | NotDefinedException | NotEnabledException
            | NotHandledException e) {
        throw new RuntimeException(e);
    }
    return true;
}
 
开发者ID:insweat,项目名称:hssd,代码行数:25,代码来源:DropEntryHandler.java

示例4: MultiPageToolbarEditorSite

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
/**
 * Creates a site for the given editor nested within the given multi-page editor.
 * 
 * @param multiPageEditor
 *          the multi-page editor
 * @param editor
 *          the nested editor
 */
public MultiPageToolbarEditorSite(MultiPageToolbarEditorPart multiPageEditor, IEditorPart editor) {
	Assert.isNotNull(multiPageEditor);
	Assert.isNotNull(editor);
	this.multiPageEditor = multiPageEditor;
	this.editor = editor;

	final IServiceLocator parentServiceLocator = multiPageEditor.getSite();
	IServiceLocatorCreator slc = (IServiceLocatorCreator) parentServiceLocator.getService(IServiceLocatorCreator.class);
	this.serviceLocator = (ServiceLocator) slc.createServiceLocator(multiPageEditor.getSite(), null, new IDisposable() {
		public void dispose() {
			// Fix for ensuring compilation in E4
			getMultiPageEditor().close();
		}
	});

	initializeDefaultServices();
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:26,代码来源:MultiPageToolbarEditorSite.java

示例5: run

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void run(final IAction action) {

	// Obtain IServiceLocator implementer, e.g. from PlatformUI.getWorkbench():
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	// or a site from within a editor or view:
	// IServiceLocator serviceLocator = getSite();

	ICommandService commandService = serviceLocator.getService(ICommandService.class);

	try {
		// Lookup commmand with its ID
		Command command = commandService.getCommand("org.eclipse.xtext.ui.shared.OpenXtextElementCommand");

		// Optionally pass a ExecutionEvent instance, default no-param arg creates blank event
		command.executeWithChecks(new ExecutionEvent());

	} catch (Exception e) {

		// Replace with real-world exception handling
		e.printStackTrace();
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:25,代码来源:DelegateForAllElements.java

示例6: updateElement

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void updateElement(UIElement element, Map parameters) {
	IServiceLocator serviceLocator = element.getServiceLocator();
	IPartService partService = (IPartService)serviceLocator.getService(IPartService.class);
	partService.addPartListener(ACTIVE_EDITOR_LISTENER); // adding the same listener multiple times is ok and ignored
	PlanModifierFactory elementFactory = (PlanModifierFactory)serviceLocator.getService(PlanModifierFactory.class);
	IPlanModifier planModifier = getCurrentPlanModifier(parameters);
	PlanModifierFactory planFactory = PlanModifierRegistry.getInstance().getFactory(planModifier);
	if (elementFactory != null) {
		if (elementFactory == planFactory) {
			element.setChecked(true);
		} else {
			element.setChecked(false);
		}
	} else if (PLAN_MODIFIER_FACTORIES.size() == 2) {
		boolean checked = !(planModifier instanceof DirectPlanModifier);
		element.setChecked(checked);
		if (planFactory != null) {
			element.setTooltip(planFactory.getName());
			element.setIcon(planFactory.getImageDescriptor());
		}
	}
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:24,代码来源:PlanModifierHandler.java

示例7: callRuleGenerationCommand

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
private boolean callRuleGenerationCommand(EPackage ePack, PatternInstance pattern, IPath iPath) {
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	ICommandService commandService = serviceLocator.getService(ICommandService.class);
	IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
	Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation.rule");
	try {
		IParameter parameter = command.getParameter(MACLCommandContext.ID);
		String contextId = UUID.randomUUID().toString();
		Activator.put(contextId, context);
		Parameterization parameterization = new Parameterization(parameter, contextId);
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
		return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
		
	} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
		return false;
	}
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:18,代码来源:MACLIncQueryGenerator.java

示例8: execute

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public boolean execute(EPackage ePack, PatternInstance pattern, IPath iPath) {
	IServiceLocator serviceLocator = PlatformUI.getWorkbench();
	ICommandService commandService = serviceLocator.getService(ICommandService.class);
	IHandlerService handlerService = serviceLocator.getService(IHandlerService.class);
	Command command = commandService.getCommand("org.mondo.collaboration.security.macl.tao.generation");
	try {
		IParameter parameter = command.getParameter(MACLCommandContext.ID);
		MACLCommandContext context = new MACLCommandContext(ePack, pattern, iPath);
		String contextId = UUID.randomUUID().toString();
		Activator.put(contextId, context);
		Parameterization parameterization = new Parameterization(parameter, contextId);
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, new Parameterization[] { parameterization });
		return (Boolean) handlerService.executeCommand(parameterizedCommand, null);
		
	} catch (ExecutionException | NotDefinedException | NotEnabledException | NotHandledException e1) {
		return false;
	}
}
 
开发者ID:FTSRG,项目名称:mondo-collab-framework,代码行数:20,代码来源:MACLPatternImplementation.java

示例9: test

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
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;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:20,代码来源:CommandsPropertyTester.java

示例10: loadModelBackend

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
private static BindingManager loadModelBackend(IServiceLocator locator) {
	IBindingService bindingService = (IBindingService) locator.getService(IBindingService.class);
	BindingManager bindingManager = new BindingManager(new ContextManager(), new CommandManager());
	final Scheme[] definedSchemes = bindingService.getDefinedSchemes();
	try {
		Scheme modelActiveScheme = null;
		for (int i = 0; i < definedSchemes.length; i++) {
			final Scheme scheme = definedSchemes[i];
			final Scheme copy = bindingManager.getScheme(scheme.getId());
			copy.define(scheme.getName(), scheme.getDescription(), scheme.getParentId());
			if (definedSchemes[i] == bindingService.getActiveScheme()) {
				modelActiveScheme = copy;
			}
		}
		bindingManager.setActiveScheme(modelActiveScheme);
	} catch (final NotDefinedException e) {
		StatusManager.getManager()
				.handle(new Status(IStatus.WARNING, WorkbenchPlugin.PI_WORKBENCH,
						"Keys page found an undefined scheme", e)); //$NON-NLS-1$
	}
	bindingManager.setLocale(bindingService.getLocale());
	bindingManager.setPlatform(bindingService.getPlatform());
	bindingManager.setBindings(bindingService.getBindings());
	return bindingManager;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:26,代码来源:KeyController2.java

示例11: updateElement

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public final void updateElement(UIElement element, Map parameters) {
	IServiceLocator serviceLocator = element.getServiceLocator();
	IPartService partService = (IPartService) serviceLocator
			.getService(IPartService.class);

	installListeners(partService);
	updateEnablement();
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:11,代码来源:AbstractTimelineCommandHandler.java

示例12: createContributionItems

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator,
		IContributionRoot additions) {
    
    ISelectionService service = (ISelectionService)serviceLocator.getService(ISelectionService.class);
       ISelection selection = service.getSelection();
       if (selection instanceof IStructuredSelection) {
           // TODO check for all elements in the selection
           Object selectedObject = ((IStructuredSelection)selection).getFirstElement();            
   		Map<String, IConfigurationElement> extensions = extensionPointLauncher.getExtensions();
           for (String name: extensions.keySet()) {
   		    IConfigurationElement extension = extensions.get(name);
   		    String enableFor = extension.getAttribute("enableFor");
               if (enableFor != null) {
                   try {
                       Class<?> enableForClass = Thread.currentThread().getContextClassLoader().loadClass(enableFor);
                       if (enableForClass.isAssignableFrom(selectedObject.getClass())) {
                           addCommand(serviceLocator, additions, name);    
                       }
                   } catch (ClassNotFoundException e) {
                       logger.log(ILogger.WARNING, "enablefor class " + enableFor + " could not found.", e);
                   }
               } else {                    
                   addCommand(serviceLocator, additions, name);
               }
   		}		
       }
}
 
开发者ID:markus1978,项目名称:clickwatch,代码行数:29,代码来源:PredefinedAnalysis.java

示例13: initialize

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void initialize(IServiceLocator serviceLocator) {
	handlerService = serviceLocator.getService(IHandlerService.class);
}
 
开发者ID:eclipse,项目名称:tm4e,代码行数:5,代码来源:ThemeContribution.java

示例14: findSourceProvider

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
/**
 * Finds a source provider using the specified locator (for example, a
 * workbench window)
 */
@SuppressWarnings("unchecked")
public static <T> T findSourceProvider(IServiceLocator locator, String sourceName, Class<T> expectedClass) {
    ISourceProviderService service = (ISourceProviderService) locator.getService(ISourceProviderService.class);
    return (T) service.getSourceProvider(sourceName);
}
 
开发者ID:yamcs,项目名称:yamcs-studio,代码行数:10,代码来源:RCPUtils.java

示例15: createContributionItems

import org.eclipse.ui.services.IServiceLocator; //导入方法依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator,
		IContributionRoot additions) {
	// TODO Auto-generated method stub
	
	ISelectionService serv = (ISelectionService) serviceLocator.getService(ISelectionService.class);
	ISelection selection = serv.getSelection();
	TreeSelection treeselection = (TreeSelection)selection;
	Object firstelement = treeselection.getFirstElement();
		
	if(firstelement instanceof IProject || firstelement instanceof IFolder){
		IProject pro = null;
		if(firstelement instanceof IProject)
			pro = (IProject)firstelement;	
		if(firstelement instanceof IFolder)
			pro = ((IFolder)firstelement).getProject();			
		try {
			IProjectNature nature = pro.getNature(WTNewProjectNature.ID);
			if(nature==null)
				return;
		} catch (CoreException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		MenuManager menu = new MenuManager();
		menu.setMenuText("New WT");			
		if(firstelement instanceof IProject)
		{
			CommandContributionItemParameter pcommand = new CommandContributionItemParameter(serviceLocator,
		"", "org.eclipse.ui.newWizard", CommandContributionItem.STYLE_PUSH);
			pcommand.parameters = new HashMap<String,String>();
			pcommand.parameters.put("newWizardId", "org.mondo.wt.cstudy.collectioninputoutput.collectioninputoutputNewFile");
			CommandContributionItem itemitsInputOutput = new CommandContributionItem(pcommand);
			menu.add(itemitsInputOutput);
			pcommand.parameters.put("newWizardId", "org.mondo.wt.cstudy.mainsubsystem.mainsubsystemNewFile");
			CommandContributionItem itemitsSubsystems = new CommandContributionItem(pcommand);
			menu.add(itemitsSubsystems);
		}
		else if(firstelement instanceof IFolder)
		{
			IFolder fol = (IFolder)firstelement;
			IPath filePath = fol.getFullPath().append("/"+fol.getName().concat(".xmi"));
			XMI_File file = new XMI_File(URI.createPlatformResourceURI(filePath.toString(), true), true);
			EObject root = null;
			try {
				root = file.Get_Root();
			} catch (IOException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			}
			
			if(root!=null)
			{					
			}				
		}
		additions.addContributionItem(menu, null);
	}
}
 
开发者ID:mondo-project,项目名称:mondo-demo-wt,代码行数:60,代码来源:CreateMenu.java


注:本文中的org.eclipse.ui.services.IServiceLocator.getService方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。