Bug 70819

Summary: [MPE] [EditorMgmt] No access to active editor if part of MultiPageEditorPart
Product: [Eclipse Project] Platform Reporter: Troy Self <tself>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: bokowski, gnosticus, markus.kell.r, n.a.edgar, remy.suen
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on: 46207    
Bug Blocks:    

Description Troy Self CLA 2004-07-26 10:06:09 EDT
The MultiPageEditorPart does not provide access to the editor page in use.
Plugins that attach special behavior to an ITextEditor will do so by asking the
Workbench for the active Editor. If that editor is an ITextEditor, the plugin
can be attached. However, if that editor is a MultiPageEditorPart, there is no
way to access the actual editor being used to see if it is an ITextEditor.
A remedy would be to either allow MultiPageEditorPart to adapt to the active
editor page type or, better yet, expose the getActiveEditor() method in 
MultiPageEditorPart as public.

The plugin that spawns this report is the viPlugin, which adds vi functionality
to ITextEditors in Eclipse. It does not work with the manifest editors 
(plugin.xml, feature.xml) because when it asks for the active editor, it 
receives a MultiPageEditorPart and then has no way to investigate further if
the active editor page is an ITextEditor. Ideally, the viPlugin should be able
to ask the MultiPageEditorPart for its active editor with
multiPageEditorPart.getActiveEditor().

Please either expose MultiPageEditorPart.getActiveEditor() or add adapter 
functionality
similar to below. Thank you.

-- tBs


public Object getAdapter(Class adapter)
{
   if(ITextEditor.class.equals(adapter) || IEditorPart.class.equals(adapter))
   {
      if(getActiveEditor() instanceof ITextEditor)
         return getActiveEditor();
      if(getActiveEditor() instanceof IAdaptable)
      {
         return ((IAdaptable)(getActiveEditor())).getAdapter
(ITextEditor.class);
      }
   }
   return super.getAdapter(adapter);
}
Comment 1 Markus Keller CLA 2004-08-17 03:32:18 EDT
Exposing getActiveEditor() alone is not enough. Clients also need to be able to
register a "page listener" which notifies them on page activation events
(similar to the way a part listener notifies on part activation events).
Comment 2 Michael Bartl CLA 2004-09-23 09:05:13 EDT
As author of the viPlugin I'm directly affected by this API problem. I'm
currently reflecting the method and disable the access control to get what I
need, which is the second ugly hack to make something like a viPlugin possible.
A listener would be needed too, that is true, otherwise I wouldn't find out that
the current active page of the MultiPart has changed.

Has it already been considered to open the API at these points?

Thx,
Michael Bartl
Comment 3 Douglas Pollock CLA 2004-09-23 09:20:42 EDT
This is a hot topic of debate right now.  See Bug 53700 and Bug 46207. 
Comment 4 Michael Van Meekeren CLA 2006-04-21 13:19:50 EDT
Moving Dougs bugs
Comment 5 Susan McCourt CLA 2009-07-09 19:05:52 EDT
As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009
Comment 6 Boris Bokowski CLA 2009-11-17 13:01:36 EST
Remy is now responsible for watching the [EditorMgmt] component area.
Comment 7 Remy Suen CLA 2009-11-24 10:04:09 EST
(In reply to comment #0)
> Please either expose MultiPageEditorPart.getActiveEditor() or add adapter 
> functionality

getAdapter(Class) was added to MPEP in in 3.2. Is the viPlugin working properly now?

(In reply to comment #1)
> Exposing getActiveEditor() alone is not enough. Clients also need to be able to
> register a "page listener" which notifies them on page activation events
> (similar to the way a part listener notifies on part activation events).

We added listeners in 3.5, see bug 201391.
Comment 8 Eclipse Webmaster CLA 2019-09-06 16:18:25 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.