From be433ace81027bfe9225513badbf4a07d3816377 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 22 Apr 2013 15:06:09 +0300 Subject: 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 --- server/src/com/vaadin/ui/AbstractField.java | 38 ++++++++++++++++++++++++++--- server/src/com/vaadin/ui/Label.java | 33 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 4 deletions(-) (limited to 'server/src/com/vaadin/ui') 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 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 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. + *

+ * If legacy Property toString mode is enabled, returns the value of this + * Field converted to a String. + *

+ *

+ * If legacy Property toString mode is disabled, the string representation + * has no special meaning + *

+ * + * @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, markAsDirty(); } + /** + * Returns a string representation of this object. The returned string + * representation depends on if the legacy Property toString mode is enabled + * or disabled. + *

+ * If legacy Property toString mode is enabled, returns the value displayed + * by this label. + *

+ *

+ * If legacy Property toString mode is disabled, the string representation + * has no special meaning + *

+ * + * @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); + } + } } -- cgit v1.2.3