aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-server
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2017-03-06 16:19:51 +0200
committerHenri Sara <henri.sara@gmail.com>2017-03-07 12:36:54 +0200
commit14c160e720d0c3b2ded071d8996fd3fed00ca0be (patch)
treec39ad1b6676d1a5cbe075f8d6444ff29ae93c059 /compatibility-server
parentc9436d8a25ceacc2850ea63732ed4aa57e17f901 (diff)
downloadvaadin-framework-14c160e720d0c3b2ded071d8996fd3fed00ca0be.tar.gz
vaadin-framework-14c160e720d0c3b2ded071d8996fd3fed00ca0be.zip
Restore column based width for compatibility selects
Diffstat (limited to 'compatibility-server')
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java45
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java47
-rw-r--r--compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java46
3 files changed, 135 insertions, 3 deletions
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java
index 91b3c8375d..4a741b293c 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java
@@ -33,6 +33,7 @@ import com.vaadin.v7.data.Container;
@Deprecated
public class ListSelect extends AbstractSelect {
+ private int columns = 0;
private int rows = 0;
public ListSelect() {
@@ -51,7 +52,45 @@ public class ListSelect extends AbstractSelect {
super(caption);
}
- // Columns are no longer used for width.
+ /**
+ * Sets the width of the component so that it can display approximately the
+ * given number of letters.
+ * <p>
+ * Calling {@code setColumns(10);} is equivalent to calling
+ * {@code setWidth("10em");}
+ * </p>
+ *
+ * @deprecated As of 7.0. "Columns" does not reflect the exact number of
+ * characters that will be displayed. It is better to use
+ * setWidth together with "em" to control the width of the
+ * field.
+ * @param columns
+ * the number of columns to set.
+ */
+ @Deprecated
+ public void setColumns(int columns) {
+ if (columns < 0) {
+ columns = 0;
+ }
+ if (this.columns != columns) {
+ this.columns = columns;
+ markAsDirty();
+ }
+ }
+
+ /**
+ * Gets the number of columns for the component.
+ *
+ * @see #setColumns(int)
+ * @deprecated As of 7.0. "Columns" does not reflect the exact number of
+ * characters that will be displayed. It is better to use
+ * setWidth together with "em" to control the width of the
+ * field.
+ */
+ @Deprecated
+ public int getColumns() {
+ return columns;
+ }
public int getRows() {
return rows;
@@ -78,6 +117,10 @@ public class ListSelect extends AbstractSelect {
@Override
public void paintContent(PaintTarget target) throws PaintException {
target.addAttribute("type", "list");
+ // Adds the number of columns
+ if (columns != 0) {
+ target.addAttribute("cols", columns);
+ }
// Adds the number of rows
if (rows != 0) {
target.addAttribute("rows", rows);
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
index 3f53969bc7..e69f7c620b 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/NativeSelect.java
@@ -42,6 +42,9 @@ import com.vaadin.v7.event.FieldEvents;
public class NativeSelect extends AbstractSelect
implements FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {
+ // width in characters, mimics TextField
+ private int columns = 0;
+
public NativeSelect() {
super();
registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
@@ -62,9 +65,53 @@ public class NativeSelect extends AbstractSelect
registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent));
}
+ /**
+ * Sets the width of the component so that it can display approximately the
+ * given number of letters.
+ * <p>
+ * Calling {@code setColumns(10);} is equivalent to calling
+ * {@code setWidth("10em");}
+ * </p>
+ *
+ * @deprecated As of 7.0. "Columns" does not reflect the exact number of
+ * characters that will be displayed. It is better to use
+ * setWidth together with "em" to control the width of the
+ * field.
+ * @param columns
+ * the number of columns to set.
+ */
+ @Deprecated
+ public void setColumns(int columns) {
+ if (columns < 0) {
+ columns = 0;
+ }
+ if (this.columns != columns) {
+ this.columns = columns;
+ markAsDirty();
+ }
+ }
+
+ /**
+ * Gets the number of columns for the component.
+ *
+ * @see #setColumns(int)
+ * @deprecated As of 7.0. "Columns" does not reflect the exact number of
+ * characters that will be displayed. It is better to use
+ * setWidth together with "em" to control the width of the
+ * field.
+ */
+ @Deprecated
+ public int getColumns() {
+ return columns;
+ }
+
@Override
public void paintContent(PaintTarget target) throws PaintException {
target.addAttribute("type", "native");
+ // Adds the number of columns
+ if (columns != 0) {
+ target.addAttribute("cols", columns);
+ }
super.paintContent(target);
}
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java
index 965fe85e99..c90cddb595 100644
--- a/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java
+++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java
@@ -35,6 +35,7 @@ import com.vaadin.v7.shared.ui.twincolselect.TwinColSelectState;
@Deprecated
public class TwinColSelect extends AbstractSelect {
+ private int columns = 0;
private int rows = 0;
private String leftColumnCaption;
@@ -65,7 +66,45 @@ public class TwinColSelect extends AbstractSelect {
setMultiSelect(true);
}
- // Columns are no longer used for width.
+ /**
+ * Sets the width of the component so that it displays approximately the
+ * given number of letters in each of the two selects.
+ * <p>
+ * Calling {@code setColumns(10);} is roughly equivalent to calling
+ * {@code setWidth((10*2+4)+"10em");}
+ * </p>
+ *
+ * @deprecated As of 7.0. "Columns" does not reflect the exact number of
+ * characters that will be displayed. It is better to use
+ * setWidth together with "em" to control the width of the
+ * field.
+ * @param columns
+ * the number of columns to set.
+ */
+ @Deprecated
+ public void setColumns(int columns) {
+ if (columns < 0) {
+ columns = 0;
+ }
+ if (this.columns != columns) {
+ this.columns = columns;
+ markAsDirty();
+ }
+ }
+
+ /**
+ * Gets the number of columns for the component.
+ *
+ * @see #setColumns(int)
+ * @deprecated As of 7.0. "Columns" does not reflect the exact number of
+ * characters that will be displayed. It is better to use
+ * setWidth together with "em" to control the width of the
+ * field.
+ */
+ @Deprecated
+ public int getColumns() {
+ return columns;
+ }
public int getRows() {
return rows;
@@ -107,7 +146,10 @@ public class TwinColSelect extends AbstractSelect {
@Override
public void paintContent(PaintTarget target) throws PaintException {
target.addAttribute("type", "twincol");
- // Width is no longer based on columns
+ // Adds the number of columns
+ if (columns != 0) {
+ target.addAttribute("cols", columns);
+ }
// Adds the number of rows
if (rows != 0) {
target.addAttribute("rows", rows);