Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » adapting underlying models - loading a emf model and editing a different one
adapting underlying models - loading a emf model and editing a different one [message #513930] Thu, 11 February 2010 12:18 Go to next message
Eclipse UserFriend
Originally posted by: murbieta.gpi.com.ar

Hi, for sake of simplicity i have developed a simplified model for an
existing XSD and also generated its GMF editor. Additionally i have
derivated the XSD schema and generated its EMF components.
So, i'm looking for the right place to introduce a hand-made adapter
that maps when loading the persisted model to the one that will be used
in-memory. this adapter should be called when user performs a save or
load operation.
I have checked GenentityDiagramEditorUtil.createDiagram() and i tried to
introduce a ToBePersistedModel for having both model in memory. It looks
like:
....
attachModelToResource(createToBePersistedModel(), diagramResource);
AModel modelToBeEdited=createToBeEditedInViewMode()
Diagram diagram = ViewService.createDiagram(modelToBeEdited,
ModelEditPart.MODEL_ID,
GenentityDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
if (diagram != null) {
diagramResource.getContents().add(diagram);
diagram.setName(diagramName);
diagram.setElement(modelToBeEdited);
}

But it doesn work..

Thanks in advance.
Re: adapting underlying models - loading a emf model and editing a different one [message #513952 is a reply to message #513930] Thu, 11 February 2010 18:48 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080703070906060901070600
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Matias,

I wonder if this option would help do additional processing during load
and save?

/**
* A {@link ResourceHandler} value that can be registered to
receive call backs
* for loading from an input stream or saving to an output stream.
* @see org.eclipse.emf.ecore.xmi.XMLResource.ResourceHandler
* @see org.eclipse.emf.ecore.xmi.impl.BasicResourceHandler
*/
String OPTION_RESOURCE_HANDLER = "RESOURCE_HANDLER";

In any case, I suspect you're best off to try to hide all this in your
resource implementation rather than be tweaking GMF itself.


Matias Urbieta wrote:
> Hi, for sake of simplicity i have developed a simplified model for an
> existing XSD and also generated its GMF editor. Additionally i have
> derivated the XSD schema and generated its EMF components.
> So, i'm looking for the right place to introduce a hand-made adapter
> that maps when loading the persisted model to the one that will be
> used in-memory. this adapter should be called when user performs a
> save or load operation.
> I have checked GenentityDiagramEditorUtil.createDiagram() and i tried
> to introduce a ToBePersistedModel for having both model in memory. It
> looks like:
> ...
> attachModelToResource(createToBePersistedModel(), diagramResource);
> AModel modelToBeEdited=createToBeEditedInViewMode()
> Diagram diagram = ViewService.createDiagram(modelToBeEdited,
> ModelEditPart.MODEL_ID,
>
> GenentityDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
> if (diagram != null) {
> diagramResource.getContents().add(diagram);
> diagram.setName(diagramName);
> diagram.setElement(modelToBeEdited);
> }
>
> But it doesn work..
>
> Thanks in advance.
>

--------------080703070906060901070600
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Matias,<br>
<br>
I wonder if this option would help do additional processing during load
and save?<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * A {@link ResourceHandler} value that can be registered to
receive call backs </small><br>
<small>&nbsp;&nbsp; * for loading from an input stream or saving to an output
stream.</small><br>
<small>&nbsp;&nbsp; * @see org.eclipse.emf.ecore.xmi.XMLResource.ResourceHandler</small ><br>
<small>&nbsp;&nbsp; * @see org.eclipse.emf.ecore.xmi.impl.BasicResourceHandler</small> <br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String OPTION_RESOURCE_HANDLER = "RESOURCE_HANDLER";</small><br>
</blockquote>
In any case, I suspect you're best off to try to hide all this in your
resource implementation rather than be tweaking GMF itself.<br>
<br>
<br>
Matias Urbieta wrote:
<blockquote cite="mid:hl1du3$kse$1@build.eclipse.org" type="cite">Hi,
for sake of simplicity i have developed a simplified model for an
existing XSD and also generated its GMF editor. Additionally i have
derivated the XSD schema and generated its EMF components.
<br>
So, i'm looking for the right place to introduce a hand-made adapter
that maps when loading the persisted model to the one that will be used
in-memory. this adapter should be called when user performs a save or
load operation.
<br>
I have checked GenentityDiagramEditorUtil.createDiagram() and i tried
to introduce a ToBePersistedModel for having both model in memory. It
looks like:
<br>
....
<br>
attachModelToResource(createToBePersistedModel(), diagramResource);
<br>
AModel modelToBeEdited=createToBeEditedInViewMode()
<br>
Diagram diagram = ViewService.createDiagram(modelToBeEdited,
<br>
ModelEditPart.MODEL_ID,
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
GenentityDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
<br>
if (diagram != null) {
<br>
diagramResource.getContents().add(diagram);
<br>
diagram.setName(diagramName);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; diagram.setElement(modelToBeEdited);
<br>
&nbsp;&nbsp;&nbsp;&nbsp;}
<br>
<br>
But it doesn work..
<br>
<br>
Thanks in advance.
<br>
<br>
</blockquote>
</body>
</html>

--------------080703070906060901070600--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Problem with multiple Link mappings
Next Topic:edit part disposal
Goto Forum:
  


Current Time: Fri Apr 26 23:04:35 GMT 2024

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

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

Back to the top