Java Code Examples for com.google.gwt.user.client.DOM#getChild()
The following examples show how to use
com.google.gwt.user.client.DOM#getChild() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
@Override public void onBrowserEvent(Event event) { debug("VComboBoxMultiselect.SP: onBrowserEvent()"); if (event.getTypeInt() == Event.ONCLICK) { final Element target = DOM.eventGetTarget(event); if (target == this.up || target == DOM.getChild(this.up, 0)) { this.lazyPageScroller.scrollUp(); } else if (target == this.down || target == DOM.getChild(this.down, 0)) { this.lazyPageScroller.scrollDown(); } } /* * Prevent the keyboard focus from leaving the textfield by * preventing the default behaviour of the browser. Fixes #4285. */ handleMouseDownEvent(event); }
Example 2
Source File: TableAggregationRow.java From cuba with Apache License 2.0 | 6 votes |
public void setCellWidth(int cellIx, int width) { // CAUTION: copied from VScrollTableRow with small changes final Element cell = DOM.getChild(tr, cellIx); Style wrapperStyle = cell.getFirstChildElement().getStyle(); int wrapperWidth = width; if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isOpera10()) { /* * Some versions of Webkit and Opera ignore the width * definition of zero width table cells. Instead, use 1px * and compensate with a negative margin. */ if (width == 0) { wrapperWidth = 1; wrapperStyle.setMarginRight(-1, Style.Unit.PX); } else { wrapperStyle.clearMarginRight(); } } wrapperStyle.setPropertyPx("width", wrapperWidth); cell.getStyle().setPropertyPx("width", width); }
Example 3
Source File: VComboBoxMultiselect.java From vaadin-combobox-multiselect with Apache License 2.0 | 6 votes |
@Override public void onBrowserEvent(Event event) { debug("VComboBoxMultiselect.SP: onBrowserEvent()"); if (event.getTypeInt() == Event.ONCLICK) { final Element target = DOM.eventGetTarget(event); if (target == this.up || target == DOM.getChild(this.up, 0)) { this.lazyPageScroller.scrollUp(); } else if (target == this.down || target == DOM.getChild(this.down, 0)) { this.lazyPageScroller.scrollDown(); } } /* * Prevent the keyboard focus from leaving the textfield by * preventing the default behaviour of the browser. Fixes #4285. */ handleMouseDownEvent(event); }
Example 4
Source File: MaterialCheckBox.java From gwt-material with Apache License 2.0 | 6 votes |
/** * Setting the type of Checkbox. */ public void setType(CheckBoxType type) { this.type = type; switch (type) { case FILLED: Element input = DOM.getChild(getElement(), 0); input.setAttribute("class", CssName.FILLED_IN); break; case INTERMEDIATE: addStyleName(type.getCssName() + "-checkbox"); break; default: addStyleName(type.getCssName()); break; } }
Example 5
Source File: MaterialCheckBoxTest.java From gwt-material with Apache License 2.0 | 6 votes |
public void testType() { // UiBinder // given MaterialCheckBox widget = getWidget(false); // when / then widget.setType(CheckBoxType.FILLED); assertEquals(CheckBoxType.FILLED, widget.getType()); widget.setType(CheckBoxType.INTERMEDIATE); assertEquals(CheckBoxType.INTERMEDIATE, widget.getType()); // Standard // given attachWidget(); // when / then widget.setType(CheckBoxType.FILLED); Element cb = widget.getElement(); Element input = DOM.getChild(cb, 0); assertTrue(input.hasClassName(CssName.FILLED_IN)); widget.setType(CheckBoxType.INTERMEDIATE); assertTrue(widget.getElement().hasClassName(CheckBoxType.INTERMEDIATE.getCssName() + "-checkbox")); }
Example 6
Source File: MaterialRadioButtonTest.java From gwt-material with Apache License 2.0 | 6 votes |
public void testType() { // UiBinder // given MaterialRadioButton radioButton = getWidget(false); // when / then radioButton.setType(RadioButtonType.GAP); assertEquals(RadioButtonType.GAP, radioButton.getType()); radioButton.setType(RadioButtonType.NO_GAP); assertEquals(RadioButtonType.NO_GAP, radioButton.getType()); assertEquals("", radioButton.getType().getCssName()); // Standard // given attachWidget(); // when / then assertNotNull(DOM.getChild(radioButton.getElement(), 0)); Element element = DOM.getChild(radioButton.getElement(), 0); radioButton.setType(RadioButtonType.GAP); assertTrue(element.hasClassName(RadioButtonType.GAP.getCssName())); radioButton.setType(RadioButtonType.NO_GAP); assertFalse(element.hasClassName(RadioButtonType.GAP.getCssName())); assertEquals("", radioButton.getType().getCssName()); }
Example 7
Source File: Draggable.java From document-management-system with GNU General Public License v2.0 | 5 votes |
/** * getSelectedElement */ public static Element getSelectedElement(Element element) { if (DOM.getFirstChild(element).getClassName().contains("gwt-TreeItem")) { // Case node without childs return DOM.getFirstChild(element); } else { return DOM.getChild(DOM.getChild(DOM.getChild(DOM.getChild(DOM.getChild(element, 0), 0), 0), 1), 0); } }
Example 8
Source File: TableAggregationRow.java From cuba with Apache License 2.0 | 5 votes |
public double getRealCellWidth(int colIdx) { if (colIdx >= tr.getChildCount()) { return -1; } Element cell = DOM.getChild(tr, colIdx); ComputedStyle cs = new ComputedStyle(cell); return cs.getWidth() + cs.getPaddingWidth() + cs.getBorderWidth(); }
Example 9
Source File: UniTimeTable.java From unitime with Apache License 2.0 | 5 votes |
private void swapRows(int r0, int r1) { if (r0 == r1) return; if (r0 > r1) { swapRows(r1, r0); } else { // r0 < r1 Element body = getBodyElement(); Element a = DOM.getChild(body, r0); Element b = DOM.getChild(body, r1); body.removeChild(a); body.removeChild(b); DOM.insertChild(body, b, r0); DOM.insertChild(body, a, r1); } }
Example 10
Source File: UniTimeMobileMenu.java From unitime with Apache License 2.0 | 5 votes |
public String getStackText(int index) { if (index >= getWidgetCount()) { return null; } Element tdWrapper = DOM.getChild((Element) DOM.getChild(body, index * 2), 0); return DOM.getFirstChild(tdWrapper).getInnerText(); }
Example 11
Source File: UniTimeSideBar.java From unitime with Apache License 2.0 | 5 votes |
public String getStackText(int index) { if (index >= getWidgetCount()) { return null; } Element tdWrapper = DOM.getChild((Element) DOM.getChild(body, index * 2), 0); return DOM.getFirstChild(tdWrapper).getInnerText(); }
Example 12
Source File: CubaGroupTableWidget.java From cuba with Apache License 2.0 | 4 votes |
private void calcAndSetWidthForSpannedCell() { int cells = tHead.getVisibleCellCount(); for (int i = 0; i < groupColIndex; i++) { int w = CubaGroupTableWidget.this.getColWidth(getColKeyByIndex(i)); if (w < 0) { w = 0; } super.setCellWidth(i, w); } Element tr = getElement(); int totalSpannedWidth = 0; for (int i = groupColIndex; i < cells; i++) { HeaderCell headerCell = tHead.getHeaderCell(i); int headerWidth = headerCell.getOffsetWidth() > headerCell.getWidth() + MAX_ROUNDING_DIFF ? headerCell.getWidth() : headerCell.getOffsetWidth(); totalSpannedWidth += headerWidth; } Element td = DOM.getChild(tr, DOM.getChildCount(tr) - 1); Style wrapperStyle = td.getFirstChildElement().getStyle(); WidgetUtil.setWidthExcludingPaddingAndBorder(td, totalSpannedWidth, 13, false); int wrapperWidth; ComputedStyle style = new ComputedStyle(td); if (style.getPaddingWidth() > 1.0) { // this is applied for havana theme, because it has vertical padding // for cell-container and width of TD element must be less, then whole row String tdWidthPx = td.getStyle().getWidth().replace("px", ""); wrapperWidth = Integer.parseInt(tdWidthPx); } else { // this is applied for halo theme, because it hasn't vertical padding // for cell-container and width of TD element must be equal to whole row - 1px // 1px is the padding-left of :first-child wrapperWidth = totalSpannedWidth - 1; } if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isOpera10()) { /* * Some versions of Webkit and Opera ignore the width definition of zero width table cells. * Instead, use 1px and compensate with a negative margin. */ if (totalSpannedWidth == 0) { wrapperWidth = 1; wrapperStyle.setMarginRight(-1, Style.Unit.PX); } else { wrapperStyle.clearMarginRight(); } } wrapperStyle.setPropertyPx("width", wrapperWidth); }
Example 13
Source File: MaterialRadioButton.java From gwt-material with Apache License 2.0 | 4 votes |
protected CssTypeMixin<RadioButtonType, TypeWidget<RadioButtonType>> getTypeMixin() { if (typeMixin == null) { typeMixin = new CssTypeMixin<>(new TypeWidget<>(DOM.getChild(getElement(), 0))); } return typeMixin; }