Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » File names of all the resources in workspace
File names of all the resources in workspace [message #647388] Wed, 05 January 2011 22:07 Go to next message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
I'm implementing an HyperlinkHelper. I would like to link an include
statement to the correct file.
How can I obtain files names of all the Resources in the workspace?
Thankyou in advance
Re: File names of all the resources in workspace [message #647390 is a reply to message #647388] Wed, 05 January 2011 22:25 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Diego,

IResourceDescriptions#getAllResourceDescriptions will return all known
resources which expose their URI.
Simply use
@Inject
private IResourceDescriptions descriptions;
in your HyperlinkHelper.

Does that help?

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 05.01.11 23:07, schrieb Diego Castronuovo:
> I'm implementing an HyperlinkHelper. I would like to link an include
> statement to the correct file.
> How can I obtain files names of all the Resources in the workspace?
> Thankyou in advance
Re: File names of all the resources in workspace [message #647891 is a reply to message #647390] Mon, 10 January 2011 10:55 Go to previous messageGo to next message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
thank you Sebastian, this help me. But now I dont know how to link my grammar element to the file (the correct Uri). With this:


Iterable<IResourceDescription> allResourceDescriptions = descriptions.getAllResourceDescriptions();
for (IResourceDescription description : allResourceDescriptions) {
.....
FileName fileName = (FileName) eObject;
if(description.getURI().toString().contains(fileName.getName ().toString())) {

// Now I dont know how to tell to linker to open the file...

}
Re: File names of all the resources in workspace [message #647911 is a reply to message #647891] Mon, 10 January 2011 12:32 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jake,

please have a look at the org.eclipse.xtext.ui.editor.IURIEditorOpener.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 10.01.11 11:55, schrieb Jake:
> thank you Sebastian, this help me. But now I dont know how to link my
> grammar element to the file (the correct Uri). With this:
>
>
> Iterable<IResourceDescription> allResourceDescriptions =
> descriptions.getAllResourceDescriptions();
> for (IResourceDescription description : allResourceDescriptions) { .....
> FileName fileName = (FileName) eObject;
> if(description.getURI().toString().contains(fileName.getName
> ().toString())) { // Now I dont know how to tell to linker to open the
> file... }
Re: File names of all the resources in workspace [message #648150 is a reply to message #647911] Tue, 11 January 2011 13:49 Go to previous messageGo to next message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
Thankyou very much!

with this:

uriEditorOpener.open(description.getURI(), true);

I'm able to open the correct file, but there is just a problem. The file is opening without any click! I mean, simple passing with the cursor and ctrl/cmd pressed. Any idea?
Re: File names of all the resources in workspace [message #648217 is a reply to message #648150] Tue, 11 January 2011 20:26 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jake,

sorry, but I have the strong impression that I'm doing your homework ...
Nevertheless:
<copy'n'paste from the documentation which is available as Eclipse help>
Customizing Available Hyperlinks

The hyperlinks are provided by the HyperlinkHelper which will create
links for cross-referenced objects by default. Clients may want to
override createHyperlinksByOffset(XtextResource, int,
IHyperlinkAcceptor) to provide additional links or supersede the default
implementation.
</end>

Create instances of XtextHyperlink, configure their URI and pass them
into the acceptor. Please look at HyperlinkHelper#createHyperlinksTo to
learn more about the API.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com

Am 11.01.11 14:49, schrieb Jake:
> Thankyou very much!
>
> with this:
>
> uriEditorOpener.open(description.getURI(), true);
>
> I'm able to open the correct file, but there is just a problem. The file
> is opening without any click! I mean, simple passing with the cursor and
> ctrl/cmd pressed. Any idea?
>
Re: File names of all the resources in workspace [message #648222 is a reply to message #648217] Tue, 11 January 2011 21:05 Go to previous message
Jake is currently offline JakeFriend
Messages: 21
Registered: November 2010
Junior Member
Sorry, i'm a newbie. I found what I need here:

http://code.google.com/a/eclipselabs.org/p/elysium/source/br owse/org.elysium.ui/src/org/elysium/ui/hyperlinks/LilyPondHy perlinkHelper.java?spec=svn4283d31181514423bead01f7e7d8c2f46 1aafe7e&r=4283d31181514423bead01f7e7d8c2f461aafe7e

Thankyou
bye
Previous Topic:How to relate an externel model with my textual model created with xtext
Next Topic:problem of semantic predicates in Xtext
Goto Forum:
  


Current Time: Thu Apr 25 12:21:51 GMT 2024

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

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

Back to the top