本文整理汇总了Java中org.eclipse.ui.IWorkbenchPage.findEditor方法的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchPage.findEditor方法的具体用法?Java IWorkbenchPage.findEditor怎么用?Java IWorkbenchPage.findEditor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.IWorkbenchPage
的用法示例。
在下文中一共展示了IWorkbenchPage.findEditor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: activateEditor
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
@Override
public void activateEditor(final IWorkbenchPage page, final IStructuredSelection selection) {
if (null != selection && !selection.isEmpty()) {
final Object firstElement = selection.getFirstElement();
if (firstElement instanceof ResourceNode) {
final File fileResource = ((ResourceNode) firstElement).getResource();
if (fileResource.exists() && fileResource.isFile()) {
final URI uri = URI.createFileURI(fileResource.getAbsolutePath());
final IResource resource = externalLibraryWorkspace.getResource(uri);
if (resource instanceof IFile) {
final IEditorInput editorInput = EditorUtils.createEditorInput(new URIBasedStorage(uri));
final IEditorPart editor = page.findEditor(editorInput);
if (null != editor) {
page.bringToTop(editor);
return;
}
}
}
}
}
super.activateEditor(page, selection);
}
示例2: getEditor
import org.eclipse.ui.IWorkbenchPage; //导入方法依赖的package包/类
/**
* Obtains an editor that may edits the contents of a file.
* @param file the file
* @return the editor of the file, or <code>null</code> if none
*/
public static IEditorPart getEditor(IFile file) {
IEditorInput input = new FileEditorInput(file);
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (IWorkbenchWindow window : windows) {
IWorkbenchPage[] pages = window.getPages();
for (IWorkbenchPage page : pages) {
IEditorPart part = page.findEditor(input);
return part;
}
}
return null;
}