Package org.gwtoolbox.widget.client.table.basic.selection

Examples of org.gwtoolbox.widget.client.table.basic.selection.SingleCellSelectionModel


        private RecordPanel() {
            main = new BasicTable();
            main.setWidth("100%");
            main.setHeaderText(0, "Field");
            main.setHeaderText(1, "Value");
            SingleCellSelectionModel selectionModel = new SingleCellSelectionModel();
            selectionModel.setSelectionFilter(new CellSelectionFilter() {
                public boolean isSelectable(int row, int column) {
                    return column != 0;
                }
            });
            main.setSelectionModel(selectionModel);
View Full Code Here


        });

        Button singleCellSelectionButton = new Button("Set Single Cell Selection");
        singleCellSelectionButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                SingleCellSelectionModel selectionModel = new SingleCellSelectionModel();
                table.setSelectionModel(selectionModel);
                selectionModel.addListener(new SingleCellSelection.Listener() {
                    public void selectionCleared() {
                        messageLabel.setText("");
                    }

                    public void cellSelected(int row, int column) {
                        messageLabel.setText("Selected cell (row: " + row + ", col: " + column + ")");
                    }
                });
                GGrowl.showMessage("Selection Model Changed", "Single cell selection is enabled. Hold the Ctrl key to unselect a cell", 5000);
            }
        });

        Button singleRowSelectionButton = new Button("Set Single Row Selection");
        singleRowSelectionButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                SingleRowSelectionModel selectionModel = new SingleRowSelectionModel();
                table.setSelectionModel(selectionModel);
                selectionModel.addListener(new SingleRowSelection.Listener() {
                    public void selectionCleared() {
                        messageLabel.setText("");
                    }

                    public void rowSelected(int row) {
                        messageLabel.setText("Selected row: " + row);
                    }
                });
                GGrowl.showMessage("Selection Model Changed", "Single row selection is enabled. Hold the Ctrl key to unselect a row", 5000);
            }
        });

        Button multiRowSelectionButton = new Button("Set Multi-Row Selection");
        multiRowSelectionButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                MultiRowSelectionModel selectionModel = new MultiRowSelectionModel();
                table.setSelectionModel(selectionModel);
                selectionModel.addListener(new MultiRowSelection.Listener() {
                    public void selectionCleared() {
                        messageLabel.setText("");
                    }

                    public void rowSelected(int row, MultiRowSelection model) {
                        printSelection(model);
                    }

                    public void rowUnselected(int row, MultiRowSelection model) {
                        printSelection(model);
                    }

                    private void printSelection(MultiRowSelection model) {
                        StringBuilder builder = new StringBuilder();
                        for (int selectedRow : model.getSelectedRows()) {
                            if (builder.length() > 0) {
                                builder.append(", ");
                            }
                            builder.append(selectedRow);
                        }
                        messageLabel.setText("Selected rows: " + builder.toString());
                    }
                });
                GGrowl.showMessage("Selection Model Changed", "Multi-row selection is enabled. Hold the Ctrl key to un/select multiple rows", 5000);
            }
        });

        Button multiCellSelectionButton = new Button("Set Multi-Cell Selection");
        multiCellSelectionButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
                MultiCellSelectionModel selectionModel = new MultiCellSelectionModel();
                table.setSelectionModel(selectionModel);
                selectionModel.addListener(new MultiCellSelection.Listener() {
                    public void selectionCleared() {
                        messageLabel.setText("");
                    }

                    public void cellSelected(int row, int column, MultiCellSelection model) {
View Full Code Here

TOP

Related Classes of org.gwtoolbox.widget.client.table.basic.selection.SingleCellSelectionModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.