Home » Modeling » TMF (Xtext) » Additional proposal info for content assist
Additional proposal info for content assist [message #643639] |
Tue, 07 December 2010 17:53 |
Jérôme Fouletier 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 |
Sebastian Zarnekow 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 |
Jérôme Fouletier 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 |
Sebastian Zarnekow 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
|
|
| | |
Goto Forum:
Current Time: Tue Apr 23 08:34:27 GMT 2024
Powered by FUDForum. Page generated in 0.04454 seconds
|