Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » XXXViewFactory.decorateView -> different behavior in GMF 2.1 vs. GMF 2.1.1
XXXViewFactory.decorateView -> different behavior in GMF 2.1 vs. GMF 2.1.1 [message #207107] Thu, 25 September 2008 16:26 Go to next message
Thomas Beyer is currently offline Thomas BeyerFriend
Messages: 47
Registered: July 2009
Member
This is a multi-part message in MIME format.

------=_NextPart_000_001C_01C91F3C.33AAA510
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear community,


I am encoutering a difference in the behavior of the =
decorateView-method.

My use-case is as follows:

Upon creation of a new Diagram, I am filling notation and domain-files =
with predefined elements (basically, this is an import version from a =
different format).

GMF 2.1:=20
The XXXViewFactory#decorateView(...) in generated XXXViewFactory is =
never called when creating the View with the =
XXXViewFactory.createView(...).
Therefore my nodes lack of labels and comparment-nodes.
So I subclassed the generated XXVViewFactory to make the =
decorateView(...) public and invoked it explicitely right after the =
createView(...)-method.
This approach worked.

GMF 2.1.1:
The XXXViewFactory#decorateView(...) in generated XXXViewFactory is =
called when creating the View with the XXXViewFactory.createView(...).
However the child nodes, that should be created in the =
XXXViewFactory#decorateView(...) are not created.
Subclassing as explained above for GMF 2.1 also does not create the =
child views.

What can I do in GMF 2.1.1 and furture versions to properly create a =
View with its children and corresponding styles?



TIA & regards=20
Thomas



------=_NextPart_000_001C_01C91F3C.33AAA510
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2180" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Dear community,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am encoutering a difference in the =
behavior of=20
the decorateView-method.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My use-case is as follows:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Upon&nbsp;creation of a new Diagram, I =
am=20
filling&nbsp;notation and domain-files with predefined elements =
(basically, this=20
is an import version from a different format).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>GMF 2.1: </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>The XXXViewFactory#decorateView(...) in =
generated=20
XXXViewFactory is never called when creating the View with the=20
XXXViewFactory.createView(...).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Therefore my nodes lack of labels and=20
comparment-nodes.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>So I subclassed</FONT><FONT =
face=3DArial size=3D2> the=20
generated XXVViewFactory to make the decorateView(...) public and =
invoked it=20
explicitely right after the createView(...)-method.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>This approach worked.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>GMF 2.1.1:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>The XXXViewFactory#decorateView(...) in =
generated=20
XXXViewFactory is called when creating the View with the=20
XXXViewFactory.createView(...).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>However the child nodes, that should be =
created in=20
the XXXViewFactory#decorateView(...)&nbsp; are not created.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Subclassing =
as&nbsp;explained&nbsp;above&nbsp;for=20
GMF 2.1 also does not create the child views.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>What can I do in GMF 2.1.1 and furture =
versions to=20
properly create a View with its children and corresponding =
styles?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>TIA &amp; regards </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thomas</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_001C_01C91F3C.33AAA510--
Re: XXXViewFactory.decorateView -> different behavior in GMF 2.1 vs. GMF 2.1.1 [message #207136 is a reply to message #207107] Fri, 26 September 2008 10:20 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Thomas,

Use ViewService API co create all vew instances. As a result all necessary
child views (compartments/labels) will be created automatically.

-----------------
Alex Shatalin
Re: XXXViewFactory.decorateView -> different behavior in GMF 2.1 vs. GMF 2.1.1 [message #207193 is a reply to message #207136] Sat, 27 September 2008 10:56 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas BeyerFriend
Messages: 47
Registered: July 2009
Member
This is a multi-part message in MIME format.
--------------080606050600060409030403
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Alex,

I tried this also with the same result.
The Node is created, I can add layoutconstraint to it, but the children
are missing.
Debugging the corresponding ViewFactory show, that the child nodes (for
labels and compartments) are created fine, but somehow not attached to
the parent-view resp. they dont go in the notation model.

My routine is as follows:

public static Resource createDiagram(URI diagramURI, URI modelURI,
IProgressMonitor progressMonitor, final Document doc) {
TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE
.createEditingDomain();


progressMonitor.beginTask(Settings.Lbl_ProgressTask_CreateDi agram, 3);
final Resource diagramResource = editingDomain.getResourceSet()
.createResource(diagramURI);
final Resource modelResource = editingDomain.getResourceSet()
.createResource(modelURI);

// set model name from last segment without file extension
final String diagramName =
diagramURI.trimFileExtension().lastSegment();

AbstractTransactionalCommand command = new
AbstractTransactionalCommand(
editingDomain, Settings.Lbl_Cmd_CreateDiagram,
Collections.EMPTY_LIST) {
protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {

// create diagram and domain diagram
HMIDiagram diagramM =
HmiFactory.eINSTANCE.createHMIDiagram();
diagramM.setName(diagramName);

Diagram diagramD = ViewService.createDiagram(diagramM,
HMIDiagramEditPart.MODEL_ID, DPH);

diagramD.setName(diagramName);

// create contents of diagram
createContents(diagramM, diagramD, doc);

// add tree to resources
if (diagramD != null) {
diagramResource.getContents().add(diagramD);
}
if (diagramM != null)
modelResource.getContents().add(diagramM);

// save resources
try {
modelResource.save(hmi.diagram.part.HmiDiagramEditorUtil
.getSaveOptions());

diagramResource.save(hmi.diagram.part.HmiDiagramEditorUtil
.getSaveOptions());
}
catch (IOException e) {
Activator.getDefault()
.logError(Settings.Msg_Store_Error, e);
//$NON-NLS-1$
}
return CommandResult.newOKCommandResult();
}
};

try {
OperationHistoryFactory.getOperationHistory().execute(comman d,
new SubProgressMonitor(progressMonitor, 1), null);
setCharset(WorkspaceSynchronizer.getFile(modelResource));
setCharset(WorkspaceSynchronizer.getFile(diagramResource));
}
catch (ExecutionException e) {
Activator.getDefault().logError(
Settings.Msg_CreateDiagram_Error, e); //$NON-NLS-1$
}
return diagramResource;
}

in the createContents-method, the actual content is being created.
something like:
Desktop desktopModel = HmiFactory.eINSTANCE.createDesktop();
diagramM.getToplevelDisplayNodes().add(desktopModel);
View desktopView = ViewService.createNode(containerView,
desktopModel,"2012", DPH);
//set bounds of Node
setLayoutConstraints(desktopView);

What am I doing wrong?

TIA
Thomas



Alex Shatalin schrieb:
> Hello Thomas,
>
> Use ViewService API co create all vew instances. As a result all
> necessary child views (compartments/labels) will be created
> automatically.
>
> -----------------
> Alex Shatalin
>
>


--------------080606050600060409030403
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Alex,<br>
<br>
I tried this also with the same result.<br>
The Node is created, I can add layoutconstraint to it, but the children
are missing.<br>
Debugging the corresponding ViewFactory show, that the child nodes (for
labels and compartments) are created fine, but somehow not attached to
the parent-view resp. they dont go in the notation model.<br>
<br>
My routine is as follows:<br>
<br>
public static Resource createDiagram(URI diagramURI, URI modelURI,<br>
            IProgressMonitor progressMonitor, final Document doc) {<br>
        TransactionalEditingDomain editingDomain =
GMFEditingDomainFactory.INSTANCE<br>
                .createEditingDomain();<br>
        <br>
       
progressMonitor.beginTask(Settings.Lbl_ProgressTask_CreateDi agram, 3);<br>
        final Resource diagramResource = editingDomain.getResourceSet()<br>
                .createResource(diagramURI);<br>
        final Resource modelResource = editingDomain.getResourceSet()<br>
                .createResource(modelURI);<br>
<br>
        // set model name from last segment without file extension<br>
        final String diagramName =
diagramURI.trimFileExtension().lastSegment();<br>
<br>
        AbstractTransactionalCommand command = new
AbstractTransactionalCommand(<br>
                editingDomain, Settings.Lbl_Cmd_CreateDiagram,<br>
                Collections.EMPTY_LIST) {<br>
            protected CommandResult doExecuteWithResult(<br>
                    IProgressMonitor monitor, IAdaptable info)<br>
                    throws ExecutionException {<br>
                <br>
                // create diagram and domain diagram<br>
                HMIDiagram diagramM =
HmiFactory.eINSTANCE.createHMIDiagram();<br>
                diagramM.setName(diagramName);<br>
                <br>
                Diagram diagramD = ViewService.createDiagram(diagramM,<br>
                        HMIDiagramEditPart.MODEL_ID, DPH);<br>
<br>
                diagramD.setName(diagramName);<br>
<br>
                // create contents of diagram<br>
                <font color="#3366ff">createContents(diagramM,
diagramD, doc);</font><br>
<br>
                // add tree to resources<br>
                if (diagramD != null) {<br>
                    diagramResource.getContents().add(diagramD);<br>
                }<br>
                if (diagramM != null)<br>
                    modelResource.getContents().add(diagramM);<br>
<br>
                // save resources<br>
                try {<br>
                   
modelResource.save(hmi.diagram.part.HmiDiagramEditorUtil<br >
                            .getSaveOptions());<br>
                   
diagramResource.save(hmi.diagram.part.HmiDiagramEditorUtil<br >
                            .getSaveOptions());<br>
                }<br>
                catch (IOException e) {<br>
                    Activator.getDefault()<br>
                            .logError(Settings.Msg_Store_Error, e);
//$NON-NLS-1$<br>
                }<br>
                return CommandResult.newOKCommandResult();<br>
            }<br>
        };<br>
        <br>
        try {<br>
           
OperationHistoryFactory.getOperationHistory().execute(comman d, <br>
                    new SubProgressMonitor(progressMonitor, 1), null);<br>
            setCharset(WorkspaceSynchronizer.getFile(modelResource));<br >
            setCharset(WorkspaceSynchronizer.getFile(diagramResource));<br >
        }<br>
        catch (ExecutionException e) {<br>
            Activator.getDefault().logError(<br>
                    Settings.Msg_CreateDiagram_Error, e); //$NON-NLS-1$<br>
        }<br>
        return diagramResource;<br>
    }<br>
<br>
in the createContents-method, the actual content is being created.<br>
something like:<br>
        Desktop desktopModel = HmiFactory.eINSTANCE.createDesktop();<br>
        diagramM.getToplevelDisplayNodes().add(desktopModel);<br>
        <font color="#3366ff">View desktopView =
ViewService.createNode(containerView, desktopModel,"2012", DPH);</font><br>
         //set bounds of Node<br>
        setLayoutConstraints(desktopView);<br>
<br>
What am I doing wrong?<br>
<br>
TIA<br>
Thomas<br>
<br>
       <br>
<br>
Alex Shatalin schrieb:
<blockquote cite="mid:3c3172e626f688caede972e52f67@news.eclipse.org"
type="cite">Hello Thomas,
<br>
<br>
Use ViewService API co create all vew instances. As a result all
necessary child views (compartments/labels) will be created
automatically.
<br>
<br>
-----------------
<br>
Alex Shatalin
<br>
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------080606050600060409030403--
Re: XXXViewFactory.decorateView -> different behavior in GMF 2.1vs. GMF 2.1.1 [message #207225 is a reply to message #207193] Mon, 29 September 2008 10:11 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Thomas,

> Debugging the corresponding ViewFactory show, that the child nodes
> (for labels and compartments) are created fine, but somehow not attached to
> the parent-view resp. they dont go in the notation model.
See BasicNodeViewFactory.createView() ("ViewUtil.insertChildView(containerView,
node, index, persisted);" method call).
Corresponding child elements (compartments/labels) should be attached to
the parent element there.

> My routine is as follows:
Looks reasonable. At least, I can not find anythis incorrect in this code
from the very beggining. Try to continue debugging view factory to see the
reason of incorrect child elements creation.

-----------------
Alex Shatalin
Re: XXXViewFactory.decorateView -> different behavior in GMF 2.1vs. GMF 2.1.1 [message #208335 is a reply to message #207225] Fri, 10 October 2008 22:38 Go to previous messageGo to next message
Thomas Beyer is currently offline Thomas BeyerFriend
Messages: 47
Registered: July 2009
Member
Hello Alex,

thank for your pointer.
I did a lot of debugging and testing.
However, the behavior seems absurd to me.
Creating Views via ViewService triggers the correct generated
XXViewFactories.
I can see, that the create-method of BasicNodeViewFactory calls the
specific decorate-method in generated XXXViewFactory. There the nodes
for label and compartment are created (I can access them), but NOT
persisted in the notation model?!
I fell back to my initial solution by subclassing the generated
XXXViewFactories to make the protected decorate-view method public.
Additionally i had to add the domain element in the notationa view and
then decorate it.

After all these are the steps:
1. Create a the domain model object
2. Create the view object via ViewService
3. Add the domain model object to the created view object
(setElement...) -> actually ViewService should be doing this already,
but doesn't!
4. decorate the created view with the subclassed generated
XXXViewFactories to generated label and compartment-nodes.

It seems quiet odd.

I also noticed, that in the BasicNodeViewFactory, there have been made
some changes in the EMF-operation options (the static definitions at the
begininning).

Simply creating a view (with corresponding labels and compartments) view
ViewService doesn't work.

Given that my DSL is quiet complex, a have to do a hell lot of redundant
coding, to make this work.
Maybe there still is a bug somewhere.


Regards
Thomas




Alex Shatalin schrieb:
> Hello Thomas,
>
>> Debugging the corresponding ViewFactory show, that the child nodes
>> (for labels and compartments) are created fine, but somehow not
>> attached to
>> the parent-view resp. they dont go in the notation model.
> See BasicNodeViewFactory.createView()
> ("ViewUtil.insertChildView(containerView, node, index, persisted);"
> method call).
> Corresponding child elements (compartments/labels) should be attached to
> the parent element there.
>
>> My routine is as follows:
> Looks reasonable. At least, I can not find anythis incorrect in this
> code from the very beggining. Try to continue debugging view factory to
> see the reason of incorrect child elements creation.
>
> -----------------
> Alex Shatalin
>
>
Re: XXXViewFactory.decorateView -> different behavior in GMF 2.1vs.GMF 2.1.1 [message #208668 is a reply to message #208335] Wed, 15 October 2008 10:26 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Thomas,

> for label and compartment are created (I can access them), but NOT
> persisted in the notation model?!
Do you mean, corresponsing objects will be available through EMF api, but
will not be stored in a diagam file? Can you use in-memory instances for
your purposes?

> Maybe there still is a bug somewhere.
Well, I think so. Appropriate ViewFactory should be called through the ViewService
and this part of GMF is definitely working well (at least same sequence of
methods should be executed each time you create a diagram element)...

-----------------
Alex Shatalin
Previous Topic:Unexpected DND Error with GMF 2.1.1
Next Topic:Diagram file won't open, Editor could not be initialized.
Goto Forum:
  


Current Time: Sat Jan 23 18:03:12 GMT 2021

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

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

Back to the top