Never been to DZone Snippets before?

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

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

content assist field descriptor implementation reusing my ContentAssistFieldCellEditor.

Using this class lets you easily configure a Eclipse IPropertySource with autocompletion fields.
See my ContentAssistFieldCellEditor implementation.

   1  
   2  import org.eclipse.jface.fieldassist.IContentProposalProvider;
   3  import org.eclipse.jface.viewers.CellEditor;
   4  import org.eclipse.swt.widgets.Composite;
   5  import org.eclipse.ui.views.properties.PropertyDescriptor;
   6  
   7  public class ContentAssistFieldDescriptor extends PropertyDescriptor 
   8  {	
   9  	protected char[] completionProposalAutoActivationCharacters;
  10  	protected IContentProposalProvider contentProposalProvider;
  11  	    /**
  12  	     * Creates an property descriptor with the given id and display name.
  13  	     * 
  14  	     * @param id the id of the property
  15  	     * @param displayName the name to display for the property
  16  	     */
  17  	public ContentAssistFieldDescriptor(Object id, String displayName, char[] completionProposalAutoActivationCharacters, IContentProposalProvider contentProposalProvider) 
  18  	{
  19          super( id, displayName);
  20          
  21          this.completionProposalAutoActivationCharacters = completionProposalAutoActivationCharacters;
  22          this.contentProposalProvider = contentProposalProvider;
  23      }
  24  	
  25  	    /**
  26  	     * The ContentAssistFieldPropertyDescriptor implementation of this 
  27  	     * IPropertyDescriptor method creates and returns a new
  28  	     * TextCellEditor.
  29  	     * 
  30  	     * The editor is configured with the current validator if there is one.
  31  	     * 
  32  	     */
  33      @Override
  34      public CellEditor createPropertyEditor(Composite parent) 
  35      {
  36      	ContentAssistFieldCellEditor editor = new ContentAssistFieldCellEditor( parent, completionProposalAutoActivationCharacters, contentProposalProvider);
  37          if (getValidator() != null) 
  38          {
  39  	     editor.setValidator(getValidator());
  40  	}
  41          return editor;
  42      }
  43  }
  44  
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS