本文整理汇总了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());
}
}
}
示例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]);
}