adapting underlying models - loading a emf model and editing a different one [message #513930] |
Thu, 11 February 2010 12:18 |
Eclipse User |
|
|
|
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 |
Ed Merks Messages: 33216 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> /**</small><br>
<small> * A {@link ResourceHandler} value that can be registered to
receive call backs </small><br>
<small> * for loading from an input stream or saving to an output
stream.</small><br>
<small> * @see org.eclipse.emf.ecore.xmi.XMLResource.ResourceHandler</small ><br>
<small> * @see org.eclipse.emf.ecore.xmi.impl.BasicResourceHandler</small> <br>
<small> */</small><br>
<small> 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>
GenentityDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT);
<br>
if (diagram != null) {
<br>
diagramResource.getContents().add(diagram);
<br>
diagram.setName(diagramName);
<br>
diagram.setElement(modelToBeEdited);
<br>
}
<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/
|
|
|
Powered by
FUDForum. Page generated in 0.02541 seconds