diff options
author | Artur Signell <artur@vaadin.com> | 2013-04-22 15:06:09 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-24 09:41:22 +0000 |
commit | be433ace81027bfe9225513badbf4a07d3816377 (patch) | |
tree | 0cac26e36226ab27901a58276a4ebadd9eae3ccd /server/src/com/vaadin/ui | |
parent | 9fe007a843805e8f8d8926848ce07bdab0bcd1d7 (diff) | |
download | vaadin-framework-be433ace81027bfe9225513badbf4a07d3816377.tar.gz vaadin-framework-be433ace81027bfe9225513badbf4a07d3816377.zip |
Re-added Property.toString warning messages (#10916)
* Made it possible to toggle the toString() behavior using the "legacyPropertyToString" init parameter. The default value is "warning" which enables the legacy Property.toString implementation and logs a warning message when it is used. Other supported values are "true" which enables the legacy mode and "false" which disables it.
Change-Id: Ife19352b86590464c8e441b7f82f4fec3b1f3235
Diffstat (limited to 'server/src/com/vaadin/ui')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractField.java | 38 | ||||
-rw-r--r-- | server/src/com/vaadin/ui/Label.java | 33 |
2 files changed, 67 insertions, 4 deletions
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java index eb8fc30a45..6648f69ff9 100644 --- a/server/src/com/vaadin/ui/AbstractField.java +++ b/server/src/com/vaadin/ui/AbstractField.java @@ -25,13 +25,13 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Locale; -import java.util.logging.Logger; import com.vaadin.data.Buffered; import com.vaadin.data.Property; import com.vaadin.data.Validatable; import com.vaadin.data.Validator; import com.vaadin.data.Validator.InvalidValueException; +import com.vaadin.data.util.LegacyPropertyHelper; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.Converter.ConversionException; import com.vaadin.data.util.converter.ConverterUtil; @@ -75,9 +75,6 @@ public abstract class AbstractField<T> extends AbstractComponent implements /* Private members */ - private static final Logger logger = Logger.getLogger(AbstractField.class - .getName()); - /** * Value of the abstract field. */ @@ -371,6 +368,39 @@ public abstract class AbstractField<T> extends AbstractComponent implements return buffered; } + /** + * Returns a string representation of this object. The returned string + * representation depends on if the legacy Property toString mode is enabled + * or disabled. + * <p> + * If legacy Property toString mode is enabled, returns the value of this + * <code>Field</code> converted to a String. + * </p> + * <p> + * If legacy Property toString mode is disabled, the string representation + * has no special meaning + * </p> + * + * @see LegacyPropertyHelper#isLegacyToStringEnabled() + * + * @return A string representation of the value value stored in the Property + * or a string representation of the Property object. + * @deprecated As of 7.0. Use {@link #getValue()} to get the value of the + * field, {@link #getConvertedValue()} to get the field value + * converted to the data model type or + * {@link #getPropertyDataSource()} .getValue() to get the value + * of the data source. + */ + @Deprecated + @Override + public String toString() { + if (!LegacyPropertyHelper.isLegacyToStringEnabled()) { + return super.toString(); + } else { + return LegacyPropertyHelper.legacyPropertyToString(this); + } + } + /* Property interface implementation */ /** diff --git a/server/src/com/vaadin/ui/Label.java b/server/src/com/vaadin/ui/Label.java index 72f556ee5b..d037652a09 100644 --- a/server/src/com/vaadin/ui/Label.java +++ b/server/src/com/vaadin/ui/Label.java @@ -21,6 +21,8 @@ import java.util.Locale; import java.util.logging.Logger; import com.vaadin.data.Property; +import com.vaadin.data.util.AbstractProperty; +import com.vaadin.data.util.LegacyPropertyHelper; import com.vaadin.data.util.converter.Converter; import com.vaadin.data.util.converter.ConverterUtil; import com.vaadin.shared.ui.label.ContentMode; @@ -525,4 +527,35 @@ public class Label extends AbstractComponent implements Property<String>, markAsDirty(); } + /** + * Returns a string representation of this object. The returned string + * representation depends on if the legacy Property toString mode is enabled + * or disabled. + * <p> + * If legacy Property toString mode is enabled, returns the value displayed + * by this label. + * </p> + * <p> + * If legacy Property toString mode is disabled, the string representation + * has no special meaning + * </p> + * + * @see AbstractProperty#isLegacyToStringEnabled() + * + * @return The value displayed by this label or a string representation of + * this Label object. + * + * @deprecated As of 7.0, use {@link #getValue()} to get the value of the + * label or {@link #getPropertyDataSource()}.getValue() to get + * the value of the data source. + */ + @Deprecated + @Override + public String toString() { + if (!LegacyPropertyHelper.isLegacyToStringEnabled()) { + return super.toString(); + } else { + return LegacyPropertyHelper.legacyPropertyToString(this); + } + } } |