]> source.dussan.org Git - vaadin-framework.git/commitdiff
#5865. Deprecated usage of Button as CheckBox
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 4 Nov 2010 17:49:51 +0000 (17:49 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Thu, 4 Nov 2010 17:49:51 +0000 (17:49 +0000)
svn changeset:15870/svn branch:6.5

13 files changed:
src/com/vaadin/ui/Button.java
src/com/vaadin/ui/NativeButton.java
tests/src/com/vaadin/tests/TestForRichTextEditor.java
tests/src/com/vaadin/tests/tickets/Ticket1710.java
tests/src/com/vaadin/tests/tickets/Ticket1857.java
tests/src/com/vaadin/tests/tickets/Ticket1983.java
tests/src/com/vaadin/tests/tickets/Ticket20.java
tests/src/com/vaadin/tests/tickets/Ticket2001.java
tests/src/com/vaadin/tests/tickets/Ticket2038.java
tests/src/com/vaadin/tests/tickets/Ticket2107.java
tests/src/com/vaadin/tests/tickets/Ticket2125.java
tests/src/com/vaadin/tests/tickets/Ticket736.java
tests/src/com/vaadin/tests/tickets/Ticket846.java

index 0d193168e6754e50a999d158bea27ce6a039236f..af85513692e98f1be2db04c2b763e4f523a6cb54 100644 (file)
@@ -49,7 +49,6 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier,
      */
     public Button() {
         setValue(Boolean.FALSE);
-        setSwitchMode(false);
     }
 
     /**
@@ -105,7 +104,9 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier,
      * @param state
      *            the Initial state of the switch-button.
      * @param initialState
+     * @deprecated use {@link CheckBox} instead of Button in "switchmode"
      */
+    @Deprecated
     public Button(String caption, boolean initialState) {
         setCaption(caption);
         setValue(Boolean.valueOf(initialState));
@@ -118,7 +119,9 @@ public class Button extends AbstractField implements FieldEvents.BlurNotifier,
      * @param state
      *            the Initial state of the switch-button.
      * @param dataSource
+     * @deprecated use {@link CheckBox} instead of Button in "switchmode"
      */
+    @Deprecated
     public Button(String caption, Property dataSource) {
         setCaption(caption);
         setSwitchMode(true);
index f84f270b26b281a8654d8e541189a2217c79472a..6d128b4bb49ae658140c4c635309038025a941ab 100644 (file)
@@ -32,7 +32,9 @@ public class NativeButton extends Button {
      * @param state
      *            the Initial state of the switch-button.
      * @param initialState
+     * @deprecated use the {@link CheckBox} component instead
      */
+    @Deprecated
     public NativeButton(String caption, boolean initialState) {
         super(caption, initialState);
     }
@@ -43,7 +45,9 @@ public class NativeButton extends Button {
      * @param state
      *            the Initial state of the switch-button.
      * @param dataSource
+     * @deprecated use the {@link CheckBox} component instead
      */
+    @Deprecated
     public NativeButton(String caption, Property dataSource) {
         super(caption, dataSource);
     }
index 11fb97fce02e62b37eb039975d2bda9232bce0ba..50b7be91ef010ab309a3490ad4e721dd7375f699 100644 (file)
@@ -8,6 +8,7 @@ import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.CustomComponent;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.RichTextArea;
@@ -47,8 +48,7 @@ public class TestForRichTextEditor extends CustomComponent implements
         l = new Label("", Label.CONTENT_XHTML);
         main.addComponent(l);
 
-        Button b = new Button("enabled");
-        b.setSwitchMode(true);
+        CheckBox b = new CheckBox("enabled");
         b.setImmediate(true);
         b.addListener(new Button.ClickListener() {
             public void buttonClick(ClickEvent event) {
index 1d326acd1855b78d22d9a8df5b8493827923a735..abf981f25188fa3385dc8f745eacddd4efba4724 100644 (file)
@@ -9,6 +9,7 @@ import com.vaadin.terminal.SystemError;
 import com.vaadin.terminal.ThemeResource;\r
 import com.vaadin.ui.AbstractComponent;\r
 import com.vaadin.ui.Button;\r
+import com.vaadin.ui.CheckBox;\r
 import com.vaadin.ui.Component;\r
 import com.vaadin.ui.ComponentContainer;\r
 import com.vaadin.ui.DateField;\r
@@ -45,7 +46,7 @@ public class Ticket1710 extends com.vaadin.Application {
         final VerticalLayout orderedLayout = new VerticalLayout();\r
         LayoutTestingPanel oltp = new LayoutTestingPanel("OrderedLayout",\r
                 orderedLayout);\r
-        hidingControls.addComponent(new Button("OrderedLayout",\r
+        hidingControls.addComponent(new CheckBox("OrderedLayout",\r
                 new MethodProperty<Boolean>(oltp, "visible")));\r
         lo.addComponent(oltp);\r
         orderedLayout.setSpacing(false);\r
@@ -54,7 +55,7 @@ public class Ticket1710 extends com.vaadin.Application {
         // GridLayout\r
         GridLayout grid = new GridLayout(1, 1);\r
         Panel g1tp = new LayoutTestingPanel("Gridlayout with 1 column", grid);\r
-        hidingControls.addComponent(new Button("GridLayout (1col)",\r
+        hidingControls.addComponent(new CheckBox("GridLayout (1col)",\r
                 new MethodProperty<Boolean>(g1tp, "visible")));\r
         g1tp.setVisible(false);\r
         lo.addComponent(g1tp);\r
@@ -127,7 +128,7 @@ public class Ticket1710 extends com.vaadin.Application {
         Button fb1 = new Button("Test button");\r
         fb1.setComponentError(new SystemError("Test error"));\r
         f.addField("fb1", fb1);\r
-        Button fb2 = new Button("Test button", true);\r
+        CheckBox fb2 = new CheckBox("Test button", true);\r
         fb2.setComponentError(new SystemError("Test error"));\r
         f.addField("fb2", fb2);\r
         TextField ft1 = new TextField("With caption");\r
@@ -149,9 +150,8 @@ public class Ticket1710 extends com.vaadin.Application {
         button.setComponentError(new SystemError("Test error"));\r
         lo.addComponent(button);\r
 \r
-        Button b2 = new Button("Test button");\r
+        CheckBox b2 = new CheckBox("Test button");\r
         b2.setComponentError(new SystemError("Test error"));\r
-        b2.setSwitchMode(true);\r
         lo.addComponent(b2);\r
 \r
         TextField t1 = new TextField("With caption");\r
@@ -223,11 +223,11 @@ public class Ticket1710 extends com.vaadin.Application {
         Layout testedLayout;\r
 \r
         HorizontalLayout controls = new HorizontalLayout();\r
-        Button marginLeft = new Button("m-left", false);\r
-        Button marginRight = new Button("m-right", false);\r
-        Button marginTop = new Button("m-top", false);\r
-        Button marginBottom = new Button("m-bottom", false);\r
-        Button spacing = new Button("spacing", false);\r
+        CheckBox marginLeft = new CheckBox("m-left", false);\r
+        CheckBox marginRight = new CheckBox("m-right", false);\r
+        CheckBox marginTop = new CheckBox("m-top", false);\r
+        CheckBox marginBottom = new CheckBox("m-bottom", false);\r
+        CheckBox spacing = new CheckBox("spacing", false);\r
         VerticalLayout testPanelLayout = new VerticalLayout();\r
 \r
         LayoutTestingPanel(String caption, Layout layout) {\r
@@ -254,13 +254,13 @@ public class Ticket1710 extends com.vaadin.Application {
             controls.addComponent(new Label("width"));\r
             controls.addComponent(new TextField(new MethodProperty<Float>(\r
                     testedLayout, "width")));\r
-            controls.addComponent(new Button("%", new MethodProperty<Boolean>(\r
-                    this, "widthPercents")));\r
+            controls.addComponent(new CheckBox("%",\r
+                    new MethodProperty<Boolean>(this, "widthPercents")));\r
             controls.addComponent(new Label("height"));\r
             controls.addComponent(new TextField(new MethodProperty<Float>(\r
                     testedLayout, "height")));\r
-            controls.addComponent(new Button("%", new MethodProperty<Boolean>(\r
-                    this, "heightPercents")));\r
+            controls.addComponent(new CheckBox("%",\r
+                    new MethodProperty<Boolean>(this, "heightPercents")));\r
             controls.addComponent(marginLeft);\r
             controls.addComponent(marginRight);\r
             controls.addComponent(marginTop);\r
index 1fda97919808d2ff114602b716b0bc61526a193b..f82467b519f1c54a31d1b0f5cfb046b7b02192b5 100644 (file)
@@ -5,7 +5,7 @@ import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.event.Action;
 import com.vaadin.event.Action.Handler;
-import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.VerticalLayout;
@@ -35,7 +35,8 @@ public class Ticket1857 extends Application implements Handler {
         el.addComponent(footer);
         footer.setSpacing(true);
 
-        final Button actionHandlerEnabler = new Button("Action handlers", false);
+        final CheckBox actionHandlerEnabler = new CheckBox("Action handlers",
+                false);
         footer.addComponent(actionHandlerEnabler);
         actionHandlerEnabler.setImmediate(true);
         actionHandlerEnabler.addListener(new Property.ValueChangeListener() {
@@ -48,7 +49,7 @@ public class Ticket1857 extends Application implements Handler {
             }
         });
 
-        final Button cellStylesEnabler = new Button("Cell styles", false);
+        final CheckBox cellStylesEnabler = new CheckBox("Cell styles", false);
         footer.addComponent(cellStylesEnabler);
         cellStylesEnabler.setImmediate(true);
         cellStylesEnabler.addListener(new Property.ValueChangeListener() {
index 26e61e9cf43af9ddde70e69decc627f2677c7cb6..12198ab2477abac14f801ea24e41d2a1843db7d4 100644 (file)
@@ -5,6 +5,7 @@ import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.terminal.Sizeable;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.HorizontalSplitPanel;
 import com.vaadin.ui.Layout;
 import com.vaadin.ui.SplitPanel;
@@ -114,7 +115,7 @@ public class Ticket1983 extends Application {
             ol.addComponent(button);
             leftSide.setFirstComponent(ol);
 
-            button = new Button("Two col");
+            button = new CheckBox("Two col");
             button.addListener(new Button.ClickListener() {
                 public void buttonClick(ClickEvent event) {
                     Button b = event.getButton();
@@ -127,7 +128,6 @@ public class Ticket1983 extends Application {
                 }
 
             });
-            button.setSwitchMode(true);
             ol.addComponent(button);
 
             return leftSide;
index 51f1a938b998509cb6b32d38f766306f153fb71b..55fee95de38116fba52e81715416d113ed18e2b6 100644 (file)
@@ -5,6 +5,7 @@ import com.vaadin.data.Validator;
 import com.vaadin.data.util.MethodProperty;
 import com.vaadin.data.validator.CompositeValidator;
 import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.TextField;
 import com.vaadin.ui.Window;
 
@@ -79,8 +80,8 @@ public class Ticket20 extends Application {
                 "readOnly", "readThrough", "invalidCommitted",
                 "validationVisible" };
         for (int i = 0; i < visibleProps.length; i++) {
-            Button b = new Button(visibleProps[i], new MethodProperty<Boolean>(
-                    tx, visibleProps[i]));
+            CheckBox b = new CheckBox(visibleProps[i],
+                    new MethodProperty<Boolean>(tx, visibleProps[i]));
             b.setImmediate(true);
             mainWin.addComponent(b);
         }
index 64dd47c2e295a55dcfcf666f8a04b7b0181ed073..4796451dc03799406436b082fa703f0df3123f2a 100644 (file)
@@ -3,7 +3,7 @@ package com.vaadin.tests.tickets;
 import com.vaadin.Application;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.VerticalLayout;
 import com.vaadin.ui.Window;
@@ -20,7 +20,7 @@ public class Ticket2001 extends Application {
         l.addComponent(new Label("row 2"));
         w.addComponent(l);
 
-        final Button b = new Button("fixed width: 30px", false);
+        final CheckBox b = new CheckBox("fixed width: 30px", false);
         b.addListener(new Property.ValueChangeListener() {
             public void valueChange(ValueChangeEvent event) {
                 if (b.booleanValue()) {
index ff5ceb22e7c00e5a03244b88ed1073a6ea996214..85a5a4b7014cc3672e016f0ebacc6c496d5c80d4 100644 (file)
@@ -3,7 +3,7 @@ package com.vaadin.tests.tickets;
 import com.vaadin.Application;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.TextField;
 import com.vaadin.ui.Window;
 import com.vaadin.ui.Window.Notification;
@@ -29,7 +29,7 @@ public class Ticket2038 extends Application {
         });
         w.addComponent(tf);
 
-        final Button b = new Button(
+        final CheckBox b = new CheckBox(
                 "Field should use error message. (!) should be shown when invalid.",
                 false);
         w.addComponent(b);
index 4c185801c3c82ac645c742afa4b97480efc37bbc..199b278343afb97c4ff9d48ebbfe028b89c5461c 100644 (file)
@@ -4,7 +4,7 @@ import com.vaadin.Application;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Validator;
-import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.TextField;
 import com.vaadin.ui.Window;
 import com.vaadin.ui.Window.Notification;
@@ -44,7 +44,7 @@ public class Ticket2107 extends Application {
         });
         w.addComponent(tf);
 
-        final Button b = new Button(
+        final CheckBox b = new CheckBox(
                 "Field should use error message. (!) should be shown when empty.",
                 false);
         w.addComponent(b);
index 378952489f38e8b0b52a25851ba11e2c87dc7544..b296a4ff46ebc1b147df49220bd4c1f67dd04789 100644 (file)
@@ -2,7 +2,7 @@ package com.vaadin.tests.tickets;
 
 import com.vaadin.Application;
 import com.vaadin.data.util.MethodProperty;
-import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Component;
 import com.vaadin.ui.Label;
 import com.vaadin.ui.Table;
@@ -52,7 +52,7 @@ public class Ticket2125 extends Application {
                 }
 
             });
-            Button b = new Button("editmode", new MethodProperty<Boolean>(
+            CheckBox b = new CheckBox("editmode", new MethodProperty<Boolean>(
                     table, "editable"));
             b.setImmediate(true);
             addComponent(b);
index ba2e4406736b1d90af3cfbac943de3b8827823cd..ac7868cb48c3b7216bac58ef74e9c0e89258cf30 100644 (file)
@@ -9,6 +9,7 @@ import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Form;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.Panel;
@@ -65,8 +66,8 @@ public class Ticket736 extends Application {
                 "readOnly", "readThrough", "writeThrough", "invalidCommitted",
                 "validationVisible", "immediate" };
         for (int i = 0; i < visibleProps.length; i++) {
-            Button b = new Button(visibleProps[i], new MethodProperty<Boolean>(
-                    f, visibleProps[i]));
+            CheckBox b = new CheckBox(visibleProps[i],
+                    new MethodProperty<Boolean>(f, visibleProps[i]));
             b.setImmediate(true);
             formProperties.addComponent(b);
         }
index 3f9e0ccf6f9a64d16f1c46eff59ccf8b69fad98f..23f3134308cf3479e98df97ee94f6e61fd596705 100644 (file)
@@ -4,6 +4,7 @@ import com.vaadin.Application;
 import com.vaadin.data.Validator;
 import com.vaadin.data.util.MethodProperty;
 import com.vaadin.ui.Button;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.TextField;
 import com.vaadin.ui.Window;
 
@@ -40,8 +41,8 @@ public class Ticket846 extends Application {
                 "readOnly", "readThrough", "invalidCommitted",
                 "validationVisible" };
         for (int i = 0; i < visibleProps.length; i++) {
-            Button b = new Button(visibleProps[i], new MethodProperty<Boolean>(
-                    tx, visibleProps[i]));
+            CheckBox b = new CheckBox(visibleProps[i],
+                    new MethodProperty<Boolean>(tx, visibleProps[i]));
             b.setImmediate(true);
             mainWin.addComponent(b);
         }