1 package org.hibernate.eclipse.mapper.editors; 2 3 import java.util.ArrayList ; 4 import java.util.Arrays ; 5 import java.util.List ; 6 7 import org.eclipse.jdt.core.IJavaProject; 8 import org.eclipse.jface.text.contentassist.CompletionProposal; 9 import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest; 10 import org.hibernate.eclipse.mapper.extractor.HBMInfoExtractor; 11 import org.hibernate.eclipse.mapper.extractor.HBMInfoHandler; 12 import org.w3c.dom.Node ; 13 14 public class HBMXMLContentAssistProcessor extends HibernateContentAssistProcessor { 15 16 private HBMInfoExtractor sourceLocator = new HBMInfoExtractor(); 17 18 public HBMXMLContentAssistProcessor(IJavaProject javaProject) { 19 super(javaProject); 20 } 21 22 private static final boolean DEBUG = false; 23 24 public List getAttributeValueProposals(String attributeName, String start, int offset, ContentAssistRequest contentAssistRequest) { 25 Node node = contentAssistRequest.getNode(); 26 List proposals = new ArrayList (); 27 28 String path = node.getNodeName() + ">" + attributeName; 29 HBMInfoHandler handler = sourceLocator.getAttributeHandler(path); 30 if (handler != null) { 31 proposals.addAll(Arrays.asList(handler.attributeCompletionProposals(getJavaProject(), node, attributeName, start, offset))); 32 } 33 34 if (DEBUG) { 35 String string = contentAssistRequest.getDocumentRegion().getText(); 36 string = string.replace('<', '['); 37 string = string.replace('>', ']'); 38 CompletionProposal completionProposal = new CompletionProposal("[" + start + "],[" + path + "],[" + offset + "]", offset, 1, 4, null, null, null, string); 39 40 proposals.add(completionProposal); 41 } 42 43 return proposals; 44 } 45 46 47 48 } 49 | Popular Tags |