[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform] Re: rich text in content assist additional info

Xavier Décoret wrote:

Daniel Megert a écrit :

Xavier Décoret wrote:

Hi,

I am trying to display rich text in additional info of a CompletionProposal, but this does not work:

result.add(new CompletionProposal(candidate,o,offset-o,candidate.length(),
null,
candidate,
null,
"Additional <em>info</em> with <b>tags</b>"));



Does anyone know how to do this?


Either your proposal or your content assistant must use an information control creator that can handle those tags. As a reference take a look at
JavaSourceViewerConfiguration.getInformationControlCreator(ISourceViewer)


   JavaSourceViewerConfiguration.getContentAssistant(ISourceViewer)

Dani


That's what I ended up doing:

public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

        ContentAssistant assistance = new ContentAssistant();
        MyContentAssistProcessor qcp = new MyContentAssistProcessor();

assistance.setContentAssistProcessor(qcp,IDocument.DEFAULT_CONTENT_TYPE);
assistance.setInformationControlCreator(new IInformationControlCreator() {
@SuppressWarnings("restriction")
public IInformationControl createInformationControl(Shell parent) {
return new DefaultInformationControl(parent, new HTMLTextPresenter());
}
});
assistance.enableAutoActivation(true);
assistance.setAutoActivationDelay(500);


assistance.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);

        return assistance;
    }

where I use the HTMLTextPresenter of package org.eclipse.jface.internal.text.link.contentassist but I have two problems:

- First Eclipse (3.2) give me a warning (hence the @SuppressWarnings("restriction")) so I guess I am doing this wrong

Correct, because this is internal non-API code.

- The above HTMLTextPresenter only support a very basic subset of HTML.

That's why it is internal. It only handles a minimal set that fitted to our needs.



I am missing something?

Nope, but if you can live with a dependency to JDT UI then you could get it via JavaSourceViewerConfiguration. This is even better because it uses an HTML Browser as information control and hence can handle all html.


Dani