KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > mapper > editors > HBMXMLContentAssistProcessor


1 package org.hibernate.eclipse.mapper.editors;
2
3 import java.util.ArrayList JavaDoc;
4 import java.util.Arrays JavaDoc;
5 import java.util.List JavaDoc;
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 JavaDoc;
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 JavaDoc getAttributeValueProposals(String JavaDoc attributeName, String JavaDoc start, int offset, ContentAssistRequest contentAssistRequest) {
25         Node JavaDoc node = contentAssistRequest.getNode();
26         List JavaDoc proposals = new ArrayList JavaDoc();
27         
28         String JavaDoc 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 JavaDoc 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