Object file = myGetFile(); IEditorInput input; if (file instanceof IFile) { input = new FileEditorInput((IFile)file); else { if (file instanceof IFileStore) { input = new FileStoreEditorInput((IFileStore)file); } else { throw new MyException("file is null, not found"); } }
/** * Default implementation of {@link #getDocumentKey(Object)} that returns a * {@link FileEditorInput} for the element if the element adapts to {@link IFile}. * @see org.eclipse.compare.ISharedDocumentAdapter#getDocumentKey(java.lang.Object) */ public IEditorInput getDocumentKey(Object element) { IFile file = getFile(element); if (file != null && file.exists()) { return new FileEditorInput(file); } return null; }
private static AbstractDecoratedTextEditor findOpenTextEditorForFile(IWorkbenchPage page, IFile file) { if (file == null) return null; FileEditorInput input = new FileEditorInput(file); IEditorPart[] editors = findOpenEditorsForFile(page, input); return findTextEditor(page, editors, input); }
private ITextEditor showOpenTextEditor(IWorkbenchPage page, IFile file) { IEditorPart editor= page.findEditor(new FileEditorInput(file)); if (editor instanceof ITextEditor) { page.bringToTop(editor); return (ITextEditor) editor; } return null; }
protected IFileEditorInput getEditorInput(URI resourceURI, StatusWrapper status) { IFile file = projectUtil.findFileStorage(resourceURI, true); if (file == null) { status.add(ERROR, "No suitable storage found for resource {0}.", resourceURI); return null; } return new FileEditorInput(file); }
/** * Returns true if the given file is open in an editor. */ final boolean beingEdited(IFile file) { IDocumentProvider dp= JavaPlugin.getDefault().getCompilationUnitDocumentProvider(); FileEditorInput input= new FileEditorInput(file); return dp.getDocument(input) != null; }
public static IEditorInput getEditorInput(Object input) { if (input instanceof IJavaElement) return getEditorInput((IJavaElement) input); if (input instanceof IFile) return new FileEditorInput((IFile) input); if (JavaModelUtil.isOpenableStorage(input)) return new JarEntryEditorInput((IStorage)input); return null; }
public static boolean openSchema(IFile file) { if (file != null && file.exists()) { IEditorInput input = new FileEditorInput(file); try { return PDEPlugin.getActivePage().openEditor(input, IPDEUIConstants.SCHEMA_EDITOR_ID) != null; } catch (PartInitException e) { } } return false; }
@Override public void monitoredFileAdded(IFile file) { if (fInputContextManager == null) return; String name = file.getName(); if (name.equalsIgnoreCase(ICoreConstants.BUILD_FILENAME_DESCRIPTOR)) { if (!fInputContextManager.hasContext(BuildInputContext.CONTEXT_ID)) { IEditorInput in = new FileEditorInput(file); fInputContextManager.putContext(in, new BuildInputContext(this, in, false)); } } }
protected IEditorPart getOpenEditor(URI uri, IWorkbenchPage page) { IFile file = projectUtil.findFileStorage(uri.trimFragment(), true); if (file != null) { FileEditorInput fileEditorInput = new FileEditorInput(file); return page.findEditor(fileEditorInput); } return null; }
@Override public void run() { IWorkbenchPage page1 = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { page1.openEditor(new FileEditorInput(file), "taeconfigurator.editors.MultiPageEditor"); } catch (PartInitException e) { } } });
@Override protected void createResourceContexts(InputContextManager manager, IFileEditorInput input) { IFile file = input.getFile(); IFileEditorInput in = new FileEditorInput(file); manager.putContext(in, new SchemaInputContext(this, in, true)); manager.monitorFile(file); }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
private IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IFile file= (IFile) cu.getResource(); IDocument document= JavaUI.getDocumentProvider().getDocument(new FileEditorInput(file)); if (document == null) { return new Document(cu.getSource()); // only used by test cases } return document; }
private IAnnotationModel isInJavaAnnotationModel(ICompilationUnit original) { if (original.isWorkingCopy()) { FileEditorInput editorInput= new FileEditorInput((IFile) original.getResource()); return JavaPlugin.getDefault().getCompilationUnitDocumentProvider().getAnnotationModel(editorInput); } return null; }
public void open() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { page.openEditor(new FileEditorInput(file), "taeconfigurator.editors.MultiPageEditor"); } catch (PartInitException e) { e.printStackTrace(); } }
@Override public void run() { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); try { page.openEditor(new FileEditorInput(ffile), "taeconfigurator.editors.MultiPageEditor"); //$NON-NLS-1$ } catch (PartInitException e) { throw new InternalErrorCDE("unexpected exception"); } } });
private IDocument getDocument(ICompilationUnit cu) throws JavaModelException { IFile file= (IFile) cu.getResource(); IDocument document= JavaUI.getDocumentProvider().getDocument(new FileEditorInput(file)); if (document == null) { return new Document(cu.getSource()); // only used by test cases } return document; }
private IEditorPart showWithReuse(Object element, IWorkbenchPage wbPage) throws JavaModelException, PartInitException { IFile file= getFile(element); if (file != null) { String editorID= getEditorID(file); return showInEditor(wbPage, new FileEditorInput(file), editorID); } else { IClassFile cf= getClassFile(element); if (cf != null) return showInEditor(wbPage, new InternalClassFileEditorInput(cf), JavaUI.ID_CF_EDITOR); } return null; }