當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。