public static IEditorInput getEditorInput(Object input) { if (input instanceof EObject) return new FileEditorInput(WorkbenchResourceHelper.getFile((EObject) input)); if (input instanceof IFile) return new FileEditorInput((IFile) input); return null; }
FileEditorInput input = (FileEditorInput) editor.getEditorInput(); StyledText editorControl = ((StyledText) editor.getAdapter(Control.class)); String path = input.getFile().getRawLocationURI().getRawPath();
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { if (adapter == IClassFile.class) return (T) fClassFile; return super.getAdapter(adapter); }
final JavaEditor getEditor(IFile file) { FileEditorInput fei= new FileEditorInput(file); IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); for (int i= 0; i < windows.length; i++) { IWorkbenchPage[] pages= windows[i].getPages(); for (int x= 0; x < pages.length; x++) { IEditorPart[] editors= pages[x].getDirtyEditors(); for (int z= 0; z < editors.length; z++) { IEditorPart ep= editors[z]; if (ep instanceof JavaEditor) { JavaEditor je= (JavaEditor) ep; if (fei.equals(je.getEditorInput())) return (JavaEditor) ep; } } } } return null; }
final JavaEditor getEditor(IFile file) { FileEditorInput fei= new FileEditorInput(file); IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); for (int i= 0; i < windows.length; i++) { IWorkbenchPage[] pages= windows[i].getPages(); for (int x= 0; x < pages.length; x++) { IEditorPart[] editors= pages[x].getDirtyEditors(); for (int z= 0; z < editors.length; z++) { IEditorPart ep= editors[z]; if (ep instanceof JavaEditor) { JavaEditor je= (JavaEditor) ep; if (fei.equals(je.getEditorInput())) return (JavaEditor) ep; } } } } return null; }
public ShowInContext getShowInContext() { return new ShowInContext(new FileEditorInput(file), StructuredSelection.EMPTY); } };
/** * * @param editorinput * @return null if not found */ public static IFile getFile(IEditorInput editorinput) { FileEditorInput fileEditorInput = (FileEditorInput) editorinput .getAdapter(FileEditorInput.class); if (fileEditorInput == null || fileEditorInput.getFile() == null) { return null; } return fileEditorInput.getFile(); }
final JavaEditor getEditor(IFile file) { FileEditorInput fei= new FileEditorInput(file); IWorkbench workbench= JavaPlugin.getDefault().getWorkbench(); IWorkbenchWindow[] windows= workbench.getWorkbenchWindows(); for (int i= 0; i < windows.length; i++) { IWorkbenchPage[] pages= windows[i].getPages(); for (int x= 0; x < pages.length; x++) { IEditorPart[] editors= pages[x].getDirtyEditors(); for (int z= 0; z < editors.length; z++) { IEditorPart ep= editors[z]; if (ep instanceof JavaEditor) { JavaEditor je= (JavaEditor) ep; if (fei.equals(je.getEditorInput())) return (JavaEditor) ep; } } } } return null; }
@SuppressWarnings("unchecked") @Override public <T> T getAdapter(Class<T> adapter) { if (adapter == IClassFile.class) return (T) fClassFile; return super.getAdapter(adapter); }
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"); } }
/** * @param doc * @return IEditorInput * @throws Exception * @throws IOException */ public IEditorInput getEditorInput(SearchResultDoc doc) throws Exception { return new FileEditorInput(doc.getFile()); }
@Override public Object getParent(Object o) { return FileEditorInput.this.getFile().getParent(); } });
private static IEditorInput getEditorInput(Object input) { IResource[] resources = Utils.getContributedResources(new Object[] { input }); if (resources.length > 0) input = resources[0]; if (input instanceof IFile) return new FileEditorInput((IFile) input); return null; }
@Override public String toString() { return getClass().getName() + "(" + getFile().getFullPath() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ }
private static IEditorPart openWorkspacePlugin(IFile pluginFile) { return openEditor(new FileEditorInput(pluginFile)); }
protected IFile getActiveFile() { return DocumentUtils.getActiveEditorInput().getFile(); }
public void underlyingFileMoved(IFileBuffer file, IPath newLocation) { IWorkspace workspace=ResourcesPlugin.getWorkspace(); IFile newFile= workspace.getRoot().getFile(newLocation); IEditorInput input= newFile == null ? null : new FileEditorInput(newFile); List list= new ArrayList(fElementStateListeners); Iterator e= list.iterator(); while (e.hasNext()) { IElementStateListener l= (IElementStateListener) e.next(); Iterator i= getElements(file); while (i.hasNext()) l.elementMoved(i.next(), input); } }
/** * Saves the server configuration using the given {@link FileEditorInput}. * * @param fei * the {@link FileEditorInput} * @throws ServerConfigurationWriterException * @throws CoreException * @throws IOException */ private void saveConfiguration( FileEditorInput fei, IProgressMonitor monitor ) throws CoreException, IOException { String xml = serverXmlIO.toXml( serverConfiguration ); fei.getFile().setContents( new ByteArrayInputStream( xml.getBytes() ), true, true, monitor ); }
/** * Sends out the notification that the file serving as document input has been moved. * * @param fileEditorInput the input of an text editor * @param path the path of the new location of the file */ protected void handleElementMoved(IFileEditorInput fileEditorInput, IPath path) { IWorkspace workspace= ResourcesPlugin.getWorkspace(); IFile newFile= workspace.getRoot().getFile(path); fireElementMoved(fileEditorInput, new FileEditorInput(newFile)); }