Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sapphire » Using multiple source models
Using multiple source models [message #730519] Wed, 28 September 2011 14:41 Go to next message
Rob Cernich is currently offline Rob Cernich
Messages: 40
Registered: September 2011
Member
Hey all,

I'm in the process of evaluating Sapphire and have a situation where the user will be editing source that is modified during the build. Because of this, I need access to both the input (source) document and the output (target) document (similar to the Maven pom editor: pom.xml and derived pom.xml). Making matters more complicated, the documents have the same structure and the user may edit details in the derived model, but those changes should be stored in the source model (i.e. the source file overrides any automatically generated content). How might I go about doing something like this in Sapphire?

Thanks in advance,
Rob
Re: Using multiple source models [message #730554 is a reply to message #730519] Wed, 28 September 2011 15:40 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
Well... You should be able to leverage DefaultValueService to present values from build-generated file as default values when editing the source file. When the user sets the value, it would be written to the source file. User will also be able to use existing Sapphire facilities to see what the default value is and to revert to it.

The above should be sufficient for value properties, but if you need to default structured content (provide defaults for list or element properties), we don't support that yet in as simple of a manner. There is an open enhancement request, but it's quite a big chunk of work. Sapphire also has the concept of a resource that sits beneath a model element and handles read/write of properties. It is designed such that adopters can provide their own custom implementation of a resource and it is possible to merge content from multiple files at this level.

- Konstantin
Re: Using multiple source models [message #730590 is a reply to message #730554] Wed, 28 September 2011 16:44 Go to previous messageGo to next message
Rob Cernich is currently offline Rob Cernich
Messages: 40
Registered: September 2011
Member
Hey Konstantin,

Thanks for the reply. Could you please provide a link to that enhancement request? With respect to the resources, is it possible to reparent the elements? For example, if the user wishes to modify an attribute on a derived element, would there be a way for me to merge that with the parent structure in the source document? I'm anticipating that this could get really hairy, really fast, but I'm also guessing I don't fully understand the interaction between resources and elements and how I might go about customizing them.

Thanks again for the help!
Rob
Re: Using multiple source models [message #730605 is a reply to message #730590] Wed, 28 September 2011 17:11 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin Komissarchik
Messages: 940
Registered: July 2009
Senior Member
> Could you please provide a link to that enhancement request?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=329081

> With respect to the resources, is it possible to reparent the elements?
> For example, if the user wishes to modify an attribute on a derived element,
> would there be a way for me to merge that with the parent structure in the
> source document?

Your resource implementation can be arbitrary complex. The default XML resource holds a DOM element that it reads/writes. Your implementation can hold a DOM element from source file and a DOM element from build file. You can then decide that a property write means that you copy some stuff from one DOM element to another before setting the value. Certainly possible, but not exactly easy. May want to consider using Sapphire to implement a simpler editor first before moving on to more complex scenarios like this one.

- Konstantin
Re: Using multiple source models [message #730630 is a reply to message #730605] Wed, 28 September 2011 18:12 Go to previous message
Rob Cernich is currently offline Rob Cernich
Messages: 40
Registered: September 2011
Member
Hey Konstantin,

Thanks for the advice. That's the approach I'm currently taking, as I need some experience with the basics. I'll post an update this thread once I've gotten a little further along.

Thanks again,
Rob
Previous Topic:Generating Code
Next Topic:Status of 0.3.1 release
Goto Forum:
  


Current Time: Tue Sep 23 20:26:22 GMT 2014

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

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