List of usage examples for com.google.gwt.user.client.ui Button Button
public Button(String html, ClickHandler handler)
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.header.ColSpanOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Row selection final TextBox rowBox = new TextBox(); rowBox.setText("1"); rowBox.setWidth("50px"); form.addLabeledWidget("Row Index:", rowBox); // Cell selection final TextBox cellBox = new TextBox(); cellBox.setText("0"); cellBox.setWidth("50px"); form.addLabeledWidget("Cell Index:", cellBox); // Colspan selection final TextBox colSpanBox = new TextBox(); colSpanBox.setText("1"); colSpanBox.setWidth("50px"); form.addLabeledWidget("ColSpan:", colSpanBox); // Rowspan selection final TextBox rowSpanBox = new TextBox(); rowSpanBox.setText("1"); rowSpanBox.setWidth("50px"); form.addLabeledWidget("RowSpan:", rowSpanBox); // Add button to set the spans {//from www . j av a 2 s .c o m Button button = new Button("Set row/colspan", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); int cell = Integer.parseInt(cellBox.getText()); int rowSpan = Integer.parseInt(rowSpanBox.getText()); int colSpan = Integer.parseInt(colSpanBox.getText()); FlexTable headerTable = ScrollTableDemo.get().getHeaderTable(); headerTable.getFlexCellFormatter().setRowSpan(row, cell, rowSpan); headerTable.getFlexCellFormatter().setColSpan(row, cell, colSpan); 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); } return form; }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.header.InsertHeaderRowOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Row selection final TextBox rowBox = new TextBox(); rowBox.setText("1"); rowBox.setWidth("50px"); form.addLabeledWidget("Row Index:", rowBox); // Add button to insert one row {// w w w. j a v a2 s . c o m Button button = new Button("Insert 1 Row", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); FlexTable headerTable = ScrollTableDemo.get().getHeaderTable(); headerTable.insertRow(row); headerTable.setHTML(row, 0, " "); 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 button to remove a row { Button button = new Button("Remove Row", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); ScrollTableDemo.get().getHeaderTable().removeRow(row); 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); } // Cell selection final TextBox cellBox = new TextBox(); cellBox.setText("0"); cellBox.setWidth("50px"); form.addLabeledWidget("Cell Index", cellBox); // Add button to insert one cell { Button button = new Button("Insert 1 Cell", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); int cell = Integer.parseInt(cellBox.getText()); FlexTable headerTable = ScrollTableDemo.get().getHeaderTable(); headerTable.insertCell(row, cell); headerTable.setHTML(row, 0, " "); } 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 remove a cell { Button button = new Button("Remove Cell", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); int cell = Integer.parseInt(cellBox.getText()); ScrollTableDemo.get().getHeaderTable().removeCell(row, cell); } 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.header.SetHeaderTextOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Row selection final TextBox rowBox = new TextBox(); rowBox.setText("1"); rowBox.setWidth("50px"); form.addLabeledWidget("Row Index", rowBox); // Column selection final TextBox columnBox = new TextBox(); columnBox.setText("2"); columnBox.setWidth("50px"); form.addLabeledWidget("Column Index", columnBox); // Text selection final TextBox textBox = new TextBox(); textBox.setText("<b>Hello World</b>"); form.addLabeledWidget("Text", textBox); // Add button to set text {/*from w ww .j a va2s. c om*/ Button button = new Button("Set Cell Text", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); int column = Integer.parseInt(columnBox.getText()); String text = textBox.getText(); ScrollTableDemo.get().getHeaderTable().setText(row, column, text); } 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 set html { Button button = new Button("Set Cell HTML", new ClickHandler() { public void onClick(ClickEvent event) { try { int row = Integer.parseInt(rowBox.getText()); int column = Integer.parseInt(columnBox.getText()); String text = textBox.getText(); ScrollTableDemo.get().getHeaderTable().setHTML(row, column, text); } 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.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 {/* w w w .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.log.LogOption.java
License:Apache License
@Override protected Widget onInitialize() { layout = new FlexTable(); // Create the log area logLabel = new HTML(); logLabel.setHeight("200px"); DOM.setStyleAttribute(logLabel.getElement(), "font", "8pt/10pt courier"); ScrollPanel scrollPanel = new ScrollPanel(logLabel); scrollPanel.setPixelSize(500, 200);//from ww w .j av a 2s .com DOM.setStyleAttribute(scrollPanel.getElement(), "border", "1px solid black"); layout.setWidget(0, 0, scrollPanel); layout.getFlexCellFormatter().setColSpan(0, 0, 2); // Add a clear button Button clearButton = new Button("Clear Log", new ClickHandler() { public void onClick(ClickEvent event) { logLabel.setHTML(""); lineCount = 0; } }); layout.setWidget(1, 0, clearButton); layout.getFlexCellFormatter().setColSpan(1, 0, 2); // Add labels for highlighting final Label highlightedCellLabel = new Label("Highlighted cell:"); final Label highlightedRowLabel = new Label("Highlighted row:"); final Label unhighlightedCellLabel = new Label("Last unhighlighted cell:"); final Label unhighlightedRowLabel = new Label("Last unhighlighted row:"); layout.setWidget(2, 0, highlightedCellLabel); layout.setWidget(3, 0, highlightedRowLabel); layout.setWidget(2, 1, unhighlightedRowLabel); layout.setWidget(3, 1, unhighlightedCellLabel); // Add all of the listeners FixedWidthGrid dataTable = ScrollTableDemo.get().getDataTable(); dataTable.addTableListener(new TableListener() { public void onCellClicked(SourcesTableEvents sender, int row, int cell) { addLogEntry("cell clicked: (" + row + "," + cell + ")", "#ff00ff"); } }); dataTable.addColumnSortHandler(new ColumnSortHandler() { public void onColumnSorted(ColumnSortEvent event) { ColumnSortList sortList = event.getColumnSortList(); int column = -1; boolean ascending = true; if (sortList != null) { column = sortList.getPrimaryColumn(); ascending = sortList.isPrimaryAscending(); } if (ascending) { addLogEntry("sorted column: " + column + " (ascending)", "black"); } else { addLogEntry("sorted column: " + column, "black"); } } }); dataTable.addCellHighlightHandler(new CellHighlightHandler() { public void onCellHighlight(CellHighlightEvent event) { Cell cell = event.getValue(); highlightedCellLabel .setText("Highlighted cell: (" + cell.getRowIndex() + "," + cell.getCellIndex() + ")"); } }); dataTable.addCellUnhighlightHandler(new CellUnhighlightHandler() { public void onCellUnhighlight(CellUnhighlightEvent event) { Cell cell = event.getValue(); unhighlightedCellLabel.setText( "Last unhighlighted cell: (" + cell.getRowIndex() + "," + cell.getCellIndex() + ")"); } }); dataTable.addRowHighlightHandler(new RowHighlightHandler() { public void onRowHighlight(RowHighlightEvent event) { Row cell = event.getValue(); highlightedRowLabel.setText("Highlighted row: (" + cell.getRowIndex() + ")"); } }); dataTable.addRowUnhighlightHandler(new RowUnhighlightHandler() { public void onRowUnhighlight(RowUnhighlightEvent event) { Row cell = event.getValue(); unhighlightedRowLabel.setText("Last unhighlighted row: (" + cell.getRowIndex() + ")"); } }); dataTable.addRowSelectionHandler(new RowSelectionHandler() { public void onRowSelection(RowSelectionEvent event) { // Show the previously selected rows Set<Row> deselectedRows = event.getDeselectedRows(); String previous = "Previously selected rows: "; for (Row row : event.getOldValue()) { if (deselectedRows.contains(row)) { previous += "-"; } previous += row.getRowIndex() + ", "; } addLogEntry(previous, "green"); // Show the currently selected rows Set<Row> selectedRows = event.getSelectedRows(); String current = "Currently selected rows: "; for (Row row : event.getNewValue()) { if (selectedRows.contains(row)) { current += "+"; } current += row.getRowIndex() + ", "; } addLogEntry(current, "green"); } }); // Paging specific options if (PagingScrollTableDemo.get() != null) { PagingScrollTable<Student> pagingScrollTable = PagingScrollTableDemo.get().getPagingScrollTable(); if (pagingScrollTable != null) { pagingScrollTable.addPageChangeHandler(new PageChangeHandler() { public void onPageChange(PageChangeEvent event) { pageLoadDuration = new Duration(); } }); pagingScrollTable.addPageLoadHandler(new PageLoadHandler() { public void onPageLoad(PageLoadEvent event) { // Convert to 1 based index int page = event.getPage() + 1; int duration = -1; if (pageLoadDuration != null) { duration = pageLoadDuration.elapsedMillis(); pageLoadDuration = null; } String text = "Page " + page + " loaded in " + duration + "ms"; addLogEntry(text, "black"); } }); } } return layout; }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.paging.CacheSizeOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Pre cache size final TextBox preCacheBox = new TextBox(); preCacheBox.setText("50"); preCacheBox.setWidth("50px"); form.addLabeledWidget("Pre Cache Size:", preCacheBox); // Post cache size final TextBox postCacheBox = new TextBox(); postCacheBox.setText("50"); postCacheBox.setWidth("50px"); form.addLabeledWidget("Post Cache Size:", postCacheBox); // Add button to set the row count {/* w ww.j a va 2 s .c om*/ Button button = new Button("Set Cache Size", new ClickHandler() { public void onClick(ClickEvent event) { try { int preCache = Integer.parseInt(preCacheBox.getText()); int postCache = Integer.parseInt(postCacheBox.getText()); PagingScrollTableDemo.get().getCachedTableModel().setPreCachedRowCount(preCache); PagingScrollTableDemo.get().getCachedTableModel().setPostCachedRowCount(postCache); } catch (NumberFormatException e) { Window.alert("Please enter valid integers for the row and column."); } } }); form.addButton(button); } return form; }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.paging.CrossPageSelectionOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Add the current status statusLabel = new Label(); form.addLabeledWidget("Current Status:", statusLabel); refreshStatus();/*from w w w.j a v a 2 s.c o m*/ // Add button to change status { Button button = new Button("Toggle Cross Page Selection", new ClickHandler() { public void onClick(ClickEvent event) { boolean enabled = PagingScrollTableDemo.get().getPagingScrollTable() .isCrossPageSelectionEnabled(); PagingScrollTableDemo.get().getPagingScrollTable().setCrossPageSelectionEnabled(!enabled); refreshStatus(); } }); form.addButton(button); } return form; }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.paging.ModeSelectionOption.java
License:Apache License
@Override protected Widget onInitialize() { layout.setBorderWidth(2);// ww w. j a va 2s. c om // Labels { int rowCount = layout.getRowCount(); layout.setHTML(rowCount, 0, "<b>Mode</b>"); layout.setHTML(rowCount, 1, "<b>Status</b>"); layout.setHTML(rowCount, 2, "<b>Description</b>"); } // Error Mode { final int rowCount = layout.getRowCount(); Button button = new Button("Toggle Error Mode", new ClickHandler() { public void onClick(ClickEvent event) { if (PagingScrollTableDemo.get().getTableModel().isErrorModeEnabled()) { PagingScrollTableDemo.get().getTableModel().setErrorModeEnabled(false); layout.setText(rowCount, 1, "disabled"); } else { PagingScrollTableDemo.get().getTableModel().setErrorModeEnabled(true); layout.setText(rowCount, 1, "enabled"); } } }); layout.setWidget(rowCount, 0, button); layout.setText(rowCount, 1, "disabled"); layout.setText(rowCount, 2, "If the table model throws an error during " + "a paging request, the ScrollTable will display the error " + "gracefully."); } // RPC Mode { final int rowCount = layout.getRowCount(); Button button = new Button("Toggle RPC Mode", new ClickHandler() { public void onClick(ClickEvent event) { if (PagingScrollTableDemo.get().getTableModel().isRPCModeEnabled()) { PagingScrollTableDemo.get().getTableModel().setRPCModeEnabled(false); layout.setText(rowCount, 1, "disabled"); } else { PagingScrollTableDemo.get().getTableModel().setRPCModeEnabled(true); layout.setText(rowCount, 1, "enabled"); } } }); layout.setWidget(rowCount, 0, button); layout.setText(rowCount, 1, "disabled"); layout.setText(rowCount, 2, "Retrieve data from a server using an RPC " + "request instead of generating data locally. " + "This requests an RPC server."); } // Zero Mode { final int rowCount = layout.getRowCount(); Button button = new Button("Toggle Zero Mode", new ClickHandler() { public void onClick(ClickEvent event) { if (PagingScrollTableDemo.get().getTableModel().isZeroModeEnabled()) { PagingScrollTableDemo.get().getTableModel().setZeroModeEnabled(false); layout.setText(rowCount, 1, "disabled"); } else { PagingScrollTableDemo.get().getTableModel().setZeroModeEnabled(true); layout.setText(rowCount, 1, "enabled"); } } }); layout.setWidget(rowCount, 0, button); layout.setText(rowCount, 1, "disabled"); layout.setText(rowCount, 2, "Enable to return zero results for each " + "request, resulting in a special widget being display."); } // Add the description return layout; }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.paging.PageSizeOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Num rows selection final TextBox rowCountBox = new TextBox(); rowCountBox.setText("1000"); rowCountBox.setWidth("50px"); form.addLabeledWidget("Total Row Count:", rowCountBox); // Add button to set the row count {/* ww w. j a v a2s . c o m*/ Button button = new Button("Set Total Row Count", new ClickHandler() { public void onClick(ClickEvent event) { try { int rowCount = Integer.parseInt(rowCountBox.getText()); PagingScrollTableDemo.get().getCachedTableModel().setRowCount(rowCount); } catch (NumberFormatException e) { Window.alert("Please enter valid integers for the row and column."); } } }); form.addButton(button); } // Page Size selection final TextBox pageSizeBox = new TextBox(); pageSizeBox.setText("10"); pageSizeBox.setWidth("50px"); form.addLabeledWidget("Page Size", pageSizeBox); // Add button to insert one cell { Button button = new Button("Set Page Size", new ClickHandler() { public void onClick(ClickEvent event) { try { int pageSize = Integer.parseInt(pageSizeBox.getText()); PagingScrollTableDemo.get().getPagingScrollTable().setPageSize(pageSize); } catch (NumberFormatException e) { Window.alert("Please enter valid integers for the row and column."); } } }); form.addButton(button); } return form; }
From source file:com.google.gwt.gen2.demo.scrolltable.client.option.setup.ResizeCheckingOption.java
License:Apache License
@Override protected Widget onInitialize() { CustomForm form = new CustomForm(); // Add the current status statusLabel = new Label(); form.addLabeledWidget("Current Status:", statusLabel); refreshStatus();//from ww w.j av a2 s. c om // Add button to change status { Button button = new Button("Toggle Resize Checking", new ClickHandler() { public void onClick(ClickEvent event) { ResizableWidgetCollection.get() .setResizeCheckingEnabled(!ResizableWidgetCollection.get().isResizeCheckingEnabled()); refreshStatus(); } }); form.addButton(button); } // Add a button to resize the table now { Button button = new Button("Redraw Now", new ClickHandler() { public void onClick(ClickEvent event) { ScrollTableDemo.get().getScrollTable().redraw(); } }); form.addButton(button); } return form; }