From 7305474e4a666d8b986d1d95e7a89fed64277935 Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Sat, 23 Aug 2014 13:32:06 +0300 Subject: Make table selectable based on presence of ValueChangeListener (#13864). Change-Id: I272703f1e3178c91a2b1e3e4d0f7c79e4c86e552 --- server/src/com/vaadin/ui/Table.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java index ec345e3fc3..e202a4e925 100644 --- a/server/src/com/vaadin/ui/Table.java +++ b/server/src/com/vaadin/ui/Table.java @@ -62,6 +62,7 @@ import com.vaadin.server.Resource; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.MultiSelectMode; import com.vaadin.shared.ui.table.TableConstants; +import com.vaadin.shared.util.SharedUtil; /** *

@@ -442,7 +443,7 @@ public class Table extends AbstractSelect implements Action.Container, /** * Holds value of property selectable. */ - private boolean selectable = false; + private Boolean selectable; /** * Holds value of property columnHeaderMode. @@ -1601,15 +1602,19 @@ public class Table extends AbstractSelect implements Action.Container, } /** - * Getter for property selectable. + * Returns whether table is selectable. * *

- * The table is not selectable by default. + * The table is not selectable until it's explicitly set as selectable or at + * least one {@link ValueChangeListener} is added. *

* - * @return the Value of property selectable. + * @return whether table is selectable. */ public boolean isSelectable() { + if (selectable == null) { + return hasListeners(ValueChangeEvent.class); + } return selectable; } @@ -1617,14 +1622,16 @@ public class Table extends AbstractSelect implements Action.Container, * Setter for property selectable. * *

- * The table is not selectable by default. + * The table is not selectable until it's explicitly set as selectable via + * this method or alternatively at least one {@link ValueChangeListener} is + * added. *

* * @param selectable * the New value of property selectable. */ public void setSelectable(boolean selectable) { - if (this.selectable != selectable) { + if (!SharedUtil.equals(this.selectable, selectable)) { this.selectable = selectable; markAsDirty(); } -- cgit v1.2.3 From 4ad7cefcc06e372df8b67a2456616d7410c768d8 Mon Sep 17 00:00:00 2001 From: wodencafe Date: Wed, 28 Jan 2015 09:42:18 -0600 Subject: Fixed UI.getPushConfiguration().getTransport() always returning null (#16499) Change-Id: I31a923faf5ae369ffc2160cdeb12584ca0babc9d --- server/src/com/vaadin/ui/PushConfiguration.java | 2 +- .../vaadin/ui/PushConfigurationTransportTest.java | 46 ++++++++++++++++++++++ shared/src/com/vaadin/shared/ui/ui/Transport.java | 8 ++++ 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 server/tests/src/com/vaadin/ui/PushConfigurationTransportTest.java (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/PushConfiguration.java b/server/src/com/vaadin/ui/PushConfiguration.java index 84f59d0313..90ad28542c 100644 --- a/server/src/com/vaadin/ui/PushConfiguration.java +++ b/server/src/com/vaadin/ui/PushConfiguration.java @@ -208,7 +208,7 @@ class PushConfigurationImpl implements PushConfiguration { public Transport getTransport() { try { return Transport - .valueOf(getParameter(PushConfigurationState.TRANSPORT_PARAM)); + .getByIdentifier(getParameter(PushConfigurationState.TRANSPORT_PARAM)); } catch (IllegalArgumentException e) { return null; } diff --git a/server/tests/src/com/vaadin/ui/PushConfigurationTransportTest.java b/server/tests/src/com/vaadin/ui/PushConfigurationTransportTest.java new file mode 100644 index 0000000000..305b2e06cd --- /dev/null +++ b/server/tests/src/com/vaadin/ui/PushConfigurationTransportTest.java @@ -0,0 +1,46 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.ui; + +import org.junit.Assert; +import org.junit.Test; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.ui.Transport; + +/** + * @author Vaadin Ltd + */ +public class PushConfigurationTransportTest { + @Test + public void testTransportModes() throws Exception { + UI ui = new UI() { + + @Override + protected void init(VaadinRequest request) { + // TODO Auto-generated method stub + + } + + }; + for (Transport transport : Transport.values()) { + ui.getPushConfiguration().setTransport(transport); + Assert.assertEquals(ui.getPushConfiguration().getTransport(), + transport); + } + + } +} diff --git a/shared/src/com/vaadin/shared/ui/ui/Transport.java b/shared/src/com/vaadin/shared/ui/ui/Transport.java index 6eafba185e..39174caddf 100644 --- a/shared/src/com/vaadin/shared/ui/ui/Transport.java +++ b/shared/src/com/vaadin/shared/ui/ui/Transport.java @@ -46,4 +46,12 @@ public enum Transport { return identifier; } + public static Transport getByIdentifier(String identifier) { + for (Transport t : values()) { + if (t.getIdentifier().equals(identifier)) { + return t; + } + } + return null; + } } -- cgit v1.2.3