From 0f1dcd23a0bffae76fc312d95d7b64bf7861df88 Mon Sep 17 00:00:00 2001 From: patrik Date: Tue, 7 Apr 2015 13:31:32 +0300 Subject: Enable setResponsive/isReponsive API for AbstractComponent (#17369) Change-Id: I2fb48bff5e55d3d494d9fa927305447dc0c4d816 --- server/src/com/vaadin/ui/AbstractComponent.java | 21 ++++-------- .../design/AbstractComponentSetResponsiveTest.java | 37 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java diff --git a/server/src/com/vaadin/ui/AbstractComponent.java b/server/src/com/vaadin/ui/AbstractComponent.java index ebe438b908..dae073904b 100644 --- a/server/src/com/vaadin/ui/AbstractComponent.java +++ b/server/src/com/vaadin/ui/AbstractComponent.java @@ -982,11 +982,6 @@ public abstract class AbstractComponent extends AbstractClientConnector Integer.class)); } - // handle responsive - if (attr.hasKey("responsive")) { - setResponsive(DesignAttributeHandler.getFormatter().parse( - attr.get("responsive"), Boolean.class)); - } // check for unsupported attributes Set supported = new HashSet(); supported.addAll(getDefaultAttributes()); @@ -1032,11 +1027,11 @@ public abstract class AbstractComponent extends AbstractClientConnector /** * Toggles responsiveness of this component. * - * @since 7.4 + * @since * @param responsive * boolean enables responsiveness, false disables */ - private void setResponsive(boolean responsive) { + public void setResponsive(boolean responsive) { if (responsive) { // make responsive if necessary if (!isResponsive()) { @@ -1057,10 +1052,10 @@ public abstract class AbstractComponent extends AbstractClientConnector /** * Returns true if the component is responsive * - * @since 7.4 + * @since * @return true if the component is responsive */ - private boolean isResponsive() { + public boolean isResponsive() { for (Extension e : getExtensions()) { if (e instanceof Responsive) { return true; @@ -1233,8 +1228,8 @@ public abstract class AbstractComponent extends AbstractClientConnector private static final String[] customAttributes = new String[] { "width", "height", "debug-id", "error", "width-auto", "height-auto", - "width-full", "height-full", "size-auto", "size-full", - "responsive", "immediate", "locale", "read-only", "_id" }; + "width-full", "height-full", "size-auto", "size-full", "immediate", + "locale", "read-only", "_id" }; /* * (non-Javadoc) @@ -1280,10 +1275,6 @@ public abstract class AbstractComponent extends AbstractClientConnector ((Focusable) def).getTabIndex(), Integer.class); } - // handle responsive - if (isResponsive()) { - attr.put("responsive", ""); - } } /* diff --git a/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java b/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java new file mode 100644 index 0000000000..f7dbd0c97e --- /dev/null +++ b/server/tests/src/com/vaadin/tests/design/AbstractComponentSetResponsiveTest.java @@ -0,0 +1,37 @@ +/* + * 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.tests.design; + +import org.junit.Test; + +import com.vaadin.tests.design.DeclarativeTestBase; +import com.vaadin.ui.GridLayout; + +public class AbstractComponentSetResponsiveTest extends + DeclarativeTestBase { + + @Test + public void testResponsiveFlag() { + GridLayout gl = new GridLayout(); + gl.setResponsive(true); + + String design = ""; + + testWrite(design, gl); + testRead(design, gl); + } + +} -- cgit v1.2.3