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 20:02 |
Samantha Chan Messages: 60 Registered: July 2009 |
Member |
|
|
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 12:11 |
Dani Megert Messages: 3802 Registered: July 2009 |
Senior Member |
|
|
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
>
|
|
| | | | | |
Goto Forum:
Current Time: Wed Apr 24 22:09:30 GMT 2024
Powered by FUDForum. Page generated in 0.03462 seconds
|