Example usage for org.eclipse.jface.fieldassist ContentProposalAdapter FILTER_NONE

List of usage examples for org.eclipse.jface.fieldassist ContentProposalAdapter FILTER_NONE

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist ContentProposalAdapter FILTER_NONE.

Prototype

int FILTER_NONE

To view the source code for org.eclipse.jface.fieldassist ContentProposalAdapter FILTER_NONE.

Click Source Link

Document

Indicates that there should be no filter applied as keys are typed in the popup.

Usage

From source file:com.siteview.mde.internal.ui.util.PDEJavaHelperUI.java

License:Open Source License

/**
 * Disposer returned used to dispose of label provider and remove listeners
 * Callers responsibility to call dispose method when underlying text 
 * widget is being disposed/*from  w  w  w .  jav  a 2s.c o  m*/
 * @param text
 * @param project
 */
public static TypeFieldAssistDisposer addTypeFieldAssistToText(Text text, IProject project, int searchScope) {
    // Decorate the text widget with the light-bulb image denoting content
    // assist
    int bits = SWT.TOP | SWT.LEFT;
    ControlDecoration controlDecoration = new ControlDecoration(text, bits);
    // Configure text widget decoration
    // No margin
    controlDecoration.setMarginWidth(0);
    // Custom hover tip text
    String description = null;
    IBindingService bindingService = (IBindingService) PlatformUI.getWorkbench()
            .getAdapter(IBindingService.class);
    TriggerSequence[] activeBindings = bindingService
            .getActiveBindingsFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
    if (activeBindings.length == 0)
        description = MDEUIMessages.PDEJavaHelper_msgContentAssistAvailable;
    else
        description = NLS.bind(MDEUIMessages.PDEJavaHelper_msgContentAssistAvailableWithKeyBinding,
                activeBindings[0].format());

    controlDecoration.setDescriptionText(description);

    // Custom hover properties
    controlDecoration.setShowHover(true);
    controlDecoration.setShowOnlyOnFocus(true);
    // Hover image to use
    FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    controlDecoration.setImage(contentProposalImage.getImage());

    // Create the proposal provider
    TypeContentProposalProvider proposalProvider = new TypeContentProposalProvider(project, searchScope);
    // Default text widget adapter for field assist
    TextContentAdapter textContentAdapter = new TextContentAdapter();
    // Set auto activation character to be a '.'
    char[] autoActivationChars = new char[] { TypeContentProposalProvider.F_DOT };
    // Create the adapter
    ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter,
            proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST, autoActivationChars);
    // Configure the adapter
    // Add label provider
    ILabelProvider labelProvider = new TypeProposalLabelProvider();
    adapter.setLabelProvider(labelProvider);
    // Replace text field contents with accepted proposals
    adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    // Disable default filtering - custom filtering done
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    // Add listeners required to reset state for custom filtering
    TypeContentProposalListener proposalListener = new TypeContentProposalListener();
    adapter.addContentProposalListener((IContentProposalListener) proposalListener);
    adapter.addContentProposalListener((IContentProposalListener2) proposalListener);

    return new TypeFieldAssistDisposer(adapter, proposalListener);
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandDataDialog.java

License:Open Source License

private ContentProposalAdapter addContentAssistSimple(Text textControl) {
    char[] autoActivationCharacters = new char[] { '$', '{' };
    KeyStroke keyStroke = null;/* w w  w. ja v a 2  s  . c o  m*/
    try {
        keyStroke = KeyStroke.getInstance("Ctrl+Space");
    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // assume that myTextControl has already been created in some way
    List<Variable> variables = Variable.getVisibleVariables();
    String[] proposals = new String[variables.size()];
    for (int i = 0; i < variables.size(); i++) {
        proposals[i] = variables.get(i).getFullVariableName();
    }
    ContentProposalAdapter adapter = new ContentProposalAdapter(textControl, new TextContentAdapter(),
            new SimpleContentProposalProvider(proposals), keyStroke, autoActivationCharacters);
    adapter.setPropagateKeys(false);
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    //adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    return adapter;
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.CommandDataDialog.java

License:Open Source License

private ContentProposalAdapter addContentAssistExtended(Text textControl) {
    char[] autoActivationCharacters = new char[] { '$', '{' };
    Map<String, String> proposals = new LinkedHashMap<String, String>();
    // add own variables
    proposals.putAll(Variable.getVariableInfoMap());
    // add eclipse variables
    proposals.putAll(Variable.getEclipseVariableInfoMap());
    ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl,
            new CommandVariableContentAdapter(), new CommandVariableContentProposalProvider(proposals), null,
            autoActivationCharacters, true);
    adapter.setPropagateKeys(false);/*from w  w w. j a  v a 2  s.  c  om*/
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    return adapter;
}

From source file:de.anbos.eclipse.easyshell.plugin.preferences.MenuDataDialog.java

License:Open Source License

private ContentProposalAdapter addContentAssistExtended(Text textControl) {
    char[] autoActivationCharacters = new char[] { '$', '{' };
    Map<String, String> proposals = new LinkedHashMap<String, String>();
    // add internal variables
    proposals.putAll(Variable.getInternalVariableInfoMap());
    ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(textControl,
            new CommandVariableContentAdapter(), new CommandVariableContentProposalProvider(proposals), null,
            autoActivationCharacters, true);
    adapter.setPropagateKeys(false);// www  .  j a v a  2s .c  om
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    return adapter;
}

From source file:org.apache.directory.studio.connection.ui.widgets.ExtendedContentAssistCommandAdapter.java

License:Apache License

/**
 * Creates a new instance of ExtendedContentAssistCommandAdapter 
 * with the following settings:// w w w  .j  ava 2 s  . c  o  m
 * <ul>
 * <li>setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE )</li>
 * <li>setFilterStyle( ContentProposalAdapter.FILTER_NONE )</li>
 * <li>setAutoActivationCharacters( null )</li>
 * <li>setAutoActivationDelay( 0 )</li>
 * </ul>
 * 
 * @param control the control
 * @param controlContentAdapter the control content adapter
 * @param proposalProvider the proposal provider
 * @param commandId the command id
 * @param autoActivationCharacters the auto activation characters
 * @param installDecoration the install decoration
 */
public ExtendedContentAssistCommandAdapter(Control control, IControlContentAdapter controlContentAdapter,
        IContentProposalProvider proposalProvider, String commandId, char[] autoActivationCharacters,
        boolean installDecoration) {
    super(control, controlContentAdapter, proposalProvider, commandId, autoActivationCharacters,
            installDecoration);

    setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    setAutoActivationCharacters(null);
    setAutoActivationDelay(0);
}

From source file:org.apache.directory.studio.ldapbrowser.common.wizards.NewEntryDnWizardPage.java

License:Apache License

/**
 * {@inheritDoc}/*  w w w . ja  v a2 s  . c o  m*/
 */
public void createControl(Composite parent) {
    if (wizard.isNewContextEntry()) {
        // the combo
        Composite composite = BaseWidgetUtils.createColumnContainer(parent, 1, 1);
        contextEntryDnCombo = BaseWidgetUtils.createCombo(composite, ArrayUtils.EMPTY_STRING_ARRAY, 0, 1);
        contextEntryDnCombo.addModifyListener(event -> validate());

        // attach content proposal behavior
        contextEntryDnComboCPA = new ContentProposalAdapter(contextEntryDnCombo, new ComboContentAdapter(),
                null, null, null);
        contextEntryDnComboCPA.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
        contextEntryDnComboCPA.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);

        setControl(composite);
    } else {
        dnBuilderWidget = new DnBuilderWidget(true, true);
        dnBuilderWidget.addWidgetModifyListener(this);
        Composite composite = dnBuilderWidget.createContents(parent);
        setControl(composite);
    }
}

From source file:org.eclipse.birt.chart.ui.swt.fieldassist.FieldAssistHelper.java

License:Open Source License

private int getContentAssistFilterStyle() {
    IPreferenceStore store = getPreferenceStore();
    String acceptanceStyle = store.getString(PreferenceConstants.PREF_CONTENTASSISTFILTER);
    if (acceptanceStyle.equals(PreferenceConstants.PREF_CONTENTASSISTFILTER_CHAR))
        return ContentProposalAdapter.FILTER_CHARACTER;
    if (acceptanceStyle.equals(PreferenceConstants.PREF_CONTENTASSISTFILTER_CUMULATIVE))
        return ContentProposalAdapter.FILTER_CUMULATIVE;
    return ContentProposalAdapter.FILTER_NONE;
}

From source file:org.eclipse.dltk.freemarker.internal.ui.jdt.FreemarkerJavaHelperUI.java

License:Open Source License

/**
 * Disposer returned used to dispose of label provider and remove listeners
 * Callers responsibility to call dispose method when underlying text widget
 * is being disposed//from w w  w  . ja  v a2 s  . co m
 * 
 * @param text
 * @param project
 */
public static TypeFieldAssistDisposer addTypeFieldAssistToText(Text text, IProject project, int searchScope) {
    // Decorate the text widget with the light-bulb image denoting content
    // assist
    int bits = SWT.TOP | SWT.LEFT;
    ControlDecoration controlDecoration = new ControlDecoration(text, bits);
    // Configure text widget decoration
    // No margin
    controlDecoration.setMarginWidth(0);
    // Custom hover tip text
    controlDecoration
            .setDescriptionText(FreemarkerUIPluginMessages.FreemarkerJavaHelper_msgContentAssistAvailable);
    // Custom hover properties
    controlDecoration.setShowHover(true);
    controlDecoration.setShowOnlyOnFocus(true);
    // Hover image to use
    FieldDecoration contentProposalImage = FieldDecorationRegistry.getDefault()
            .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
    controlDecoration.setImage(contentProposalImage.getImage());

    // Create the proposal provider
    TypeContentProposalProvider proposalProvider = new TypeContentProposalProvider(project, searchScope);
    // Default text widget adapter for field assist
    TextContentAdapter textContentAdapter = new TextContentAdapter();
    // Set auto activation character to be a '.'
    char[] autoActivationChars = new char[] { TypeContentProposalProvider.F_DOT };
    // Create the adapter
    ContentAssistCommandAdapter adapter = new ContentAssistCommandAdapter(text, textContentAdapter,
            proposalProvider, IWorkbenchCommandConstants.EDIT_CONTENT_ASSIST, autoActivationChars);
    // Configure the adapter
    // Add label provider
    ILabelProvider labelProvider = new TypeProposalLabelProvider();
    adapter.setLabelProvider(labelProvider);
    // Replace text field contents with accepted proposals
    adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    // Disable default filtering - custom filtering done
    adapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    // Add listeners required to reset state for custom filtering
    TypeContentProposalListener proposalListener = new TypeContentProposalListener();
    adapter.addContentProposalListener((IContentProposalListener) proposalListener);
    adapter.addContentProposalListener((IContentProposalListener2) proposalListener);

    return new TypeFieldAssistDisposer(adapter, proposalListener);
}

From source file:org.eclipse.jubula.client.ui.rcp.controllers.ContentAssistCellEditor.java

License:Open Source License

/**
 * Activates content assist (if it is supported).
 * //from   www  . j a va  2 s .c o  m
 * @param contentProposalProvider
 *          The proposal provider to use for content assist.
 * @param proposalAcceptanceStyle
 *         The integer style that indicates how an accepted proposal 
 *         affects the control's content. See 
 *         {@link ContentProposalAdapter#setProposalAcceptanceStyle(int)}.
 *          
 */
private void enableContentProposal(IContentProposalProvider contentProposalProvider,
        int proposalAcceptanceStyle) {
    if (contentProposalProvider != null) {

        ContentProposalAdapter contentProposalAdapter = new ContentProposalAdapter(text,
                new TextContentAdapter(), contentProposalProvider, ContentAssistUtil.getTriggerKeyStroke(),
                ContentAssistUtil.getTriggerChars());

        contentProposalAdapter.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
        contentProposalAdapter.setProposalAcceptanceStyle(proposalAcceptanceStyle);

        // Listen for popup open/close events to be able to handle focus events
        // correctly
        contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() {

            @SuppressWarnings("synthetic-access")
            public void proposalPopupClosed(ContentProposalAdapter adapter) {
                m_popupOpen = false;
            }

            @SuppressWarnings("synthetic-access")
            public void proposalPopupOpened(ContentProposalAdapter adapter) {
                m_popupOpen = true;
            }
        });
    }
}

From source file:org.eclipse.jubula.client.ui.rcp.widgets.CheckedParamTextContentAssisted.java

License:Open Source License

/**
 * /*  ww w . ja  va 2s. com*/
 * @param parent parent
 * @param style style
 * @param node current node, associated with parameter for this value
 * @param desc parameter description associated with current edited value
 * @param dataValidator validator for data validation
 * @param proposalProvider The content proposal provider for this text
 *                         field, or <code>null</code> if no content
 *                         assist is available.
 */
@SuppressWarnings("synthetic-access")
public CheckedParamTextContentAssisted(Composite parent, int style, IParameterInterfacePO node,
        IParamDescriptionPO desc, IParamValueValidator dataValidator,
        IContentProposalProvider proposalProvider) {
    super(parent, style, node, desc, dataValidator);

    m_popupListener = new IContentProposalListener2Implementation();

    ContentProposalAdapter cpa = new ContentProposalAdapter(this, new TextContentAdapter(), proposalProvider,
            ContentAssistUtil.getTriggerKeyStroke(), ContentAssistUtil.getTriggerChars());
    cpa.setFilterStyle(ContentProposalAdapter.FILTER_NONE);
    cpa.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
    cpa.addContentProposalListener(m_popupListener);
}