]> source.dussan.org Git - vaadin-framework.git/commitdiff
Make is possible to click a detached button again (#12781)
authorArtur Signell <artur@vaadin.com>
Thu, 18 Dec 2014 16:01:37 +0000 (18:01 +0200)
committerVaadin Code Review <review@vaadin.com>
Thu, 18 Dec 2014 20:40:11 +0000 (20:40 +0000)
Partial revert of the earlier fix

Change-Id: I67d016f1ea073189fdb53fc99f7c1b45b21ac124

server/src/com/vaadin/ui/Button.java
server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java

index 677f29ba13b9651b9cde3e084b5a08cb4ffb1433..6beb6ed686c00ab4aba583204f328dee8a1fad1a 100644 (file)
@@ -365,7 +365,7 @@ public class Button extends AbstractComponent implements
      * No action is taken is the button is disabled.
      */
     public void click() {
-        if (isConnectorEnabled() && !isReadOnly()) {
+        if (isEnabled() && !isReadOnly()) {
             fireClick();
         }
     }
index b41e93900f62749d6bec1513d35ba5942502e9b1..3d5fe77f8e95d1cbb9f0baa116124b0c8a938eef 100644 (file)
@@ -3,9 +3,11 @@ package com.vaadin.tests.server.component.button;
 import org.junit.Assert;
 import org.junit.Test;
 
+import com.vaadin.data.util.ObjectProperty;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
 import com.vaadin.ui.UI;
 
 /**
@@ -14,6 +16,22 @@ import com.vaadin.ui.UI;
 public class ButtonClick {
     private boolean clicked = false;
 
+    @Test
+    public void clickDetachedButton() {
+        Button b = new Button();
+        final ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
+        b.addClickListener(new ClickListener() {
+
+            @Override
+            public void buttonClick(ClickEvent event) {
+                counter.setValue(counter.getValue() + 1);
+            }
+        });
+
+        b.click();
+        Assert.assertEquals(Integer.valueOf(1), counter.getValue());
+    }
+
     @Test
     public void testClick() {
         getButton().click();
@@ -36,22 +54,6 @@ public class ButtonClick {
         Assert.assertFalse("Read only button fires click events", clicked);
     }
 
-    @Test
-    public void testClickConnectorDisabled() {
-        Button b = new Button() {
-            @Override
-            public boolean isConnectorEnabled() {
-                return false;
-            }
-        };
-        UI ui = createUI();
-        b.setParent(ui);
-        addClickListener(b);
-        b.click();
-        Assert.assertFalse("Button with disabled connector fires click events",
-                clicked);
-    }
-
     private Button getButton() {
         Button b = new Button();
         UI ui = createUI();