1 11 package org.eclipse.jdt.internal.ui.text.java; 12 13 14 15 import org.eclipse.swt.graphics.Image; 16 17 import org.eclipse.jface.resource.ImageDescriptor; 18 19 import org.eclipse.jface.text.contentassist.IContextInformation; 20 import org.eclipse.jface.text.contentassist.IContextInformationExtension; 21 22 import org.eclipse.jdt.core.CompletionProposal; 23 24 import org.eclipse.jdt.ui.text.java.CompletionProposalLabelProvider; 25 26 import org.eclipse.jdt.internal.ui.JavaPlugin; 27 28 29 32 public final class ProposalContextInformation implements IContextInformation, IContextInformationExtension { 33 34 private final String fContextDisplayString; 35 private final String fInformationDisplayString; 36 private final Image fImage; 37 private int fPosition; 38 39 42 public ProposalContextInformation(CompletionProposal proposal) { 43 CompletionProposalLabelProvider labelProvider= new CompletionProposalLabelProvider(); 46 fInformationDisplayString= labelProvider.createParameterList(proposal); 47 ImageDescriptor descriptor= labelProvider.createImageDescriptor(proposal); 48 if (descriptor != null) 49 fImage= JavaPlugin.getImageDescriptorRegistry().get(descriptor); 50 else 51 fImage= null; 52 if (proposal.getCompletion().length == 0) 53 fPosition= proposal.getCompletionLocation() + 1; 54 else 55 fPosition= -1; 56 fContextDisplayString= labelProvider.createLabel(proposal); 57 } 58 59 62 public boolean equals(Object object) { 63 if (object instanceof IContextInformation) { 64 IContextInformation contextInformation= (IContextInformation) object; 65 boolean equals= getInformationDisplayString().equalsIgnoreCase(contextInformation.getInformationDisplayString()); 66 if (getContextDisplayString() != null) 67 equals= equals && getContextDisplayString().equalsIgnoreCase(contextInformation.getContextDisplayString()); 68 return equals; 69 } 70 return false; 71 } 72 73 76 public String getInformationDisplayString() { 77 return fInformationDisplayString; 78 } 79 80 83 public Image getImage() { 84 return fImage; 85 } 86 87 90 public String getContextDisplayString() { 91 return fContextDisplayString; 92 } 93 94 97 public int getContextInformationPosition() { 98 return fPosition; 99 } 100 101 107 public void setContextInformationPosition(int position) { 108 fPosition= position; 109 } 110 } 111 | Popular Tags |