Community
Participate
Working Groups
In Eclipse, editor inputs are used to represent things that can be opened in an editor. However, there is not a well defined, general way of creating an editor input instance. As a result, it is not possible write plugins capable of opening any type of "input" in an editor programmatically. Most visibly, it is not possible to provide a generic "open selection in an editor" functionality without resorting to plugin specific API's - see org.eclipse.jdt.ui.JavaUI.openInEditor(IJavaElement). It would be better if any IAdaptable instance was able to provide a "IEditorInputProvider" instance using the adapter mechanism, which would in turn be used to create a new editor input. Here is some possible code: public interface IEditorInputProvider { IEditorInput createEditorInput(Object obj); String getDefaultEditorId(); } public class MyInputProvider implements IEditorInputProvider { IEditorInput createEditorInput(Object obj) { if (!(item instanceof MyItem)) return; return new MyItemInput((MyItem) item); } String getDefaultEditorId() { return "my.editor.id"; } Then, when you have a selection, IStructuredSelection selection = ...; IAdaptable element = (IAdaptable) selection.getFirstElement(); IEditorInputProvider provider = (IEditorInputProvider) element.getAdapter( IEditorInputProvider.class); IWorkbenchPage page = ...; // get the active page page.openInEditor(provider.createEditorInput(element), provider.getDefaultEditorId()); I hope this makes sense...
This is an interesting idea. Any implementation for this need to ensure that plugins do not get eagerly loaded and we do not defeat the resource change listeners in Core. Agree that this is a P3 enhancement.
I've been thinking of something along these lines. I think we need an open-ended mechanism for mapping from an arbitrary object to an editor input and/or editor id. Using IAdaptable as above is one possibility. An extension point to allow pluggable strategies for this is another.
See bug 47600 for an interesting use case.
See also bug 74263. It seems like the editor input chosen should be a function of the editor too. We can't limit this to just the default editor case.
Reassigning bugs in component areas that are changing ownership.
Prakash is now responsible for watching bugs in the [RCP] component area.