Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Reading from the memory
Reading from the memory [message #171896] Fri, 08 February 2008 15:06 Go to next message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Good afternoon!!

I have to make a staff but I have no idea how to start. I have a simple
sequence diagram editor, where I have nodes and edges between nodes. My
Diagram Element is called Diagram, and the nodes are stored in it and the
edges between the nodes are stored in the sourceNode.

So, I know that when a Diagram Element is created, it is stored in the
memory. All this staff is made by GMF, doesn't it? And when I use the editor
and I create a node, it is stored in the diagram, in the memory. When I
click on save button, all the information that was stored in the memory,
will be stored in the file.

So, if I am right, now, I have to get this stored information and I have to
use it. So, my question is, how can I get this information? How can I get
the diagram that is stored in the memory? If I am not wrong, there should
exist some Extension Points that help me doing this staff, doesn't they?

If somebody helps me, it would be greatful. Thanks in advance.

Aritz

P.D: Sorry because of my poor english.
Re: Reading from the memory [message #172057 is a reply to message #171896] Mon, 11 February 2008 13:23 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Aritz,

You can load diagram.model file sy using EMF API - standard EMF serialization
mechanizm used to store all information to disk.

If you need instnace of model element(s) loaded by diagram editor then you
can access it either from the eclipse selection or using xxxDiagramEditor.getDiagram()
method.

-----------------
Alex Shatalin
Re: Reading from the memory [message #172363 is a reply to message #172057] Wed, 13 February 2008 08:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Hello Alex and others,

I have read your answer and I am thank you because of it. The problem is
that I knew about it before and this is not what I am looking for. Maybe I
didn't explain very well what I meant.

So, apart the diagram that is stored in the memory, I want to get all the
changes that the user makes. I mean, I have a new diagram that is stored in
the memory, and this is in the screen to be used by the user; so, I when the
user makes a change, I want to get the change, "I want to be notified". So,
if I am not wrong, there should exist some Extension Points that help me
doing this staff, doesn't they?

I hope that you will understand. Thanks in advance.

Aritz

P.D: I am sorry because of my poor English.




"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e61db208ca3ad0cab71cac@news.eclipse.org...
> Hello Aritz,
>
> You can load diagram.model file sy using EMF API - standard EMF
> serialization mechanizm used to store all information to disk.
>
> If you need instnace of model element(s) loaded by diagram editor then you
> can access it either from the eclipse selection or using
> xxxDiagramEditor.getDiagram() method.
>
> -----------------
> Alex Shatalin
>
>
Re: Reading from the memory [message #172439 is a reply to message #172363] Wed, 13 February 2008 14:28 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Aritz,

If you'd like to receive notifications on any model changes then you should
use EMF Adapters mechanism. You can have a look on org.eclipse.emf.ecore.util.EContentAdapter
if you need to receive any notifications from any model elements.

-----------------
Alex Shatalin
Re: Reading from the memory [message #172795 is a reply to message #172439] Mon, 18 February 2008 14:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: aritz.galdos.iese.fraunhofer.de

Hello,

Thank you for your answers but I am sorry because I am not sure what you
mean exactly. In this moment, I have my workspace, my workspace root, my
project, my file, my editor... (the source code is in the end).

Now, I have to get the model, I think that is called the runtime model,
because when the user makes a modification in the editor, I have to be
notified for this change. Alex answered me that the
org.eclipse.emf.ecore.util.EContentAdapter package is about the
notifications.The problem is that I have to get the model, where all the
information is stored in the file but I don't know. Alex answered me:

"You can load diagram.model file sy using EMF API - standard EMF
serialization
mechanizm used to store all information to disk.
If you need instnace of model element(s) loaded by diagram editor then you
can access it either from the eclipse selection or using
xxxDiagramEditor.getDiagram()method."



I am sorry but I don't understand what you mean. I have been looking for the
explanation but I couldn't. I hope that somebody could help me.



//getting the workspace

IWorkspace myWorkspace =
org.eclipse.core.resources.ResourcesPlugin.getWorkspace();



//getting the root of the workspace

IWorkspaceRoot myWorkspaceRoot = myWorkspace.getRoot();



//getting the project

String projectName = "new_Project";

IProject myProject = myWorkspaceRoot.getProject(projectName);



//getting the file

String fileName = "default.ecore_diagram";

IFile myFile = myProject.getFile(fileName);



//getting the editor

IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActi vePage();

IEditorDescriptor desc =
PlatformUI.getWorkbench().getEditorRegistry().getDefaultEdit or(myFile.getName());

IEditorInput myEditorInput = new FileEditorInput(myFile);

String myDescId = desc.getId();

try {

EditorPart myEditor = (EditorPart) page.openEditor(myEditorInput,
myDescId);

System.out.println ("myEditor: " + myEditor);

}catch (Exception e) {

System.out.println("PartInitException: " + e);}



Thank you in advance, and I am sorry because of my poor English.



Aritz




"Alex Shatalin" <vano@borland.com> wrote in message
news:3c3172e61dd828ca3c6c38503d80@news.eclipse.org...

> Hello Aritz,
>
> If you'd like to receive notifications on any model changes then you
> should use EMF Adapters mechanism. You can have a look on
> org.eclipse.emf.ecore.util.EContentAdapter if you need to receive any
> notifications from any model elements.
>
> -----------------
> Alex Shatalin
Re: Reading from the memory [message #172832 is a reply to message #172795] Mon, 18 February 2008 16:43 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Aritz,

> EditorPart myEditor = (EditorPart) page.openEditor(myEditorInput,
> myDescId);
DiagramDocumentEditor myDiagramDocumentEditor = (DiagramDocumentEditor) myEditor;
Diagram myDiagram = myDiagramDocumentEditor.getDiagram();

/*
* Process view-related information here, access other diagram elements using:
*
* myDiagram.getEdges()
* myDiagram.getChildren()
*/

EObject myUnderlyingDomainElement = myDiagram.getElement();
/*
* Process domain-specific information here using
* myUnderlyingDomainElement
*/


-----------------
Alex Shatalin
Previous Topic:automatic diagram migration
Next Topic:[GMF|OAW] imcomplete gmfmap metamodel
Goto Forum:
  


Current Time: Thu May 09 11:16:40 GMT 2024

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

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

Back to the top