Home » Modeling » TMF (Xtext) » Additional proposal info for content assist
Additional proposal info for content assist [message #643639] |
Tue, 07 December 2010 12:53  |
Eclipse User |
|
|
|
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 13:43   |
Eclipse User |
|
|
|
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 12:21   |
Eclipse User |
|
|
|
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 05:04] by Moderator
|
|
|
Re: Additional proposal info for content assist [message #644760 is a reply to message #644668] |
Tue, 14 December 2010 02:29   |
Eclipse User |
|
|
|
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 #761592 is a reply to message #644668] |
Tue, 06 December 2011 12:46  |
Eclipse User |
|
|
|
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 15:21] by Moderator
|
|
|
Goto Forum:
Current Time: Sat Jul 05 22:49:44 EDT 2025
Powered by FUDForum. Page generated in 0.04337 seconds
|