KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > eclipse > mapper > extractor > HBMXMLResultCollector


1 /*
2  * Created on 19-Nov-2004
3  *
4  */

5 package org.hibernate.eclipse.mapper.extractor;
6
7 import org.eclipse.jdt.core.CompletionProposal;
8 import org.eclipse.jdt.core.ICompilationUnit;
9 import org.eclipse.jdt.core.IJavaProject;
10 import org.eclipse.jdt.ui.text.java.CompletionProposalCollector;
11
12 /**
13  * @author max
14  *
15  */

16 public class HBMXMLResultCollector extends CompletionProposalCollector {
17
18     public HBMXMLResultCollector(ICompilationUnit cu) {
19         super(cu);
20     }
21     
22     HBMXMLResultCollector(IJavaProject project) {
23         super(project);
24     }
25
26     static class Settings {
27         private boolean acceptTypes = false;
28         private boolean acceptPackages = false;
29         private boolean acceptClasses = false;
30         private boolean acceptInterfaces = false;
31         private boolean acceptFields = false;
32         private boolean acceptMethods = false;
33         
34         
35         /**
36          * @return Returns the acceptClasses.
37          */

38         public boolean isAcceptClasses() {
39             return acceptClasses;
40         }
41         /**
42          * @param acceptClasses The acceptClasses to set.
43          */

44         public void setAcceptClasses(boolean acceptClasses) {
45             this.acceptClasses = acceptClasses;
46         }
47         /**
48          * @return Returns the acceptFields.
49          */

50         public boolean isAcceptFields() {
51             return acceptFields;
52         }
53         /**
54          * @param acceptFields The acceptFields to set.
55          */

56         public void setAcceptFields(boolean acceptFields) {
57             this.acceptFields = acceptFields;
58         }
59         /**
60          * @return Returns the acceptInterfaces.
61          */

62         public boolean isAcceptInterfaces() {
63             return acceptInterfaces;
64         }
65         /**
66          * @param acceptInterfaces The acceptInterfaces to set.
67          */

68         public void setAcceptInterfaces(boolean acceptInterfaces) {
69             this.acceptInterfaces = acceptInterfaces;
70         }
71         /**
72          * @return Returns the acceptMethods.
73          */

74         public boolean isAcceptMethods() {
75             return acceptMethods;
76         }
77         /**
78          * @param acceptMethods The acceptMethods to set.
79          */

80         public void setAcceptMethods(boolean acceptMethods) {
81             this.acceptMethods = acceptMethods;
82         }
83         /**
84          * @return Returns the acceptPackages.
85          */

86         public boolean isAcceptPackages() {
87             return acceptPackages;
88         }
89         /**
90          * @param acceptPackages The acceptPackages to set.
91          */

92         public void setAcceptPackages(boolean acceptPackages) {
93             this.acceptPackages = acceptPackages;
94         }
95         /**
96          * @return Returns the acceptTypes.
97          */

98         public boolean isAcceptTypes() {
99             return acceptTypes;
100         }
101         /**
102          * @param acceptTypes The acceptTypes to set.
103          */

104         public void setAcceptTypes(boolean acceptTypes) {
105             this.acceptTypes = acceptTypes;
106         }
107     }
108     
109     Settings settings;
110     public void setAccepts(boolean types, boolean packages, boolean classes, boolean interfaces, boolean fields, boolean methods) {
111         settings = new Settings();
112         settings.acceptTypes = types;
113         settings.acceptPackages = packages;
114         settings.acceptClasses = classes;
115         settings.acceptInterfaces = interfaces;
116         settings.acceptFields = fields;
117         settings.acceptMethods = methods;
118         
119         setIgnored(CompletionProposal.ANONYMOUS_CLASS_DECLARATION,true);
120         setIgnored(CompletionProposal.FIELD_REF,!isAcceptFields());
121         setIgnored(CompletionProposal.KEYWORD, true);
122         setIgnored(CompletionProposal.LABEL_REF, true);
123         setIgnored(CompletionProposal.LOCAL_VARIABLE_REF,true);
124         setIgnored(CompletionProposal.METHOD_DECLARATION,true);
125         setIgnored(CompletionProposal.METHOD_NAME_REFERENCE,true); // maybe true to handle properties ?
126
setIgnored(CompletionProposal.METHOD_REF,true); // maybe true to handle properties ?
127
setIgnored(CompletionProposal.PACKAGE_REF,!isAcceptPackages());
128         setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION,true);
129         setIgnored(CompletionProposal.TYPE_REF,!(isAcceptClasses() || isAcceptInterfaces())); // decide during completion if accepted truly
130
setIgnored(CompletionProposal.VARIABLE_DECLARATION, true);
131     }
132     
133     public void setAccepts(Settings settings) {
134         setAccepts(settings.acceptTypes,settings.acceptPackages,settings.acceptClasses,settings.acceptInterfaces, settings.acceptFields, settings.acceptMethods);
135     }
136         
137     /**
138      * @return Returns the acceptClasses.
139      */

140     public boolean isAcceptClasses() {
141         return settings.acceptClasses;
142     }
143     /**
144      * @param acceptClasses The acceptClasses to set.
145      */

146     public void setAcceptClasses(boolean acceptClasses) {
147         settings.acceptClasses = acceptClasses;
148     }
149     /**
150      * @return settings.Returns the acceptFields.
151      */

152     public boolean isAcceptFields() {
153         return settings.acceptFields;
154     }
155     /**
156      * @param acceptFields The acceptFields to set.
157      */

158     public void setAcceptFields(boolean acceptFields) {
159         settings.acceptFields = acceptFields;
160     }
161     /**
162      * @return settings.Returns the acceptInterfaces.
163      */

164     public boolean isAcceptInterfaces() {
165         return settings.acceptInterfaces;
166     }
167     /**
168      * @param acceptInterfaces The acceptInterfaces to set.
169      */

170     public void setAcceptInterfaces(boolean acceptInterfaces) {
171         settings.acceptInterfaces = acceptInterfaces;
172     }
173     /**
174      * @return settings.Returns the acceptPackages.
175      */

176     public boolean isAcceptPackages() {
177         return settings.acceptPackages;
178     }
179     /**
180      * @param acceptPackages The acceptPackages to set.
181      */

182     public void setAcceptPackages(boolean acceptPackages) {
183         settings.acceptPackages = acceptPackages;
184     }
185     /**
186      * @return settings.Returns the acceptTypes.
187      */

188     public boolean isAcceptTypes() {
189         return settings.acceptTypes;
190     }
191     /**
192      * @param acceptTypes The acceptTypes to set.
193      */

194     public void setAcceptTypes(boolean acceptTypes) {
195         settings.acceptTypes = acceptTypes;
196     }
197     
198     public void accept(CompletionProposal proposal) {
199         super.accept(proposal);
200     }
201 }
202
Popular Tags