List of usage examples for org.eclipse.jface.fieldassist ContentProposal ContentProposal
public ContentProposal(String content, String label, String description)
From source file:ch.elexis.core.ui.contacts.proposalProvider.CityInformationProposalProvider.java
License:Open Source License
public IContentProposal[] getProposals(String contents, int position) { // System.out.println("getProposals()"); List<ContentProposal> cp = new LinkedList<ContentProposal>(); List<String[]> cities = ContactGeonames.getLabeledCities(); for (int i = 0; i < cities.size(); i++) { String[] currCity = cities.get(i); if (contents == null) { cp.add(new ContentProposal(currCity[0], currCity[0] + " (" + currCity[1] + ")", null)); } else if (currCity[0].toLowerCase().startsWith(contents.toLowerCase())) { cp.add(new ContentProposal(currCity[0], currCity[0] + " (" + currCity[1] + ")", null)); }// w w w . ja v a 2s. c o m } return cp.toArray(new ContentProposal[] {}); }
From source file:de.sebastianbenz.task.ui.contentassist.TextProposalProvider.java
License:Open Source License
public IContentProposal[] getProposals(String contents, int position) { ICompletionProposal[] proposals = computeCompletionProposals(contents, position); IContentProposal[] result = new IContentProposal[proposals.length]; int i = 0;/* w w w.j a va 2 s. c om*/ for (ICompletionProposal completionProposal : proposals) { String description = ""; String label = completionProposal.getDisplayString(); String content = prefixMatcher.apply(contents, position, label); result[i] = new ContentProposal(content, label, description); i++; } return result; }
From source file:org.eclipse.mylyn.internal.tasks.ui.OptionsProposalProvider.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { Set<String> filteredProposals = new HashSet<>(proposals); filteredProposals.remove(""); //$NON-NLS-1$ String lastValue = ""; //$NON-NLS-1$ // If the attribute is of type multi-select, filter the past values from the proposals if (isMultiSelect) { String[] contentsArray = contents.split(VALUE_SEPARATOR, -1); if (contentsArray.length > 0) { List<String> trimmedContents = LabelsAttributeEditor.getTrimmedValues(contentsArray); filteredProposals.removeAll(trimmedContents); lastValue = contentsArray[contentsArray.length - 1].trim(); }/*from w w w . j a v a 2s. c o m*/ } else { lastValue = contents; } // If there is a last value, then filter the remaining the proposals to contain it if (!lastValue.isEmpty()) { for (Iterator<String> iterator = filteredProposals.iterator(); iterator.hasNext();) { String proposal = iterator.next(); if (!proposal.toLowerCase().contains(lastValue.toLowerCase())) { iterator.remove(); } } } // Since the contents of the editor is replaced, we need to include the existing values in the replacement final String existingValues = contents.substring(0, contents.length() - lastValue.length()); ImmutableList<String> sortedProposals = FluentIterable.from(filteredProposals) .toSortedList(Ordering.from(String.CASE_INSENSITIVE_ORDER)); return FluentIterable.from(sortedProposals).transform(new Function<String, IContentProposal>() { public IContentProposal apply(String proposal) { return new ContentProposal(existingValues + proposal, proposal, null); } }).toArray(IContentProposal.class); }
From source file:org.sonar.ide.eclipse.ui.internal.wizards.associate.SonarSearchEngineProvider.java
License:Open Source License
public IContentProposal[] getProposals(String contents, int position) { List<IContentProposal> list = new ArrayList<IContentProposal>(); for (ISonarServer sonarServer : sonarServers) { List<ISonarRemoteModule> remoteModules = WSClientFactory.getSonarClient(sonarServer) .searchRemoteModules(contents); for (ISonarRemoteModule resource : remoteModules) { RemoteSonarProject prj = new RemoteSonarProject(sonarServer.getUrl(), resource.getKey(), resource.getName()); list.add(new ContentProposal(prj.asString(), resource.getName(), prj.getDescription())); }//from w w w.j a v a 2 s .c om } if (!list.isEmpty()) { parentPage.setMessage("", IMessageProvider.NONE); return list.toArray(new IContentProposal[list.size()]); } else { parentPage.setMessage("No result", IMessageProvider.INFORMATION); return new IContentProposal[0]; } }
From source file:org.sonarlint.eclipse.ui.internal.bind.SearchEngineProvider.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { if (!server.isUpdated()) { parentPage.setMessage("Please update server first", IMessageProvider.INFORMATION); return new IContentProposal[0]; }// ww w. j a va2s .co m List<IContentProposal> list = new ArrayList<>(); try { List<RemoteModule> modules = getModuleIndex().search(contents); for (RemoteModule m : modules) { RemoteSonarProject prj = new RemoteSonarProject(server.getId(), m.getKey(), m.getName()); list.add(new ContentProposal(prj.asString(), m.getName(), prj.getDescription())); } } catch (Exception e) { SonarLintCorePlugin.getDefault().debug("Unable to search modules from server " + server.getId(), e); } if (!list.isEmpty()) { parentPage.setMessage("", IMessageProvider.NONE); return list.toArray(new IContentProposal[list.size()]); } else { parentPage.setMessage("No results", IMessageProvider.INFORMATION); return new IContentProposal[0]; } }
From source file:org.sonarlint.eclipse.ui.internal.server.wizard.OrganizationProvider.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { List<IContentProposal> list = new ArrayList<>(); TextSearchIndex<RemoteOrganization> organizationsIndex = model.getOrganizationsIndex(); Map<RemoteOrganization, Double> filtered = organizationsIndex != null ? organizationsIndex.search(contents) : Collections.emptyMap(); if (filtered.isEmpty()) { parentPage.setMessage("No results", IMessageProvider.INFORMATION); } else {/*from w ww.j a va 2 s . c o m*/ parentPage.setMessage("", IMessageProvider.NONE); } List<Map.Entry<RemoteOrganization, Double>> entries = new ArrayList<>(filtered.entrySet()); entries.sort(Comparator.comparing(Map.Entry<RemoteOrganization, Double>::getValue).reversed() .thenComparing(Comparator.comparing(e -> e.getKey().getName(), String.CASE_INSENSITIVE_ORDER))); for (Map.Entry<RemoteOrganization, Double> e : entries) { list.add(new ContentProposal(e.getKey().getKey(), e.getKey().getName(), toDescription(e.getKey()))); } return list.toArray(new IContentProposal[list.size()]); }