Example usage for com.google.gwt.gen2.table.client SelectionGrid isSelectionEnabled

List of usage examples for com.google.gwt.gen2.table.client SelectionGrid isSelectionEnabled

Introduction

In this page you can find the example usage for com.google.gwt.gen2.table.client SelectionGrid isSelectionEnabled.

Prototype

public boolean isSelectionEnabled() 

Source Link

Usage

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.highlight.RowSelectionPolicyOption.java

License:Apache License

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

    // Add the current status
    statusLabel = new Label();
    form.addLabeledWidget("Selection Status:", statusLabel);

    // Add the current policy
    policyBox = new ListBox();
    policyBox.addItem("Multi Row");
    policyBox.addItem("Single Row");
    policyBox.addItem("Checkboxes");
    policyBox.addItem("Radio Buttons");
    form.addLabeledWidget("Selection Policy:", policyBox);

    // Add button to change policy
    {/*  www .j a  va2s. c o m*/
        Button button = new Button("Set Selection Policy", new ClickHandler() {
            public void onClick(ClickEvent event) {
                SelectionGrid grid = ScrollTableDemo.get().getDataTable();
                switch (policyBox.getSelectedIndex()) {
                case 0:
                    grid.setSelectionPolicy(SelectionPolicy.MULTI_ROW);
                    break;
                case 1:
                    grid.setSelectionPolicy(SelectionPolicy.ONE_ROW);
                    break;
                case 2:
                    grid.setSelectionPolicy(SelectionPolicy.CHECKBOX);
                    break;
                case 3:
                    grid.setSelectionPolicy(SelectionPolicy.RADIO);
                    break;
                }
                PagingScrollTableDemo.get().getPagingScrollTable().reloadPage();
            }
        });
        form.addButton(button);
    }

    // Add button to change status
    {
        Button button = new Button("Toggle Status", new ClickHandler() {
            public void onClick(ClickEvent event) {
                SelectionGrid grid = ScrollTableDemo.get().getDataTable();
                grid.setSelectionEnabled(!grid.isSelectionEnabled());
                refreshPolicy();
            }
        });
        form.addButton(button);
    }

    // Refresh policy and return
    refreshPolicy();
    return form;
}

From source file:com.google.gwt.gen2.demo.scrolltable.client.option.highlight.RowSelectionPolicyOption.java

License:Apache License

/**
 * Refresh the policy.//from ww w  .j  a v  a  2s . co  m
 */
private void refreshPolicy() {
    SelectionGrid grid = ScrollTableDemo.get().getDataTable();

    // Refresh the status
    if (grid.isSelectionEnabled()) {
        statusLabel.setText("enabled");
    } else {
        statusLabel.setText("disabled");
    }

    // Refresh the policy
    SelectionPolicy policy = grid.getSelectionPolicy();
    if (policy == SelectionPolicy.MULTI_ROW) {
        policyBox.setSelectedIndex(0);
    } else if (policy == SelectionPolicy.ONE_ROW) {
        policyBox.setSelectedIndex(1);
    } else if (policy == SelectionPolicy.CHECKBOX) {
        policyBox.setSelectedIndex(2);
    } else if (policy == SelectionPolicy.RADIO) {
        policyBox.setSelectedIndex(3);
    }
}