Example usage for org.eclipse.jface.fieldassist SimpleContentProposalProvider setProposals

List of usage examples for org.eclipse.jface.fieldassist SimpleContentProposalProvider setProposals

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist SimpleContentProposalProvider setProposals.

Prototype

public void setProposals(String... items) 

Source Link

Document

Set the Strings to be used as content proposals.

Usage

From source file:org.jboss.ide.eclipse.as.classpath.ui.containers.custom.LayeredPathProviderFragment.java

License:Open Source License

private void setAutoCompletion(Text text, String value, String[] possible) {
    try {/*  w  w  w .  j  a v a 2 s . c  o  m*/
        ContentProposalAdapter adapter = null;
        SimpleContentProposalProvider scp = new SimpleContentProposalProvider(possible);
        scp.setProposals(possible);
        scp.setFiltering(true);
        KeyStroke ks = KeyStroke.getInstance(KEY_PRESS);
        adapter = new ContentProposalAdapter(text, new TextContentAdapter(), scp, ks, null);
        adapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.panel.grouping.GroupingConfigDialog.java

License:Apache License

@Override
protected Composite createDialogArea(Composite parent) {
    Composite composite = super.createDialogArea(parent);

    List<String> proposals = new ArrayList<>();
    for (DBDAttributeBinding attr : resultsContainer.getOwnerPresentation().getController().getModel()
            .getAttributes()) {//  w w  w . j a v a2s . com
        proposals.add(attr.getName());
    }
    SimpleContentProposalProvider proposalProvider = new SimpleContentProposalProvider(new String[0]);
    proposalProvider.setFiltering(true);
    proposalProvider.setProposals(proposals.toArray(new String[0]));
    columnsTable = StringEditorTable.createEditableList(composite, "Columns",
            resultsContainer.getGroupAttributes(), DBIcon.TREE_ATTRIBUTE, proposalProvider);

    Collections.addAll(proposals, "COUNT", "AVG", "MAX", "MIN", "SUM");
    proposalProvider.setProposals(proposals.toArray(new String[0]));
    functionsTable = StringEditorTable.createEditableList(composite, "Functions",
            resultsContainer.getGroupFunctions(), DBIcon.TREE_FUNCTION, proposalProvider);

    return composite;
}

From source file:org.rssowl.ui.internal.OwlUI.java

License:Open Source License

/**
 * @param values// ww  w .j a va  2 s .  com
 * @param provider
 * @param adapter
 * @param autoActivate
 */
public static void applyAutoCompleteProposals(Collection<String> values, SimpleContentProposalProvider provider,
        ContentProposalAdapter adapter, boolean autoActivate) {

    /* Extract Proposals */
    final String[] proposals = new String[values.size()];
    Set<Character> charSet = new HashSet<Character>();
    int i = 0;
    for (String value : values) {
        proposals[i] = value;

        char c = value.charAt(0);
        charSet.add(Character.toLowerCase(c));
        charSet.add(Character.toUpperCase(c));
        i++;
    }

    /* Auto-Activate on first Key typed */
    char[] activationChars = new char[charSet.size()];
    i = 0;
    for (char c : charSet) {
        activationChars[i] = c;
        i++;
    }

    /* Apply proposals and auto-activation chars */
    provider.setProposals(proposals);
    if (autoActivate)
        adapter.setAutoActivationCharacters(activationChars);
}