Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » content assistant
content assistant [message #176706] Wed, 07 January 2004 13:34 Go to next message
Eclipse UserFriend
Originally posted by: pieter.west.NOSPAM.nl

I'm trying to add content assistance to an editor I'm writing. However, in
the Edit-menu the item "Content assist" is not showing up.
For this part of the editor I'm relying on the code from a book "The Java
developer's guide to Eclipse" from Shavor. I essentially copied the code
from that book. It does, however, not seem to work (i.e. Ctrl+Space does
nothing).

The code below is what, to my knowledge, should get content assistance to
work:

public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
ContentAssistant assistant;
assistant = new ContentAssistant();
assistant.setContentAssistProcessor(
new MyCompletionProcessor(),
IDocument.DEFAULT_CONTENT_TYPE);
assistant.enableAutoActivation(true);
assistant.setAutoActivationDelay(500);
assistant.setProposalPopupOrientation(
IContentAssistant.CONTEXT_INFO_BELOW);
assistant.setContextInformationPopupOrientation(
IContentAssistant.CONTEXT_INFO_BELOW);
assistant.enableAutoInsert(true);
return assistant;
}

However, I'm probably forgetting something. Could someone point out to me
what I should do to get it to work.
Re: content assistant [message #176729 is a reply to message #176706] Wed, 07 January 2004 13:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jparks.noteworthyms.com

What's going on in MyCompletionProcessor? Specifically, what's inside
computeCompletionProposals?

Do you have a properties file configured for the plugin?

-joe

"Pieter van der Spek" <pieter@west.NOSPAM.nl> wrote in message
news:bth1t9$flo$1@eclipse.org...
> I'm trying to add content assistance to an editor I'm writing. However, in
> the Edit-menu the item "Content assist" is not showing up.
> For this part of the editor I'm relying on the code from a book "The Java
> developer's guide to Eclipse" from Shavor. I essentially copied the code
> from that book. It does, however, not seem to work (i.e. Ctrl+Space does
> nothing).
>
> The code below is what, to my knowledge, should get content assistance to
> work:
>
> public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
> ContentAssistant assistant;
> assistant = new ContentAssistant();
> assistant.setContentAssistProcessor(
> new MyCompletionProcessor(),
> IDocument.DEFAULT_CONTENT_TYPE);
> assistant.enableAutoActivation(true);
> assistant.setAutoActivationDelay(500);
> assistant.setProposalPopupOrientation(
> IContentAssistant.CONTEXT_INFO_BELOW);
> assistant.setContextInformationPopupOrientation(
> IContentAssistant.CONTEXT_INFO_BELOW);
> assistant.enableAutoInsert(true);
> return assistant;
> }
>
> However, I'm probably forgetting something. Could someone point out to me
> what I should do to get it to work.
>
Re: content assistant [message #176827 is a reply to message #176729] Wed, 07 January 2004 17:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse.guide.removeMe.andMeToo.earthlink.net

There is an errata for this chapter that might be the cause. See errata on
this page:
http://www.awprofessional.com/catalog/product.asp?product_id ={DF615A81-6FB0-
4130-9EA4-E2D0BEF340E3}. I thought the publisher did a fairly good job of
hiding this page <g>. If that's not it, repost and I'll bring it to Scott's
attention.

-- Dan
-----------------------------------------------------
co-author, "The Java Developer's Guide to Eclipse"
http://www.amazon.com/exec/obidos/ASIN/0321159640

"Joe Parks" <jparks@noteworthyms.com> wrote in message
news:bth36l$h6o$1@eclipse.org...
> What's going on in MyCompletionProcessor? Specifically, what's inside
> computeCompletionProposals?
>
> Do you have a properties file configured for the plugin?
>
> -joe
>
> "Pieter van der Spek" <pieter@west.NOSPAM.nl> wrote in message
> news:bth1t9$flo$1@eclipse.org...
> > I'm trying to add content assistance to an editor I'm writing. However,
in
> > the Edit-menu the item "Content assist" is not showing up.
> > For this part of the editor I'm relying on the code from a book "The
Java
> > developer's guide to Eclipse" from Shavor. I essentially copied the code
> > from that book. It does, however, not seem to work (i.e. Ctrl+Space does
> > nothing).
> >
> > The code below is what, to my knowledge, should get content assistance
to
> > work:
> >
> > public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
{
> > ContentAssistant assistant;
> > assistant = new ContentAssistant();
> > assistant.setContentAssistProcessor(
> > new MyCompletionProcessor(),
> > IDocument.DEFAULT_CONTENT_TYPE);
> > assistant.enableAutoActivation(true);
> > assistant.setAutoActivationDelay(500);
> > assistant.setProposalPopupOrientation(
> > IContentAssistant.CONTEXT_INFO_BELOW);
> > assistant.setContextInformationPopupOrientation(
> > IContentAssistant.CONTEXT_INFO_BELOW);
> > assistant.enableAutoInsert(true);
> > return assistant;
> > }
> >
> > However, I'm probably forgetting something. Could someone point out to
me
> > what I should do to get it to work.
> >
>
>
Re: content assistant [message #177144 is a reply to message #176729] Thu, 08 January 2004 12:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pieter.west.NOSPAM.nl

This is what happens in MyCompletionProcessor:

public ICompletionProposal[] computeCompletionProposals(ITextViewer
viewer, int documentOffset) {

WordPartDetector wordPart =
new WordPartDetector(viewer, documentOffset);

// iterate over all the different categories
for (int i = 0; i < allWords.length; i++) {
String[] list = (String[]) allWords[i];
// iterate over the current category
for (int y = 0; y < list.length; y++) {
if (list[y].startsWith(wordPart.getString().toUpperCase()))
proposalList.add(list[y]);
}
}

return turnProposalVectorIntoAdaptedArray(wordPart);
}

protected ICompletionProposal[]
turnProposalVectorIntoAdaptedArray(WordPartDetector word) {

ICompletionProposal[] result =
new ICompletionProposal[proposalList.size()];

int index = 0;

for (Iterator i = proposalList.iterator(); i.hasNext();) {
String keyWord = (String) i.next();

IContextInformation info =
new ContextInformation(keyWord, getContentInfoString(keyWord));
//Creates a new completion proposal.
result[index] =
new CompletionProposal(keyWord,
word.getOffset(),
word.getString().length(),
keyWord.length(),
null,
keyWord,
info,
getContentInfoString(keyWord));
index++;
}

proposalList.removeAllElements();
return result;
}


Joe Parks wrote:

> What's going on in MyCompletionProcessor? Specifically, what's inside
> computeCompletionProposals?

> Do you have a properties file configured for the plugin?

> -joe

> "Pieter van der Spek" <pieter@west.NOSPAM.nl> wrote in message
> news:bth1t9$flo$1@eclipse.org...
> > I'm trying to add content assistance to an editor I'm writing. However, in
> > the Edit-menu the item "Content assist" is not showing up.
> > For this part of the editor I'm relying on the code from a book "The Java
> > developer's guide to Eclipse" from Shavor. I essentially copied the code
> > from that book. It does, however, not seem to work (i.e. Ctrl+Space does
> > nothing).
> >
> > The code below is what, to my knowledge, should get content assistance to
> > work:
> >
> > public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
> > ContentAssistant assistant;
> > assistant = new ContentAssistant();
> > assistant.setContentAssistProcessor(
> > new MyCompletionProcessor(),
> > IDocument.DEFAULT_CONTENT_TYPE);
> > assistant.enableAutoActivation(true);
> > assistant.setAutoActivationDelay(500);
> > assistant.setProposalPopupOrientation(
> > IContentAssistant.CONTEXT_INFO_BELOW);
> > assistant.setContextInformationPopupOrientation(
> > IContentAssistant.CONTEXT_INFO_BELOW);
> > assistant.enableAutoInsert(true);
> > return assistant;
> > }
> >
> > However, I'm probably forgetting something. Could someone point out to me
> > what I should do to get it to work.
> >
Re: content assistant [message #177151 is a reply to message #176827] Thu, 08 January 2004 12:44 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pieter.west.NOSPAM.nl

Regretfully, the code concerning content assistance remains the same

Dan Kehn wrote:

> There is an errata for this chapter that might be the cause. See errata on
> this page:
> http://www.awprofessional.com/catalog/product.asp?product_id ={DF615A81-6FB0-
> 4130-9EA4-E2D0BEF340E3}. I thought the publisher did a fairly good job of
> hiding this page <g>. If that's not it, repost and I'll bring it to Scott's
> attention.

> -- Dan
> -----------------------------------------------------
> co-author, "The Java Developer's Guide to Eclipse"
> http://www.amazon.com/exec/obidos/ASIN/0321159640

> "Joe Parks" <jparks@noteworthyms.com> wrote in message
> news:bth36l$h6o$1@eclipse.org...
> > What's going on in MyCompletionProcessor? Specifically, what's inside
> > computeCompletionProposals?
> >
> > Do you have a properties file configured for the plugin?
> >
> > -joe
> >
> > "Pieter van der Spek" <pieter@west.NOSPAM.nl> wrote in message
> > news:bth1t9$flo$1@eclipse.org...
> > > I'm trying to add content assistance to an editor I'm writing. However,
> in
> > > the Edit-menu the item "Content assist" is not showing up.
> > > For this part of the editor I'm relying on the code from a book "The
> Java
> > > developer's guide to Eclipse" from Shavor. I essentially copied the code
> > > from that book. It does, however, not seem to work (i.e. Ctrl+Space does
> > > nothing).
> > >
> > > The code below is what, to my knowledge, should get content assistance
> to
> > > work:
> > >
> > > public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
> {
> > > ContentAssistant assistant;
> > > assistant = new ContentAssistant();
> > > assistant.setContentAssistProcessor(
> > > new MyCompletionProcessor(),
> > > IDocument.DEFAULT_CONTENT_TYPE);
> > > assistant.enableAutoActivation(true);
> > > assistant.setAutoActivationDelay(500);
> > > assistant.setProposalPopupOrientation(
> > > IContentAssistant.CONTEXT_INFO_BELOW);
> > > assistant.setContextInformationPopupOrientation(
> > > IContentAssistant.CONTEXT_INFO_BELOW);
> > > assistant.enableAutoInsert(true);
> > > return assistant;
> > > }
> > >
> > > However, I'm probably forgetting something. Could someone point out to
> me
> > > what I should do to get it to work.
> > >
> >
> >
Re: content assistant [message #177185 is a reply to message #176706] Thu, 08 January 2004 13:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: hcs33.egon.gyaloglo.hu

Hi,

I think you have to register the appropriate actions for your editor as
well. For example to use the content assistant feature for your editor you
need to do something like that:

public class YourEditor ...
{
....
protected void createActions()
{
super.createActions();

// Creates action for content assist (Ctrl+Space)
IAction action = new
TextOperationAction(TranslatorEditorMessages.getResourceBund le(),
"ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS);

action.setActionDefinitionId(ITextEditorActionDefinitionIds. CONTENT_ASSIST_P
ROPOSALS);
setAction("ContentAssistProposal", action);
...
}
....
}

And in the resource bundle you use in TextOperationAction you can use
something like that:
ContentAssistProposal.label=Content Assist@Ctrl+SPACE
ContentAssistProposal.tooltip=Content Assist
ContentAssistProposal.image=
ContentAssistProposal.description=Content Assist

After doing this Ctrl+Space should work.

For including content assist in the context menu (and the main Edit menu)
read Eclipse help-->Platform Plug-in Developer Guide-->Programmer's
Guide-->Editors-->Registering editor actions for details, it may help you.

HTH,
Regards,
Csaba

"Pieter van der Spek" <pieter@west.NOSPAM.nl> wrote in message
news:bth1t9$flo$1@eclipse.org...
> I'm trying to add content assistance to an editor I'm writing. However, in
> the Edit-menu the item "Content assist" is not showing up.
> For this part of the editor I'm relying on the code from a book "The Java
> developer's guide to Eclipse" from Shavor. I essentially copied the code
> from that book. It does, however, not seem to work (i.e. Ctrl+Space does
> nothing).
>
> The code below is what, to my knowledge, should get content assistance to
> work:
>
> public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
> ContentAssistant assistant;
> assistant = new ContentAssistant();
> assistant.setContentAssistProcessor(
> new MyCompletionProcessor(),
> IDocument.DEFAULT_CONTENT_TYPE);
> assistant.enableAutoActivation(true);
> assistant.setAutoActivationDelay(500);
> assistant.setProposalPopupOrientation(
> IContentAssistant.CONTEXT_INFO_BELOW);
> assistant.setContextInformationPopupOrientation(
> IContentAssistant.CONTEXT_INFO_BELOW);
> assistant.enableAutoInsert(true);
> return assistant;
> }
>
> However, I'm probably forgetting something. Could someone point out to me
> what I should do to get it to work.
>
Re: content assistant [message #177660 is a reply to message #177185] Fri, 09 January 2004 12:30 Go to previous message
Eclipse UserFriend
Originally posted by: pieter.west.NOSPAM.nl

This did the trick

Horváth, Csaba wrote:

> Hi,

> I think you have to register the appropriate actions for your editor as
> well. For example to use the content assistant feature for your editor you
> need to do something like that:

> public class YourEditor ...
> {
> ....
> protected void createActions()
> {
> super.createActions();

> // Creates action for content assist (Ctrl+Space)
> IAction action = new
> TextOperationAction(TranslatorEditorMessages.getResourceBund le(),
> "ContentAssistProposal.", this, ISourceViewer.CONTENTASSIST_PROPOSALS);

> action.setActionDefinitionId(ITextEditorActionDefinitionIds. CONTENT_ASSIST_P
> ROPOSALS);
> setAction("ContentAssistProposal", action);
> ...
> }
> ....
> }

> And in the resource bundle you use in TextOperationAction you can use
> something like that:
> ContentAssistProposal.label=Content Assist@Ctrl+SPACE
> ContentAssistProposal.tooltip=Content Assist
> ContentAssistProposal.image=
> ContentAssistProposal.description=Content Assist

> After doing this Ctrl+Space should work.

> For including content assist in the context menu (and the main Edit menu)
> read Eclipse help-->Platform Plug-in Developer Guide-->Programmer's
> Guide-->Editors-->Registering editor actions for details, it may help you.

> HTH,
> Regards,
> Csaba

> "Pieter van der Spek" <pieter@west.NOSPAM.nl> wrote in message
> news:bth1t9$flo$1@eclipse.org...
> > I'm trying to add content assistance to an editor I'm writing. However, in
> > the Edit-menu the item "Content assist" is not showing up.
> > For this part of the editor I'm relying on the code from a book "The Java
> > developer's guide to Eclipse" from Shavor. I essentially copied the code
> > from that book. It does, however, not seem to work (i.e. Ctrl+Space does
> > nothing).
> >
> > The code below is what, to my knowledge, should get content assistance to
> > work:
> >
> > public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
> > ContentAssistant assistant;
> > assistant = new ContentAssistant();
> > assistant.setContentAssistProcessor(
> > new MyCompletionProcessor(),
> > IDocument.DEFAULT_CONTENT_TYPE);
> > assistant.enableAutoActivation(true);
> > assistant.setAutoActivationDelay(500);
> > assistant.setProposalPopupOrientation(
> > IContentAssistant.CONTEXT_INFO_BELOW);
> > assistant.setContextInformationPopupOrientation(
> > IContentAssistant.CONTEXT_INFO_BELOW);
> > assistant.enableAutoInsert(true);
> > return assistant;
> > }
> >
> > However, I'm probably forgetting something. Could someone point out to me
> > what I should do to get it to work.
> >
Previous Topic:Category Sorting in Property Sheets
Next Topic:Eclipse 2.1.2 won't restart after (cvs) compare/merge session
Goto Forum:
  


Current Time: Sat Nov 09 05:04:17 GMT 2024

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

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

Back to the top