Home » Modeling » GMF (Graphical Modeling Framework) » Problem about MultiPageEditor
Problem about MultiPageEditor [message #88632] |
Sun, 31 December 2006 04:11  |
Eclipse User |
|
|
|
Originally posted by: xiaoxiaoleemin.gmail.com
hi,
everyone.
now i have an ecore model(named school.ecore), and i want to edit
different aspects of the domain model with different editors, At first,i
created school.gmfgraph, school.gmftool,school.gmfmap and school.gmfgen for
one editor(editor1),Then i created school2.gmfgraph,
school2.gmftool,school2.gmfmap and school2.gmfgen for the other
editor(editor2).
Because i want to share the editingDomain between these two editors
,after generating diagram code as two independent plug-in projects, i
modified them according to
http://wiki.eclipse.org/index.php/GMF_Tips#Sharing_single_Ed itingDomain_instance_across_several_diagrams
as two independent editors, they work well.
But when i add editor1 and editor2 as different pages of my own
MultiPageEditor, only page1(that's editor1) works well. In page2, i can't
add any element from the palette to the editor. I trid to add breakpoint in
the **ViewProvider class of the second editor, but nothing happened.
is there anyone know the reason?
thank you:)
best wishes
Min Li
|
|
| | | | |
Re: Problem about MultiPageEditor [message #89168 is a reply to message #89154] |
Wed, 03 January 2007 08:56   |
Eclipse User |
|
|
|
Hello min,
> ***BaseItemSemanticEditPolicy.getSemanticCommand() for editor-1.
Well, looks like the Diagram (org.eclipse.gmf.runtime.notation.Diagram) instance
you’ve used to open editor-2 is actually an instance of diagram suitable
for editor-1. ;-) Both generated editors have “Model ID” parameters. These
parameters (can be customized in .gmfgen model) should be different to distinguish
them. AFAIU, you have changed this parameter correctly to make them unique
because you said that separated editors works well.
I guess you have the following problem and I’ll try to argument it step-by-step
below:
1. In your situation BaseItemSemanticEditPolicy for editor-1 called to create
something on editor-2
2. Since all EditPolicies are attached to the corresponding EditPart directly
in the generated code, 1. means you have incorrect EditPart created for diagram-2
(diagram-1 EditPart was used instead).
3. Correct EditParts are created by generated EditPart provider based on
MODEL_ID property of the passed notation model element (MODEL_ID == diagram.getType()
is a criteria).
4. I suppose that you have two different modelIDs specified for diagram-1
and diagram-2, so 3. means you are passing diagram with modelID of diagram-1
while trying to open diagram-2.
5. 4. means you have used initialization code of diagram-1 to create notation
model element for diagram-2 in your multipage editor.
So, if all these steps are correct and I did not made any mistakes there,
I have to ask you to pay attention on diagram creation code (the place there
you are creating new or choosing existing instance of Diagram (notation model
element) for editor-1 and editor-2 tabs of multi-page editor. Can you please
ensure that correct initialization code called?
You an place a breakpoint into both generated ???EditpartProvider.provides()
method and open multi-page editor + switch to inactive page - you'll see
which EditPart provider will be called. I correct situation AFAIU editor-1
provider should be called first and then editor-2 provider.
> I set different editor ID for editor1 and editor 2, but it seems
> when I switch from editor1 to editor2 in MyMultiPageEditor, the ID didn't
> change.
> I think that's the reason why editor-2 doesn't work well.
Well, that’s reasonable, but following the sequence I’ve described above
I still can not came to this conclusion. ;-) AFAIU, EditorID used only to
open correct instance of DiagramEditor and to contribute some actions (popup
menus …) there. This should not affect process of opening diagram and creating
correct notation model/EditPart/EditPolicies instances. So, I suggest you
to dig in the area of creation new Diagram instance for editor-2.
I can try to help you more if you describe me the process of creation (initialization)
of notation model for both pages in your editor.
-----------------
Alex Shatalin
|
|
|
Re: Problem about MultiPageEditor [message #89199 is a reply to message #89168] |
Wed, 03 January 2007 10:54   |
Eclipse User |
|
|
|
Originally posted by: xiaoxiaoleemin.gmail.com
Hello, Alex
First, a big thank you:)
Thank you for so much step-by-step explanation for me.
I tried as follows:
1.I use the editor-2 as separate editor( not in MyMultiPageEditor), it
works well. And it can arrive the breakpoint at
***EditPartProvider.provide() for editor-2.
2. I set two breakpoint at **EditPartProvider.provider() for editor-1
and editor-2, but when I use the MyMultiPageEditor, only the breakpoint for
editor-1 can be arrived, the breakpoint for editor-2 can't be arrived.
Because when editor-2 is used as separate editor, it can arrive the
breakpoint for editor-2. So I think perhaps the problem is in
MyMultiPageEditor.
I only implement the createPages() method for MyMultiPageEditor, which
extends org.eclipse.ui.part.MultiPageEditorPart as follows:
protected void createPages() {
try{
IEditorPart editorPart1 = (IEditorPart)new SchoolDiagramEditor();
IEditorPart editorPart2 = (IEditorPart)new
com.example.school2.diagram.part.SchoolDiagramEditor();
int schoolEditorID1 = addPage(editorPart1, getEditorInput());
int schoolEditorID2 = addPage(editorPart2, getEditorInput());
setPageText(schoolEditorID1, "editor1");
setPageText(schoolEditorID2, "editor2");
setActivePage(schoolEditorID1);
}catch(PartInitException e)
{
ErrorDialog.openError(
getSite().getShell(),
"Open Error",
"En error occured during opening the editor.",
e.getStatus());
}
}
The extension point is declared in the plugin.xml for editor-1,and the
MyMultiPageEditor is placed in the same package as Editor for diagram1.
<extension point="org.eclipse.ui.editors">
<?gmfgen generated="true"?>
<editor
id="com.example.school.diagram.part.MyMultiPageEditorID"
name="MyMultiPage Editor"
icon="icons/obj16/SchoolDiagramFile.gif"
extensions="school_diagram"
default="true"
class="com.example.school.diagram.part.MyMultiPageEditor">
</editor>
</extension>
Now the palette for two editors are displayed correctly with different
tool entrys, and the code for two diagrams are generated by GMF. I am
confused why **EditPartProvider.provide() for editor-2 can't be called.
Thank you very much:)
"Alex Shatalin" <vano@borland.com> д
|
|
| | |
Goto Forum:
Current Time: Sat May 10 12:34:12 EDT 2025
Powered by FUDForum. Page generated in 0.03529 seconds
|