本文整理汇总了Java中org.eclipse.jface.text.contentassist.ICompletionProposal.getDisplayString方法的典型用法代码示例。如果您正苦于以下问题:Java ICompletionProposal.getDisplayString方法的具体用法?Java ICompletionProposal.getDisplayString怎么用?Java ICompletionProposal.getDisplayString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.contentassist.ICompletionProposal
的用法示例。
在下文中一共展示了ICompletionProposal.getDisplayString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createQuickFixAction
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
private IAction createQuickFixAction(final ICompletionProposal proposal) {
return new Action(proposal.getDisplayString()) {
@Override
public void run() {
proposal.apply(sourceViewer.getDocument());
}
@Override
public ImageDescriptor getImageDescriptor() {
Image image = proposal.getImage();
if (image != null)
return ImageDescriptor.createFromImage(image);
return null;
}
};
}
示例2: getPrefixCompletion
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
/**
* Extracts the replacement string from an <code>ICompletionProposal</code>. If <code>proposal</code> is a
* <code>ICompletionProposalExtension3</code>, its <code>getCompletionText</code> method is called, otherwise, the
* display string is used.
*
* @param proposal
* the proposal to extract the text from
* @return the proposals completion text
* @since 3.1
*/
private CharSequence getPrefixCompletion(ICompletionProposal proposal)
{
CharSequence insertion = null;
if (proposal instanceof ICompletionProposalExtension3)
{
insertion = ((ICompletionProposalExtension3) proposal).getPrefixCompletionText(
fContentAssistSubjectControlAdapter.getDocument(), fFilterOffset);
}
if (insertion == null)
{
insertion = proposal.getDisplayString();
}
return insertion;
}
示例3: compare
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
@Override
public int compare(ICompletionProposal p1, ICompletionProposal p2) {
int compr = 0;
if (p1 != null && p1.getDisplayString() != null && p2 != null
&& p2.getDisplayString() != null) {
boolean p1IsGet = p1.getDisplayString().startsWith("get");
boolean p2IsGet = p2.getDisplayString().startsWith("get");
if (p1IsGet && !p2IsGet) {
compr = Integer.MAX_VALUE;
} else if (p2IsGet && !p1IsGet) {
compr = Integer.MIN_VALUE;
} else {
compr = p1.getDisplayString().compareToIgnoreCase(
p2.getDisplayString());
}
}
return compr;
}
示例4: getCompletionProposalDisplayStrings
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
/**
* Gets the completion proposal display strings.
*
* @param computedProposals
* the computed proposals
* @return the completion proposal display strings
*/
private String getCompletionProposalDisplayStrings(final ICompletionProposal... computedProposals) {
String result = "";
for (ICompletionProposal p : computedProposals) {
result += p.getDisplayString() + SEPARATOR; // NOPMD
}
if (result != null && result.length() > SEPARATOR.length()) {
return result.substring(0, result.length() - SEPARATOR.length());
}
return null;
}
示例5: createProposal
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
@Override
protected ICompletionProposal createProposal(CompletionProposal proposal) {
if (proposal.getKind() != CompletionProposal.TYPE_REF) {
return null;
}
// NOTE: Resulting qualified name is dot-separated, even for enclosing
// types. Generic signatures are not produced. See
// org.eclipse.jdt.internal.codeassist.CompletionEngine.createTypeProposal.
String qualifiedTypeName = String.valueOf(Signature.toCharArray(proposal.getSignature()));
String typePackage = JavaUtilities.getPackageName(qualifiedTypeName);
String typeSimpleName = Signature.getSimpleName(qualifiedTypeName);
if (packageName != null && !typePackage.equals(packageName)) {
return null;
}
ICompletionProposal javaCompletionProposal = JavaContentAssistUtilities.getJavaCompletionProposal(
proposal, getContext(), getJavaProject());
if (javaCompletionProposal != null) {
return new WidgetProposal(typeSimpleName, typePackage, null,
javaCompletionProposal.getDisplayString(),
javaCompletionProposal.getImage(), getReplaceOffset(),
getReplaceLength(), packageManager);
} else {
return new WidgetProposal(typeSimpleName, typePackage, null,
typeSimpleName, null, getReplaceOffset(), getReplaceLength(),
packageManager);
}
}
示例6: fromExistingCompletionProposal
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
/**
* Creates a {@link ReplacementCompletionProposal} with the given text and
* position, but attempts to copy additional information from an existing
* {@link ICompletionProposal}.
*
* @param text the replacement text
* @param offset the offset to the text to replace
* @param length the length of the text to replace
* @param existingCompletionProposal the existing {@link ICompletionProposal}
* to copy info from
* @return an {@link ReplacementCompletionProposal}
*/
public static ReplacementCompletionProposal fromExistingCompletionProposal(
String text, int offset, int length,
ICompletionProposal existingCompletionProposal) {
if (existingCompletionProposal != null) {
return new ReplacementCompletionProposal(text, offset, length,
ReplacementCompletionProposal.DEFAULT_CURSOR_POSITION,
existingCompletionProposal.getAdditionalProposalInfo(),
existingCompletionProposal.getDisplayString(),
existingCompletionProposal.getImage());
} else {
return new ReplacementCompletionProposal(text, offset, length);
}
}
示例7: setSelectedProposal
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
/**
* setSelectedProposal
*
* @param prefix
* @param proposals
*/
protected void setSelectedProposal(String prefix, ICompletionProposal[] proposals)
{
if (prefix == null || prefix.equals(StringUtil.EMPTY) || proposals == null)
{
return;
}
for (ICompletionProposal proposal : proposals)
{
String displayString = proposal.getDisplayString();
int comparison = displayString.compareToIgnoreCase(prefix);
if (comparison >= 0)
{
if (displayString.toLowerCase().startsWith(prefix.toLowerCase()))
{
if (displayString.startsWith(prefix))
{
((ICommonCompletionProposal) proposal).setRelevance(ICommonCompletionProposal.RELEVANCE_HIGH);
}
else
{
((ICommonCompletionProposal) proposal).setRelevance(ICommonCompletionProposal.RELEVANCE_MEDIUM);
}
}
}
}
}
示例8: setSelectedProposal
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
/**
* setSelectedProposal
*
* @param prefix
* @param proposals
*/
public void setSelectedProposal(String prefix, ICompletionProposal[] proposals)
{
if (prefix == null || prefix.equals(StringUtil.EMPTY) || proposals == null)
{
return;
}
for (ICompletionProposal proposal : proposals)
{
String displayString = proposal.getDisplayString();
if (proposal instanceof SnippetTemplateProposal)
{
displayString = ((SnippetTemplateProposal) proposal).getActivationString();
}
int comparison = displayString.compareToIgnoreCase(prefix);
if (comparison >= 0)
{
if (displayString.toLowerCase().startsWith(prefix.toLowerCase()))
{
if (displayString.startsWith(prefix))
{
((ICommonCompletionProposal) proposal).setRelevance(ICommonCompletionProposal.RELEVANCE_HIGH);
}
else
{
((ICommonCompletionProposal) proposal).setRelevance(ICommonCompletionProposal.RELEVANCE_MEDIUM);
}
}
}
}
}
示例9: setSelectedProposal
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
/**
* setSelectedProposal
*
* @param prefix
* @param proposals
*/
protected void setSelectedProposal(String prefix, ICompletionProposal[] proposals)
{
if (StringUtil.isEmpty(prefix) || proposals == null)
{
return;
}
for (ICompletionProposal proposal : proposals)
{
String displayString = proposal.getDisplayString();
int comparison = displayString.compareToIgnoreCase(prefix);
if (comparison >= 0)
{
if (displayString.toLowerCase().startsWith(prefix.toLowerCase()))
{
if (displayString.startsWith(prefix))
{
((ICommonCompletionProposal) proposal).setRelevance(ICommonCompletionProposal.RELEVANCE_HIGH);
}
else
{
((ICommonCompletionProposal) proposal).setRelevance(ICommonCompletionProposal.RELEVANCE_MEDIUM);
}
}
}
}
}
示例10: removeSchemaWidgetProposals
import org.eclipse.jface.text.contentassist.ICompletionProposal; //导入方法依赖的package包/类
private void removeSchemaWidgetProposals(List<ICompletionProposal> proposals,
IDocument document) {
PackageBasedNamespaceManager packageManager = new PackageBasedNamespaceManager();
IDOMModel model = (IDOMModel) StructuredModelManager.getModelManager().getExistingModelForRead(
document);
try {
packageManager.readFromElement(model.getDocument().getDocumentElement());
} finally {
if (model != null) {
model.releaseFromRead();
}
}
Iterator<ICompletionProposal> it = proposals.iterator();
while (it.hasNext()) {
ICompletionProposal proposal = it.next();
if (!(proposal instanceof CustomCompletionProposal)) {
// Schema-generated widget proposals are instances of this class
continue;
}
String displayString = proposal.getDisplayString();
String prefix = XmlUtilities.getPrefix(displayString);
if (prefix == null) {
// Must have a namespace
continue;
}
String packageName = packageManager.getPackageName(prefix);
if (packageName == null) {
// This doesn't map to a widget
continue;
}
String widgetName = XmlUtilities.getUnprefixed(displayString);
if (widgetName.length() == 0
|| !Character.isUpperCase(widgetName.charAt(0))) {
// Not a widget
continue;
}
// Passes our test, it must be a widget!
it.remove();
}
}