How to display IInformationControl? [message #178021] |
Thu, 16 September 2004 13:50 |
Eclipse User |
|
|
|
Originally posted by: zcox.cra.com
Hi all - I'm a newbie to Eclipse plug-in development (just started this
morning). I'm trying to add a new Quick Assist (see
org.eclipse.jdt.ui.quickAssistProcessors). Everything is setup correctly
and my IQuickAssistProcessor is getting called as it should.
What I want to do is to display a custom GUI to the user with a bunch of
radio buttons that they can use to configue the Quick Assist. I created a
custom implementation of IJavaCompletionProposal and also had it implement
ICompletionProposalExtension3 to get the getInformationControlCreator
method. In that method I return a custom implementation of
IInformationControlCreator that returns a new DefaultInformationControl in
its createInformationControl method. I'm using DefaultInformationControl
just to test this all out and see if I can get a custom GUI component to
display.
However, the DefaultInformationControl only appears on-screen if I call
setVisible(true) on it before returning it, and even then it only appears
for a split-second before disappearing.
Below is the code I'm using - can anyone see anything wrong with it? I
apologize if this isn't the right place to ask this kind of question.
package com.cra.shared.lit;
import org.eclipse.core.runtime.*;
import org.eclipse.jdt.ui.text.java.*;
import org.eclipse.jface.text.*;
import org.eclipse.jface.text.contentassist.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
public class ListImplementationToolProcessor implements
IQuickAssistProcessor
{
public boolean hasAssists(IInvocationContext context) throws
CoreException
{
return true;
}
public IJavaCompletionProposal[] getAssists(IInvocationContext context,
IProblemLocation[] locations) throws CoreException
{
return new IJavaCompletionProposal[] {new LitJavaCompletionProposal()};
}
public static class LitJavaCompletionProposal implements
IJavaCompletionProposal, ICompletionProposalExtension3
{
public int getRelevance()
{
return 100;
}
public void apply(IDocument document)
{
}
public Point getSelection(IDocument document)
{
return null;
}
public String getAdditionalProposalInfo()
{
return "Additional Proposal Info";
}
public String getDisplayString()
{
return "Choose List Implementation";
}
public Image getImage()
{
return null;
}
public IContextInformation getContextInformation()
{
return null;
}
public IInformationControlCreator getInformationControlCreator()
{
System.out.println("getInformationControlCreator");
return new LitInformationControlCreator();
}
public CharSequence getPrefixCompletionText(IDocument document, int
completionOffset)
{
return null;
}
public int getPrefixCompletionStart(IDocument document, int
completionOffset)
{
return 0;
}
}
public static class LitInformationControlCreator implements
IInformationControlCreator
{
public IInformationControl createInformationControl(Shell parent)
{
System.out.println("createInformationControl: " + parent);
DefaultInformationControl control = new
DefaultInformationControl(parent);
control.setInformation("This is a custom information control.");
control.setVisible(true);
return control;
}
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.03853 seconds