DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Content Assist Field Descriptor Implementation Reusing My ContentAssistFieldCellEditor.
Using this class lets you easily configure a Eclipse IPropertySource with autocompletion fields.
See my <a href="http://snippets.dzone.com/posts/show/3944">ContentAssistFieldCellEditor implementation</a>.
import org.eclipse.jface.fieldassist.IContentProposalProvider;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.PropertyDescriptor;
public class ContentAssistFieldDescriptor extends PropertyDescriptor
{
protected char[] completionProposalAutoActivationCharacters;
protected IContentProposalProvider contentProposalProvider;
/**
* Creates an property descriptor with the given id and display name.
*
* @param id the id of the property
* @param displayName the name to display for the property
*/
public ContentAssistFieldDescriptor(Object id, String displayName, char[] completionProposalAutoActivationCharacters, IContentProposalProvider contentProposalProvider)
{
super( id, displayName);
this.completionProposalAutoActivationCharacters = completionProposalAutoActivationCharacters;
this.contentProposalProvider = contentProposalProvider;
}
/**
* The ContentAssistFieldPropertyDescriptor implementation of this
* IPropertyDescriptor method creates and returns a new
* TextCellEditor.
*
* The editor is configured with the current validator if there is one.
*
*/
@Override
public CellEditor createPropertyEditor(Composite parent)
{
ContentAssistFieldCellEditor editor = new ContentAssistFieldCellEditor( parent, completionProposalAutoActivationCharacters, contentProposalProvider);
if (getValidator() != null)
{
editor.setValidator(getValidator());
}
return editor;
}
}





