--- /dev/null
+package com.vaadin.tests.tickets;\r
+\r
+import com.vaadin.data.Property;\r
+import com.vaadin.data.Property.ValueChangeEvent;\r
+import com.vaadin.data.util.ObjectProperty;\r
+import com.vaadin.tests.components.TestBase;\r
+import com.vaadin.ui.Label;\r
+import com.vaadin.ui.TextField;\r
+import com.vaadin.ui.VerticalLayout;\r
+import com.vaadin.ui.Window;\r
+\r
+public class Ticket6002 extends TestBase {\r
+\r
+ @Override\r
+ public void setup() {\r
+ Window main = new Window("The Main Window");\r
+ setMainWindow(main);\r
+\r
+ final VerticalLayout mainLayout = new VerticalLayout();\r
+ main.setContent(mainLayout);\r
+ \r
+ mainLayout.addComponent(new Label("Replace the floating-point values with an integer"));\r
+\r
+ /////////////////////////////////////////////////////\r
+ // Better working case\r
+\r
+ final ObjectProperty<Double> property1 =\r
+ new ObjectProperty<Double>(new Double(42.0));\r
+\r
+ // A text field that changes its caption\r
+ final TextField tf1 = new TextField("Changing this field modifies only the textfield", property1);\r
+ tf1.addListener(new Property.ValueChangeListener() {\r
+ public void valueChange(ValueChangeEvent event) {\r
+ // This value change event is called twice if the new\r
+ // input value is an integer. The second time is during\r
+ // paint() of AbstractOrderedLayout.\r
+ \r
+ System.out.println("Value 2 is: " + property1.getValue());\r
+\r
+ tf1.setCaption("With caption " + property1.getValue());\r
+ }\r
+ });\r
+ tf1.setImmediate(true);\r
+ mainLayout.addComponent(tf1);\r
+ \r
+ /////////////////////////////////////////////////////\r
+ // Totally failing case\r
+ \r
+ final ObjectProperty<Double> property2 =\r
+ new ObjectProperty<Double>(new Double(42.0));\r
+\r
+ // A text field that adds new components\r
+ final TextField tf2 = new TextField("Changing this field modifies the layout - do it twice", property2);\r
+ tf2.addListener(new Property.ValueChangeListener() {\r
+ public void valueChange(ValueChangeEvent event) {\r
+ // This value change event is called twice if the new\r
+ // input value is an integer. The second time is during\r
+ // paint() of AbstractOrderedLayout.\r
+ \r
+ System.out.println("Value 1 is: " + property2.getValue());\r
+ \r
+ // When this listener is called the second time in paint(), the\r
+ // add operation causes a ConcurrentModificationException\r
+ mainLayout.addComponent(new Label("Added a component, value is " + property2.getValue()));\r
+ }\r
+ });\r
+ tf2.setImmediate(true);\r
+ mainLayout.addComponent(tf2);\r
+ \r
+ mainLayout.setSpacing(true);\r
+ }\r
+\r
+ @Override\r
+ protected String getDescription() {\r
+ return "";\r
+ }\r
+\r
+ @Override\r
+ protected Integer getTicketNumber() {\r
+ return 0;\r
+ }\r
+}\r