Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problem about MultiPageEditor
Problem about MultiPageEditor [message #88632] Sun, 31 December 2006 04:11 Go to next message
Eclipse UserFriend
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 #88816 is a reply to message #88632] Tue, 02 January 2007 13:29 Go to previous messageGo to next message
Eclipse UserFriend
Hello Min,

I suggest you to put a breakpoint into *ItemSemanticEditPolicy.getCreateCommand()
method for corresponding EditPolicy generated for editor-2. Execution should
be stopped there on pulling the tool from the palette and then you should
be able to see the reason why returned command is not executable.

-----------------
Alex Shatalin
Re: Problem about MultiPageEditor [message #89011 is a reply to message #88816] Wed, 03 January 2007 03:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xiaoxiaoleemin.gmail.com

Hello,Alex
thank you for your response.
i tried to put a breakpoint into
*ItemSemanticEditPolicy.getCreateCommand() as you said, but when i pull the
tool from palette of editor2(Page2 of MyMultiPageEditor), it just can't
arrive the breakpoint.At the same time, the editor2 as a independent plugin
project works well. So i think perhaps there are something special to do
when adding editors generated by GMF framework to the multipage editors? Or
perhaps there are conflicts between two editors?

"Alex Shatalin" <vano@borland.com> д
Re: Problem about MultiPageEditor [message #89078 is a reply to message #89011] Wed, 03 January 2007 07:12 Go to previous messageGo to next message
Eclipse UserFriend
Hello min,

> Hello,Alex
> to the multipage editors? Or perhaps there are conflicts between two
> editors?
I see! First idea came to my mind is editor ID – this parameter changed for
sure on switching from two different editors to one multi-page.

To find the distinct problem I suggest to continue debugging. ;-) So, the
next place to put a breakpoint is ???BaseItemSemanticEditPolicy.getSemanticCommand().
I suggest you to place breakpoints into ???BaseItemSemanticEditPolicy generated
for both editor-1 and editor-2 and try to create something in editor-2. Will
see what’s happening.

-----------------
Alex Shatalin
Re: Problem about MultiPageEditor [message #89154 is a reply to message #89078] Wed, 03 January 2007 07:59 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xiaoxiaoleemin.gmail.com

hello, Alex
thank you very much:)
I did as you told me, and found that when i create something in
editor-2, the program stopped at the breakpoint of
***BaseItemSemanticEditPolicy.getSemanticCommand() for editor-1.
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.
I am a new comer to GMF, and I can't find the real reason. Could you
help me more?


"Alex Shatalin" <vano@borland.com> д
Re: Problem about MultiPageEditor [message #89168 is a reply to message #89154] Wed, 03 January 2007 08:56 Go to previous messageGo to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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> д
Re: Problem about MultiPageEditor [message #89229 is a reply to message #89199] Wed, 03 January 2007 11:44 Go to previous messageGo to next message
Eclipse UserFriend
Hello min,

So, now I understand this situation and I’ll try to explain it. ;-)

> <?gmfgen generated="true"?>
Firs, I suggest you to remove this tag for the modified extensions to make
use of GMF plugin.xml merging functionality – your modifications will not
be overwritten on next code generation ( http://wiki.eclipse.org/index.php/GMF_New_and_Noteworthy#Mer ge_for_plugin.xml).

The problem you are facing was caused by the following lines:
> int schoolEditorID1 = addPage(editorPart1, getEditorInput());
> int schoolEditorID2 = addPage(editorPart2, getEditorInput());

You are creating two different editors and initializing both editors with
the same EditorInput returned by the main (multi-page) editor. Since you’ve
registered this editor for diagram files with .school_diagram extension (>
extensions="school_diagram"), getEditorInput() returns FileEditorInput instance
wrapping “.school_diagram” diagram file. (diagram file for editor-1). To
correctly initialize editor-2 you have to create another FileEditorInput
instance wrapping corresponding “.school2_diagram” file and pass this input
as a parameter to addPage method call:

IFile diagram1File = ((FileEditorInput) getEditorInput()).getFile();
IFile diagram2File = diagram1File.getProject().getFile(diagram1File.getProjectRel ativePath().removeFileExtension().addFileExtension(“school 2_diagram”));
FileEditorInput input2 = new FileEditorInput(diagram2File);
int schoolEditorID2 = addPage(editorPart2, input2);

To make it working you can first create two diagram files .school_diagram
and .school2_diagram by separated editor-1 and editor-2 in the same directory
and then try opening .school_diagram by editor-1.

In general, multi-page editor is responsible for providing “nested” diagram
editors with correct editor inputs. In general you can create two different
diagrams in the same file and use IDiagramEditorInput instance to open correct
one.

-----------------
Alex Shatalin
Re: Problem about MultiPageEditor [message #89270 is a reply to message #89229] Wed, 03 January 2007 22:20 Go to previous message
Eclipse UserFriend
Originally posted by: xiaoxiaoleemin.gmail.com

I made the modification as you said, and now it works as I wanted in a
correct way.
This question held me down for several days, thank you very much, Alex:)

"Alex Shatalin" <vano@borland.com> д
Previous Topic:minimum size for connection
Next Topic:MultiLine Text addition
Goto Forum:
  


Current Time: Sat May 10 12:34:12 EDT 2025

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

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

Back to the top