org.eclipse.ui.ide.IDE.getDefaultEditor()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.1k)|赞(0)|评价(0)|浏览(218)

本文整理了Java中org.eclipse.ui.ide.IDE.getDefaultEditor()方法的一些代码示例,展示了IDE.getDefaultEditor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。IDE.getDefaultEditor()方法的具体详情如下:
包路径:org.eclipse.ui.ide.IDE
类名称:IDE
方法名:getDefaultEditor

IDE.getDefaultEditor介绍

[英]Returns the default editor for a given file. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings.

A default editor id may be registered for a specific file using setDefaultEditor. If the given file has a registered default editor id the default editor will derived from it. If not, the default editor is determined by taking the file name for the file and obtaining the default editor for that name.
[中]返回给定文件的默认编辑器。此方法将尝试基于内容类型绑定以及传统名称/扩展绑定解析编辑器。
可以使用setDefaultEditor为特定文件注册默认编辑器id。如果给定文件具有注册的默认编辑器id,则默认编辑器将从中派生。如果不是,则通过获取文件名并获取该文件名的默认编辑器来确定默认编辑器。

代码示例

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

/**
 * Returns the default editor for a given file. This method will attempt to
 * resolve the editor based on content-type bindings as well as traditional
 * name/extension bindings.
 * <p>
 * A default editor id may be registered for a specific file using
 * <code>setDefaultEditor</code>. If the given file has a registered
 * default editor id the default editor will derived from it. If not, the
 * default editor is determined by taking the file name for the file and
 * obtaining the default editor for that name.
 * </p>
 *
 * @param file
 *            the file
 * @return the descriptor of the default editor, or <code>null</code> if
 *         not found
 */
public static IEditorDescriptor getDefaultEditor(IFile file) {
  return getDefaultEditor(file, true);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

.getEditorRegistry(), getDefaultEditor(file,
determineContentType));

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

getDefaultEditor(file, determineContentType), allowInteractive);

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

menuItem.setSelection(IDE.getDefaultEditor(fileResource) == null);
menuItem.setText(AntViewActionMessages.AntViewOpenWithMenu_Default_Editor_4);

代码示例来源:origin: org.eclipse/org.eclipse.search

private ITextEditor openNewTextEditor(IFile file, IWorkbenchPage activePage) throws PartInitException {
  IEditorDescriptor desc= IDE.getDefaultEditor(file);
  if (desc != null) {
    String editorID= desc.getId();
    IEditorPart editor;
    if (desc.isInternal()) {
      editor= activePage.openEditor(new FileEditorInput(file), editorID);
      if (editor instanceof ITextEditor) {
        if (editor instanceof IReusableEditor)
          fEditor= (IReusableEditor) editor;
        return (ITextEditor)editor;
      }
      activePage.closeEditor(editor, false);
    }
  }
  IEditorPart editor= activePage.openEditor(new FileEditorInput(file), "org.eclipse.ui.DefaultTextEditor"); //$NON-NLS-1$
  return (ITextEditor)editor;
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

final IEditorDescriptor preferredEditor= IDE.getDefaultEditor(file); // may be null

代码示例来源:origin: org.eclipse.platform/org.eclipse.ant.ui

IEditorDescriptor preferredEditor = IDE.getDefaultEditor(fileResource); // may be null

代码示例来源:origin: org.eclipse/org.eclipse.search

private ITextEditor openEditorReuse(Match marker) throws PartInitException {
  IWorkbenchPage page= SearchPlugin.getActivePage();
  IFile file= (IFile) marker.getElement();
  if (page == null)
    return null;
  ITextEditor textEditor= showOpenTextEditor(page, file);
  if (textEditor != null)
    return textEditor;
  String editorId= null;
  IEditorDescriptor desc= IDE.getDefaultEditor(file);
  if (desc != null && desc.isInternal())
    editorId= desc.getId();
  boolean isOpen= isEditorOpen(page, fEditor);
  boolean canBeReused= isOpen && !fEditor.isDirty() && !isPinned(fEditor);
  boolean showsSameInputType= fEditor != null && (editorId == null || fEditor.getSite().getId().equals(editorId));
  if (canBeReused) {
    if (showsSameInputType) {
      fEditor.setInput(new FileEditorInput(file));
      page.bringToTop(fEditor);
      return (ITextEditor) fEditor;
    }
    page.closeEditor(fEditor, false);
    fEditor= null;
  }
  return openNewTextEditor(file, page);
}

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

try {
  IEditorDescriptor defaultEditorDesc = IDE.getDefaultEditor(file);
  if (defaultEditorDesc != null
      && !defaultEditorDesc.isOpenExternal()) {

代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.ui.ide

IEditorDescriptor d = IDE.getDefaultEditor(file);
if (d != null)
  image = d.getImageDescriptor();

相关文章