aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/vaadin/Application.java
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2011-11-28 13:43:07 +0200
committerArtur Signell <artur@vaadin.com>2011-11-28 13:43:07 +0200
commitfaaa67cb890b5904b18491689afc9910a6e865c8 (patch)
tree78b8d915d8ce5933ee1ec4b8b17031feb10571fe /src/com/vaadin/Application.java
parente8ae3d54d9c5f984c34813240d069aa613875d6d (diff)
downloadvaadin-framework-faaa67cb890b5904b18491689afc9910a6e865c8.tar.gz
vaadin-framework-faaa67cb890b5904b18491689afc9910a6e865c8.zip
Initial implementation of converters for AbstractField
Diffstat (limited to 'src/com/vaadin/Application.java')
-rw-r--r--src/com/vaadin/Application.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/com/vaadin/Application.java b/src/com/vaadin/Application.java
index f751431e63..c96a0adc6a 100644
--- a/src/com/vaadin/Application.java
+++ b/src/com/vaadin/Application.java
@@ -20,6 +20,9 @@ import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.vaadin.data.util.converter.Converter;
+import com.vaadin.data.util.converter.ConverterFactory;
+import com.vaadin.data.util.converter.DefaultConverterFactory;
import com.vaadin.service.ApplicationContext;
import com.vaadin.terminal.ApplicationResource;
import com.vaadin.terminal.DownloadStream;
@@ -33,6 +36,7 @@ import com.vaadin.terminal.gwt.server.ChangeVariablesErrorEvent;
import com.vaadin.terminal.gwt.server.PortletApplicationContext;
import com.vaadin.terminal.gwt.server.WebApplicationContext;
import com.vaadin.ui.AbstractComponent;
+import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Window;
/**
@@ -189,6 +193,13 @@ public abstract class Application implements URIHandler,
private Terminal.ErrorListener errorHandler = this;
/**
+ * The converter factory that is used for all fields in the application.
+ */
+ // private ConverterFactory converterFactory = new
+ // DefaultConverterFactory();
+ private static ConverterFactory converterFactory = new DefaultConverterFactory();
+
+ /**
* <p>
* Gets a window by name. Returns <code>null</code> if the application is
* not running or it does not contain a window corresponding to the name.
@@ -1280,6 +1291,42 @@ public abstract class Application implements URIHandler,
}
/**
+ * Gets the {@link ConverterFactory} used to locate a suitable
+ * {@link Converter} for fields in the application.
+ *
+ * See {@link #setConverterFactory(ConverterFactory)} for more details
+ *
+ * @return The converter factory used in the application
+ */
+ // public ConverterFactory getConverterFactory() {
+ // return converterFactory;
+ // }
+ // FIXME: Should not be static
+ public static ConverterFactory getConverterFactory() {
+ return converterFactory;
+ }
+
+ /**
+ * Sets the {@link ConverterFactory} used to locate a suitable
+ * {@link Converter} for fields in the application.
+ *
+ * The {@link ConverterFactory} is used to find a suitable converter when
+ * binding data to a UI component and the data type does not match the UI
+ * component type, e.g. binding a Double to a TextField (which is based on a
+ * String).
+ *
+ * The {@link Converter} for an individual field can be overridden using
+ * {@link AbstractField#setValueConverter(Converter)}.
+ *
+ * @param converterFactory
+ * The converter factory used in the application
+ */
+ // FIXME: Should not be static
+ public static void setConverterFactory(ConverterFactory converterFactory) {
+ Application.converterFactory = converterFactory;
+ }
+
+ /**
* Contains the system messages used to notify the user about various
* critical situations that can occur.
* <p>