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


Java JavaPlugin.getActivePage方法代码示例

本文整理汇总了Java中org.eclipse.jdt.internal.ui.JavaPlugin.getActivePage方法的典型用法代码示例。如果您正苦于以下问题:Java JavaPlugin.getActivePage方法的具体用法?Java JavaPlugin.getActivePage怎么用?Java JavaPlugin.getActivePage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.internal.ui.JavaPlugin的用法示例。


在下文中一共展示了JavaPlugin.getActivePage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reopenWithGWTJavaEditor

import org.eclipse.jdt.internal.ui.JavaPlugin; //导入方法依赖的package包/类
public static void reopenWithGWTJavaEditor(IEditorReference[] openEditors) {
  IWorkbenchPage page = JavaPlugin.getActivePage();

  for (IEditorReference editorRef : openEditors) {
    try {
      IEditorPart editor = editorRef.getEditor(false);
      IEditorInput input = editorRef.getEditorInput();

      // Close the editor, prompting the user to save if document is dirty
      if (page.closeEditor(editor, true)) {
        // Re-open the .java file in the GWT Java Editor
        IEditorPart gwtEditor = page.openEditor(input, GWTJavaEditor.EDITOR_ID);

        // Save the file from the new editor if the Java editor's
        // auto-format-on-save action screwed up the JSNI formatting
        gwtEditor.doSave(null);
      }
    } catch (PartInitException e) {
      GWTPluginLog.logError(e, "Could not open GWT Java editor on {0}", editorRef.getTitleToolTip());
    }
  }
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:23,代码来源:GWTProjectPropertyPage.java

示例2: getOpenJavaEditors

import org.eclipse.jdt.internal.ui.JavaPlugin; //导入方法依赖的package包/类
public static IEditorReference[] getOpenJavaEditors(IProject project) {
  List<IEditorReference> projectOpenJavaEditors = new ArrayList<IEditorReference>();
  try {
    IWorkbenchPage page = JavaPlugin.getActivePage();
    if (page != null) {
      // Iterate through all the open editors
      IEditorReference[] openEditors = page.getEditorReferences();
      for (IEditorReference openEditor : openEditors) {
        IEditorPart editor = openEditor.getEditor(false);

        // Only look for Java Editor and subclasses
        if (editor instanceof CompilationUnitEditor) {
          IEditorInput input = openEditor.getEditorInput();
          IJavaProject inputProject = EditorUtility.getJavaProject(input);

          // See if the editor is editing a file in this project
          if (inputProject != null && inputProject.getProject().equals(project)) {
            projectOpenJavaEditors.add(openEditor);
          }
        }
      }
    }
  } catch (PartInitException e) {
    GWTPluginLog.logError(e);
  }

  return projectOpenJavaEditors.toArray(new IEditorReference[0]);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:29,代码来源:GWTProjectPropertyPage.java


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