List of usage examples for com.google.gwt.gen2.table.override.client FlexTable insertRow
@Override public int insertRow(int beforeRow)
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 ww .j a v a 2 s .c om*/ 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.PagingScrollTableDemo.java
License:Apache License
/** * This is the entry point method./*www . ja v a 2 s. c o m*/ */ @Override public void onModuleLoad() { instance = this; super.onModuleLoad(); // Create an paging options PagingOptions pagingOptions = new PagingOptions(getPagingScrollTable()); FlexTable layout = getLayout(); layout.insertRow(1); layout.setWidget(1, 1, pagingOptions); }
From source file:com.qualogy.qafe.gwt.client.ui.renderer.DataGridFactory.java
License:Apache License
public static UIObject createPagingDataGrid(final DataGridGVO gvo, final String uuid, final String parent) { final QTableModel tableModel = new QTableModel(); if (gvo.getPageSize() != null) { tableModel.setRowCount(gvo.getPageSize()); }//from ww w .java2 s .com // Create a TableCellRenderer final TableDefinition<DataContainerGVO> tableDef = new DefaultTableDefinition<DataContainerGVO>(); final FixedWidthFlexTable headerTable = new FixedWidthFlexTable(); final FixedWidthGrid dataTable = new FixedWidthGrid(); if (gvo.getMultipleSelect() != null && gvo.getMultipleSelect().booleanValue()) { dataTable.setSelectionPolicy(SelectionPolicy.MULTI_ROW); } else { dataTable.setSelectionPolicy(SelectionPolicy.ONE_ROW); } final QPagingScrollTable pagingScrollTable = new QPagingScrollTable(tableModel, dataTable, headerTable, tableDef, gvo, uuid, parent); tableModel.setSource(pagingScrollTable); // setup the bulk renderer final FixedWidthGridBulkRenderer<DataContainerGVO> bulkRenderer = new FixedWidthGridBulkRenderer<DataContainerGVO>( pagingScrollTable.getDataTable(), pagingScrollTable); pagingScrollTable.setBulkRenderer(bulkRenderer); if (gvo.getStyleClass() != null) { pagingScrollTable.setStylePrimaryName(gvo.getStyleClass()); } pagingScrollTable.setPageSize(gvo.getPageSize(), true); pagingScrollTable.setEmptyTableWidget(new AbstractComponentRenderer.MessageBox()); pagingScrollTable.setup(); pagingScrollTable.fillWidth(); pagingScrollTable.setResizePolicy(ResizePolicy.FILL_WIDTH); // Setup the formatting pagingScrollTable.setCellPadding(3); pagingScrollTable.setCellSpacing(0); FlexTable layout = null; if (gvo.getMenu() != null) { final ComponentGVO finalComponentGVO = gvo; final String finalUuid = uuid; final String finalParent = parent; layout = new FlexTable() { @Override public void onBrowserEvent(final Event event) { if (event.getTypeInt() == Event.ONCONTEXTMENU) { DOM.eventPreventDefault(event); AbstractComponentRenderer.applyContextMenu(event, finalComponentGVO, finalUuid, finalParent); } super.onBrowserEvent(event); } @Override protected void setElement(final Element elem) { super.setElement(elem); sinkEvents(Event.ONCONTEXTMENU); } }; } else { layout = new FlexTable(); } layout.setWidth("100%"); final FlexCellFormatter formatter = layout.getFlexCellFormatter(); // Add the scroll table to the layout layout.setWidget(0, 0, pagingScrollTable); formatter.setWidth(0, 0, "100%"); formatter.setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_TOP); final QPagingScrollTableOperation operations = new QPagingScrollTableOperation(pagingScrollTable); operations.initForCallback(gvo.getId(), uuid, parent, gvo.getContext()); operations.setVisible(true); final HorizontalPanel hp = new HorizontalPanel(); QPagingOptions pagingOptions = null; final Integer pageSize = gvo.getPageSize(); if ((pageSize != null) && (pageSize > -1)) { pagingOptions = new QPagingOptions(pagingScrollTable); pagingOptions.initForCallback(gvo.getId(), uuid, parent, gvo.getContext()); pagingOptions.setVisible(true); hp.add(pagingOptions); if (gvo.getPageScroll()) { pagingScrollTable.addScrollHandler(pagingScrollTable); pagingOptions.setVisible(false); } } hp.add(operations); layout.insertRow(1); layout.setWidget(1, 0, hp); RendererHelper.fillIn(gvo, pagingScrollTable, uuid, parent, gvo.getContext()); if (gvo.hasOverFlow()) { final UIObject overflow = AnyComponentRenderer.getInstance().render(gvo.getOverflow(), uuid, parent, gvo.getContext()); if (overflow != null && overflow instanceof Widget) { ((HasDataGridMethods) pagingScrollTable).setOverflow((Widget) overflow); layout.insertRow(2); layout.setWidget(2, 0, (Widget) overflow); RendererHelper.addVisibleInfo(gvo, overflow); } } return layout; }