use of org.eclipse.jface.fieldassist.IContentProposal in project bndtools by bndtools.
the class CachingContentProposalProvider method getProposals.
@Override
public final IContentProposal[] getProposals(String contents, int position) {
Collection<? extends IContentProposal> currentProposals;
if (initialProposals == null || initialContent == null || contents.length() < initialContent.length()) {
currentProposals = doGenerateProposals(contents, position);
initialContent = contents;
initialProposals = currentProposals;
} else {
List<IContentProposal> temp = new ArrayList<IContentProposal>(initialProposals.size());
for (IContentProposal proposal : initialProposals) {
if (match(contents, position, proposal)) {
temp.add(proposal);
}
}
currentProposals = temp;
}
return currentProposals.toArray(new IContentProposal[0]);
}
use of org.eclipse.jface.fieldassist.IContentProposal in project tdi-studio-se by Talend.
the class TalendEditorComponentCreationAssist method acceptProposal.
/**
* create component at current position, according to select proposal label DOC talend2 Comment method
* "createComponent".
*
* @param componentName
* @param location
*/
protected void acceptProposal() {
String componentName = assistText.getText().trim();
Iterator<IContentProposal> iter = proposalList.iterator();
IComponent component = null;
while (iter.hasNext()) {
IContentProposal proposal = iter.next();
if (proposal instanceof ComponentContentProposal && componentName.equals(proposal.getLabel())) {
component = ((ComponentContentProposal) proposal).getComponent();
break;
}
}
acceptProposal(component);
}
use of org.eclipse.jface.fieldassist.IContentProposal in project yamcs-studio by yamcs.
the class ContentProposalAdapter method proposalAccepted.
/**
* A content proposal has been accepted. Update the control contents
* accordingly and notify any listeners.
*
* @param proposal the accepted proposal
*/
public void proposalAccepted(final Proposal proposal, final boolean addToHistory) {
hasSelectedTopProposal = false;
setControlContent(proposal, true);
// Add entry to history
if (addToHistory && !(proposal.isFunction() || proposal.isPartial()))
history.addEntry(proposal.getValue());
// Update helper
helper.clearData();
helper.updateData(proposal.getTooltips());
// TODO: remove useless stuff
// In all cases, notify listeners of an accepted proposal.
IContentProposal contentProposal = new IContentProposal() {
@Override
public String getLabel() {
return proposal.getValue();
}
@Override
public String getDescription() {
return null;
}
@Override
public int getCursorPosition() {
return proposal.getValue().length();
}
@Override
public String getContent() {
return proposal.getValue();
}
};
notifyProposalAccepted(contentProposal);
}
Aggregations