private String getString(IContentProposal proposal) { if (proposal == null) { return EMPTY; } if (labelProvider == null) { return proposal.getLabel() == null ? proposal.getContent() : proposal.getLabel(); } return labelProvider.getText(proposal); }
private void proposalAccepted(IContentProposal proposal) { switch (proposalAcceptanceStyle) { case (PROPOSAL_REPLACE): setControlContent(proposal.getContent(), proposal .getCursorPosition()); break; case (PROPOSAL_INSERT): insertControlContent(proposal.getContent(), proposal .getCursorPosition()); break; default: // do nothing. Typically a listener is installed to handle this in // a custom way. break; } // In all cases, notify listeners of an accepted proposal. notifyProposalAccepted(proposal); }
@Override public void widgetSelected(SelectionEvent e) { final int i = combo.getSelectionIndex(); if (i != -1 && i < proposals.size()) { combo.setText(proposals.get(i).getContent()); if (selectionListener != null) selectionListener.widgetSelected(e); } } });
String description = p.getDescription(); if (description != null) { if (infoPopup == null) { .addDisposeListener(event -> infoPopup = null); infoPopup.setContents(p.getDescription()); } else if (infoPopup != null) { infoPopup.close();
private void proposalAccepted(IContentProposal proposal) { switch (proposalAcceptanceStyle) { case (PROPOSAL_REPLACE): setControlContent(proposal.getContent(), proposal .getCursorPosition()); break; case (PROPOSAL_INSERT): insertControlContent(proposal.getContent(), proposal .getCursorPosition()); break; default: // do nothing. Typically a listener is installed to handle this in // a custom way. break; } // In all cases, notify listeners of an accepted proposal. notifyProposalAccepted(proposal); }
/** * Sets input data for combo. * <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); }
String description = p.getDescription(); if (description != null) { if (infoPopup == null) { .getDescription()); } else if (infoPopup != null) { infoPopup.close();
private String getString(IContentProposal proposal) { if (proposal == null) { return EMPTY; } if (labelProvider == null) { return proposal.getLabel() == null ? proposal.getContent() : proposal.getLabel(); } return labelProvider.getText(proposal); }
private void proposalAccepted(IContentProposal proposal) { switch (proposalAcceptanceStyle) { case (PROPOSAL_REPLACE): setControlContent(proposal.getContent(), proposal .getCursorPosition()); break; case (PROPOSAL_INSERT): insertControlContent(proposal.getContent(), proposal .getCursorPosition()); break; default: // do nothing. Typically a listener is installed to handle this in // a custom way. break; } // In all cases, notify listeners of an accepted proposal. notifyProposalAccepted(proposal); }
private String getString(IContentProposal proposal) { if (proposal == null) { return EMPTY; } if (labelProvider == null) { return proposal.getLabel() == null ? proposal.getContent() : proposal.getLabel(); } return labelProvider.getText(proposal); }
/** * @return the content of the selected item, or just the text if it does not * match a proposal */ public String getContent() { String text = combo.getText(); for (final IContentProposal p : proposals) if (text.equals(p.getLabel())) return p.getContent(); return text; } }
private ArrayList<Object> filterContentProposals(String currentContent) { String lowerCaseCurrentContent = currentContent.toLowerCase(); ListIterator<Object> iterator = fInitialContentProposals.listIterator(); // Maintain a list of filtered search results ArrayList<Object> filteredContentProposals = new ArrayList<>(); // Iterate over the initial search results while (iterator.hasNext()) { IContentProposal proposal = (IContentProposal) iterator.next(); 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; }