Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Creating hyperlinks in Xtext editor
Creating hyperlinks in Xtext editor [message #648711] Fri, 14 January 2011 07:51 Go to next message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
I have an Xtext Editor for my DSL. Let's say one of the construct supported in my DSL has the following syntax: <var_name> = func_name(datasheet{x=y}{z}, arg1, arg2). An example would be a = foo(data{dff=sel}{pin}, b, c).

data{dff=sel}{pin} happens to be a datasheet in an Excel workbook. Let's say this datasheet is in a file called foo_data.xls

In my Xtext editor, I want to create a hyperlink on the word 'data' so that if the user double clicks 'data', I can open up 'foo_data.xls' in an Excel editor. I'm not sure how to create such a hyperlink. Or maybe I want to open up web browser (firefox), and supply a URL for foo_data.xls. Does anyone have any suggestions on how to create the hyperlink on 'data'? Not sure what interfaces I will have to implement.

I read the documentation on Xtext hyperlinking, but it seemed like it was more for linking/cross-referencing to other parts of the Xtext document. I'm not sure that is applicable here.

Thank you for any ideas.
Re: Creating hyperlinks in Xtext editor [message #648712 is a reply to message #648711] Fri, 14 January 2011 07:59 Go to previous messageGo to next message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

you bind your own implementation of HyperlinkHelper, in particular
adapting the createHyperlinksByOffset method. There you check whether
the offset corresponds to the position you are interested in and if so,
create a hyperlink (e.g. XtextHyperlink). If you look at the
XtextHyperlink class, you see that an IURIEditorOpener is responsible
for opening the hyperlink. You may have to bind your own implementation
of that opener as well, in case the default implementation cannot deal
with the URIs you provide.

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: Creating hyperlinks in Xtext editor [message #649132 is a reply to message #648712] Mon, 17 January 2011 19:56 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
Hi

Thanks for the reponse. One question. When you say bind your own impelmentination of HyperLinkHelper, do you mean the following?

public class MyCustomHyperlinkHelper implements IHyperlinkHelper { ...}

bind (HyperlinkHelper.class).to(MyCustomHyperlinkHelper.class)????


I looked at the My<DSL>UIModule.java and I don't see a method called bindIHyperlinkhelper. Thanks.
Re: Creating hyperlinks in Xtext editor [message #649153 is a reply to message #649132] Mon, 17 January 2011 22:33 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 101
Registered: August 2010
Senior Member
Nevermind, I figured it out:

Quote:

public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() { return MyCustomHyperlinkHelper.class; }



Thanks.
Re: Creating hyperlinks in Xtext editor [message #1782097 is a reply to message #649153] Sat, 17 February 2018 14:47 Go to previous messageGo to next message
Mohd Danish is currently offline Mohd DanishFriend
Messages: 49
Registered: October 2017
Member
Hello,

I am also facing the same problem. However, I am not sure where to put this dependency "public Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() { return MyCustomHyperlinkHelper.class; }". These dependencies are present in "src-gen" folder and get override when I run mwe engine. I have found the a xtend file where I think I can put these dependencies but I am not sure how to include them or how to write them in xtend . Please help.
Re: Creating hyperlinks in Xtext editor [message #1782103 is a reply to message #1782097] Sat, 17 February 2018 18:11 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12229
Registered: July 2009
Senior Member
hi,

which dependencies are you talking about?

MyDslUiModule.xtend is in src and you should create your MyCustomHyperlinkHelper there too.

the xtend syntax for the binding is

override Class<? extends IHyperlinkHelper> bindIHyperlinkHelper() { return MyCustomHyperlinkHelper; }



Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Sat, 17 February 2018 18:14]

Report message to a moderator

Previous Topic:Maven generate-sources for two grammars
Next Topic:Lexical syntax highlighting
Goto Forum:
  


Current Time: Wed Sep 19 04:45:05 GMT 2018

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

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

Back to the top