List of usage examples for org.eclipse.jface.fieldassist ContentProposal ContentProposal
public ContentProposal(String content)
From source file:ch.elexis.core.ui.contacts.proposalProvider.StreetInformationProposalProvider.java
License:Open Source License
public IContentProposal[] getProposals(String contents, int position) { List<ContentProposal> cp = new LinkedList<ContentProposal>(); for (int i = 0; i < streets.size(); i++) { String currStreet = streets.get(i); if (contents == null) { cp.add(new ContentProposal(currStreet)); } else if (currStreet.toLowerCase().startsWith(contents.toLowerCase())) { cp.add(new ContentProposal(currStreet)); }//www .j a v a 2 s .c o m } return cp.toArray(new ContentProposal[] {}); }
From source file:ch.elexis.core.ui.contacts.proposalProvider.TitleProposalProvider.java
License:Open Source License
private void initContentProposals() { titleProposalPrefix = new LinkedList<IContentProposal>(); for (int i = 0; i < titlePrefix.length; i++) { titleProposalPrefix.add(new ContentProposal(titlePrefix[i])); }// ww w. j a v a 2 s .c om titleProposalSuffix = new LinkedList<IContentProposal>(); for (int i = 0; i < titleSuffix.length; i++) { titleProposalSuffix.add(new ContentProposal(titleSuffix[i])); } }
From source file:ch.elexis.core.ui.contacts.proposalProvider.ZipInformationProposalProvider.java
License:Open Source License
public IContentProposal[] getProposals(String contents, int position) { List<ContentProposal> cp = new LinkedList<ContentProposal>(); List<String> zips = ContactGeonames.getZip(); for (int i = 0; i < zips.size(); i++) { String currZip = zips.get(i); if (contents == null) cp.add(new ContentProposal(currZip)); if (currZip.startsWith(contents)) cp.add(new ContentProposal(currZip)); }/*from w w w. ja v a2 s. c om*/ return cp.toArray(new ContentProposal[] {}); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.properties.FlagValueCompleter.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { List<IContentProposal> proposals = new ArrayList<IContentProposal>(mValues.length); String prefix = contents;/*from www . j av a 2s.c om*/ int flagStart = prefix.lastIndexOf('|'); String prepend = null; if (flagStart != -1) { prepend = prefix.substring(0, flagStart + 1); prefix = prefix.substring(flagStart + 1).trim(); } boolean exactMatch = false; for (String value : mValues) { if (prefix.equals(value)) { exactMatch = true; proposals.add(new ContentProposal(contents)); break; } } if (exactMatch) { prepend = contents + '|'; prefix = ""; } for (String value : mValues) { if (AdtUtils.startsWithIgnoreCase(value, prefix)) { if (prepend != null && prepend.contains(value)) { continue; } String match; if (prepend != null) { match = prepend + value; } else { match = value; } proposals.add(new ContentProposal(match)); } } return proposals.toArray(new IContentProposal[proposals.size()]); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.properties.ResourceValueCompleter.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { if (contents.startsWith(PREFIX_RESOURCE_REF)) { CommonXmlEditor editor = this.xmlProperty.getXmlEditor(); if (editor != null) { String[] matches = computeResourceStringMatches(editor, this.xmlProperty.mDescriptor, contents.substring(0, position)); List<IContentProposal> proposals = null; if (matches != null && matches.length > 0) { proposals = new ArrayList<IContentProposal>(matches.length); for (String match : matches) { proposals.add(new ContentProposal(match)); }/* w ww . ja v a 2s. co m*/ return proposals.toArray(new IContentProposal[proposals.size()]); } } } return new IContentProposal[0]; }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.properties.ValueCompleter.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { AttributeDescriptor descriptor = getDescriptor(); IAttributeInfo info = descriptor.getAttributeInfo(); EnumSet<Format> formats = info.getFormats(); List<IContentProposal> proposals = new ArrayList<IContentProposal>(); String prefix = contents; // TODO: Go back to position inside the array? // TODO: If the user is typing in a number, or a number plus a prefix of a dimension unit, // then propose that number plus the completed dimension unit (using sp for text, dp // for other properties and maybe both if I'm not sure) if (formats.contains(STRING) && !contents.isEmpty() && (formats.size() > 1 && formats.contains(REFERENCE) || formats.size() > 2) && !contents.startsWith(PREFIX_RESOURCE_REF) && !contents.startsWith(PREFIX_THEME_REF)) { proposals.add(new ContentProposal(contents)); }/* w w w .ja va 2 s. c o m*/ if (!contents.isEmpty() && Character.isDigit(contents.charAt(0)) && (formats.contains(DIMENSION) || formats.contains(INTEGER) || formats.contains(FLOAT))) { StringBuilder sb = new StringBuilder(); for (int i = 0, n = contents.length(); i < n; i++) { char c = contents.charAt(i); if (Character.isDigit(c)) { sb.append(c); } else { break; } } String number = sb.toString(); if (formats.contains(Format.DIMENSION)) { if (descriptor.getXmlLocalName().equals(ATTR_TEXT_SIZE)) { proposals.add(new ContentProposal(number + UNIT_SP)); } proposals.add(new ContentProposal(number + UNIT_DP)); } else if (formats.contains(Format.INTEGER)) { proposals.add(new ContentProposal(number)); } // Perhaps offer other units too -- see AndroidContentAssist.sDimensionUnits } if (formats.contains(REFERENCE) || contents.startsWith(PREFIX_RESOURCE_REF) || contents.startsWith(PREFIX_THEME_REF)) { CommonXmlEditor editor = getEditor(); if (editor != null) { String[] matches = ResourceValueCompleter.computeResourceStringMatches(editor, descriptor, contents.substring(0, position)); for (String match : matches) { proposals.add(new ContentProposal(match)); } } } if (formats.contains(FLAG)) { String[] values = info.getFlagValues(); if (values != null) { // Flag completion int flagStart = prefix.lastIndexOf('|'); String prepend = null; if (flagStart != -1) { prepend = prefix.substring(0, flagStart + 1); prefix = prefix.substring(flagStart + 1).trim(); } boolean exactMatch = false; for (String value : values) { if (prefix.equals(value)) { exactMatch = true; proposals.add(new ContentProposal(contents)); break; } } if (exactMatch) { prepend = contents + '|'; prefix = ""; } for (String value : values) { if (SdkUtils.startsWithIgnoreCase(value, prefix)) { if (prepend != null && prepend.contains(value)) { continue; } String match; if (prepend != null) { match = prepend + value; } else { match = value; } proposals.add(new ContentProposal(match)); } } } } else if (formats.contains(ENUM)) { String[] values = info.getEnumValues(); if (values != null) { for (String value : values) { if (SdkUtils.startsWithIgnoreCase(value, prefix)) { proposals.add(new ContentProposal(value)); } } for (String value : values) { if (!SdkUtils.startsWithIgnoreCase(value, prefix)) { proposals.add(new ContentProposal(value)); } } } } else if (formats.contains(BOOLEAN)) { proposals.add(new ContentProposal(VALUE_TRUE)); proposals.add(new ContentProposal(VALUE_FALSE)); } return proposals.toArray(new IContentProposal[proposals.size()]); }
From source file:com.github.caofangkun.bazelipse.wizard.BazelTargetCompletionContentProposalProvider.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { if (bazel == null) { return null; }//from ww w. j a v a2s . c o m try { ImmutableList<String> completions = bazel.complete(contents.substring(0, position)); if (completions != null) { IContentProposal[] result = new IContentProposal[completions.size()]; int i = 0; for (String s : completions) { result[i] = new ContentProposal(s); i++; } return result; } } catch (IOException e) { Activator.error("Failed to run Bazel to get completion information", e); } catch (InterruptedException e) { Activator.error("Bazel was interrupted", e); } return null; }
From source file:fr.esrf.icat.manager.core.icatserver.EntityListProposalContentProvider.java
License:Apache License
@Override public IContentProposal[] getProposals(String contents, int position) { currentItems.clear();//from w ww . j a v a 2s .c o m if (null != initialBean) { currentItems.add(initialBean); } currentText = contents; caretPosition = position; boolean hasResult = false; try { hasResult = currentItems.addAll(client .search(canDoCaseInsensitive ? makeSearchStringJPQL(contents) : makeSearchString(contents))); } catch (ICATClientException e) { LOG.error("Unable to load entity content for entity " + entityName, e); } if (hasResult) { IContentProposal[] props = new IContentProposal[currentItems.size()]; String[] items = new String[currentItems.size()]; int i = 0; for (Object bean : currentItems) { final String text = lblprovider.getText(bean); props[i] = new ContentProposal(text); items[i] = text; i++; } imglbl.setImage(EntityEditDialog.WARNING_IMAGE); txtlbl.setText(getCurrentFilter()); container.layout(); return props; } else { imglbl.setImage(EntityEditDialog.ERROR_IMAGE); txtlbl.setText("No result for " + getCurrentFilter()); container.layout(); return new IContentProposal[0]; } }
From source file:org.dawnsci.common.widgets.celleditor.ExpressionFunctionProposalProvider.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { lastPosition = position;/*from www . ja v a 2s. c o m*/ //empty string if (contents.isEmpty()) { Set<String> keys = proposalMap.keySet(); IContentProposal[] proposals = new ContentProposal[keys.size()]; int i = 0; for (String key : keys) { proposals[i++] = new ContentProposal(key); } return proposals; } //last with colon String sub = contents.substring(0, position); Matcher m = functionp.matcher(sub); String last = null; int lastEnd = 0; while (m.find()) { last = m.group(); lastMatchBounds[0] = m.start(); lastMatchBounds[1] = m.end(); lastEnd = m.end(); } if (last == null || lastEnd != position) { m = namespacep.matcher(sub); while (m.find()) { last = m.group(); lastEnd = m.end(); lastMatchBounds[0] = m.start(); lastMatchBounds[1] = m.end(); } if (last != null && lastEnd == position) { Set<String> keys = proposalMap.keySet(); List<IContentProposal> content = new ArrayList<IContentProposal>(); for (String key : keys) { if (key.startsWith(last)) content.add(new ContentProposal(key)); } return content.toArray(new IContentProposal[content.size()]); } else { Set<String> keys = proposalMap.keySet(); IContentProposal[] content = new IContentProposal[keys.size()]; int i = 0; for (String key : keys) content[i++] = new ContentProposal(key); return content; } } String[] strArray = last.split(":"); if (strArray.length == 2) { List<ContentProposal> contentList = proposalMap.get(strArray[0]); if (contentList == null) return new IContentProposal[] { new ContentProposal("") }; List<IContentProposal> content = new ArrayList<IContentProposal>(); for (ContentProposal prop : contentList) { if (prop.getContent().startsWith(strArray[1])) content.add(prop); } return content.toArray(new IContentProposal[content.size()]); } else if (strArray.length == 1) { List<ContentProposal> contentList = proposalMap.get(strArray[0]); if (contentList == null) return new IContentProposal[] { new ContentProposal("") }; return contentList.toArray(new IContentProposal[contentList.size()]); } return new IContentProposal[] { new ContentProposal("") }; }
From source file:org.dawnsci.common.widgets.celleditor.ExpressionFunctionProposalProvider.java
License:Open Source License
public void setProposals(Map<String, Object> functions) { List<String> combinedNames = new ArrayList<String>(); proposalMap = new HashMap<String, List<ContentProposal>>(); if (functions == null) return;// w w w . ja v a2s . c o m for (String key : functions.keySet()) { Object funcClass = functions.get(key); Method[] methods = ((Class<?>) funcClass).getMethods(); List<ContentProposal> methodNames = new ArrayList<ContentProposal>(); for (Method method : methods) { combinedNames.add(key + ":" + method.getName()); Type[] types = method.getGenericParameterTypes(); StringBuilder sb = new StringBuilder(); sb.append(method.getName() + "("); for (int i = 0; i < types.length; ++i) { if (types[i] instanceof Class<?>) { sb.append(getSimplifiedName(((Class<?>) types[i]).getSimpleName())); } else if (types[i] instanceof Object) { sb.append(getSimplifiedName(types[i].toString())); } else sb.append(types[i].toString()); if (i != types.length - 1) sb.append(", "); } sb.append(")"); methodNames.add(new ContentProposal(sb.toString())); } proposalMap.put(key, methodNames); } }