Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsPutting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/667732/#msg_667732
I've followed the tutorial and I think I understand the basic concepts but I'm having a little trouble figuring out how to use Graphiti to create a functional editor
-I've created an EMF model from the schema for the XML format I want to deal with. From the tutorial I can see I need to use this as the Graphiti diagram is created and edited
-More of a problem is how to provide the functionality of saving the XML file. Does this go in Graphiti or elsewhere? In the tutorial there's no export or indication the model is output is accessible outside of the diagram.
-A little like the save issue, how do I import existing XML files? I've seen the dark processing feature and understand I could run through the file, construct the model and then display the diagram for it but again I don't see where this functionality goes.
Apologies if this is all completely outside Graphiti's scope! Some pointers for where to look would be appreciated.]]>Stuart Harper2011-05-01T19:57:32-00:00Re: Putting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/667736/#msg_667736
> I'd like to use Graphiti to create an editor which ultimately outputs an
> XML file.
Just to clarify - the default file format used to store your EMF Ecore
model is XML-based. I assume that you need to create a different kind of
output file.
I'd recommed to keep the Ecore-based model because it's much easier to
simply generate the "target XML file" when saving the editor.
> -More of a problem is how to provide the functionality of saving the XML
> file. Does this go in Graphiti or elsewhere?
It should be possible to override the method doSave of the DiagramEditor
and add your own XML output to the editor. What method you choose to
create the XML file is up to you. If you use a "complete" workbench
instead of a RCP application, you could also use a builder - in this
case, you don't need to modify the editor at all because the logic to
create your XML file from the diagram file is encapsulated in the builder.
> -A little like the save issue, how do I import existing XML files?
I'd recommend an import wizard that creates the model file from your
existing XML files. How you read these files is again up to you (SAX,
DOM, whatever). You then create the corresponding EMF object (the
"business object", add it to the model file, then create an AddContext
and/or an AddConnectionContext to add the business object to the
diagram. You then pass this context to the feature provider method
addIfPossible (you can get the FP using
GraphitiUI.getExtensionManager().createFeatureProvider(diagr am)).
It's a bit complex, but I'd recommend starting with a simple import
wizard (see http://wiki.eclipse.org/FAQ_How_do_I_add_my_wizard_to_the_Ne w,_Import,_or_Export_menu_categories%3F
and related sources), add some XML reading of your choice and dump the
contents to stderr / stdout. Then add the EMF model objects and use the
reflective editor to check whether that works. If you've got the
non-diagram stuff running, it's much easier to add the diagram creation.
HTH
Volker
--
* Volker Wegert * http://www.volker-wegert.de/contact *]]>Volker Wegert2011-05-01T21:10:04-00:00Re: Putting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/667813/#msg_667813
an idea might be to plug-in your own
org.eclipse.emf.ecore.resource.Resource
implementation.
For handling EMF Resources with regard to Graphiti you may have a look
at the examples.tutorial and the examples.common plugins.
Best regards, Tim]]>Tim Kaiser2011-05-02T09:33:09-00:00Re: Putting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/667815/#msg_667815
regarding your second question, you might have a look at
CreateDiagramWithAllClassesHandler
in the tutorial plug-in.
There you can see an example of how to generate an initial diagram etc
Best, Tim]]>Tim Kaiser2011-05-02T09:42:52-00:00Re: Putting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/667816/#msg_667816
second...;-)]]>Tim Kaiser2011-05-02T09:44:35-00:00Re: Putting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/715552/#msg_715552
I also have a question about XML output in Graphiti.
(apparently the same question as Stuart - sorry, in case I overlooked the answer)
My EMF model is generated out of a XSD. As output file I need a XML file which is valid to this XSD.
As Volker said, the model is stored in XML.
Is there a simple way to get this XML file?
best regards
matt
]]>Matt H.2011-08-14T13:13:03-00:00Re: Putting it all together
https://www.eclipse.org/forums/index.php/mv/msg/208445/715710/#msg_715710
as Volker mentioned you might override
the doSave method in the DiagramEditor
class. There, you can inspect the saved resources, validate them etc.
You might also query a business/graphiti object from the diagram anytime
and use EMF's eResource() method on the object to retrieve its resource.
For how a mapping between EMF Resources/EObjects and Files can be done
you can have a look at Graphiti's EMFService.