Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Creating hyperlinks in Xtext editor
Creating hyperlinks in Xtext editor [message #648711] Fri, 14 January 2011 02:51 Go to next message
Eclipse UserFriend
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 02:59 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: Creating hyperlinks in Xtext editor [message #649132 is a reply to message #648712] Mon, 17 January 2011 14:56 Go to previous messageGo to next message
Eclipse UserFriend
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 17:33 Go to previous messageGo to next message
Eclipse UserFriend
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 09:47 Go to previous messageGo to next message
Eclipse UserFriend
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 13:11 Go to previous message
Eclipse UserFriend
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; }

[Updated on: Sat, 17 February 2018 13:14] by Moderator

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


Current Time: Thu Jul 03 10:51:28 EDT 2025

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

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

Back to the top