List of usage examples for org.eclipse.jface.fieldassist ContentProposal ContentProposal
public ContentProposal(String content, String label, String description, int cursorPosition)
From source file:org.eclipse.cdt.internal.docker.launcher.ContainerDataVolumeDialog.java
License:Open Source License
/** * Creates an {@link IContentProposalProvider} to propose * {@link IDockerContainer} names based on the current text. * //w w w. ja v a 2 s . c o m * @param items * @return */ private IContentProposalProvider getContainerNameContentProposalProvider(final Combo containerSelectionCombo) { return (contents, position) -> { final List<IContentProposal> proposals = new ArrayList<>(); for (String containerName : containerSelectionCombo.getItems()) { if (containerName.contains(contents)) { proposals.add(new ContentProposal(containerName, containerName, containerName, position)); } } return proposals.toArray(new IContentProposal[0]); }; }
From source file:org.eclipse.linuxtools.internal.docker.ui.launch.RunImageMainTab.java
License:Open Source License
/** * Creates an {@link IContentProposalProvider} to propose * {@link IDockerImage} names based on the current text. * * @param items/* w ww . j av a2s . co m*/ * @return */ private IContentProposalProvider getImageNameContentProposalProvider(final Combo imageSelectionCombo) { return (contents, position) -> { final List<IContentProposal> proposals = new ArrayList<>(); for (String imageName : imageSelectionCombo.getItems()) { if (imageName.contains(contents)) { proposals.add(new ContentProposal(imageName, imageName, imageName, position)); } } return proposals.toArray(new IContentProposal[0]); }; }
From source file:org.eclipse.linuxtools.internal.docker.ui.wizards.ImageBuildDialog.java
License:Open Source License
/** * Creates an {@link IContentProposalProvider} to propose * {@link IDockerContainer} names based on the current text. * //from w w w . ja va 2 s . c om * @param items * @return */ private IContentProposalProvider getConnectionNameContentProposalProvider( final Combo connectionNamesSelectionCombo) { return (contents, position) -> { final List<IContentProposal> proposals = new ArrayList<>(); for (String connectionName : connectionNamesSelectionCombo.getItems()) { if (connectionName.contains(contents)) { proposals.add(new ContentProposal(connectionName, connectionName, connectionName, position)); } } return proposals.toArray(new IContentProposal[0]); }; }
From source file:org.eclipse.ptp.internal.rdt.editor.preferences.HeaderFooterProposalProvider.java
License:Open Source License
/** * Retrieves the list of proposals//ww w.ja v a 2s. c o m * @param text the currently text in the field * @param position the position of the cursor * @return */ @Override public IContentProposal[] getProposals(String text, int position) { init(); List<IContentProposal> result = new ArrayList<IContentProposal>(); String prefix = text.substring(0, position).trim(); for (HeaderFooterProposalPair pair : _list) if (pair._var.startsWith(prefix)) result.add(new ContentProposal(pair._var, pair._var, pair._description, position + pair._var.length() - prefix.length())); return result.toArray(new IContentProposal[result.size()]); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.deployimage.DeployImagePage.java
License:Open Source License
/** * Creates an {@link IContentProposalProvider} to propose * {@link IDockerImage} names based on the current text. * /* w w w . j av a 2 s .co m*/ * @param items * @return */ private IContentProposalProvider getImageNameContentProposalProvider(final Text imageNameText) { return new IContentProposalProvider() { @Override public IContentProposal[] getProposals(final String input, final int position) { return model.getImageNames().stream().filter(name -> name.contains(input)) .map(n -> new ContentProposal(n, n, null, position)) .toArray(size -> new IContentProposal[size]); } }; }
From source file:org.jkiss.dbeaver.ui.controls.resultset.ResultSetFilterPanel.java
License:Open Source License
@Override public IContentProposal[] getProposals(String contents, int position) { SQLSyntaxManager syntaxManager = new SQLSyntaxManager(); if (viewer.getDataContainer() != null) { syntaxManager.init(viewer.getDataContainer().getDataSource()); }//from w w w. j a v a 2 s. c om SQLWordPartDetector wordDetector = new SQLWordPartDetector(new Document(contents), syntaxManager, position); final String word = wordDetector.getFullWord().toLowerCase(Locale.ENGLISH); List<IContentProposal> proposals = new ArrayList<>(); for (DBDAttributeBinding attribute : viewer.getModel().getAttributes()) { final String name = attribute.getName(); if (CommonUtils.isEmpty(word) || name.toLowerCase(Locale.ENGLISH).startsWith(word)) { final String content = name.substring(word.length()) + " "; proposals.add(new ContentProposal(content, attribute.getName(), SQLCompletionProcessor .makeObjectDescription(VoidProgressMonitor.INSTANCE, attribute.getAttribute(), false), content.length())); } } return proposals.toArray(new IContentProposal[proposals.size()]); }
From source file:ralfstx.mylyn.bugview.internal.WordProposalProvider.java
License:Open Source License
public IContentProposal[] getProposals(String contents, int position) { ArrayList<IContentProposal> list = new ArrayList<IContentProposal>(); int wordStart = findWordStart(contents, position); int wordEnd = findWordEnd(contents, position); if (wordEnd > wordStart) { String prefix = contents.substring(wordStart, position); for (String suggestion : suggestions) { if (startsWithIgnoreCase(suggestion, prefix)) { String replacement = replaceRange(contents, wordStart, wordEnd, suggestion); if (wordEnd == contents.length()) { replacement += " "; }/*from w w w.j a v a 2 s . c om*/ int cursorPosition = wordStart + suggestion.length() + 1; list.add(new ContentProposal(replacement, suggestion, null, cursorPosition)); } } } return list.toArray(new IContentProposal[list.size()]); }