本文整理汇总了Java中org.eclipse.ui.services.IServiceLocator类的典型用法代码示例。如果您正苦于以下问题:Java IServiceLocator类的具体用法?Java IServiceLocator怎么用?Java IServiceLocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IServiceLocator类属于org.eclipse.ui.services包,在下文中一共展示了IServiceLocator类的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) {
}
});
}
}
示例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) {
}
});
}
}
示例3: create
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public Object create(Class serviceInterface, IServiceLocator parentLocator,
IServiceLocator locator) {
if(disposed) {
return null;
}
Object rv = serviceRegistry.get(serviceInterface);
if(rv == null) {
if(serviceInterface == IDService.class) {
rv = new IDService();
serviceRegistry.put(serviceInterface, rv);
}
}
return rv;
}
示例4: 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;
}
示例5: createContributionItems
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@Override
public void createContributionItems(final IServiceLocator serviceLocator,
final IContributionRoot additions)
{ // See http://blog.vogella.com/2009/12/03/commands-menu-runtime
// for ExtensionContributionFactory example
try
{
final String setting = Preferences.getTopDisplays();
final List<DisplayInfo> displays = DisplayInfoXMLUtil.fromDisplaysXML(setting);
for (DisplayInfo display : displays)
{
final IAction action = new OpenDisplayAction(display);
final IContributionItem item = new ActionContributionItem(action);
additions.addContributionItem(item, null);
}
}
catch (Exception ex)
{
logger.log(Level.WARNING, "Cannot create 'top displays'", ex);
}
}
示例6: createContributionItems
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@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);
}
}
示例7: createContributionItems
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator,
IContributionRoot additions) {
CommandContributionItemParameter toggleWatchpointParam = new CommandContributionItemParameter(serviceLocator, null, "org.eclipse.debug.ui.commands.ToggleWatchpoint", CommandContributionItem.STYLE_PUSH);
toggleWatchpointParam.icon = DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT);
toggleWatchpointParam.disabledIcon = DebugUITools.getImageDescriptor(IDebugUIConstants.IMG_OBJS_WATCHPOINT_DISABLED);
toggleWatchpointParam.label = "Add Watchpoint";
CommandContributionItem toggleWatchpoint = new CommandContributionItem(toggleWatchpointParam);
Expression toggleWatchpointVisible = new Expression() {
@Override
public EvaluationResult evaluate(IEvaluationContext context)
throws CoreException {
return EvaluationResult.valueOf((context.getVariable("activeEditor") instanceof BfEditor));
}
};
additions.addContributionItem(toggleWatchpoint, toggleWatchpointVisible);
}
示例8: createContributionItems
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@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();
}
}
}
示例9: 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();
}
示例10: createPartControl
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
/**
* The <code>MultiPageEditor</code> implementation of this <code>IWorkbenchPart</code> method creates the control for
* the multi-page editor by calling <code>createContainer</code>, then <code>createPages</code>. Subclasses should
* implement <code>createPages</code> rather than overriding this method.
*
* @param parent
* The parent in which the editor should be created; must not be <code>null</code>.
*/
public final void createPartControl(Composite parent) {
Composite pageContainer = createPageContainer(parent);
this.container = createContainer(pageContainer);
createPages();
// set the active page (page 0 by default), unless it has already been
// done
if (getActivePage() == -1) {
setActivePage(0);
IEditorPart part = getEditor(0);
if (part != null) {
final IServiceLocator serviceLocator = part.getEditorSite();
if (serviceLocator instanceof INestable) {
activeServiceLocator = (INestable) serviceLocator;
activeServiceLocator.activate();
}
}
}
initializePageSwitching();
initializeSubTabSwitching();
}
示例11: dispose
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
public void dispose() {
pageChangeListeners.clear();
for (IEditorPart editor : nestedEditors) {
disposePart(editor);
}
nestedEditors.clear();
if (pageContainerSite instanceof IDisposable) {
((IDisposable) pageContainerSite).dispose();
pageContainerSite = null;
}
for (IServiceLocator sl : pageSites) {
if (sl instanceof IDisposable) {
((IDisposable) sl).dispose();
}
}
pageSites.clear();
super.dispose();
}
示例12: create
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@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) {
System.out.println("Exception in initializing injector: " + e.getMessage());
}
}
return serviceProvider.get(serviceInterface);
}
示例13: 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();
}
}
示例14: createContributionItems
import org.eclipse.ui.services.IServiceLocator; //导入依赖的package包/类
@Override
public void createContributionItems(IServiceLocator serviceLocator, IContributionRoot additions) {
for (PlanModifierFactory factory : PlanModifierRegistry.getInstance().getModifierFactories()) {
String name = factory.getName();
ImageDescriptor imageDescriptor = factory.getImageDescriptor();
String id = null;
String commandId = TEMPORAL_MODIFICATION_COMMAND_ID;
Map<?, ?> parameters = Collections.singletonMap("name", name);
ImageDescriptor icon = imageDescriptor;
String label = name;
String tooltip = name;
FactoryServiceLocator locator = new FactoryServiceLocator(serviceLocator, factory);
CommandContributionItemParameter parameter = new CommandContributionItemParameter(locator, id, commandId, parameters, icon, null, null, label, null, tooltip, SWT.RADIO, null, false);
IContributionItem item = new CommandContributionItem(parameter);
Expression visibleWhen = null;
additions.addContributionItem(item, visibleWhen);
}
}
示例15: 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());
}
}
}