Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » Who should create the inner editor part in a multi editor?
Who should create the inner editor part in a multi editor? [message #540082] Mon, 14 June 2010 16:02 Go to next message
Eclipse UserFriend
Hi,

I am not sure if this is the expected behavior, or if this is a bug, or if I have set up something incorrectly.

I have a file that creates some generated source in another file. When the user double clicks on the raw file, I would like to open a MultiEditor, that shows the raw file and the generated file side-by-side.

I was able to achieve this by setting up an editor launcher. And this is what my launcher looks like:

public class MultiEditorLauncher implements IEditorLauncher {

public void open(IPath file) {
String[] editorIds = new String[] {"com.ibm.rawEditor", "com.ibm.generatedEditor"};

IEditorInput[] inputs = new IEditorInput[] {rawInput, generatedInput};
MultiEditorInput mInput = new MultiEditorInput(editorIds, inputs);

try {
IDE.openEditor(page, mInput, "com.ibm.multieditor", true);
} catch (PartInitException e) {
e.printStackTrace();
}
}

I subclassed from MultiEditor, and in my MyMultiEditor#createPartControl, I call #createInnerPartControl(...) as documented by the API.

When I tried to use MyMultiEditor, I found that my inner editor's #createPartControl method is called twice.

The first call to #createPartControl is done by the EditorManager#OpenMultiEditor method. The inner editors are created before the MultiEditor.createPartControl is even called.

This stacktrace shows the inner editor being created by the EditorManager:

Thread [main] (Suspended (entry into method createPartControl in XtextEditor))
XtextEditor.createPartControl(Composite) line: 331
EditorManager$InnerEditor(EditorReference).createPartHelper( ) line: 670
EditorManager$InnerEditor(EditorReference).createPart() line: 465
EditorManager$InnerEditor(WorkbenchPartReference).getPart(bo olean) line: 595
EditorManager$InnerEditor(EditorReference).getEditor(boolean ) line: 289
EditorManager.openMultiEditor(IEditorReference, AbstractMultiEditor, MultiEditorInput) line: 766
...

Later, MultiEditor#createPartControl is called, and since my createPartControl is also calling #createInnerPartControl, the inner editors are created twice.

My question is... is the Editor Manager supposed to create the inner editor before the multi editor's create part control is called? Am I supposed to call #createInnerPartControl in my multi-editor? If I do not call #createInnerPartControl in my multi editor, my multi editor is not populated. I am trying to figure out who is responsible for creating the inner editor parts. I did not expect the editor manager to create the inner editor parts.

Thanks...
Samantha
Re: Who should create the inner editor part in a multi editor? [message #540214 is a reply to message #540082] Tue, 15 June 2010 08:11 Go to previous messageGo to next message
Eclipse UserFriend
Samantha Chan wrote:
> Hi,
>
> I am not sure if this is the expected behavior, or if this is a bug,
> or if I have set up something incorrectly.
There are quite a few bugs with MultiEditor (see my comments in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=212244) and there's no
concrete usage of it in the SDK. I wouldn't dare to use it ;-)

Dani
>
> I have a file that creates some generated source in another file.
> When the user double clicks on the raw file, I would like to open a
> MultiEditor, that shows the raw file and the generated file side-by-side.
>
> I was able to achieve this by setting up an editor launcher. And this
> is what my launcher looks like:
>
> public class MultiEditorLauncher implements IEditorLauncher {
>
> public void open(IPath file) {
> String[] editorIds = new String[] {"com.ibm.rawEditor",
> "com.ibm.generatedEditor"};
>
> IEditorInput[] inputs = new IEditorInput[] {rawInput, generatedInput};
> MultiEditorInput mInput = new MultiEditorInput(editorIds, inputs);
>
> try {
> IDE.openEditor(page, mInput, "com.ibm.multieditor", true);
> } catch (PartInitException e) {
> e.printStackTrace();
> }
> }
>
> I subclassed from MultiEditor, and in my
> MyMultiEditor#createPartControl, I call #createInnerPartControl(...)
> as documented by the API.
> When I tried to use MyMultiEditor, I found that my inner editor's
> #createPartControl method is called twice.
>
> The first call to #createPartControl is done by the
> EditorManager#OpenMultiEditor method. The inner editors are created
> before the MultiEditor.createPartControl is even called.
>
> This stacktrace shows the inner editor being created by the
> EditorManager:
>
> Thread [main] (Suspended (entry into method createPartControl in
> XtextEditor))
> XtextEditor.createPartControl(Composite) line: 331
> EditorManager$InnerEditor(EditorReference).createPartHelper( )
> line: 670
> EditorManager$InnerEditor(EditorReference).createPart() line: 465
> EditorManager$InnerEditor(WorkbenchPartReference).getPart(bo
> olean) line: 595
> EditorManager$InnerEditor(EditorReference).getEditor(boolean )
> line: 289
> EditorManager.openMultiEditor(IEditorReference,
> AbstractMultiEditor, MultiEditorInput) line: 766
> ..
>
> Later, MultiEditor#createPartControl is called, and since my
> createPartControl is also calling #createInnerPartControl, the inner
> editors are created twice.
>
> My question is... is the Editor Manager supposed to create the inner
> editor before the multi editor's create part control is called? Am I
> supposed to call #createInnerPartControl in my multi-editor? If I do
> not call #createInnerPartControl in my multi editor, my multi editor
> is not populated. I am trying to figure out who is responsible for
> creating the inner editor parts. I did not expect the editor manager
> to create the inner editor parts.
>
> Thanks...
> Samantha
>
Re: Who should create the inner editor part in a multi editor? [message #540216 is a reply to message #540082] Tue, 15 June 2010 08:23 Go to previous messageGo to next message
Eclipse UserFriend
This might be a (known) bug. The code in EditorManager that creates the
editors seems solid enough.

If you leave it to the EditorManager to create your editors, can you get
to the next step or does it not work?

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: Who should create the inner editor part in a multi editor? [message #540228 is a reply to message #540214] Tue, 15 June 2010 08:49 Go to previous messageGo to next message
Eclipse UserFriend
Daniel Megert wrote:
> Samantha Chan wrote:
>> Hi,
>>
>> I am not sure if this is the expected behavior, or if this is a bug,
>> or if I have set up something incorrectly.
> There are quite a few bugs with MultiEditor (see my comments in
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=212244) and there's no
> concrete usage of it in the SDK. I wouldn't dare to use it ;-)
>
> Dani


Dani's correct. Even our own TileEditor testing editor exhibits the
same "createPartControl(*) called twice" bug. It's just not used
anywhere in the SDK.

PW

--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: Who should create the inner editor part in a multi editor? [message #540322 is a reply to message #540228] Tue, 15 June 2010 11:50 Go to previous messageGo to next message
Eclipse UserFriend
If you don't dare use it... then I won't dare either? Smile

In the MultiEditor, if I do not create the inner editor in my editor's createPartControl, the inner editors will not show up.

If MultiEditor is so problematic, do you recommend using AbstractMultiEditor instead?

Instead of subclassing MultiEditor, I subclassed from AbstractMultiEditor. In my implementation of AbstractMultiEditor, I only created the sashform to be used as the parent of the inner editors. Then I let the editor manager create the inner editors. I also returned the sashform in MyMultiEditor#getInnerEditorContainer() so the editor manager can get to the container when it needs the composite for creating the inner editor.

This seems to work for me, except that I have some trouble with context menu actions. I have to investigate what's wrong there still.

But is this the expected usage of AbstractMultiEditor?

Thanks...
Samantha
Re: Who should create the inner editor part in a multi editor? [message #540337 is a reply to message #540322] Tue, 15 June 2010 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Samantha Chan wrote:
> Instead of subclassing MultiEditor, I subclassed from
> AbstractMultiEditor. In my implementation of AbstractMultiEditor, I
> only created the sashform to be used as the parent of the inner
> editors. Then I let the editor manager create the inner editors. I
> also returned the sashform in MyMultiEditor#getInnerEditorContainer() so
> the editor manager can get to the container when it needs the composite
> for creating the inner editor.

I think that's more likely to work if you don't run into
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316892
AbstractMultiEditor was refactored recently and wasn't constrained by
what MultiEditor may or may not do.

Please let us know how it goes :-)

PW



--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse .platform.doc.isv/guide/workbench.htm
Re: Who should create the inner editor part in a multi editor? [message #540453 is a reply to message #540337] Wed, 16 June 2010 04:22 Go to previous message
Eclipse UserFriend
Paul Webster wrote:
> Samantha Chan wrote:
>> Instead of subclassing MultiEditor, I subclassed from
>> AbstractMultiEditor. In my implementation of AbstractMultiEditor, I
>> only created the sashform to be used as the parent of the inner
>> editors. Then I let the editor manager create the inner editors. I
>> also returned the sashform in MyMultiEditor#getInnerEditorContainer()
>> so the editor manager can get to the container when it needs the
>> composite for creating the inner editor.
>
> I think that's more likely to work if you don't run into
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=316892
> AbstractMultiEditor was refactored recently and wasn't constrained by
> what MultiEditor may or may not do.
I didn't look at this myself but you might want to look at the example
in https://bugs.eclipse.org/bugs/show_bug.cgi?id=244364

Dani
>
> Please let us know how it goes :-)
>
> PW
>
>
>
Previous Topic:Is it possible to access the current workspace name and set this to a variable?
Next Topic:Eclipse with wide screen
Goto Forum:
  


Current Time: Wed Jul 23 10:59:41 EDT 2025

Powered by FUDForum. Page generated in 0.05280 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top