]> source.dussan.org Git - vaadin-framework.git/commitdiff
ProgressIndicator now stops polling when removed (#10130) 07/207/1
authorArtur Signell <artur@vaadin.com>
Mon, 5 Nov 2012 14:18:21 +0000 (16:18 +0200)
committerArtur Signell <artur@vaadin.com>
Mon, 5 Nov 2012 14:18:51 +0000 (16:18 +0200)
Change-Id: I9f422d387a95f3f711c575d15973c101792769e7

client/src/com/vaadin/client/ui/progressindicator/ProgressIndicatorConnector.java
uitest/src/com/vaadin/tests/components/progressindicator/ProgressIndicatorInvisible.java

index 40b3a227c429b34699465e1673b629bded96a180..a92fea55f94b638a30c97f82d744ec60894edd85 100644 (file)
@@ -58,6 +58,12 @@ public class ProgressIndicatorConnector extends AbstractFieldConnector {
         }
     }
 
+    @Override
+    public void onUnregister() {
+        super.onUnregister();
+        poller.cancel();
+    }
+
     @Override
     public VProgressIndicator getWidget() {
         return (VProgressIndicator) super.getWidget();
index 2c58e9226a7a836305e6bb937fdf02dc747233fe..4542d0c6c8110d85109930861402b0d978cf777f 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.components.progressindicator;
 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.ProgressIndicator;
 import com.vaadin.ui.VerticalLayout;
 
@@ -18,22 +19,62 @@ public class ProgressIndicatorInvisible extends TestBase {
         pi.setPollingInterval(400);
         lo.addComponent(pi);
 
+        Button hideProgressIndicator = new Button("Hide progress indicator",
+                new ClickListener() {
+
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        pi.setVisible(!pi.isVisible());
+                        event.getButton().setCaption(
+                                (pi.isVisible() ? "Hide" : "Show")
+                                        + " progress indicator");
+
+                    }
+                });
+        addComponent(hideProgressIndicator);
+
+        Button disableProgressIndicator = new Button(
+                "Disable progress indicator", new ClickListener() {
+
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        pi.setEnabled(!pi.isEnabled());
+                        event.getButton().setCaption(
+                                (pi.isEnabled() ? "Disable" : "Enable")
+                                        + " progress indicator");
+
+                    }
+                });
+
+        addComponent(disableProgressIndicator);
+        Button removeProgressIndicator = new Button(
+                "Remove progress indicator", new ClickListener() {
+
+                    @Override
+                    public void buttonClick(ClickEvent event) {
+                        if (pi.getParent() != null) {
+                            lo.removeComponent(pi);
+                            event.getButton().setCaption(
+                                    "Add progress indicator");
+                        } else {
+                            lo.addComponent(pi);
+                            event.getButton().setCaption(
+                                    "Remove progress indicator");
+                        }
+
+                    }
+                });
+
+        addComponent(removeProgressIndicator);
         final Button b = new Button("Hide container of progress indicator");
         addComponent(b);
 
         b.addClickListener(new Button.ClickListener() {
             @Override
             public void buttonClick(ClickEvent event) {
-                // If we skip hiding the layout, hiding the ProgressIndicator
-                // will stop the polling
                 lo.setVisible(!lo.isVisible());
-                // Not even this works
-                pi.setVisible(!lo.isVisible());
-                if (!lo.isVisible()) {
-                    b.setCaption("Still polling");
-                } else {
-                    b.setCaption("Hide container of progress indicator");
-                }
+                b.setCaption((lo.isVisible() ? "Hide" : "Show")
+                        + " container of progress indicator");
 
             }