本文整理匯總了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;
}