1 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 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 38 public boolean isAcceptClasses() { 39 return acceptClasses; 40 } 41 44 public void setAcceptClasses(boolean acceptClasses) { 45 this.acceptClasses = acceptClasses; 46 } 47 50 public boolean isAcceptFields() { 51 return acceptFields; 52 } 53 56 public void setAcceptFields(boolean acceptFields) { 57 this.acceptFields = acceptFields; 58 } 59 62 public boolean isAcceptInterfaces() { 63 return acceptInterfaces; 64 } 65 68 public void setAcceptInterfaces(boolean acceptInterfaces) { 69 this.acceptInterfaces = acceptInterfaces; 70 } 71 74 public boolean isAcceptMethods() { 75 return acceptMethods; 76 } 77 80 public void setAcceptMethods(boolean acceptMethods) { 81 this.acceptMethods = acceptMethods; 82 } 83 86 public boolean isAcceptPackages() { 87 return acceptPackages; 88 } 89 92 public void setAcceptPackages(boolean acceptPackages) { 93 this.acceptPackages = acceptPackages; 94 } 95 98 public boolean isAcceptTypes() { 99 return acceptTypes; 100 } 101 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); setIgnored(CompletionProposal.METHOD_REF,true); setIgnored(CompletionProposal.PACKAGE_REF,!isAcceptPackages()); 128 setIgnored(CompletionProposal.POTENTIAL_METHOD_DECLARATION,true); 129 setIgnored(CompletionProposal.TYPE_REF,!(isAcceptClasses() || isAcceptInterfaces())); 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 140 public boolean isAcceptClasses() { 141 return settings.acceptClasses; 142 } 143 146 public void setAcceptClasses(boolean acceptClasses) { 147 settings.acceptClasses = acceptClasses; 148 } 149 152 public boolean isAcceptFields() { 153 return settings.acceptFields; 154 } 155 158 public void setAcceptFields(boolean acceptFields) { 159 settings.acceptFields = acceptFields; 160 } 161 164 public boolean isAcceptInterfaces() { 165 return settings.acceptInterfaces; 166 } 167 170 public void setAcceptInterfaces(boolean acceptInterfaces) { 171 settings.acceptInterfaces = acceptInterfaces; 172 } 173 176 public boolean isAcceptPackages() { 177 return settings.acceptPackages; 178 } 179 182 public void setAcceptPackages(boolean acceptPackages) { 183 settings.acceptPackages = acceptPackages; 184 } 185 188 public boolean isAcceptTypes() { 189 return settings.acceptTypes; 190 } 191 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 |