1 11 package org.eclipse.jface.internal.databinding.provisional; 12 13 import org.eclipse.jface.internal.databinding.provisional.conversion.IConverter; 14 import org.eclipse.jface.internal.databinding.provisional.validation.IDomainValidator; 15 import org.eclipse.jface.internal.databinding.provisional.validation.IValidator; 16 17 25 public class BindSpec { 26 27 private IConverter[] modelToTargetConverters = new IConverter[1];; 28 29 private IConverter[] targetToModelConverters = new IConverter[1];; 30 31 private IValidator[] targetValidators = new IValidator[1]; 32 33 private IDomainValidator domainValidator; 34 35 private Integer modelUpdatePolicy; 36 37 private Integer validatePolicy; 38 39 private Integer targetUpdatePolicy; 40 41 private boolean updateModel = true; 42 43 private boolean updateTarget = true; 44 45 58 public BindSpec(IConverter modelToTargetConverter, 59 IConverter targetToModelConverter, IValidator targetValidator, 60 IDomainValidator domainValidator, Integer modelUpdatePolicy, 61 Integer validatePolicy, Integer targetUpdatePolicy) { 62 63 this.modelToTargetConverters[0] = modelToTargetConverter; 64 this.targetToModelConverters[0] = targetToModelConverter; 65 this.targetValidators[0] = targetValidator; 66 this.domainValidator = domainValidator; 67 this.modelUpdatePolicy = modelUpdatePolicy; 68 this.validatePolicy = validatePolicy; 69 this.targetUpdatePolicy = targetUpdatePolicy; 70 } 71 72 85 public BindSpec(IConverter[] modelToTargetConverter, 86 IConverter[] targetToModelConverter, IValidator[] targetValidator, 87 IDomainValidator domainValidator, Integer modelUpdatePolicy, 88 Integer validatePolicy, Integer targetUpdatePolicy) { 89 90 this.modelToTargetConverters = modelToTargetConverter; 91 this.targetToModelConverters = targetToModelConverter; 92 this.targetValidators = targetValidator; 93 this.domainValidator = domainValidator; 94 this.modelUpdatePolicy = modelUpdatePolicy; 95 this.validatePolicy = validatePolicy; 96 this.targetUpdatePolicy = targetUpdatePolicy; 97 } 98 99 109 public BindSpec(IConverter modelToTargetConverter, 110 IConverter targetToModelConverter, IValidator targetValidator, 111 IDomainValidator domainValidator) { 112 this(modelToTargetConverter, targetToModelConverter, targetValidator, 113 domainValidator, null, null, null); 114 } 115 116 119 public BindSpec() { 120 this((IConverter)null, null, null, null, null, null, null); 121 } 122 123 129 public IConverter getModelToTargetConverter() { 130 return modelToTargetConverters[0]; 131 } 132 133 138 public IConverter[] getModelToTargetConverters() { 139 return modelToTargetConverters; 140 } 141 142 148 public IConverter getTargetToModelConverter() { 149 return targetToModelConverters[0]; 150 } 151 152 157 public IConverter[] getTargetToModelConverters() { 158 return targetToModelConverters; 159 } 160 161 167 public IValidator getTypeConversionValidator() { 168 return targetValidators[0]; 169 } 170 171 176 public IValidator[] getTypeConversionValidators() { 177 return targetValidators; 178 } 179 180 186 public IDomainValidator getDomainValidator() { 187 return domainValidator; 188 } 189 190 199 public Integer getModelUpdatePolicy() { 200 return modelUpdatePolicy; 201 } 202 203 212 public Integer getValidatePolicy() { 213 return validatePolicy; 214 } 215 216 225 public Integer getTargetUpdatePolicy() { 226 return targetUpdatePolicy; 227 } 228 229 233 public BindSpec setModelToTargetConverter(IConverter converter) { 234 this.modelToTargetConverters[0] = converter; 235 return this; 236 } 237 238 242 public BindSpec setModelToTargetConverters(IConverter[] converters) { 243 this.modelToTargetConverters = converters; 244 return this; 245 } 246 247 251 public BindSpec setTargetToModelConverter(IConverter converter) { 252 this.targetToModelConverters[0] = converter; 253 return this; 254 } 255 256 260 public BindSpec setTargetToModelConverters(IConverter[] converters) { 261 this.modelToTargetConverters = converters; 262 return this; 263 } 264 265 269 public BindSpec setValidator(IValidator validator) { 270 this.targetValidators[0] = validator; 271 return this; 272 } 273 274 278 public BindSpec setValidators(IValidator[] validators) { 279 this.targetValidators = validators; 280 return this; 281 } 282 283 287 public BindSpec setDomainValidator(IDomainValidator validator) { 288 this.domainValidator = validator; 289 return this; 290 } 291 292 295 public boolean updateModel() { 296 return updateModel; 297 } 298 299 302 public boolean updateTarget() { 303 return updateTarget; 304 } 305 306 311 public BindSpec setUpdateModel(boolean updateModel) { 312 this.updateModel = updateModel; 313 return this; 314 } 315 316 321 public BindSpec setUpdateTarget(boolean updateTarget) { 322 this.updateTarget = updateTarget; 323 return this; 324 } 325 326 331 public BindSpec setModelUpdatePolicy(Integer modelUpdatePolicy) { 332 this.modelUpdatePolicy = modelUpdatePolicy; 333 return this; 334 } 335 336 341 public BindSpec setTargetUpdatePolicy(Integer targetUpdatePolicy) { 342 this.targetUpdatePolicy = targetUpdatePolicy; 343 return this; 344 } 345 346 351 public BindSpec setValidatePolicy(Integer validatePolicy) { 352 this.validatePolicy = validatePolicy; 353 return this; 354 } 355 356 } 357 | Popular Tags |