@Override protected boolean resetFocusOnCell() { boolean focused = false; if (hasFilterHeaders() && filterFocusedCellColumn > -1 && filterFocusedCellRow > -1) { TableSectionElement thead = getTableHeadElement(); NodeList<TableRowElement> rows = thead.getRows(); if (filterFocusedCellRow < rows.getLength()) { TableRowElement row = rows.getItem(filterFocusedCellRow); NodeList<TableCellElement> cells = row.getCells(); if (filterFocusedCellColumn < cells.getLength()) { TableCellElement cell = cells.getItem(filterFocusedCellColumn); if (getHeaderBuilder().isHeader(cell)) { Header<?> header = getHeaderBuilder().getHeader(cell); Context context = new Context(0, 0, header.getKey()); focused = resetFocusOnFilterCellImpl(context, header, cell); } } } } if (!focused) { focused = super.resetFocusOnCell(); } return focused; }
@Override protected void redraw() { TableSectionElement nbody = Document.get().createTBodyElement(); for ( int iRow = 0; iRow < data.size(); iRow++ ) { DynamicDataRow rowData = data.get( iRow ); TableRowElement tre = Document.get().createTRElement(); tre.setClassName( getRowStyle( iRow ) ); populateTableRowElement( tre, rowData ); nbody.appendChild( tre ); } // Update table to DOM table.replaceChild( nbody, tbody ); tbody = nbody; }
/** * Get the TD element * * @param root * @param column * @param row * @return */ public static TableCellElement getCell( Element root, int column, int row ) { TableSectionElement tbody = getTBodyElement( root ); TableRowElement tr = tbody.getChild( row ).cast(); TableCellElement td = tr.getChild( column ).cast(); return td; }
private Element getTableCellElementAncestor( Element e ) { Element parent = e.getParentElement(); while ( !TableSectionElement.is( parent ) && !TableCellElement.is( parent ) ) { parent = parent.getParentElement(); } return parent; }
public void deleteRow( int index ) { //UI Components Widget widget = widgets.get( index ); remove( widget ); getBody().<TableSectionElement>cast().deleteRow( index ); widgets.remove( index ); fixStyles( index ); }
@Override public TableSectionElement getTableHeadElement() { return super.getTableHeadElement(); }
@Override public TableSectionElement getTableFootElement() { return super.getTableFootElement(); }
@Override protected void onBrowserEvent2(Event event) { if (hasFilterHeaders()) { EventTarget eventTarget = event.getEventTarget(); if (!Element.is(eventTarget)) { return; } final Element target = event.getEventTarget().cast(); TableSectionElement thead = getTableHeadElement(); TableSectionElement targetTableSection = null; TableCellElement targetTableCell = null; Element headerParent = null; Element maybeTableCell = null; Element cur = target; while (cur != null && targetTableSection == null) { if (cur == thead) { targetTableSection = cur.cast(); if (maybeTableCell != null) { targetTableCell = maybeTableCell.cast(); break; } } String tagName = cur.getTagName(); if (TableCellElement.TAG_TD.equalsIgnoreCase(tagName) || TableCellElement.TAG_TH.equalsIgnoreCase(tagName)) { maybeTableCell = cur; } if (headerParent == null && getHeaderBuilder().isHeader(cur)) { headerParent = cur; } cur = cur.getParentElement(); } if (targetTableCell != null) { String eventType = event.getType(); TableRowElement targetTableRow = targetTableCell.getParentElement().cast(); int col = targetTableCell.getCellIndex(); if (targetTableSection == thead) { if (headerParent != null) { Header<?> header = getHeaderBuilder().getHeader(headerParent); if (header != null) { int headerIndex = getHeaderBuilder().getRowIndex(targetTableRow); if (header instanceof StringFilterHeader) { if (StringFilterHeader.isFilterFocusEvent(eventType)) { filterFocusedCellColumn = col; filterFocusedCellRow = headerIndex; } else { filterFocusedCellColumn = -1; filterFocusedCellRow = -1; } } } } } } } super.onBrowserEvent2(event); }
public static TableSectionElement getTBodyElement( Element root ) { return root.getChild( 1 ).cast(); }
public InputDatePicker() { super(Document.get().createDivElement()); StyleUtils.addStyle(this, InputDatePicker.STYLE_DATEPICKER); this.getElement().appendChild(this.datepickerHeader); StyleUtils.addStyle(this.datepickerHeader, InputDatePicker.STYLE_HEADER); /* month selecter */ this.datepickerHeader.appendChild(this.monthPickerButton); StyleUtils.addStyle(this.monthPickerButton, InputDatePicker.STYLE_MONTH_PICKER_BUTTON); /* pagination */ this.datepickerHeader.appendChild(this.monthPagerUl); StyleUtils.addStyle(this.monthPagerUl, InputDatePicker.STYLE_MONTH_PAGER); this.createLi(this.pagePreviusMonthLi, InputDatePicker.STYLE_MONTH_PREVIOUS, "◄"); this.createLi(this.pageTodayLi, InputDatePicker.STYLE_TODAY, "◉"); this.createLi(this.pageNextMonthLi, InputDatePicker.STYLE_MONTH_NEXT, "►"); this.monthPagerUl.appendChild(this.pagePreviusMonthLi); this.monthPagerUl.appendChild(this.pageTodayLi); this.monthPagerUl.appendChild(this.pageNextMonthLi); /* Calendar Picker */ this.getElement().appendChild(this.monthPicker); this.monthPicker.appendChild(this.monthPickerInner); StyleUtils.addStyle(this.monthPicker, InputDatePicker.STYLE_MONTH_PICKER); /* Calendar Picker */ this.getElement().appendChild(this.calendarTable); StyleUtils.addStyle(this.calendarTable, InputDatePicker.STYLE_CALENDAR_PICKER); /* DayPicker Header */ TableSectionElement head = Document.get().createTHeadElement(); TableRowElement headRow = Document.get().createTRElement(); this.calendarTable.appendChild(head); head.appendChild(headRow); for (int i = 0; i < 7; i++) { TableCellElement th = Document.get().createTHElement(); headRow.appendChild(th); int dayToDisplay = (i + InputDatePicker.DATE_TIME_FORMAT_INFO.firstDayOfTheWeek()) % InputDatePicker.DAYS.length; th.setInnerText(InputDatePicker.DAYS[dayToDisplay]); } /* DayPicker Body */ this.calendarTable.appendChild(this.calendatBody); this.today = InputDatePicker.ATTRIBUTE_DATE_FORMAT.parse(InputDatePicker.ATTRIBUTE_DATE_FORMAT.format(new Date())); this.setValue(this.today); Event.sinkEvents(this.getElement(), Event.ONKEYDOWN); Event.sinkEvents(this.monthPickerButton, Event.ONCLICK); Event.sinkEvents(this.pagePreviusMonthLi, Event.ONCLICK); Event.sinkEvents(this.pageTodayLi, Event.ONCLICK); Event.sinkEvents(this.pageNextMonthLi, Event.ONCLICK); this.redraw(); }
public TableHead() { super(TableSectionElement.TAG_THEAD); this.append(this.headerRow); }
@UiConstructor public TableBody(String bodyId) { super(TableSectionElement.TAG_TBODY); this.bodyId = bodyId; }
/** * Constructs a new instance setting the number of columns for each row and attaching it to a table section element. * @param parentElement The table section to attach the item-rows under. In most cases you'll be fine with the other * version of the constructor. * @param columns Number of columns each row will have, this number cannot be changed later. */ public TableRowAdapter(TableSectionElement parentElement, int columns) { super(parentElement); this.columns = columns; }