Skip to main content



      Home
Home » Modeling » Graphiti » Putting it all together
Putting it all together [message #667732] Sun, 01 May 2011 15:57 Go to next message
Eclipse UserFriend
I'd like to use Graphiti to create an editor which ultimately outputs an XML file.

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.
Re: Putting it all together [message #667736 is a reply to message #667732] Sun, 01 May 2011 17:10 Go to previous messageGo to next message
Eclipse UserFriend
Am 01.05.11 21:57, schrieb Stuart Harper:
> 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 *
Re: Putting it all together [message #667813 is a reply to message #667736] Mon, 02 May 2011 05:33 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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
Re: Putting it all together [message #667815 is a reply to message #667813] Mon, 02 May 2011 05:42 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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
Re: Putting it all together [message #667816 is a reply to message #667815] Mon, 02 May 2011 05:44 Go to previous messageGo to next message
Eclipse UserFriend
....obviously, in the last post, i targeted your last question and not the
second...;-)
Re: Putting it all together [message #715552 is a reply to message #667816] Sun, 14 August 2011 09:13 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

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
Re: Putting it all together [message #715710 is a reply to message #715552] Mon, 15 August 2011 05:21 Go to previous message
Eclipse UserFriend
Hi Matt,

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.

Best, Tim
Previous Topic:Bug with Undo after RenameEClassFeature
Next Topic:Diagram properties
Goto Forum:
  


Current Time: Fri Jul 04 17:56:34 EDT 2025

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

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

Back to the top