类org.eclipse.ui.services.IServiceLocator源码实例Demo

下面列出了怎么用org.eclipse.ui.services.IServiceLocator的API类实例代码及写法,或者点击链接到github查看源代码。


@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
  ITextEditor editor = (ITextEditor)
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
  IVerticalRulerInfo rulerInfo = editor.getAdapter(IVerticalRulerInfo.class);

  try {
    List<IMarker> markers = getMarkers(editor, rulerInfo);
    additions.addContributionItem(new ReviewMarkerMenuContribution(editor, markers), null);
    if (!markers.isEmpty()) {
      additions.addContributionItem(new Separator(), null);
    }
  } catch (CoreException e) {
    AppraiseUiPlugin.logError("Error creating marker context menus", e);
  }
}
 
源代码2 项目: EasyShell   文件: DefineCommands.java

@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
    MenuDataList items = MenuDataStore.instance().getEnabledCommandMenuDataList();
    for (MenuData item : items) {
        ResourceType resTypeWanted = getWantedResourceType();
        ResourceType resTypeSupported;
        try {
            resTypeSupported = item.getCommandData().getResourceType();
            if ((resTypeSupported == ResourceType.resourceTypeFileOrDirectory)
                    || (resTypeSupported == resTypeWanted)) {
                addItem(serviceLocator, additions, item.getNameExpanded(),
                        "de.anbos.eclipse.easyshell.plugin.commands.execute",
                        Utils.getParameterMapFromMenuData(item), item.getImageId(),
                        true);
            }
        } catch (UnknownCommandID e) {
            e.logInternalError();
        }
    }
}
 
源代码3 项目: gama   文件: LabelProviderFactory.java

@SuppressWarnings ("unchecked")
@Override
public Object create(final Class serviceInterface, final IServiceLocator parentLocator,
		final IServiceLocator locator) {
	if (serviceProvider == null) {
		// if (dependencyInjector != null)
		// return dependencyInjector.getInstance(c);
		try {
			serviceProvider = IResourceServiceProvider.Registry.INSTANCE
					.getResourceServiceProvider(URI.createPlatformResourceURI("dummy/dummy.gaml", false));
		} catch (final Exception e) {
			DEBUG.ERR("Exception in initializing injector: " + e.getMessage());
		}
	}
	return serviceProvider.get(serviceInterface);
}
 

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;
}
 

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;
}
 
源代码6 项目: tmxeditor8   文件: KeyController2.java

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;
}
 

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;
}
 
源代码8 项目: tmxeditor8   文件: KeyController2.java

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;
}
 
源代码9 项目: neoscada   文件: KeyInstanceProvider.java

@Override
public void initialize ( final IServiceLocator locator )
{
    super.initialize ( locator );
    this.mgr = KeyInstanceManager.getInstance ( Display.getCurrent () );
    this.mgr.addStatusListener ( this );
}
 
源代码10 项目: depan   文件: WizardMenuContributions.java

private IContributionItem buildWizardItem(
    IServiceLocator srvcLocator, String planId,
    LayoutPlanDocument<? extends LayoutPlan> planDoc) {
  String name = planDoc.getName();
  String id = MessageFormat.format("{0}.{1}", MENU_ROOT, name); 
  int style = CommandContributionItem.STYLE_PUSH;

  Map<String, String> parameters = LayoutNodesHandler.buildParameters(planId);
  IContributionItem result = new CommandContributionItem(
      new CommandContributionItemParameter(srvcLocator, id,
          LayoutNodesHandler.LAYOUT_COMMAND, parameters, null, null, null, name,
          null, null, style, null, false));

  return result;
}
 

@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
  ITextEditor editor = (ITextEditor)
      PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();

  additions.addContributionItem(new TextEditorContextMenuContribution(editor), null);
}
 
源代码12 项目: EasyShell   文件: DefineCommands.java

private void addItem(IServiceLocator serviceLocator, IContributionRoot additions, String commandLabel,
        String commandId, Map<String, Object> commandParamametersMap, String commandImageId, boolean visible) {
    CommandContributionItemParameter param = new CommandContributionItemParameter(serviceLocator, "", commandId,
            SWT.PUSH);
    param.label = commandLabel;
    param.icon = Activator.getImageDescriptor(commandImageId);
    param.parameters = commandParamametersMap;
    CommandContributionItem item = new CommandContributionItem(param);
    item.setVisible(visible);
    additions.addContributionItem(item, null);
}
 
源代码13 项目: gama   文件: MetaDataServiceFactory.java

@Override
public Object create(final Class serviceInterface, final IServiceLocator parentLocator,
		final IServiceLocator locator) {
	if (IFileMetaDataProvider.class.equals(serviceInterface))
		return FileMetaDataProvider.getInstance();
	return null;
}
 
源代码14 项目: translationstudio8   文件: KeyController2.java

public void init(IServiceLocator locator, List<String> lstRemove) {
	getEventManager().clear();
	this.serviceLocator = locator;
//	filterDupliteBind();
	fBindingManager = loadModelBackend(serviceLocator);
	contextModel = new ContextModel(this);
	contextModel.init(serviceLocator);
	fSchemeModel = new SchemeModel(this);
	fSchemeModel.init(fBindingManager);
	bindingModel = new BindingModel2(this);
	bindingModel.init(serviceLocator, fBindingManager, contextModel);

	HashSet<BindingElement> set = bindingModel.getBindings();
	Iterator<BindingElement> iterator = set.iterator();
	while (iterator.hasNext()) {
		BindingElement bindingElement = iterator.next();
		if (lstRemove.contains(bindingElement.getId())) {
			iterator.remove();
		}
	}
	bindingModel.setBindings(set);
	Map<Binding, BindingElement> mapBBe = bindingModel.getBindingToElement();
	Iterator<Entry<Binding, BindingElement>> it = mapBBe.entrySet().iterator();
	while (it.hasNext()) {
		Entry<Binding, BindingElement> entry = (Entry<Binding, BindingElement>) it.next();
		if (lstRemove.contains(entry.getValue().getId())) {
			it.remove();
		}
	}
	bindingModel.setBindingToElement(mapBBe);

	conflictModel = new ConflictModel2(this);
	conflictModel.init(fBindingManager, bindingModel);
	addSetContextListener();
	addSetBindingListener();
	addSetConflictListener();
	addSetKeySequenceListener();
	addSetSchemeListener();
	addSetModelObjectListener();
}
 
源代码15 项目: dawnsci   文件: ImageServiceMock.java

@Override
public Object create(@SuppressWarnings("rawtypes") Class serviceInterface, IServiceLocator parentLocator, IServiceLocator locator) {
	
	if (serviceInterface==IImageService.class) {
		return new ImageServiceMock();
	} 
	return null;
}
 
源代码16 项目: dawnsci   文件: PlotImageServiceMock.java

@Override
public Object create(Class serviceInterface, IServiceLocator parentLocator,
		IServiceLocator locator) {
	
	if (serviceInterface==IPlotImageService.class) {
		return new PlotImageServiceMock();
	} else if (serviceInterface==IFileIconService.class) {
		return new PlotImageServiceMock();
	}
	return null;
}
 
源代码17 项目: tmxeditor8   文件: KeyController2.java

public void init(IServiceLocator locator, List<String> lstRemove) {
	getEventManager().clear();
	this.serviceLocator = locator;
//	filterDupliteBind();
	fBindingManager = loadModelBackend(serviceLocator);
	contextModel = new ContextModel(this);
	contextModel.init(serviceLocator);
	fSchemeModel = new SchemeModel(this);
	fSchemeModel.init(fBindingManager);
	bindingModel = new BindingModel2(this);
	bindingModel.init(serviceLocator, fBindingManager, contextModel);

	HashSet<BindingElement> set = bindingModel.getBindings();
	Iterator<BindingElement> iterator = set.iterator();
	while (iterator.hasNext()) {
		BindingElement bindingElement = iterator.next();
		if (lstRemove.contains(bindingElement.getId())) {
			iterator.remove();
		}
	}
	bindingModel.setBindings(set);
	Map<Binding, BindingElement> mapBBe = bindingModel.getBindingToElement();
	Iterator<Entry<Binding, BindingElement>> it = mapBBe.entrySet().iterator();
	while (it.hasNext()) {
		Entry<Binding, BindingElement> entry = (Entry<Binding, BindingElement>) it.next();
		if (lstRemove.contains(entry.getValue().getId())) {
			it.remove();
		}
	}
	bindingModel.setBindingToElement(mapBBe);

	conflictModel = new ConflictModel2(this);
	conflictModel.init(fBindingManager, bindingModel);
	addSetContextListener();
	addSetBindingListener();
	addSetConflictListener();
	addSetKeySequenceListener();
	addSetSchemeListener();
	addSetModelObjectListener();
}
 
源代码18 项目: tmxeditor8   文件: KeyController2.java

public void init(IServiceLocator locator, List<String> lstRemove) {
	getEventManager().clear();
	this.serviceLocator = locator;
//	filterDupliteBind();
	fBindingManager = loadModelBackend(serviceLocator);
	contextModel = new ContextModel(this);
	contextModel.init(serviceLocator);
	fSchemeModel = new SchemeModel(this);
	fSchemeModel.init(fBindingManager);
	bindingModel = new BindingModel2(this);
	bindingModel.init(serviceLocator, fBindingManager, contextModel);

	HashSet<BindingElement> set = bindingModel.getBindings();
	Iterator<BindingElement> iterator = set.iterator();
	while (iterator.hasNext()) {
		BindingElement bindingElement = iterator.next();
		if (lstRemove.contains(bindingElement.getId())) {
			iterator.remove();
		}
	}
	bindingModel.setBindings(set);
	Map<Binding, BindingElement> mapBBe = bindingModel.getBindingToElement();
	Iterator<Entry<Binding, BindingElement>> it = mapBBe.entrySet().iterator();
	while (it.hasNext()) {
		Entry<Binding, BindingElement> entry = (Entry<Binding, BindingElement>) it.next();
		if (lstRemove.contains(entry.getValue().getId())) {
			it.remove();
		}
	}
	bindingModel.setBindingToElement(mapBBe);

	conflictModel = new ConflictModel2(this);
	conflictModel.init(fBindingManager, bindingModel);
	addSetContextListener();
	addSetBindingListener();
	addSetConflictListener();
	addSetKeySequenceListener();
	addSetSchemeListener();
	addSetModelObjectListener();
}
 
源代码19 项目: goclipse   文件: CommandsHelper.java

public static CommandContributionItemParameter contribItemParameter(IServiceLocator svLocator, String commandId) {
	return new CommandContributionItemParameter(svLocator, 
		commandId, 
		commandId, 
		CommandContributionItem.STYLE_PUSH
	);
}
 
源代码20 项目: goclipse   文件: CommandsHelper.java

public static CommandContributionItemParameter contribItemParameter2(IServiceLocator svLocator, String commandId,
		ImageDescriptor icon) {
	CommandContributionItemParameter cip = new CommandContributionItemParameter(svLocator, 
		commandId, 
		commandId, 
		CommandContributionItem.STYLE_PUSH
	);
	cip.icon = icon;
	return cip;
}
 
源代码21 项目: goclipse   文件: CommandsHelper.java

public static CommandContributionItemParameter contribItemParameter(IServiceLocator svLocator, String commandId,
		String contribId) {
	return new CommandContributionItemParameter(svLocator, 
		contribId, 
		commandId, 
		CommandContributionItem.STYLE_PUSH
	);
}
 
源代码22 项目: neoscada   文件: ProfilesContribution.java

@Override
public void initialize ( final IServiceLocator serviceLocator )
{
    this.serviceLocator = serviceLocator;
}
 
源代码23 项目: tm4e   文件: ThemeContribution.java

@Override
public void initialize(IServiceLocator serviceLocator) {
	handlerService = serviceLocator.getService(IHandlerService.class);
}
 

private static boolean argumentsValid( Object receiver, String property, Object[] args ) {
  return receiver instanceof IServiceLocator
      && IS_TRUE.equals( property )
      && args.length == 1
      && args[ 0 ] instanceof String;
}
 
源代码25 项目: eclipse-extras   文件: ServiceHelper.java

public static <T> T getService( IServiceLocator serviceLocator, Class<T> api ){
  return api.cast( serviceLocator.getService( api ) );
}
 

@Before
public void setUp() {
  serviceLocator = mock( IServiceLocator.class );
  preferenceStore = new PreferenceStore();
  propertyTester = new PreferencePropertyTester( preferenceStore );
}
 
源代码27 项目: gama   文件: ModelRunner.java

@Override
public Object create(final Class serviceInterface, final IServiceLocator parentLocator,
		final IServiceLocator locator) {
	return this;
}
 
源代码28 项目: gama   文件: EditorMenu.java

@Override
public void initialize(final IServiceLocator serviceLocator) {}
 
源代码29 项目: gama   文件: UserDialogFactory.java

@Override
public Object create(final Class serviceInterface, final IServiceLocator parentLocator,
		final IServiceLocator locator) {
	return this;
}
 
源代码30 项目: gama   文件: StatusDisplayerFactory.java

@Override
public Object create(final Class serviceInterface, final IServiceLocator parentLocator,
		final IServiceLocator locator) {
	return displayer;
}
 
 类所在包
 类方法
 同包方法