/** * {@inheritDoc} */ public void selectRows(int toRow) { super.selectRows(toRow); HTMLTable.RowFormatter formatter = getRowFormatter(); int from = Math.min(getCurrentRow(), toRow); int to = Math.max(getCurrentRow(), toRow); for (int i = from; i <= to; i++) { if (formatter.getStyleName(i).contains(HierarchicalGrid.SUBGRID_ROW_STYLE)) { formatter.removeStyleName(i, "selected-row"); getSelectionModel().remove(i); } } }
/** * This method calculates subgrid rows number before the specified row. * * @param row is a row number. * @return number of subgrid rows. */ protected int getSubgridRowsBefore(int row) { int result = 0; for (int i = 0; i < row; i++) { if (HierarchicalGrid.SUBGRID_ROW_STYLE.equals(getGrid().getRowFormatter().getStyleName(i))) result++; } return result; }
protected boolean isSubgridRow(int row) { EditableGrid grid = getPanel().getGrid(); return HierarchicalGrid.SUBGRID_ROW_STYLE.equals(grid.getRowFormatter().getStyleName(row)); } }
while ( last > 0 && last < getRowCount() && rowFormatter.getStyleName(last).contains(HierarchicalGrid.SUBGRID_ROW_STYLE) ) { last++;
/** * {@inheritDoc} */ public void setColumnWidth(int column, int size) { HTMLTable.RowFormatter rowFormatter = getRowFormatter(); if (isResizable()) { Element th = getThElement(column); if (th != null) DOM.setStyleAttribute(th, "width", size + "px"); if (getRowCount() > 0) { HTMLTable.CellFormatter formatter = getBodyTable().getCellFormatter(); Element td = formatter.getElement(0, column); DOM.setStyleAttribute(td, "width", size + "px"); for (int i = 1; !GWTUtil.isIE() && i < getRowCount(); i++) { if (!SUBGRID_ROW_STYLE.equals(rowFormatter.getStyleName(i)) || column < getCellCount(i)) { td = formatter.getElement(i, column); DOM.setStyleAttribute(td, "width", size + "px"); } } } for (int i = 0; i < getRowCount(); i++) { if (!SUBGRID_ROW_STYLE.equals(rowFormatter.getStyleName(i))) { GridPanel panel = getGridPanel(i, column); if (panel != null) panel.resize(); } } } }
/** * {@inheritDoc} */ public void drawContent(GridDataModel model) { int count = 0; EditableGrid grid = getGrid(); while (grid.getRowCount() > count) { if (HierarchicalGrid.SUBGRID_ROW_STYLE.equals(grid.getRowFormatter().getStyleName(count))) grid.removeRow(count); else count++; } super.drawContent(model); GridDataModel dataModel = grid.getModel(); if (dataModel instanceof Hierarchical) { int rowCount = grid.getRowCount(); int expandedCells = 0; for (int i = 0; i < rowCount; i++) { int modelRow = super.getModelRow(i); int expandedBefore = expandedCells; for (int j = grid.getCellCount(i + expandedBefore) - 1; j >= 0; j--) { if (((Hierarchical) dataModel).isExpanded(modelRow, j)) { ((HierarchicalGrid) grid).expandCell(i + expandedBefore, j); expandedCells++; } } } } }
/** * {@inheritDoc} */ protected void removeColumn(int column) { if (getHeaderWidgets().size() > column) { removeHeaderWidget(column); boolean expandable = isExpandable(column); for (int i = 0; i < getRowCount(); i++) { if (!SUBGRID_ROW_STYLE.equals(getRowFormatter().getStyleName(i))) { Widget originalWidget = getOriginalWidget(i, column); if (expandable && ((ExpandableCell) originalWidget).isExpanded()) collapseCell(i, column); removeCell(i, column); } } } }
/** * {@inheritDoc} */ public void drawColumn(Object[] data, int column, boolean overwrite) { if (!overwrite && column < getGrid().getHeaderWidgets().size()) getGrid().insertHeaderCell(getGrid().getColumnByModelColumn(column)); HeaderCell cell = getCellFactory().create(column, getGrid().getHeaders()[column]); cell.displayActive(false); for (int i = 0; i < data.length && i < getGrid().getRowCount(); i++) { Object cellData = data[i]; if (!HierarchicalGrid.SUBGRID_ROW_STYLE.equals(getGrid().getRowFormatter().getStyleName(i))) drawCell(cellData, i, column, false); } }
/** * {@inheritDoc} */ public int getRowByModelRow(int modelRow) { for (int i = 0; i < getGrid().getRowCount(); i++) { if (!HierarchicalGrid.SUBGRID_ROW_STYLE.equals(getGrid().getRowFormatter().getStyleName(i)) && getModelRow(i) == modelRow) return i; } return -1; }