1 11 package org.eclipse.jface.contentassist; 12 13 import org.eclipse.jface.text.ITextViewer; 14 import org.eclipse.jface.text.contentassist.IContentAssistProcessor; 15 import org.eclipse.jface.text.contentassist.IContextInformation; 16 17 18 28 public final class SubjectControlContextInformationValidator implements ISubjectControlContextInformationValidator { 29 30 31 private IContentAssistProcessor fProcessor; 32 33 private IContextInformation fContextInformation; 34 35 private IContentAssistSubjectControl fContentAssistSubjectControl; 36 37 43 public SubjectControlContextInformationValidator(IContentAssistProcessor processor) { 44 fProcessor= processor; 45 } 46 47 50 public void install(IContextInformation contextInformation, ITextViewer viewer, int offset) { 51 throw new UnsupportedOperationException (); 52 } 53 54 57 public void install(IContextInformation contextInformation, IContentAssistSubjectControl contentAssistSubjectControl, int offset) { 58 fContextInformation= contextInformation; 59 fContentAssistSubjectControl= contentAssistSubjectControl; 60 } 61 62 65 public boolean isContextInformationValid(int offset) { 66 if (fContentAssistSubjectControl != null && fProcessor instanceof ISubjectControlContentAssistProcessor) { 67 IContextInformation[] infos= ((ISubjectControlContentAssistProcessor)fProcessor).computeContextInformation(fContentAssistSubjectControl, offset); 68 if (infos != null && infos.length > 0) { 69 for (int i= 0; i < infos.length; i++) { 70 if (fContextInformation.equals(infos[i])) 71 return true; 72 } 73 } 74 } 75 return false; 76 } 77 } 78 | Popular Tags |