From 7c559ce9eaa7258235885aad7553748e18f20a12 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Tue, 7 Jul 2015 21:49:45 +0300 Subject: Make it possible to avoid select caption conversion (#16845) Change-Id: If88b7cf6298a24cfad3c936a1af566ed919ec0e7 --- server/src/com/vaadin/ui/AbstractSelect.java | 41 ++++++++++++---------------- 1 file changed, 17 insertions(+), 24 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index 498ae2de0a..5152a38a85 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -49,6 +49,7 @@ import com.vaadin.server.KeyMapper; import com.vaadin.server.PaintException; import com.vaadin.server.PaintTarget; import com.vaadin.server.Resource; +import com.vaadin.server.VaadinSession; import com.vaadin.shared.ui.combobox.FilteringMode; import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.ui.declarative.DesignAttributeHandler; @@ -79,11 +80,18 @@ public abstract class AbstractSelect extends AbstractField implements Container.ItemSetChangeListener, LegacyComponent { public enum ItemCaptionMode { + /** + * Item caption mode: Item's ID converted to a String using + * {@link VaadinSession#getConverterFactory()} is used as caption. + */ + ID, /** * Item caption mode: Item's ID's String representation is * used as caption. + * + * @since */ - ID, + ID_TOSTRING, /** * Item caption mode: Item's String representation is used * as caption. @@ -97,8 +105,9 @@ public abstract class AbstractSelect extends AbstractField implements INDEX, /** * Item caption mode: If an Item has a caption it's used, if not, Item's - * ID's String representation is used as caption. This - * is the default. + * ID converted to a String using + * {@link VaadinSession#getConverterFactory()} is used as caption. + * This is the default. */ EXPLICIT_DEFAULTS_ID, /** @@ -1190,7 +1199,9 @@ public abstract class AbstractSelect extends AbstractField implements case ID: caption = idToCaption(itemId); break; - + case ID_TOSTRING: + caption = itemId.toString(); + break; case INDEX: if (items instanceof Container.Indexed) { caption = String.valueOf(((Container.Indexed) items) @@ -1297,27 +1308,9 @@ public abstract class AbstractSelect extends AbstractField implements /** * Sets the item caption mode. * + * See {@link ItemCaptionMode} for a description of the modes. *

- * The mode can be one of the following ones: - *

    - *
  • ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID : Items - * Id-objects toString is used as item caption. If caption is - * explicitly specified, it overrides the id-caption. - *
  • ITEM_CAPTION_MODE_ID : Items Id-objects - * toString is used as item caption.
  • - *
  • ITEM_CAPTION_MODE_ITEM : Item-objects - * toString is used as item caption.
  • - *
  • ITEM_CAPTION_MODE_INDEX : The index of the item is used - * as item caption. The index mode can only be used with the containers - * implementing Container.Indexed interface.
  • - *
  • ITEM_CAPTION_MODE_EXPLICIT : The item captions must be - * explicitly specified.
  • - *
  • ITEM_CAPTION_MODE_PROPERTY : The item captions are read - * from property, that must be specified with - * setItemCaptionPropertyId.
  • - *
- * The ITEM_CAPTION_MODE_EXPLICIT_DEFAULTS_ID is the default - * mode. + * {@link ItemCaptionMode#EXPLICIT_DEFAULTS_ID} is the default mode. *

* * @param mode -- cgit v1.2.3