Example usage for com.google.gwt.user.client.ui Button Button

List of usage examples for com.google.gwt.user.client.ui Button Button

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Button Button.

Prototype

public Button(String html, ClickHandler handler) 

Source Link

Document

Creates a button with the given HTML caption and click listener.

Usage

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.setup.ScrollPolicyOption.java

License:Apache License

@Override
protected Widget onInitialize() {
    CustomForm form = new CustomForm();

    // Add the policy
    scrollPolicyBox = new ListBox();
    scrollPolicyBox.addItem("both");
    scrollPolicyBox.addItem("horizontal");
    scrollPolicyBox.addItem("disabled");
    form.addLabeledWidget("Scroll Policy:", scrollPolicyBox);
    refreshPolicy();//from  w  ww  .java 2s .  co  m

    // Add button to change status
    {
        Button button = new Button("Set Scroll Policy", new ClickHandler() {
            public void onClick(ClickEvent event) {
                AbstractScrollTable scrollTable = ScrollTableDemo.get().getScrollTable();
                switch (scrollPolicyBox.getSelectedIndex()) {
                case 0:
                    scrollTable.setScrollPolicy(ScrollTable.ScrollPolicy.BOTH);
                    break;
                case 1:
                    scrollTable.setScrollPolicy(ScrollTable.ScrollPolicy.HORIZONTAL);
                    break;
                case 2:
                    scrollTable.setScrollPolicy(ScrollTable.ScrollPolicy.DISABLED);
                    break;
                }
            }
        });
        form.addButton(button);
    }

    return form;
}

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.setup.TableSizeOption.java

License:Apache License

@Override
protected Widget onInitialize() {
    CustomForm form = new CustomForm();

    // Height selection
    final TextBox heightBox = new TextBox();
    heightBox.setText("400px");
    heightBox.setWidth("50px");
    form.addLabeledWidget("Height:", heightBox);

    // Width selection
    final TextBox widthBox = new TextBox();
    widthBox.setText("95%");
    widthBox.setWidth("50px");
    form.addLabeledWidget("Width:", widthBox);

    // Add button to change status
    {//w w  w  . j  av a2  s .co m
        Button button = new Button("Set Table Size", new ClickHandler() {
            public void onClick(ClickEvent event) {
                String height = heightBox.getText();
                String width = widthBox.getText();
                ScrollTableDemo.get().getScrollTable().setSize(width, height);
            }
        });
        form.addButton(button);
    }

    // Add button to get minimum offset width
    {
        Button button = new Button("Get Minimum Offset Width", new ClickHandler() {
            public void onClick(ClickEvent event) {
                int width = ScrollTableDemo.get().getScrollTable().getMinimumOffsetWidth();
                Window.alert("Minimum Offset Width: " + width);
            }
        });
        form.addButton(button);
    }

    return form;
}

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.sort.ShiftRowsOption.java

License:Apache License

@Override
protected Widget onInitialize() {
    CustomForm form = new CustomForm();

    // Row selection
    final TextBox rowBox = new TextBox();
    rowBox.setText("3");
    rowBox.setWidth("50px");
    form.addLabeledWidget("Row Index:", rowBox);

    // Add button to shift row up
    {/*from   ww w . j  a va 2  s  . c  om*/
        Button button = new Button("Shift Row Up", new ClickHandler() {
            public void onClick(ClickEvent event) {
                try {
                    int row = Integer.parseInt(rowBox.getText());
                    if (row >= 0) {
                        ScrollTableDemo.get().getDataTable().moveRowUp(row);
                        rowBox.setText((row - 1) + "");
                    }
                } catch (NumberFormatException e) {
                    Window.alert("Please enter valid integers for the row and column.");
                } catch (IndexOutOfBoundsException e) {
                    Window.alert("The row or column index you entered is out of bounds.");
                }
            }
        });
        form.addButton(button);
    }

    // Add button to shift row down
    {
        Button button = new Button("Shift Row Down", new ClickHandler() {
            public void onClick(ClickEvent event) {
                try {
                    int row = Integer.parseInt(rowBox.getText());
                    if (row >= 0) {
                        ScrollTableDemo.get().getDataTable().moveRowDown(row);
                        rowBox.setText((row + 1) + "");
                    }
                } catch (NumberFormatException e) {
                    Window.alert("Please enter valid integers for the row and column.");
                } catch (IndexOutOfBoundsException e) {
                    Window.alert("The row or column index you entered is out of bounds.");
                }
            }
        });
        form.addButton(button);
    }

    return form;
}

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.sort.SortColumnOption.java

License:Apache License

@Override
protected Widget onInitialize() {
    CustomForm form = new CustomForm();

    // Add the current policy
    policyBox = new ListBox();
    policyBox.addItem("Disabled");
    policyBox.addItem("Single Cell");
    policyBox.addItem("Multi Cell");
    form.addLabeledWidget("Sort Policy:", policyBox);
    refreshPolicy();/*  w  w  w. java2s.c  om*/

    // Add button to change policy
    {
        Button button = new Button("Set Sort Policy", new ClickHandler() {
            public void onClick(ClickEvent event) {
                AbstractScrollTable scrollTable = ScrollTableDemo.get().getScrollTable();
                switch (policyBox.getSelectedIndex()) {
                case 0:
                    scrollTable.setSortPolicy(SortPolicy.DISABLED);
                    break;
                case 1:
                    scrollTable.setSortPolicy(SortPolicy.SINGLE_CELL);
                    break;
                case 2:
                    scrollTable.setSortPolicy(SortPolicy.MULTI_CELL);
                    break;
                }
            }
        });
        form.addButton(button);
    }

    // Select the column index
    final TextBox columnBox = new TextBox();
    columnBox.setText("3");
    columnBox.setWidth("50px");
    form.addLabeledWidget("Column Index:", columnBox);

    // Add a button to sort the column
    {
        Button button = new Button("Sort Column", new ClickHandler() {
            public void onClick(ClickEvent event) {
                try {
                    int column = Integer.parseInt(columnBox.getText());
                    ScrollTableDemo.get().getDataTable().sortColumn(column);
                    ScrollTableDemo.get().getScrollTable().redraw();
                } catch (NumberFormatException e) {
                    Window.alert("Please enter valid integers for the row and column.");
                } catch (IndexOutOfBoundsException e) {
                    Window.alert("The row or column index you entered is out of bounds.");
                }
            }
        });
        form.addButton(button);
    }

    // Add a button to make column sortable
    if (PagingScrollTableDemo.get() == null) {
        Button button = new Button("Make Sortable", new ClickHandler() {
            public void onClick(ClickEvent event) {
                try {
                    int column = Integer.parseInt(columnBox.getText());
                    ScrollTable scrollTable = (ScrollTable) ScrollTableDemo.get().getScrollTable();
                    scrollTable.setColumnSortable(column, true);
                } catch (NumberFormatException e) {
                    Window.alert("Please enter valid integers for the row and column.");
                }
            }
        });
        form.addButton(button);
    }

    // Add a button to make column unsortable
    if (PagingScrollTableDemo.get() == null) {
        Button button = new Button("Make Unsortable", new ClickHandler() {
            public void onClick(ClickEvent event) {
                try {
                    int column = Integer.parseInt(columnBox.getText());
                    ScrollTable scrollTable = (ScrollTable) ScrollTableDemo.get().getScrollTable();
                    scrollTable.setColumnSortable(column, false);
                } catch (NumberFormatException e) {
                    Window.alert("Please enter valid integers for the row and column.");
                }
            }
        });
        form.addButton(button);
    }

    return form;
}