Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » References to files
References to files [message #1049714] Fri, 26 April 2013 07:24 Go to next message
Benjamin Schwertfeger is currently offline Benjamin Schwertfeger
Messages: 47
Registered: July 2009
Member
Hello,
I am looking for a solution to reference external files (like images). The solution with a String which is validated, the resource is not updated, if the image is removed.

I have some ideas:

1. I create a new ResourceServiceProvider with EMF-Model to add images to ResourceDescriptions. For each file extension I need another EClass and additional ResourceServiceProvider. This way I can make real links in my grammar (Or is there a knwon Problem with STRING references).

2. A custom Builder "changes" the model files to trigger Xtext Builder. The files to touch can be calculated by evaluating user data of IEObjectDescriptions.

Thanks for comments,
Benjamin
Re: References to files [message #1049723 is a reply to message #1049714] Fri, 26 April 2013 07:39 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
Hi,

can you explain in more detail what you intend to do with the reference to a file? What is the functionality you want to get out of the reference?

For a small project of mine, I had the following requirements:
-check whether the file exists (only in UI)
-on F3 open the file

For that you don't necessarily need references. The validation can be done in a "UIJavavalidator" which overrides the normal one in the UI-Project only. There you can validate the "URI-String" against the existing workspace-content.
For F3 you bind a hyperlink helper that creates the correct file URI for the corresponding positions. The regular eclipse URI-Opener mechanisms can then be used.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: References to files [message #1049756 is a reply to message #1049723] Fri, 26 April 2013 08:26 Go to previous messageGo to next message
Benjamin Schwertfeger is currently offline Benjamin Schwertfeger
Messages: 47
Registered: July 2009
Member
Hi Alex,
I use the referenced files for a generator to copy and reference them. Before starting the generator I check, if the Resources contains errors. If the file does not exist, the generator can only exit with error message and the user get the feedback long time after the file was renamed.

The UIJavaValidator is a nice way to realize UI-Validations. For existence of resources, the normal Validator is sufficient.

Benjamin
Re: References to files [message #1049807 is a reply to message #1049756] Fri, 26 April 2013 09:49 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
The underlying question remains. Do you really need a reference (making sure all necessary files are indexed, scoping,...) to the file or would it be sufficient to interpret a string for validation/generation.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: References to files [message #1049811 is a reply to message #1049807] Fri, 26 April 2013 09:52 Go to previous messageGo to next message
Benjamin Schwertfeger is currently offline Benjamin Schwertfeger
Messages: 47
Registered: July 2009
Member
Sorry, I do not need real references but need to trigger validation, if the "referenced" image is removed. The linking and content assist are done manually.
Re: References to files [message #1049869 is a reply to message #1049811] Fri, 26 April 2013 11:31 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander Nittka
Messages: 1156
Registered: July 2009
Senior Member
Well,

I am speculating here... Going with option 2 of your original post, you might register an IResourceChangeListener that triggers a build in case files change. I had not read the post thoroughly enough: user data for "referenced" files would have been one of my suggestions as well.

Currently, I would prefer that approach as you are not forced to adapt everything once a new image type is to be supported.

Alex


Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext@itemis.de
Re: References to files [message #1051326 is a reply to message #1049714] Sun, 28 April 2013 16:04 Go to previous message
Sebastian Zarnekow is currently offline Sebastian Zarnekow
Messages: 2837
Registered: July 2009
Senior Member
Hi Benjamin,

the approach #1 is the one that I'd go forward with. The emf resource
impl could be straight forward and just ignore the file contents. If you
register a service provider for that one, everything else should work
like a charm. There are no known problems with references that use
STRING as underlying representation.

Best regards,
Sebastian
--
Looking for professional support for Xtext, Xtend or Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 26.04.13 09:24, schrieb Benjamin Schwertfeger:
> Hello,
> I am looking for a solution to reference external files (like images).
> The solution with a String which is validated, the resource is not
> updated, if the image is removed.
>
> I have some ideas:
>
> 1. I create a new ResourceServiceProvider with EMF-Model to add images
> to ResourceDescriptions. For each file extension I need another EClass
> and additional ResourceServiceProvider. This way I can make real links
> in my grammar (Or is there a knwon Problem with STRING references).
>
> 2. A custom Builder "changes" the model files to trigger Xtext Builder.
> The files to touch can be calculated by evaluating user data of
> IEObjectDescriptions.
>
> Thanks for comments,
> Benjamin
Previous Topic:Check duplicate name in the same Scop
Next Topic:Selection Listener
Goto Forum:
  


Current Time: Tue Sep 23 20:25:47 GMT 2014

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

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