summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/vaadin/ui/TabSheet.java7
-rw-r--r--tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.html98
-rw-r--r--tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java61
3 files changed, 126 insertions, 40 deletions
diff --git a/src/com/vaadin/ui/TabSheet.java b/src/com/vaadin/ui/TabSheet.java
index 300e507fdd..a7db4cdbd3 100644
--- a/src/com/vaadin/ui/TabSheet.java
+++ b/src/com/vaadin/ui/TabSheet.java
@@ -414,8 +414,13 @@ public class TabSheet extends AbstractComponentContainer {
target.addAttribute("key", keyMapper.key(component));
if (component.equals(selected)) {
target.addAttribute("selected", true);
+ if (!paintedTabs.contains(component)) {
+ // Ensure the component is painted if it hasn't already been
+ // painted in this tabsheet
+ component.requestRepaint();
+ paintedTabs.add(component);
+ }
component.paint(target);
- paintedTabs.add(component);
} else if (paintedTabs.contains(component)) {
component.paint(target);
} else {
diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.html b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.html
new file mode 100644
index 0000000000..19b8ce018d
--- /dev/null
+++ b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.html
@@ -0,0 +1,98 @@
+
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head profile="http://selenium-ide.openqa.org/profiles/test-case">
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<link rel="selenium.base" href="" />
+<title>New Test</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">New Test</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.tabsheet.TabSheetDiscardsMovedComponents?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/VTabsheetPanel[0]/VTextField[0]</td>
+ <td>TextField 1</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>43,10</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/VTabsheetPanel[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Component 2</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/VTabsheetPanel[0]/VTextField[0]</td>
+ <td>TextField 1</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]</td>
+ <td>48,25</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/VTabsheetPanel[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Component 2</td>
+</tr>
+<tr>
+ <td>open</td>
+ <td>/run/comvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/VTabsheetPanel[0]/VTextField[0]</td>
+ <td>TextField 1</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>41,8</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[2]/VTabsheet[0]/VTabsheetPanel[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td>Component 2</td>
+</tr>
+<tr>
+ <td>click</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[0]/VButton[0]/domChild[0]/domChild[0]</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertValue</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VTextField[0]</td>
+ <td>TextField 1</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VTabsheet[0]/domChild[0]/domChild[0]/domChild[0]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>47,6</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstabsheetTabSheetDiscardsMovedComponents::/VVerticalLayout[0]/ChildComponentContainer[1]/VVerticalLayout[0]/ChildComponentContainer[0]/VHorizontalLayout[0]/ChildComponentContainer[3]/VTabsheet[0]/VTabsheetPanel[0]/VButton[0]/domChild[0]</td>
+ <td>Component 2</td>
+</tr>
+
+</tbody></table>
+</body>
+</html> \ No newline at end of file
diff --git a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
index 22d155fef5..34b5dc86c8 100644
--- a/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
+++ b/tests/src/com/vaadin/tests/components/tabsheet/TabSheetDiscardsMovedComponents.java
@@ -3,62 +3,45 @@ package com.vaadin.tests.components.tabsheet;
import com.vaadin.tests.components.TestBase;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
-import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.GridLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextField;
-public class TabSheetDiscardsMovedComponents extends TestBase implements
- ClickListener {
+public class TabSheetDiscardsMovedComponents extends TestBase {
- private static final long serialVersionUID = 3153820728819626096L;
-
- private Component c1 = new TextField("Component 1", "TextField 1");
- private Component c2 = new Button("Component 2");
-
- private TabSheet ts = null;
- private Button moveButton = new Button("Move components to new tabsheet",
- this);
- private Button moveAndSelectButton = new Button(
- "Move components to new tabsheet and remove previous tabsheet",
- this);
-
- private HorizontalLayout hl;
+ private GridLayout grid = new GridLayout();
+ private TabSheet tabSheet = new TabSheet();
@Override
public void setup() {
- hl = new HorizontalLayout();
-
- hl.addComponent(moveButton);
- hl.addComponent(moveAndSelectButton);
+ tabSheet.addTab(new Label("The tabSheet"), "Initial content");
+ tabSheet.setSizeUndefined();
- recreateTabSheet();
+ grid.setColumns(2);
+ TextField textField = new TextField("Text field");
+ textField.setValue("Text");
+ addTestComponent(textField);
+ addTestComponent(new Button("Button"));
- hl.addComponent(ts);
- addComponent(hl);
+ addComponent(tabSheet);
+ addComponent(grid);
}
- private void recreateTabSheet() {
- ts = new TabSheet();
- ts.addTab(c1);
- ts.addTab(c2);
- }
-
- public void buttonClick(ClickEvent event) {
- if (event.getButton() == moveAndSelectButton) {
- hl.removeComponent(ts);
- }
- ts.addTab(new Label("Old tabsheet"), "Old tabsheet", null);
- recreateTabSheet();
- hl.addComponent(ts);
-
+ private void addTestComponent(final Component component) {
+ grid.addComponent(component);
+ grid.addComponent(new Button("Move to tab", new Button.ClickListener() {
+ public void buttonClick(ClickEvent event) {
+ tabSheet.addTab(component);
+ grid.removeComponent(event.getButton());
+ }
+ }));
}
@Override
protected String getDescription() {
- return "Moving components from one TabSheet to another should not cause problems. Click the second tab and then a button to move the components to another TabSheet and the caption of the Button or the contents of the TextField will disappear";
+ return "Moving an already rendered component to a tabsheet and not immediately selecting the new tab should cause no problems";
}
@Override