List of usage examples for com.google.gwt.dom.client Element setPropertyInt
@Override
public void setPropertyInt(String name, int value)
From source file:cc.alcina.framework.gwt.client.util.WidgetUtils.java
License:Apache License
public static void scrollBodyTo(int y) { BodyElement body = Document.get().getBody(); body.setPropertyInt("scrollTop", y); Element documentElement = Document.get().getDocumentElement(); documentElement.setPropertyInt("scrollTop", y); scrollTo(0, y);/*w w w . j av a2s. com*/ }
From source file:com.extjs.gxt.ui.client.widget.grid.GridView.java
License:sencha.com license
protected void processRows(int startRow, boolean skipStripe) { if (ds.getCount() < 1) { return;/*from www. ja va 2 s . com*/ } skipStripe = skipStripe || !grid.isStripeRows(); NodeList<Element> rows = getRows(); String cls = "x-grid3-row-alt"; for (int i = 0, len = rows.getLength(); i < len; i++) { Element row = rows.getItem(i); row.setPropertyInt("rowIndex", i); if (!skipStripe) { boolean isAlt = (i + 1) % 2 == 0; boolean hasAlt = row.getClassName() != null && row.getClassName().indexOf(cls) != -1; if (isAlt == hasAlt) { continue; } if (isAlt) { El.fly(row).addStyleName(cls); } else { El.fly(row).removeStyleName(cls); } } } }
From source file:com.google.gerrit.client.diff.SideBySideChunkManager.java
License:Apache License
/** * Insert a new padding div below the given line. * * @param cm parent CodeMirror to add extra space into. * @param line line to put the padding below. * @param len number of lines to pad. Padding is inserted only if {@code len >= 1}. *//*www . j a v a 2 s .co m*/ private void addPadding(CodeMirror cm, int line, final int len) { if (0 < len) { Element pad = DOM.createDiv(); pad.setClassName(SideBySideTable.style.padding()); pad.setPropertyInt(DATA_LINES, len); pad.getStyle().setHeight(guessedLineHeightPx * len, Unit.PX); focusOnClick(pad, cm.side()); paddingDivs.add(pad); padding.add(cm.addLineWidget(line == -1 ? 0 : line, pad, Configuration.create().set("coverGutter", true) .set("noHScroll", true).set("above", line == -1))); } }
From source file:com.ritchey.client.view.DockPanel.java
License:Apache License
/** * (Re)creates the DOM structure of the table representing the DockPanel, * based on the order and layout of the children. */// w w w . j a v a 2 s .co m private void realizeTable() { Element bodyElem = getBody(); while (DOM.getChildCount(bodyElem) > 0) { bodyElem.removeChild(DOM.getChild(bodyElem, 0)); } int rowCount = 1, colCount = 1; for (Iterator<Widget> it = getChildren().iterator(); it.hasNext();) { Widget child = it.next(); DockLayoutConstant dir = ((LayoutData) child.getLayoutData()).direction; if ((dir == NORTH) || (dir == SOUTH)) { ++rowCount; } else if ((dir == EAST) || (dir == WEST) || (dir == LINE_START) || (dir == LINE_END)) { ++colCount; } } TmpRow[] rows = new TmpRow[rowCount]; for (int i = 0; i < rowCount; ++i) { rows[i] = new TmpRow(); rows[i].tr = DOM.createTR(); DOM.appendChild(bodyElem, rows[i].tr); } int logicalLeftCol = 0, logicalRightCol = colCount - 1; int northRow = 0, southRow = rowCount - 1; Element centerTd = null; for (Iterator<Widget> it = getChildren().iterator(); it.hasNext();) { Widget child = it.next(); LayoutData layout = (LayoutData) child.getLayoutData(); Element td = DOM.createTD(); layout.td = td; layout.td.setPropertyString("align", layout.hAlign); layout.td.getStyle().setProperty("verticalAlign", layout.vAlign); layout.td.setPropertyString("width", layout.width); layout.td.setPropertyString("height", layout.height); if (layout.direction == NORTH) { DOM.insertChild(rows[northRow].tr, td, rows[northRow].center); DOM.appendChild(td, child.getElement()); td.setPropertyInt("colSpan", logicalRightCol - logicalLeftCol + 1); ++northRow; } else if (layout.direction == SOUTH) { DOM.insertChild(rows[southRow].tr, td, rows[southRow].center); DOM.appendChild(td, child.getElement()); td.setPropertyInt("colSpan", logicalRightCol - logicalLeftCol + 1); --southRow; } else if (layout.direction == CENTER) { // Defer adding the center widget, so that it can be added after all // the others are complete. centerTd = td; } else if (shouldAddToLogicalLeftOfTable(layout.direction)) { TmpRow row = rows[northRow]; DOM.insertChild(row.tr, td, row.center++); DOM.appendChild(td, child.getElement()); td.setPropertyInt("rowSpan", southRow - northRow + 1); ++logicalLeftCol; } else if (shouldAddToLogicalRightOfTable(layout.direction)) { TmpRow row = rows[northRow]; DOM.insertChild(row.tr, td, row.center); DOM.appendChild(td, child.getElement()); td.setPropertyInt("rowSpan", southRow - northRow + 1); --logicalRightCol; } } // If there is a center widget, add it at the end (centerTd is guaranteed // to be initialized because it will have been set in the CENTER case in // the above loop). if (center != null) { TmpRow row = rows[northRow]; DOM.insertChild(row.tr, centerTd, row.center); DOM.appendChild(centerTd, center.getElement()); } }
From source file:com.sencha.gxt.widget.core.client.DatePicker.java
License:sencha.com license
protected void createMonthPicker() { SafeHtmlBuilder builder = new SafeHtmlBuilder(); appearance.renderMonthPicker(builder, messages, dateTimeInfo.getMonthsShort()); monthPicker.removeChildren();/* www . j a va 2s .c o m*/ monthPicker.setInnerSafeHtml(builder.toSafeHtml()); monthPicker.selectNode(appearance.monthPickerOkSelector()).appendChild(monthPickerOkButton.getElement()); monthPicker.selectNode(appearance.monthPickerCancelSelector()) .appendChild(monthPickerCancelButton.getElement()); mpMonths = new CompositeElement( Util.toElementArray(monthPicker.select(appearance.monthPickerMonthSelector()))); mpYears = new CompositeElement( Util.toElementArray(monthPicker.select(appearance.monthPickerYearSelector()))); mpMonths.each(new CompositeFunction() { public void doFunction(Element elem, CompositeElement ce, int index) { index += 1; if (index % 2 == 0) { elem.setPropertyInt("xmonth", (int) (5 + (Math.round(index * .5)))); } else { elem.setPropertyInt("xmonth", (int) (Math.round((index - 1) * .5))); } } }); }
From source file:com.sencha.gxt.widget.core.client.grid.GridView.java
License:sencha.com license
/** * Makes a pass through the rows in the grid to finalize the appearance, the default implementation in * {@link GridView} assigns the row index property and stripes the rows (if striping is enabled). * * @param startRow the row index/*from w ww . ja v a 2 s.co m*/ * @param skipStripe true to prevent striping (striping is always prevented if {@link GridView#isStripeRows()} returns * false). */ protected void processRows(int startRow, boolean skipStripe) { if (ds.size() < 1) { return; } skipStripe = skipStripe || !isStripeRows(); NodeList<Element> rows = getRows(); String cls = styles.rowAlt(); for (int i = startRow, len = rows.getLength(); i < len; i++) { Element row = rows.getItem(i); row.setPropertyInt("rowindex", i); if (!skipStripe) { boolean isAlt = (i + 1) % 2 == 0; boolean hasAlt = row.getClassName() != null && row.getClassName().indexOf(cls) != -1; if (isAlt == hasAlt) { continue; } if (isAlt) { row.addClassName(cls); } else { row.removeClassName(cls); } } } }
From source file:gwt.material.design.client.ui.MaterialRange.java
License:Apache License
/** * Set the given Integer value to the attribute of the range element. *//*from ww w . j av a2 s . co m*/ private void setIntToRangeElement(String attribute, Integer val) { Element ele = getRangeElement(); if (ele != null) { ele.setPropertyInt(attribute, val); } }
From source file:org.vaadin.addon.gwtgraphics.client.impl.SVGImpl.java
License:Apache License
public void setRotation(final Element element, final int degree, final boolean attached) { element.setPropertyInt("_rotation", degree); if (degree == 0) { SVGUtil.setAttributeNS(element, "transform", ""); return;/*from ww w . j a va 2 s .co m*/ } Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { setRotateTransform(element, degree, attached); } }); }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
@Override public void setStrokeWidth(Element element, int width, boolean attached) { Element stroke = VMLUtil.getOrCreateChildElementWithTagName(element, "stroke"); stroke.setPropertyString("weight", width + "px"); stroke.setPropertyBoolean("on", width > 0 ? true : false); // store value for getter element.setPropertyInt("_stroke-width", width); if (isTextElement(element)) { fixTextPosition(element, attached); }//w w w . j a va 2s . co m }
From source file:org.vaadin.addon.gwtgraphics.client.impl.VMLImpl.java
License:Apache License
private void setXY(Element element, int xy, boolean x, boolean attached) { // Save value for getter element.setPropertyInt(x ? "_x" : "_y", xy); String tagName = VMLUtil.getTagName(element); if (tagName.equals("group")) { int other = x ? getY(element) : getX(element); StringBuilder sb = new StringBuilder(); if (x) {//w ww. ja va 2 s. co m sb.append(-xy).append(" ").append(other); } else { sb.append(other).append(" ").append(-xy); } element.setAttribute("coordorigin", sb.toString()); } else if (tagName.equals("line")) { if (x) { setLineFromTo(element, xy, null, true); } else { setLineFromTo(element, null, xy, true); } } else { if (isTextElement(element)) { int rot = getRotation(element); setRotation(element, 0, attached); if (x) { xy += (element.getOffsetWidth() / 2) - 1; } else { xy -= (element.getOffsetHeight() / 2) - 1; } setRotation(element, rot, attached); } else if (tagName.equals("oval")) { xy = xy - NumberUtil.parseIntValue(element.getStyle().getProperty(x ? "width" : "height"), 0) / 2; } element.getStyle().setPropertyPx(x ? "left" : "top", xy); } }