本文整理汇总了Java中org.eclipse.ui.IEditorSite.getService方法的典型用法代码示例。如果您正苦于以下问题:Java IEditorSite.getService方法的具体用法?Java IEditorSite.getService怎么用?Java IEditorSite.getService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IEditorSite
的用法示例。
在下文中一共展示了IEditorSite.getService方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getService
import org.eclipse.ui.IEditorSite; //导入方法依赖的package包/类
/**
* Returns an OSGi service from {@link ExecutionEvent}. It looks up a service in the following
* locations (if exist) in the given order:
*
* {@code HandlerUtil.getActiveSite(event)}
* {@code HandlerUtil.getActiveEditor(event).getEditorSite()}
* {@code HandlerUtil.getActiveEditor(event).getSite()}
* {@code HandlerUtil.getActiveWorkbenchWindow(event)}
* {@code PlatformUI.getWorkbench()}
*/
public static <T> T getService(ExecutionEvent event, Class<T> api) {
IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
if (activeSite != null) {
return activeSite.getService(api);
}
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor != null) {
IEditorSite editorSite = activeEditor.getEditorSite();
if (editorSite != null) {
return editorSite.getService(api);
}
IWorkbenchPartSite site = activeEditor.getSite();
if (site != null) {
return site.getService(api);
}
}
IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
if (workbenchWindow != null) {
return workbenchWindow.getService(api);
}
return PlatformUI.getWorkbench().getService(api);
}
示例2: init
import org.eclipse.ui.IEditorSite; //导入方法依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
setSite(site);
setInput(input);
setTitleImage(input.getImageDescriptor().createImage());
setPartName(input.getName());
// initialize the context bindings for this editor. Useful for shortcuts
IContextService service = (IContextService) site.getService(IContextService.class);
service.activateContext(CONTEXT_ID);
// get the input
avroSchema = getAvroSchema();
// load the configurations
IEditorConfiguration editorConfiguration = loadEditorConfiguration();
SchemaViewerConfiguration schemaViewerConfiguration = loadSchemaViewerConfiguration();
AttributesConfiguration attributesConfiguration = loadAttributesConfiguration();
// create and configure the main component
editor = new AvroSchemaEditor(input.getName(), getContextId(), this);
editor.setEditorConfiguration(editorConfiguration);
editor.setSchemaViewerConfiguration(schemaViewerConfiguration);
editor.setAttributesConfiguration(attributesConfiguration);
editor.setInput(avroSchema);
editor.addDirtyListener(this);
}
示例3: init
import org.eclipse.ui.IEditorSite; //导入方法依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
super.init(site, input);
IContextService contextService = (IContextService) site.getService(IContextService.class);
contextService.activateContext(CONTEXT);
}