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  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #540453 is a reply to message #540337] |
Wed, 16 June 2010 04:22  |
Eclipse User |
|
|
|
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
>
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 10:59:41 EDT 2025
Powered by FUDForum. Page generated in 0.05280 seconds
|