tableHeaderScroller = tableHeaderContainer.getElement().getParentElement(); headerPanel.setFooterWidget(tableFooterContainer); tableFooterScroller = tableFooterContainer.getElement().getParentElement(); tableHeaderScroller.getStyle().setOverflow(Overflow.HIDDEN); tableFooterScroller.getStyle().setOverflow(Overflow.HIDDEN); if (tableData.tableElem.getTBodies().getLength() > 0) { tableData.section = tableData.tableElem.getTBodies().getItem(0); } else { tableData.section = Document.get().createTBodyElement(); tableDataScroller.setHeight("100%"); headerPanel.setContentWidget(tableDataScroller); tableDataContainer = tableData.getElement().getParentElement(); tableDataContainer.getStyle().setDisplay(Display.BLOCK);
/** * Apply a style to a row and all cells in the row. * * @param tr the row element * @param rowStyle the style to apply to the row * @param cellStyle the style to apply to the cells * @param add true to add the style, false to remove */ private void setRowStyleName(TableRowElement tr, String rowStyle, String cellStyle, boolean add) { setStyleName(tr, rowStyle, add); NodeList<TableCellElement> cells = tr.getCells(); for (int i = 0; i < cells.getLength(); i++) { setStyleName(cells.getItem(i), cellStyle, add); } }
private void updateVisibility(Element container) { // If this element has an associated layer, re-run layout for it. Layer layer = getLayer(container); if (layer != null) { layout(layer); } // Walk all children, looking for elements with a '__layer' property. If one // exists, call layout() for that element. This is not cheap, but it's the // only way to correctly ensure that layout units get translated correctly. NodeList<Node> nodes = container.getChildNodes(); for (int i = 0; i < nodes.getLength(); ++i) { Node node = nodes.getItem(i); if (node.getNodeType() == Node.ELEMENT_NODE) { updateVisibility(node.<Element>cast()); } } } }
/** * Get the {@link TableCellElement} that is currently keyboard selected. * * @return the table cell element, or null if not selected */ private TableCellElement getKeyboardSelectedTableCellElement() { int colIndex = getKeyboardSelectedColumn(); if (colIndex < 0) { return null; } // Do not use getRowElement() because that will flush the presenter. int rowIndex = getKeyboardSelectedRow(); if (rowIndex < 0 || rowIndex >= getTableBodyElement().getRows().getLength()) { return null; } TableRowElement tr = getSubRowElement(rowIndex + getPageStart(), keyboardSelectedSubrow); if (tr != null) { int cellCount = tr.getCells().getLength(); if (cellCount > 0) { int column = Math.min(colIndex, cellCount - 1); return tr.getCells().getItem(column); } } return null; }
@Override protected void templateOnColumnHiddenUpdated(int col, boolean hidden, int tw) { if (!enableGrouping) return; NodeList<Element> gs = getGroups(); String display = hidden ? "none" : ""; for (int i = 0, len = gs.getLength(); i < len; i++) { Element s = gs.getItem(i).getChildNodes().getItem(2).cast(); El.fly(s).setWidth(tw); El.fly(s.getFirstChildElement()).setWidth(tw); TableSectionElement tse = s.getFirstChildElement().cast(); Element e = tse.getRows().getItem(0).getChildNodes().getItem(col).cast(); e.getStyle().setProperty("display", display); } }
protected void addRootNode(final TreeItem rootItem, final TreeItem leafItem) { rootItem.getElement().getStyle().setBackgroundColor("#eff3ff"); //$NON-NLS-1$ rootItem.getElement().getStyle().setMarginBottom(1, Unit.PX); rootItem.getElement().getStyle().setPadding(0, Unit.PX); if (leafItem != null) { rootItem.addItem(leafItem); // Defer styling in order to override padding done in: // com.google.gwt.user.client.ui.Tree -> showLeafImage Scheduler.get().scheduleDeferred(() -> { leafItem.getElement().getStyle().setBackgroundColor("#ffffff"); //$NON-NLS-1$ leafItem.getElement().getStyle().setMarginLeft(20, Unit.PX); leafItem.getElement().getStyle().setPadding(0, Unit.PX); Boolean isLeafEmpty = (Boolean) leafItem.getUserObject(); if (isLeafEmpty != null && isLeafEmpty.equals(Boolean.TRUE)) { rootItem.getElement().getElementsByTagName("td").getItem(0).getStyle().setVisibility(Visibility.HIDDEN); //$NON-NLS-1$ } rootItem.getElement().getElementsByTagName("td").getItem(1).getStyle().setWidth(100, Unit.PCT); //$NON-NLS-1$ }); } tree.addItem(rootItem); }
static void refreshSelect(SelectElement select) { int visibleSize = select.getSize(); for (int i = 0; i < select.getChildNodes().getLength(); i++) { Element e = select.getChildNodes().getItem(i).cast(); if (i < visibleSize) { // this element is visible e.getStyle().clearProperty("display"); } else { // it's not visible e.getStyle().setProperty("display", "none"); } } }
/** Hides state and status element and displays error one. */ void setFailed(String errorMessage) { state.getStyle().setDisplay(Style.Display.NONE); status.getStyle().setDisplay(Style.Display.NONE); error.getStyle().clearDisplay(); error.setInnerText("Failed"); animatedElements.remove(status); if (errorSection != null) { errorSection.removeFromParent(); } errorSection = installerFailedTemplate.cloneNode(true).cast(); // Find machine cells for (int i = 0; i < errorSection.getChildNodes().getLength(); i++) { Node n = errorSection.getChildNodes().getItem(i); if (Node.ELEMENT_NODE != n.getNodeType()) { continue; } Element e = n.cast(); switch (e.getId()) { case "installer-error": e.setInnerText(errorMessage); break; } } // Insert error row tableBody.insertAfter(errorSection, section); }
protected void updateColumnWidth(int col, int width) { int tw = getTotalWidth(); int w = getColumnWidth(col); header.updateTotalWidth(-1, tw); header.updateColumnWidth(col, width); if (footer != null) { footer.updateTotalWidth(getOffsetWidth(), tw); footer.updateColumnWidth(col, width); } NodeList<Element> ns = getRows(); for (int i = 0, len = ns.getLength(); i < len; i++) { Element row = ns.getItem(i); row.getStyle().setPropertyPx("width", tw); if (row.getFirstChild() != null) { row.getFirstChildElement().getStyle().setPropertyPx("width", tw); TableSectionElement e = row.getFirstChild().cast(); ((Element) e.getRows().getItem(0).getChildNodes().getItem(col)).getStyle().setPropertyPx("width", w); } } templateOnColumnWidthUpdated(col, w, tw); syncHScroll(); }
protected void updateColumnHidden(int index, boolean hidden) { int tw = getTotalWidth(); String display = hidden ? "none" : ""; El.fly(innerHd.dom.getFirstChildElement()).setWidth(getOffsetWidth()); El.fly(innerHd.dom.getFirstChildElement().getFirstChildElement()).setWidth(tw); header.updateColumnHidden(index, hidden); if (footer != null) { footer.updateTotalWidth(getOffsetWidth(), tw); footer.updateColumnHidden(index, hidden); } NodeList<Element> ns = getRows(); for (int i = 0, len = ns.getLength(); i < len; i++) { Element elem = ns.getItem(i); elem.getStyle().setProperty("width", tw + "px"); TableSectionElement e = (TableSectionElement) elem.getFirstChild(); if (e != null) { e.getStyle().setProperty("width", tw + "px"); Element cell = e.getRows().getItem(0).getChildNodes().getItem(index).cast(); cell.getStyle().setProperty("display", display); } } templateOnColumnHiddenUpdated(index, hidden, tw); lastViewWidth = -1; layout(); syncHScroll(); }
/** Improves splitter visibility. */ public void tuneSplitter(SplitLayoutPanel splitLayoutPanel) { NodeList<Node> nodes = splitLayoutPanel.getElement().getChildNodes(); for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.getItem(i); if (node.hasChildNodes()) { com.google.gwt.dom.client.Element el = node.getFirstChild().cast(); if ("gwt-SplitLayoutPanel-HDragger".equals(el.getClassName())) { tuneSplitter(el); } } } }
private void updateGroupWidths() { if (!enableGrouping || ds.getCount() < 1) { return; } String tw = Math.max(cm.getTotalWidth(), el.dom.getOffsetWidth() - getScrollAdjust()) + "px"; NodeList<Element> gs = getGroups(); for (int i = 0, len = gs.getLength(); i < len; i++) { Element e = gs.getItem(i).getFirstChild().cast(); e.getStyle().setProperty("width", tw); } }
private void constructDOM() { if (BrowserInfo.get().isIE()) { table.setPropertyInt("cellSpacing", 0); } table.appendChild(tBodyElement); DOM.appendChild(container, preSpacer); DOM.appendChild(container, table); DOM.appendChild(container, postSpacer); if (BrowserInfo.get().requiresTouchScrollDelegate()) { NodeList<Node> childNodes = container.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Element item = (Element) childNodes.getItem(i); item.getStyle().setProperty("webkitTransform", "translate3d(0,0,0)"); } } updateStyleNames(VScrollTablePatched.this.getStylePrimaryName()); }
private void setCursorType( Cursor cursor ) { for ( int iRow = 0; iRow < widget.headerRows.length; iRow++ ) { TableRowElement tre = widget.headerRows[ iRow ].<TableRowElement>cast(); for ( int iCol = 0; iCol < tre.getCells().getLength(); iCol++ ) { TableCellElement tce = tre.getCells().getItem( iCol ); tce.getStyle().setCursor( cursor ); } } }
private void makeWidthIsNotCorrupted(Element link, boolean allowRecursiveCall) { if (link.getOffsetWidth() > 1000) { if (allowRecursiveCall) { forceRedrawLater(false); } else { // fallback, in 99% should not happen link.getParentElement().getStyle().setWidth(DEFAULT_WIDTH + 2, Style.Unit.PX); link.getStyle().setWidth(DEFAULT_WIDTH, Style.Unit.PX); link.getNextSiblingElement().getStyle().setWidth(DEFAULT_WIDTH, Style.Unit.PX); Element input = link.getNextSiblingElement().getElementsByTagName("input").getItem(0); input.getStyle().setWidth(DEFAULT_WIDTH - 15, Style.Unit.PX); } } } }
@Override public void fixAreaOpacity() { // This is a workaround for: https://github.com/c3js/c3/issues/2551 if (chart != null) { NodeList<Element> paths = chart.getElement().getElementsByTagName("path"); int n = paths.getLength(); for (int i = 0; i < n; i++) { Element child = paths.getItem(i); String className = child.getAttribute("class"); if (className != null && className.contains("c3-area-")) { child.getStyle().setOpacity(0.2); } } } }
public void setSelection(Section section) { NodeList<com.google.gwt.user.client.Element> tabs = El.fly(sectionDiv).select("." + style.section()); for (int i = 0; i != tabs.getLength(); ++i) { Element tab = tabs.getItem(i).cast(); if (section != null && i == section.ordinal()) { tab.addClassName(style.activeSection()); } else { tab.removeClassName(style.activeSection()); } } }
@PatchMethod static NodeList<OptionElement> selectGetOptions(Object domImpl, SelectElement select) { List<OptionElement> innerList = new ArrayList<>(); for (int i = 0; i < select.getChildNodes().getLength(); i++) { Element e = select.getChildNodes().getItem(i).cast(); if ("option".equals(e.getTagName())) { OptionElement option = e.cast(); innerList.add(option); } } return JsoUtils.newNodeList(innerList); }
private void scrollSelectedItemIntoView() { NodeList<Node> items = getSuggestionMenu().getElement().getChild(1).getChild(0).getChildNodes(); for (int i = 0; i < items.getLength(); i++) { Element element = (Element) items.getItem(i); if (((Element) element.getChild(0)).getClassName().equals("item item-selected")) { element.scrollIntoView(); break; } } } }
@PatchMethod static TableRowElement insertRow(TableElement e, int index) { NodeList<TableRowElement> rows = e.getRows(); TableRowElement newRow = Document.get().createTRElement(); if (rows.getLength() < 1) { TableSectionElement tbody = Document.get().createTBodyElement(); e.appendChild(tbody); tbody.appendChild(newRow); } else { if (index == -1 || index >= rows.getLength()) { TableRowElement after = rows.getItem(rows.getLength() - 1); after.getParentElement().insertAfter(newRow, after); } else { TableRowElement before = rows.getItem(index); before.getParentElement().insertBefore(newRow, before); } } return newRow; }