Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Additional proposal info for content assist
Additional proposal info for content assist [message #643639] Tue, 07 December 2010 17:53 Go to next message
Jérôme Fouletier is currently offline Jérôme FouletierFriend
Messages: 39
Registered: September 2010
Location: France
Member
In order to make the info popup appear side-by-side with the content assist popup, one has to set the so-called additional proposal info text in the ConfigurableCompletionProposal.
The easiest way I've found to do this, is, in the MyDSLProposalProvider, to override doCreateProposal as follows:
 @Override
  protected ConfigurableCompletionProposal doCreateProposal(String proposal,
		StyledString displayString, Image image, int priority,
		ContentAssistContext context) {
	ConfigurableCompletionProposal theproposal = super
					.doCreateProposal(proposal, displayString, image, priority, context);
	if ( /* test the context */)
	        //Calculate the info text
		theproposal.setAdditionalProposalInfo(infotext);		
	}
	return theproposal;
  }

This has the intended effect, i.e. the extra text is displayed in a popup when scrolling the content assist. However, there are some severe drawbacks:
- not all context information is known at this point, making the recovery of extra info pretty difficult. I'm not sure, for example, that the current candidate EObject or EObjectReference can be found.
- I'm not quite sure it's safe to start digging in the model at that point.

Lastly, it also seems impossible to override the way the info is displayed, in order, for example, to replace the plain text viewer with something more convenient, like a javadoc viewer.

Any thoughts on the subject are welcome.
Re: Additional proposal info for content assist [message #643655 is a reply to message #643639] Tue, 07 December 2010 18:43 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jerome,

please see below.

Am 07.12.10 18:53, schrieb Jerome:
> In order to make the info popup appear side-by-side with the content
> assist popup, one has to set the so-called additional proposal info text
> in the ConfigurableCompletionProposal.
> The easiest way I've found to do this, is, in the MyDSLProposalProvider,
> to override doCreateProposal as follows:
> @Override
> protected ConfigurableCompletionProposal doCreateProposal(String proposal,
> StyledString displayString, Image image, int priority,
> ContentAssistContext context) {
> ConfigurableCompletionProposal theproposal = super
> .doCreateProposal(proposal, displayString, image, priority, context);
> if ( /* test the context */)
> //Calculate the info text
> theproposal.setAdditionalProposalInfo(infotext);
> }
> return theproposal;
> }
> This has the intended effect, i.e. the extra text is displayed in a
> popup when scrolling the content assist. However, there are some severe
> drawbacks:
> - not all context information is known at this point, making the
> recovery of extra info pretty difficult. I'm not sure, for example, that
> the current candidate EObject or EObjectReference can be found.

Right, that is inconvenient.
You could try to replace the
AbstractJavaBasedContentProposalProvider.DefaultProposalCrea tor which
provides access to the target object of a cross link.

> - I'm not quite sure it's safe to start digging in the model at that point.

It's always safe to navigate the object graphs that are provided by the
context.

>
> Lastly, it also seems impossible to override the way the info is
> displayed, in order, for example, to replace the plain text viewer with
> something more convenient, like a javadoc viewer.
>

You proposal has to implement ICompleteProposalExtension3 in order to
replace the information control creator.

> Any thoughts on the subject are welcome.

Xtext 2.0 has a very nice solution for this problem. Please feel free to
dig into the code of the master branch.

Regards,
Sebastian
--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com
Re: Additional proposal info for content assist [message #644668 is a reply to message #643639] Mon, 13 December 2010 17:21 Go to previous messageGo to next message
Jérôme Fouletier is currently offline Jérôme FouletierFriend
Messages: 39
Registered: September 2010
Location: France
Member
Thanks for the tips.
I ended up extending ConfigurableCompletionProposal with implementation of ICompletionProposalExtension3 and override one doCreateProposal signature in the xtext-created MydslProposalProvider:
protected ConfigurableCompletionProposal doCreateProposal(String proposal,
			StyledString displayString, Image image, int replacementOffset,
			int replacementLength)
       // create the extended configurable completion proposal
          return new MydslConfigurableCompletionProposal(proposal, displayString, image,
				replacementOffset, replacementLength)

The actual calculation of the additional info text is done in the override of :
public ICompletionProposal apply(IEObjectDescription candidate) {
           ICompletionProposal proposal = super.apply(candidate);
           ConfigurableCompletionProposal castproposal = (ConfigurableCompletionProposal) proposal;
           // calculate help string from the candidate
           castproposal.setAdditionalProposalInfo(helptxt);
           return castproposal;
}

The MydslConfigurableCompletionProposal then can implement getInformationControlCreator() to create a DefaultInformationControl that supports a small subset of HTML tags, which is not the case in the default 1.0.1 implementation. It also must implement the constructor used above via a super call.

[Updated on: Tue, 14 December 2010 10:04]

Report message to a moderator

Re: Additional proposal info for content assist [message #644760 is a reply to message #644668] Tue, 14 December 2010 07:29 Go to previous messageGo to next message
Sebastian Zarnekow is currently offline Sebastian ZarnekowFriend
Messages: 3118
Registered: July 2009
Senior Member
Hi Jerome,

thanks for keeping us posted. However, you messages seems to be
trunkated (see below). Would you mind to repost it so others can use
your solution as a reference?

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

Am 13.12.10 18:21, schrieb Jerome:
> Thanks for the tips.
> I ended up extending ConfigurableCompletionProposal with implementation
> of ICompletionProposalExtension3 and override one doCreateProposal
> signature in the xtext-created MydslProposalProvider:
> protected ConfigurableCompletionProposal doCreateProposal(String proposal,
> StyledString displayString, Image image, int replacementOffset,
> int replacementLength)
> // create the extended configurable completion proposal
> The actual calculation of the additional info text is done in the
> override of public ICompletionProposal apply(IEObjectDescription candidate)
> Apparently, there is no need to inject anything more than
Re: Additional proposal info for content assist [message #644811 is a reply to message #643639] Tue, 14 December 2010 10:05 Go to previous messageGo to next message
Jérôme Fouletier is currently offline Jérôme FouletierFriend
Messages: 39
Registered: September 2010
Location: France
Member
Yes, I had made a mistake in pressing the publish button too quickly. The message is now up to date.
Re: Additional proposal info for content assist [message #761592 is a reply to message #644668] Tue, 06 December 2011 17:46 Go to previous message
Federico Sellanes is currently offline Federico SellanesFriend
Messages: 71
Registered: November 2011
Member
jerome.fouletier wrote on Mon, 13 December 2010 12:21


The MydslConfigurableCompletionProposal then can implement getInformationControlCreator() to create a DefaultInformationControl that supports a small subset of HTML tags, which is not the case in the default 1.0.1 implementation. It also must implement the constructor used above via a super call.



Exist another InformationControl that support all the html tags?

I tryed to test the BrowserInformationControl but i get "DiscouragedAccess".

EDIT:

I solved that adding this class in my project http://java2s.com/Open-Source/Java-Document/IDE-Eclipse/pde/org/eclipse/pde/internal/ui/editor/contentassist/display/BrowserInformationControl.java.htm

EDIT2:

Is not solved, the BrowserInformationControl support all html tags, but not work properly, the content assist close if i try to scroll.

EDIT3:

Apparently "discourage warning" not affect the use of BrowserInformationControl, i did not know that, sorry. Its working.

Me -> Noob

Ignore the post.

[Updated on: Tue, 06 December 2011 20:21]

Report message to a moderator

Previous Topic:String to Integer Conversion in Xtend2
Next Topic:Folding woes
Goto Forum:
  


Current Time: Tue Apr 23 08:34:27 GMT 2024

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

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

Back to the top