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


Java IEditorSite.getService方法代码示例

本文整理汇总了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);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:36,代码来源:ServiceUtils.java

示例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);
       
}
 
开发者ID:Talend,项目名称:avro-schema-editor,代码行数:31,代码来源:AvroSchemaEditorPart.java

示例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);
}
 
开发者ID:RepreZen,项目名称:KaiZen-OpenAPI-Editor,代码行数:7,代码来源:JsonEditor.java


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