summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2017-08-29 14:56:36 +0300
committerHenri Sara <henri.sara@gmail.com>2017-08-30 12:10:06 +0300
commitaff7361b6667542f04801af8df382707544b69f3 (patch)
treedae76a8035b37b57badf8de71bd8146a88dffd84
parent774e2164ef5f60e566eee2d976ee113a8634d4e0 (diff)
downloadvaadin-framework-aff7361b6667542f04801af8df382707544b69f3.tar.gz
vaadin-framework-aff7361b6667542f04801af8df382707544b69f3.zip
Omit duplicate caption for a Panel in a Composite
Correctly render components that handle their own captions inside a Composite. Fixes #9848
-rw-r--r--client/src/main/java/com/vaadin/client/ui/composite/CompositeConnector.java9
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/composite/CompositePanelCaptionUI.java46
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/composite/CompositePanelCaptionUITest.java30
3 files changed, 85 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/composite/CompositeConnector.java b/client/src/main/java/com/vaadin/client/ui/composite/CompositeConnector.java
index 3322063d51..9b784b7f70 100644
--- a/client/src/main/java/com/vaadin/client/ui/composite/CompositeConnector.java
+++ b/client/src/main/java/com/vaadin/client/ui/composite/CompositeConnector.java
@@ -116,4 +116,13 @@ public class CompositeConnector extends AbstractHasComponentsConnector
((DirectionalManagedLayout) childConnector).layoutVertically();
}
}
+
+ @Override
+ public boolean delegateCaptionHandling() {
+ if (!hasChildConnector()) {
+ return true;
+ } else {
+ return getChildConnector().delegateCaptionHandling();
+ }
+ }
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/composite/CompositePanelCaptionUI.java b/uitest/src/main/java/com/vaadin/tests/components/composite/CompositePanelCaptionUI.java
new file mode 100644
index 0000000000..ee6ce4d4a0
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/composite/CompositePanelCaptionUI.java
@@ -0,0 +1,46 @@
+package com.vaadin.tests.components.composite;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Composite;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.themes.ValoTheme;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class CompositePanelCaptionUI extends AbstractTestUI {
+ @Override
+ public void setup(VaadinRequest request) {
+ Panel regularPanel = new Panel("Regular ol' panel",
+ createPanelContent());
+ CustomComponentPanel customComponentPanel = new CustomComponentPanel();
+ CompositePanel compositePanel = new CompositePanel();
+
+ addComponents(regularPanel, customComponentPanel, compositePanel);
+ }
+
+ private VerticalLayout createPanelContent() {
+ Label helloWorld = new Label("Hello world!");
+ helloWorld.addStyleName(ValoTheme.LABEL_HUGE);
+
+ return new VerticalLayout(helloWorld);
+ }
+
+ private class CustomComponentPanel extends CustomComponent {
+ public CustomComponentPanel() {
+ Panel panel = new Panel("CustomComponentPanel",
+ createPanelContent());
+ setCompositionRoot(panel);
+ }
+ }
+
+ private class CompositePanel extends Composite {
+ public CompositePanel() {
+ Panel panel = new Panel("CompositePanel", createPanelContent());
+ setCompositionRoot(panel);
+ }
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/composite/CompositePanelCaptionUITest.java b/uitest/src/test/java/com/vaadin/tests/components/composite/CompositePanelCaptionUITest.java
new file mode 100644
index 0000000000..75263e0e82
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/composite/CompositePanelCaptionUITest.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2016 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.components.composite;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class CompositePanelCaptionUITest extends SingleBrowserTest {
+
+ @Test
+ public void compositeDoesNotDuplicateCaption() {
+ openTestURL();
+ assertElementNotPresent(By.className("v-caption"));
+ }
+}