Example usage for org.eclipse.jface.fieldassist IContentProposal getLabel

List of usage examples for org.eclipse.jface.fieldassist IContentProposal getLabel

Introduction

In this page you can find the example usage for org.eclipse.jface.fieldassist IContentProposal getLabel.

Prototype

public String getLabel();

Source Link

Document

Return the label used to describe this proposal.

Usage

From source file:bndtools.utils.JavaContentProposalLabelProvider.java

License:Open Source License

@Override
public String getText(Object element) {
    IContentProposal proposal = (IContentProposal) element;

    return proposal.getLabel();
}

From source file:com.android.control.MtesterAutoCompleteField.java

License:Apache License

public MtesterAutoCompleteField(final Control control, final IControlContentAdapter controlContentAdapter,
        final String[] literals, final String[] labels, final Shell shell) {
    this.shell = shell;
    contentProposalProvider = new ContentProposalProvider(literals, labels);
    contentProposalProvider.setFiltering(false);
    contentProposalAdapter = new ContentProposalAdapter(control, new StyledTextContentAdapter(),
            contentProposalProvider, null, null);
    contentProposalAdapter.setPropagateKeys(false);
    contentProposalAdapter.setFilterStyle(ContentProposalAdapter.FILTER_CUMULATIVE);
    contentProposalAdapter.setAutoActivationCharacters(new char[] { '.' });
    contentProposalAdapter.setPopupSize(getPoint((StyledText) control));
    contentProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_INSERT);
    contentProposalAdapter.setLabelProvider(new LabelProvider() {
        @Override/*from   w w  w  .ja  v a2s .c  o m*/
        public String getText(Object element) {
            IContentProposal proposal = (IContentProposal) element;
            return proposal.getLabel();
        }

        @Override
        public Image getImage(Object element) {
            Image iconCapture = new Image(shell.getDisplay(),
                    ClassLoader.getSystemResourceAsStream("icons/function.png"));
            return iconCapture;
        }
    });
}

From source file:com.siteview.mde.internal.ui.editor.contentassist.TypeContentProposalProvider.java

License:Open Source License

private ArrayList filterContentProposals(String currentContent) {
    String lowerCaseCurrentContent = currentContent.toLowerCase();
    ListIterator iterator = fInitialContentProposals.listIterator();
    // Maintain a list of filtered search results
    ArrayList filteredContentProposals = new ArrayList();
    // Iterate over the initial search results
    while (iterator.hasNext()) {
        Object object = iterator.next();
        IContentProposal proposal = (IContentProposal) object;
        String compareString = null;
        if (lowerCaseCurrentContent.indexOf(F_DOT) == -1) {
            // Use only the type name
            compareString = proposal.getLabel().toLowerCase();
        } else {//from www. j a  v a 2s  .c  o m
            // Use the fully qualified type name
            compareString = proposal.getContent().toLowerCase();
        }
        // Filter out any proposal not matching the current contents
        // except for the edge case where the proposal is identical to the
        // current contents
        if (compareString.startsWith(lowerCaseCurrentContent, 0)) {
            filteredContentProposals.add(proposal);
        }
    }
    return filteredContentProposals;
}

From source file:gov.nasa.ensemble.common.ui.contentassist.MultiContentProposalProvider.java

License:Open Source License

@Override
public IContentProposal[] getProposals(String contents, int position) {
    List<IContentProposal> proposals = new ArrayList<IContentProposal>();
    for (IContentProposalProvider provider : proposalProviders) {
        IContentProposal[] icp = provider.getProposals(contents, position);
        if (icp == null)
            continue;
        for (IContentProposal prop : icp)
            proposals.add(prop);/*from  w w w . ja v a 2 s  . c o m*/
    }
    Collections.sort(proposals, new Comparator<IContentProposal>() {
        @Override
        public int compare(IContentProposal arg0, IContentProposal arg1) {
            return arg0.getLabel().compareTo(arg1.getLabel());
        }
    });
    return proposals.toArray(new IContentProposal[0]);
}

From source file:hydrograph.ui.graph.canvas.search.ComponentSearchUtility.java

License:Apache License

private void acceptProposal() {

    String componentName = assistText.getText().trim();
    Iterator<IContentProposal> iter = proposalList.iterator();
    ComponentDetails componentDetails = null;
    while (iter.hasNext()) {
        IContentProposal proposal = iter.next();
        if (proposal instanceof ComponentContentProposal
                && componentName.equalsIgnoreCase(proposal.getLabel())) {
            componentDetails = ((ComponentContentProposal) proposal).getComponentDetails();
            break;
        }//ww w  . j  a va2 s.c o m

    }
    acceptProposal(componentDetails);
}

From source file:org.apache.directory.studio.openldap.config.acl.widgets.AttributesWidgetContentProposalProvider.java

License:Apache License

/**
 * Sets the auto-activation characters/*w  w  w .j av a  2  s.c  o m*/
 */
private void setAutoActivationChars() {
    if (proposalAdapter != null) {
        Set<Character> characterSet = new HashSet<Character>();
        for (IContentProposal proposal : proposals) {
            String string = proposal.getLabel();
            for (int k = 0; k < string.length(); k++) {
                char ch = string.charAt(k);
                characterSet.add(Character.toLowerCase(ch));
                characterSet.add(Character.toUpperCase(ch));
            }
        }

        char[] autoActivationCharacters = new char[characterSet.size() + 1];
        autoActivationCharacters[0] = ',';
        int i = 1;
        for (Iterator<Character> it = characterSet.iterator(); it.hasNext();) {
            Character ch = it.next();
            autoActivationCharacters[i] = ch.charValue();
            i++;
        }

        proposalAdapter.setAutoActivationCharacters(autoActivationCharacters);
    }
}

From source file:org.dawnsci.common.widgets.gda.function.internal.ContentProposalLabelProvider.java

License:Open Source License

@Override
public String getText(Object element) {
    if (element instanceof IContentProposal) {
        IContentProposal iContentProposal = (IContentProposal) element;
        return iContentProposal.getLabel();
    }/*from   ww  w . ja v  a  2  s . c o  m*/
    return element.toString();
}

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

License:Open Source License

/**
 * @param currentContent/*from w w  w .j ava  2 s  . c om*/
 * @return
 */
private ArrayList filterContentProposals(String currentContent) {
    String lowerCaseCurrentContent = currentContent.toLowerCase();
    ListIterator iterator = fInitialContentProposals.listIterator();
    // Maintain a list of filtered search results
    ArrayList filteredContentProposals = new ArrayList();
    // Iterate over the initial search results
    while (iterator.hasNext()) {
        Object object = iterator.next();
        IContentProposal proposal = (IContentProposal) object;
        String compareString = null;
        if (lowerCaseCurrentContent.indexOf(F_DOT) == -1) {
            // Use only the type name
            compareString = proposal.getLabel().toLowerCase();
        } else {
            // Use the fully qualified type name
            compareString = proposal.getContent().toLowerCase();
        }
        // Filter out any proposal not matching the current contents
        // except for the edge case where the proposal is identical to the
        // current contents
        if (compareString.startsWith(lowerCaseCurrentContent, 0)) {
            filteredContentProposals.add(proposal);
        }
    }
    return filteredContentProposals;
}

From source file:org.eclipse.egit.ui.internal.components.ComboLabelingSupport.java

License:Open Source License

/**
 * Sets input data for combo.//from w w w.j av a 2  s.  c  o m
 * <p>
 * Proposals are set in provided order.
 *
 * @param proposals
 *            model of input data.
 */
public void setProposals(final List<? extends IContentProposal> proposals) {
    this.proposals = proposals;

    final String[] itemsLabels = new String[proposals.size()];
    int i = 0;
    for (final IContentProposal p : proposals)
        itemsLabels[i++] = p.getLabel();
    combo.setItems(itemsLabels);
}

From source file:org.eclipse.mylyn.tasks.tests.OptionsProposalProviderTest.java

License:Open Source License

private void assertProposal(String content, String label, IContentProposal proposal) {
    assertEquals(content, proposal.getContent());
    assertEquals(label, proposal.getLabel());
    assertNull(proposal.getDescription());
}