]> source.dussan.org Git - vaadin-framework.git/commitdiff
Button icon constructor (#9857)
authorStephan Knitelius <stephan@knitelius.com>
Wed, 23 Aug 2017 06:49:45 +0000 (08:49 +0200)
committerHenri Sara <henri.sara@gmail.com>
Wed, 23 Aug 2017 06:49:45 +0000 (09:49 +0300)
Added utility constructor for Button(Icon, ClickActionListener):

new Button(VaadinIcons.AIRPLANE, e -> { ... });

server/src/main/java/com/vaadin/ui/Button.java
uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java

index bb1f5446221b7222233a63051a711431c76d4dae..e768831e3310d38029b0593c6b8fbe52bb1a0186 100644 (file)
@@ -123,6 +123,20 @@ public class Button extends AbstractFocusable
         addClickListener(listener);
     }
 
+    /**
+     * Creates a new push button with a click listener.
+     *
+     * @param icon
+     *            the Button icon.
+     * @param listener
+     *            the Button click listener.
+     * @since 8.2
+     */
+    public Button(Resource icon, ClickListener listener) {
+        setIcon(icon);
+        addClickListener(listener);
+    }
+
     /**
      * Click event. This event is thrown, when the button is clicked.
      *
index 4f95aff06f01308ad38f43020ad25fc774fcead3..05033d9491a733f222ed9261683659b88b3cbeb2 100644 (file)
@@ -261,7 +261,7 @@ public class CommonParts extends VerticalLayout implements View {
                 delay.setValue("1000");
                 group.addComponent(delay);
 
-                Button clear = new Button(null, new ClickListener() {
+                Button clear = new Button("", new ClickListener() {
                     @Override
                     public void buttonClick(ClickEvent event) {
                         delay.setValue("");
@@ -329,14 +329,13 @@ public class CommonParts extends VerticalLayout implements View {
                 pos.addStyleName(ValoTheme.BUTTON_SMALL);
                 grid.addComponent(pos);
 
-                pos = new Button("", new ClickListener() {
+                pos = new Button(ValoTheme.BUTTON_SMALL, new ClickListener() {
                     @Override
                     public void buttonClick(ClickEvent event) {
                         notification.setPosition(Position.MIDDLE_RIGHT);
                         notification.show(Page.getCurrent());
                     }
                 });
-                pos.addStyleName(ValoTheme.BUTTON_SMALL);
                 grid.addComponent(pos);
 
                 pos = new Button("", new ClickListener() {