DomElement createDomElement(WApplication app) { boolean withIds = !app.getEnvironment().agentIsSpiderBot(); DomElement table = DomElement.createNew(this.getDomElementType()); this.setId(table, app); DomElement thead = null; if (this.headerRowCount_ != 0) { thead = DomElement.createNew(DomElementType.DomElement_THEAD); if (withIds) { thead.setId(this.getId() + "th"); } } DomElement tbody = DomElement.createNew(DomElementType.DomElement_TBODY); if (withIds) { tbody.setId(this.getId() + "tb"); } for (int col = 0; col < this.columns_.size(); ++col) { DomElement c = DomElement.createNew(DomElementType.DomElement_COL); if (withIds) { c.setId(this.columns_.get(col).getId()); } this.columns_.get(col).updateDom(c, true); table.addChild(c); } this.flags_.clear(BIT_COLUMNS_CHANGED); for (int row = 0; row < (int) this.getRowCount(); ++row) { for (int col = 0; col < (int) this.getColumnCount(); ++col) { this.itemAt(row, col).overSpanned = false; } } for (int row = 0; row < (int) this.getRowCount(); ++row) { DomElement tr = this.createRow(row, withIds, app); if (row < (int) this.headerRowCount_) { thead.addChild(tr); } else { tbody.addChild(tr); } } this.rowsAdded_ = 0; if (thead != null) { table.addChild(thead); } table.addChild(tbody); this.updateDom(table, true); this.flags_.clear(BIT_GRID_CHANGED); ; this.rowsChanged_ = null; return table; }
private DomElement createRow(int row, boolean withIds, WApplication app) { DomElement tr = DomElement.createNew(DomElementType.DomElement_TR); if (withIds) { tr.setId(this.rows_.get(row).getId()); } this.rows_.get(row).updateDom(tr, true); tr.setWasEmpty(false); int spanCounter = 0; for (int col = 0; col < this.getColumnCount(); ++col) { WTableRow.TableData d = this.itemAt(row, col); if (!d.overSpanned) { DomElement td = d.cell.createSDomElement(app); if (col < this.headerColumnCount_ || row < this.headerRowCount_) { tr.addChild(td); } else { tr.insertChildAt(td, col - spanCounter); } for (int i = 0; i < d.cell.getRowSpan(); ++i) { for (int j = 0; j < d.cell.getColumnSpan(); ++j) { if (i + j > 0) { this.itemAt(row + i, col + j).overSpanned = true; this.itemAt(row + i, col + j).cell.setRendered(false); } } } } else { spanCounter++; } } return tr; }
void updateMediaDom(DomElement element, boolean all) { if (all && this.alternative_ != null) { element.setAttribute( "onerror", "if(event.target.error && event.target.error.code==event.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED){while (this.hasChildNodes())if (Wt3_2_3.hasTag(this.firstChild,'SOURCE')){this.removeChild(this.firstChild);}else{this.parentNode.insertBefore(this.firstChild, this);}this.style.display= 'none';}"); } if (all || this.flagsChanged_) { if (!all || !EnumUtils.mask(this.flags_, WAbstractMedia.Options.Controls).isEmpty()) { element.setAttribute( "controls", !EnumUtils.mask(this.flags_, WAbstractMedia.Options.Controls).isEmpty() ? "controls" : ""); } if (!all || !EnumUtils.mask(this.flags_, WAbstractMedia.Options.Autoplay).isEmpty()) { element.setAttribute( "autoplay", !EnumUtils.mask(this.flags_, WAbstractMedia.Options.Autoplay).isEmpty() ? "autoplay" : ""); } if (!all || !EnumUtils.mask(this.flags_, WAbstractMedia.Options.Loop).isEmpty()) { element.setAttribute( "loop", !EnumUtils.mask(this.flags_, WAbstractMedia.Options.Loop).isEmpty() ? "loop" : ""); } } if (all || this.preloadChanged_) { switch (this.preloadMode_) { case PreloadNone: element.setAttribute("preload", "none"); break; default: case PreloadAuto: element.setAttribute("preload", "auto"); break; case PreloadMetadata: element.setAttribute("preload", "metadata"); break; } } this.updateEventSignals(element, all); if (all) { if (this.alternative_ != null) { element.addChild(this.alternative_.createSDomElement(WApplication.getInstance())); } } this.flagsChanged_ = this.preloadChanged_ = false; }
void getDomChanges(List<DomElement> result, WApplication app) { DomElement e = DomElement.getForUpdate(this, this.getDomElementType()); if (!this.isStubbed() && this.flags_.get(BIT_GRID_CHANGED)) { DomElement newE = this.createDomElement(app); e.replaceWith(newE); } else { if (this.rowsChanged_ != null) { for (Iterator<WTableRow> i_it = this.rowsChanged_.iterator(); i_it.hasNext(); ) { WTableRow i = i_it.next(); DomElement e2 = DomElement.getForUpdate(i, DomElementType.DomElement_TR); i.updateDom(e2, false); result.add(e2); } ; this.rowsChanged_ = null; } if (this.rowsAdded_ != 0) { DomElement etb = DomElement.getForUpdate(this.getId() + "tb", DomElementType.DomElement_TBODY); for (int i = 0; i < (int) this.rowsAdded_; ++i) { DomElement tr = this.createRow(this.getRowCount() - this.rowsAdded_ + i, true, app); etb.addChild(tr); } result.add(etb); this.rowsAdded_ = 0; } if (this.flags_.get(BIT_COLUMNS_CHANGED)) { for (int i = 0; i < this.columns_.size(); ++i) { DomElement e2 = DomElement.getForUpdate(this.columns_.get(i), DomElementType.DomElement_COL); this.columns_.get(i).updateDom(e2, false); result.add(e2); } this.flags_.clear(BIT_COLUMNS_CHANGED); } this.updateDom(e, false); } result.add(e); }
void getDomChanges(List<DomElement> result, WApplication app) { if (this.mediaId_.length() != 0) { DomElement media = DomElement.getForUpdate(this.mediaId_, DomElementType.DomElement_DIV); this.updateMediaDom(media, false); if (this.sourcesChanged_) { for (int i = 0; i < this.sourcesRendered_; ++i) { media.callJavaScript( "Wt3_2_3.remove('" + this.mediaId_ + "s" + String.valueOf(i) + "');", true); } this.sourcesRendered_ = 0; for (int i = 0; i < this.sources_.size(); ++i) { DomElement src = DomElement.createNew(DomElementType.DomElement_SOURCE); src.setId(this.mediaId_ + "s" + String.valueOf(i)); this.renderSource(src, this.sources_.get(i), i + 1 >= this.sources_.size()); media.addChild(src); } this.sourcesRendered_ = this.sources_.size(); this.sourcesChanged_ = false; media.callJavaScript(this.getJsMediaRef() + ".load();"); } result.add(media); } super.getDomChanges(result, app); }
DomElement createDomElement(WApplication app) { DomElement result = null; if (this.isInLayout()) { this.setJavaScriptMember(WT_RESIZE_JS, "function() {}"); } if (app.getEnvironment().agentIsIElt(9) || app.getEnvironment().getAgent() == WEnvironment.UserAgent.MobileWebKitAndroid) { result = DomElement.createNew(DomElementType.DomElement_DIV); if (this.alternative_ != null) { result.addChild(this.alternative_.createSDomElement(app)); } } else { DomElement media = this.createMediaDomElement(); DomElement wrap = null; if (this.isInLayout()) { media.setProperty(Property.PropertyStylePosition, "absolute"); media.setProperty(Property.PropertyStyleLeft, "0"); media.setProperty(Property.PropertyStyleRight, "0"); wrap = DomElement.createNew(DomElementType.DomElement_DIV); wrap.setProperty(Property.PropertyStylePosition, "relative"); } result = wrap != null ? wrap : media; if (wrap != null) { this.mediaId_ = this.getId() + "_media"; media.setId(this.mediaId_); } else { this.mediaId_ = this.getId(); } this.updateMediaDom(media, true); for (int i = 0; i < this.sources_.size(); ++i) { DomElement src = DomElement.createNew(DomElementType.DomElement_SOURCE); src.setId(this.mediaId_ + "s" + String.valueOf(i)); this.renderSource(src, this.sources_.get(i), i + 1 >= this.sources_.size()); media.addChild(src); } this.sourcesRendered_ = this.sources_.size(); this.sourcesChanged_ = false; if (wrap != null) { wrap.addChild(media); } } if (this.isInLayout()) { StringWriter ss = new StringWriter(); ss.append("function(self, w, h) {"); if (this.mediaId_.length() != 0) { ss.append( "v=" + this.getJsMediaRef() + ";if(v){v.setAttribute('width', w);v.setAttribute('height', h);}"); } if (this.alternative_ != null) { ss.append("a=" + this.alternative_.getJsRef() + ";if(a && a.") .append(WT_RESIZE_JS) .append(")a.") .append(WT_RESIZE_JS) .append("(a, w, h);"); } ss.append("}"); this.setJavaScriptMember(WT_RESIZE_JS, ss.toString()); } this.setId(result, app); this.updateDom(result, true); if (this.isInLayout()) { result.setEvent(PLAYBACKSTARTED_SIGNAL, ""); result.setEvent(PLAYBACKPAUSED_SIGNAL, ""); result.setEvent(ENDED_SIGNAL, ""); result.setEvent(TIMEUPDATED_SIGNAL, ""); result.setEvent(VOLUMECHANGED_SIGNAL, ""); } this.setJavaScriptMember("mediaId", "'" + this.mediaId_ + "'"); return result; }