本文整理汇总了Java中org.eclipse.jface.fieldassist.IContentProposal类的典型用法代码示例。如果您正苦于以下问题:Java IContentProposal类的具体用法?Java IContentProposal怎么用?Java IContentProposal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IContentProposal类属于org.eclipse.jface.fieldassist包,在下文中一共展示了IContentProposal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
String contentsLc = contents.toLowerCase();
String contentsNq = PATTERN_QUOTE.matcher(contentsLc).replaceAll(""); //$NON-NLS-1$
List<IContentProposal> list = new ArrayList<>();
for (IContentProposal proposal : proposals) {
String content = proposal.getContent();
if (content.contains(contentsLc)
// ignore quotes
|| PATTERN_QUOTE.matcher(content).replaceAll("").contains(contentsNq)) { //$NON-NLS-1$
list.add(proposal);
}
}
return list.toArray(new IContentProposal[list.size()]);
}
示例2: bindToViewModel
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
public void bindToViewModel(PatriciaTrie<ContentProposal> proposals, String[] sortedNames) {
final TagListContentProposalProvider proposalProvider = new TagListContentProposalProvider(proposals);
ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(
tagEntry, new ComboContentAdapter(), proposalProvider, null, null);
proposalAdapter.setPropagateKeys(true);
proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
proposalAdapter.addContentProposalListener(new IContentProposalListener() {
@Override
public void proposalAccepted(IContentProposal userSelectedProposal) {
if (proposalProvider.getMakeNewProposal() == userSelectedProposal) {
for (TagListSelectedEventHandler handler: eventHandlers) {
handler.requestNewTag(userSelectedProposal.getContent());
clearText();
}
}
addTagInternal(userSelectedProposal.getContent());
}
});
tagEntry.setItems(sortedNames);
}
示例3: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
// TODO:
// cap the number of proposals
// exclude tags already part of our set
// if the current selection is a suffix of our last guess, reuse
// the prefix
SortedMap<String, ContentProposal> selectedProposals = contentProposals
.prefixMap(contents.toLowerCase());
ArrayList<ContentProposal> proposals = new ArrayList<ContentProposal>(
selectedProposals.values());
if (!selectedProposals.containsKey(contents)) {
ContentProposal makeNew = new ContentProposal(contents,
"Create new tag: " + contents, "Creates a new tag");
makeNewProposal = makeNew;
proposals.add(makeNew);
}
return proposals.toArray(new ContentProposal[0]);
}
示例4: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@Override
public IContentProposal[] getProposals(final String contents, final int position) {
// Work-around to make sure that the popup doesn't open when the
// user has opened the dropdown of the combo. By returning an empty
// list, the popup won't be shown.
if (ignoreServerChangeEvents || serverCombo.getListVisible()) {
return new IContentProposal[0];
}
final List<IContentProposal> list = new ArrayList<IContentProposal>(proposals.size());
if (StringUtil.isNullOrEmpty(contents)) {
for (int i = 0; i < proposals.size(); i++) {
list.add(new ContentProposal(proposals.get(i)));
}
} else {
final String search = contents.toLowerCase().trim();
for (int i = 0; i < proposals.size(); i++) {
final String p = proposals.get(i);
if (StringUtil.containsIgnoreCase(p, search)) {
list.add(new ContentProposal(p));
}
}
}
return list.toArray(new IContentProposal[list.size()]);
}
示例5: filterProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
private IContentProposal[] filterProposals(
IContentProposal[] proposals, String filterString) {
if (filterString.length() == 0) {
return proposals;
}
// Check each string for a match. Use the string displayed to the
// user, not the proposal content.
ArrayList list = new ArrayList();
for (int i = 0; i < proposals.length; i++) {
String string = getString(proposals[i]);
if (string.length() >= filterString.length()
&& string.substring(0, filterString.length())
.equalsIgnoreCase(filterString)) {
list.add(proposals[i]);
}
}
return (IContentProposal[]) list.toArray(new IContentProposal[list
.size()]);
}
示例6: proposalAccepted
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
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);
}
示例7: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
private IContentProposal[] getProposals() {
if (proposalProvider == null || !isValid()) {
return null;
}
if (DEBUG) {
System.out.println(">>> obtaining proposals from provider"); //$NON-NLS-1$
}
int position = insertionPos;
if (position == -1) {
position = getControlContentAdapter().getCursorPosition(
getControl());
}
String contents = getControlContentAdapter().getControlContents(
getControl());
IContentProposal[] proposals = proposalProvider.getProposals(contents,
position);
return proposals;
}
示例8: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
NpmModule module = IDENpmModulesManager.getInstance().getNPMModule(moduleName);
if (module.isLoaded()) {
List<IContentProposal> list = new ArrayList<>();
try {
for (String proposal : module.getAvailableVersions()) {
if (proposal.length() >= contents.length()
&& proposal.substring(0, contents.length()).equalsIgnoreCase(contents)) {
list.add(new ContentProposal(proposal));
}
}
} catch (IOException e) {
// Should never occurred.
}
return list.toArray(new IContentProposal[list.size()]);
} else {
NpmInstallWidget.this.openPopup = true;
validateVersionASynch(module);
}
return null;
}
示例9: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
if (contents.length() > 1) {
list = loadList(contents);
}
List<ContentProposal> partialList = new Vector<ContentProposal>();
if (list != null && !list.isEmpty()) {
for (BTSObject o : list) {
if (o.getName() != null && o.getName().startsWith(contents)
|| o.get_id().equals(contents)) {
String desc = o.getName() + "\n" + o.get_id() + "\n" + o.getDBCollectionKey();
ContentProposal p = new ContentProposal(o.get_id(), o.getName(), desc);
partialList.add(p);
}
}
Collections.sort(partialList, getComparator());
}
return partialList.toArray(new IContentProposal[partialList.size()]);
}
示例10: getComparator
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
private Comparator<IContentProposal> getComparator() {
if (comparator == null) {
comparator = new Comparator<IContentProposal>() {
@Override
public int compare(IContentProposal p1, IContentProposal p2) {
if (p1 != null && p2 != null) {
if (p1.getLabel() != null) {
return p1.getLabel().compareTo(p2.getLabel());
}
}
return 0;
}
};
}
return comparator;
}
示例11: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@Override
public IContentProposal[] getProposals(String contents, int position) {
List<IContentProposal> partialList = new Vector<IContentProposal>();
if (list != null && !list.isEmpty()) {
for (BTSPassportEntry e : list) {
if (e.getValue() != null && e.getValue().startsWith(contents)) {
ContentProposal p = new ContentProposal(e.getValue());
partialList.add(p);
}
}
Collections.sort(partialList, getComparator());
}
return partialList.toArray(new IContentProposal[partialList.size()]);
}
示例12: getComparator
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
private Comparator<? super IContentProposal> getComparator() {
if (comparator == null) {
comparator = new Comparator<IContentProposal>() {
@Override
public int compare(IContentProposal p1, IContentProposal p2) {
if (p1 != null && p2 != null) {
if (p1.getLabel() != null) {
return p1.getLabel().compareTo(p2.getLabel());
}
}
return 0;
}
};
}
return comparator;
}
示例13: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
public IContentProposal[] getProposals(String contents, int position) {
// System.out.println("getProposals:"+contents);
if (filterProposals) {
ArrayList list = new ArrayList();
for (int i = 0; i < proposals.length; i++) {
if (proposals[i].length() >= contents.length()
&& proposals[i].substring(0, contents.length()).equalsIgnoreCase(contents)) {
list.add(makeContentProposal(proposals[i], labels[i]));
}
}
return (IContentProposal[]) list.toArray(new IContentProposal[list.size()]);
}
if (contentProposals == null) {
contentProposals = new IContentProposal[proposals.length];
for (int i = 0; i < proposals.length; i++) {
contentProposals[i] = makeContentProposal(proposals[i], labels[i]);
}
}
return contentProposals;
}
示例14: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
@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);
}
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]);
}
示例15: getProposals
import org.eclipse.jface.fieldassist.IContentProposal; //导入依赖的package包/类
public IContentProposal[] getProposals(String contents, int position) {
List<Proposal> primaryProposals= new ArrayList<Proposal>();
List<Proposal> secondaryProposals= new ArrayList<Proposal>();
String[] proposalStrings= parser.getVariables();
String contentToCursor= contents.substring(0, position);
for (int i= 0; i < proposalStrings.length; i++) {
if (stringOverlap(contentToCursor, proposalStrings[i]) > 0)
primaryProposals.add(new Proposal(proposalStrings[i]));
else
secondaryProposals.add(new Proposal(proposalStrings[i]));
}
this.latestContents= contents;
this.latestPosition= position;
primaryProposals.addAll(secondaryProposals);
return primaryProposals.toArray(new IContentProposal[0]);
}