Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Dynamic Template Proposal Hover Display
Dynamic Template Proposal Hover Display [message #1033577] Thu, 04 April 2013 11:47 Go to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
I have implemented dynamic template proposals.

The hover box that shows by default includes comments from the source of the proposal. So if you have a cross reference and it's a proposal, you can make some handy documentation available on the suggestion. I really like that.

The hover box that shows with my generated template proposals includes just the text of the template. I don't like that.

I'm having trouble discerning where the hover text for dynamic template proposals comes from.

I overrode getDocumentation in an IEObjectDocumentationProvider, but its not getting called.

I tried getFirstLine and getDocumentation in the DefaultEObjectHoverProvider, but they are not getting called either.

Unfortunately, setting a breakpoint and debugging isn't much help here. (as soon as I leave the open eclipse window, my proposals disappear.

Re: Dynamic Template Proposal Hover Display [message #1033618 is a reply to message #1033577] Thu, 04 April 2013 12:42 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

which Xtext Version do you use?
btw we did customize DefaultTemplateProposalProvider
and customized

@Override
	protected TemplateProposal doCreateProposal(Template template, TemplateContext templateContext,
			ContentAssistContext context, Image image, int relevance) {

		return new XtextTemplateProposal(template, templateContext, context.getReplaceRegion(), image, relevance) {
			@Override
			public String getAdditionalProposalInfo() {
				return ....;			}
		};
	}


~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Dynamic Template Proposal Hover Display [message #1033638 is a reply to message #1033618] Thu, 04 April 2013 13:14 Go to previous messageGo to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
That works perfectly!

Thank you very much!

(I'm using version 2.4 by the way)
Re: Dynamic Template Proposal Hover Display [message #1034926 is a reply to message #1033638] Sat, 06 April 2013 03:59 Go to previous messageGo to next message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
Actually... now that it's fully implemented I'm noticing that html tags don't get interpreted - it's straight text.

Where should I look to add html support for template proposal hovers?
Re: Dynamic Template Proposal Hover Display [message #1034970 is a reply to message #1034926] Sat, 06 April 2013 05:33 Go to previous message
Steve Kallestad is currently offline Steve KallestadFriend
Messages: 62
Registered: March 2013
Member
OK - so I actually figured this one out on my own for once. Some sample code for the next guy:

		return new XtextTemplateProposal (template, templateContext, context.getReplaceRegion(), image, relevance){
			@Override
			public IInformationControlCreator getInformationControlCreator() {
				return new IInformationControlCreator() {
					
					@Override
					public IInformationControl createInformationControl(Shell parent) {
						return new BrowserInformationControl(parent, null, "woohoo");
					}
				};
			}
			@Override
			public String getAdditionalProposalInfo() {
				return commentByDescription(template.getContextTypeId());
			}

I added the "commentByDescription" function because my userData "description" is a unique identifier for where I'm getting the comment from. That identifier is made available when the template becomes visible because I used it as the contextTypeId parameter when creating the template.

I injected a scope provider and a MultilineCommentDocumentationProvider
	@Inject
	IScopeProvider sp;
	
	@Inject
	MultiLineCommentDocumentationProvider mc;

and within my commentByDescription function I simply call the scope, find the element with the matching userData description, and call mc.getDocumentation to get the comment documentation. That only works on things defined in external files if I resolve proxies before calling it.

I didn't include that function because every implementation is going to be different and mine is dependent on changes to my scope provider and NameSpaceAwareLocalScopeProvider and probably a few other places too.
Previous Topic:Context sensitive references?
Next Topic:Question to help straightening some things out
Goto Forum:
  


Current Time: Tue Apr 23 10:19:35 GMT 2024

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

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

Back to the top