| CODENOTIFIER | HelpYou are not signed inSign in |
Project: UFace
Revision: 2260
Author: kenneth.westelinck
Date: 17 Aug 2008 04:15:35
Changes:Javadoc
Files:| ... | ...@@ -10,14 +10,45 @@ | |
| 10 | 10 | *******************************************************************************/ |
| 11 | 11 | package org.ufacekit.ui.conversion; |
| 12 | 12 | |
| 13 | import java.util.Date; | |
| 14 | ||
| 13 | 15 | import org.ufacekit.core.databinding.common.conversion.Converter; |
| 16 | import org.ufacekit.ui.controls.UIFormControl; | |
| 14 | 17 | import org.ufacekit.ui.controls.UIFormControl.BindingInfo; |
| 15 | 18 | |
| 16 | ||
| 19 | /** | |
| 20 | * This factory will facilitate the creation of a Converter {@link Converter}. | |
| 21 | * | |
| 22 | * @since 1.0 | |
| 23 | */ | |
| 17 | 24 | public interface UIConverterFactory { |
| 25 | /** | |
| 26 | * Create a converter for the given {@link UIFormControl.BindingInfo}. | |
| 27 | * | |
| 28 | * @param bindingInfo | |
| 29 | * info needed to bind the controls attribute to the business | |
| 30 | * model attribute | |
| 31 | * @return the converter responsible for converting the model to the UI | |
| 32 | * component and vice versa | |
| 33 | * @since 1.0 | |
| 34 | */ | |
| 18 | 35 | Converter create(BindingInfo bindingInfo); |
| 19 | ||
| 36 | ||
| 37 | /** | |
| 38 | * The type (i.e. {@link Class}) for the attribute on the model. E.g. | |
| 39 | * {@link Date}. | |
| 40 | * | |
| 41 | * @return the type. E.g. <tt>Date.class</tt> | |
| 42 | * @since 1.0 | |
| 43 | */ | |
| 20 | 44 | Object getModelType(); |
| 21 | 45 | |
| 46 | /** | |
| 47 | * The type (i.e. {@link Class}) used in the UI component to display the | |
| 48 | * data. E.g. a normal input field will use a {@link String}. | |
| 49 | * | |
| 50 | * @return the type. E.g. <tt>String.class</tt> | |
| 51 | * @since 1.0 | |
| 52 | */ | |
| 22 | 53 | Object getTargetType(); |
| 23 | 54 | } |
| ... | ...@@ -12,20 +12,42 @@ | |
| 12 | 12 | |
| 13 | 13 | import org.ufacekit.ui.conversion.UIConverterFactory; |
| 14 | 14 | |
| 15 | ||
| 15 | /** | |
| 16 | * Default, abstract implementation of a {@link UIConverterFactory}. All | |
| 17 | * concrete implementations should extend from this base class, instead of the | |
| 18 | * interface. | |
| 19 | * | |
| 20 | * @since 1.0 | |
| 21 | */ | |
| 16 | 22 | public abstract class DefaultUIConverterFactory implements UIConverterFactory { |
| 17 | 23 | private Object modelType; |
| 18 | 24 | private Object targetType; |
| 19 | ||
| 25 | ||
| 26 | /** | |
| 27 | * Create a factory that will facilitate the creation of converters between | |
| 28 | * modelType and targetType. | |
| 29 | * | |
| 30 | * @param modelType | |
| 31 | * E.g. <tt>Date.class<tt> | |
| 32 | * @param targetType | |
| 33 | * E.g. <tt>String.class</tt> | |
| 34 | * @since 1.0 | |
| 35 | */ | |
| 20 | 36 | public DefaultUIConverterFactory(Object modelType, Object targetType) { |
| 21 | 37 | this.modelType = modelType; |
| 22 | 38 | this.targetType = targetType; |
| 23 | 39 | } |
| 24 | 40 | |
| 41 | /** | |
| 42 | * @see UIConverterFactory#getModelType() | |
| 43 | */ | |
| 25 | 44 | public Object getModelType() { |
| 26 | 45 | return modelType; |
| 27 | 46 | } |
| 28 | 47 | |
| 48 | /** | |
| 49 | * @see UIConverterFactory#getTargetType() | |
| 50 | */ | |
| 29 | 51 | public Object getTargetType() { |
| 30 | 52 | return targetType; |
| 31 | 53 | } |