List of usage examples for com.google.gwt.dom.client Document createElement
public Element createElement(String tagName)
From source file:com.google.maps.gwt.samples.layers.client.LayerPanoramio.java
License:Apache License
@Override public void onModuleLoad() { LatLng fremont = LatLng.create(47.651743, -122.349243); MapOptions mapOpts = MapOptions.create(); mapOpts.setZoom(16);//from w w w. j a va2 s . co m mapOpts.setCenter(fremont); mapOpts.setMapTypeId(MapTypeId.ROADMAP); final GoogleMap map = GoogleMap.create(Document.get().getElementById("map_canvas"), mapOpts); PanoramioLayer panoramioLayer = PanoramioLayer.create(); panoramioLayer.setMap(map); panoramioLayer.addClickListener(new ClickHandler() { @Override public void handle(PanoramioMouseEvent event) { Document document = Document.get(); Element photoDiv = document.getElementById("photo_panel"); Text attribution = document.createTextNode( event.getFeatureDetails().getTitle() + ": " + event.getFeatureDetails().getAuthor()); Element br = document.createElement("br"); Element link = document.createElement("a"); link.setAttribute("href", event.getFeatureDetails().getUrl()); link.appendChild(attribution); photoDiv.appendChild(br); photoDiv.appendChild(link); } }); }
From source file:com.googlecode.gwtquake.client.GwtQuake.java
License:Open Source License
public void onModuleLoad() { // Initialize drivers. Document doc = Document.get(); doc.setTitle("GWT Quake II"); BodyElement body = doc.getBody();/*from w w w . ja va2 s .co m*/ Style style = body.getStyle(); style.setPadding(0, Unit.PX); style.setMargin(0, Unit.PX); style.setBorderWidth(0, Unit.PX); style.setProperty("height", "100%"); style.setBackgroundColor("#000"); style.setColor("#888"); // Window.alert("UA: " + userAgent+ " type: " + browserType); boolean wireframe = ("" + Window.Location.getHash()).indexOf("wireframe") != -1; canvas = (CanvasElement) doc.createElement("canvas"); video = doc.createElement("video"); w = Window.getClientWidth(); h = Window.getClientHeight(); canvas.setWidth(w); canvas.setHeight(h); style = canvas.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style = video.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style.setProperty("display", "none"); body.appendChild(canvas); body.appendChild(video); try { Globals.autojoin.value = Window.Location.getHash().indexOf("autojoin") != -1 ? 1.0f : 0.0f; final Renderer renderer = wireframe ? new GwtWireframeGLRenderer(canvas) : new GwtWebGLRenderer(canvas, video); Globals.re = renderer; ResourceLoader.impl = new GwtResourceLoaderImpl(); Compatibility.impl = new CompatibilityImpl(); Sound.impl = new GwtSound(); NET.socketFactory = new WebSocketFactoryImpl(); // Sys.impl = new Sys.SysImpl() { // public void exit(int status) { // Window.alert("Something's rotten in Denmark"); // Window.Location.assign("gameover.html"); // } // }; // Flags. QuakeCommon.Init(new String[] { "GQuake" }); // Enable stdout. Globals.nostdout = ConsoleVariables.Get("nostdout", "0", 0); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (Window.getClientWidth() == w && Window.getClientHeight() == h) { return; } w = Window.getClientWidth(); h = Window.getClientHeight(); renderer.GLimp_SetMode(new Dimension(w, h), 0, false); } }); // QuakeServer.main(new String[0], new DummySNetImpl(), false); timer = new Timer() { double startTime = Duration.currentTimeMillis(); @Override public void run() { try { double curTime = Duration.currentTimeMillis(); boolean pumping = ResourceLoader.Pump(); if (pumping) { Screen.UpdateScreen2(); } else { int dt = (int) (curTime - startTime); GwtKBD.Frame(dt); QuakeCommon.Frame(dt); } startTime = curTime; timer.schedule(ResourceLoader.Pump() ? LOADING_DELAY : INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); } } }; timer.schedule(INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); DivElement div = doc.createDivElement(); div.setInnerHTML(NO_WEBGL_MESSAGE); body.appendChild(div); } }
From source file:com.pronoiahealth.olhie.client.widgets.booklist3d.BookLIWidget.java
License:Open Source License
/** * Constructor/*from w w w. ja v a 2 s . c o m*/ * */ public BookLIWidget() { // Create the tocWidget tocWidget = new TOCDivWidget(); // Create the root Document doc = Document.get(); root = doc.createLIElement(); setElement(root); // Book id div bkBook = createDivWithClassStyle(doc, "bk-book book-1 bk-bookdefault", null); root.appendChild(bkBook); // Book front DivElement bookFront = createDivWithClassStyle(doc, "bk-front", null); bkBook.appendChild(bookFront); // Front Cover bookFrontCover = createDivWithClassStyle(doc, "bk-cover", null); bookFront.appendChild(bookFrontCover); // MyCollection Indicator DivElement cd1 = createDivWithClassStyle(doc, null, "float: right; margin: 10px;"); bookFrontCover.appendChild(cd1); DivElement cd2 = createDivWithClassStyle(doc, null, null); cd1.appendChild(cd2); myCollectionBtnIndicator = doc.createAnchorElement(); cd2.appendChild(myCollectionBtnIndicator); myCollectionBtnIndicatorIcon = doc.createElement("i"); myCollectionBtnIndicator.appendChild(myCollectionBtnIndicatorIcon); // BK Cover Back bkCoverBack = this.createDivWithClassStyle(doc, "bk-cover-back", "background-color: #FFFF00;"); bookFront.appendChild(bkCoverBack); // Book Page bkPage = createDivWithClassStyle(doc, "bk-page", null); bkBook.appendChild(bkPage); // Book Back bkBack = this.createDivWithClassStyle(doc, "bk-back", null); bkBook.appendChild(bkBack); bookDescription = doc.createPElement(); bkBack.appendChild(bookDescription); // Book Right DivElement bkRight = createDivWithClassStyle(doc, "bk-right", null); bkBook.appendChild(bkRight); // Left bkLeft = createDivWithClassStyle(doc, "bk-left", "background-color: #FFFF00;"); bkBook.appendChild(bkLeft); bookBinding = doc.createHElement(2); bkLeft.appendChild(bookBinding); bookBindingAuthor = doc.createSpanElement(); bookBinding.appendChild(bookBindingAuthor); bookBindingTitle = doc.createSpanElement(); bookBinding.appendChild(bookBindingTitle); // Book top and botton bkBook.appendChild(createDivWithClassStyle(doc, "bk-top", null)); bkBook.appendChild(createDivWithClassStyle(doc, "bk-bottom", null)); // Book info DivElement bkInfo = createDivWithClassStyle(doc, "bk-info", null); root.appendChild(bkInfo); // Back button ButtonElement bkBookback = doc.createButtonElement(); bkBookback.setClassName("bk-bookback"); bkInfo.appendChild(bkBookback); // Front button ButtonElement bkBookview = doc.createButtonElement(); bkBookview.setClassName("bk-bookview"); bkInfo.appendChild(bkBookview); // Rating DivElement rh = createDivWithClassStyle(doc, null, "margin-top: 15px;"); bkInfo.appendChild(rh); DivElement rh1 = createDivWithClassStyle(doc, null, "float: left; padding-right: 10px;"); rh.appendChild(rh1); Element rh11 = doc.createElement("b"); rh1.appendChild(rh11); rh11.setInnerText("Rating:"); // Holder for rating ratingHolder = doc.createDivElement(); rh.appendChild(ratingHolder); // Book hours DivElement bh = createDivWithClassStyle(doc, null, "margin-top: 15px;"); bkInfo.appendChild(bh); DivElement bh1 = createDivWithClassStyle(doc, null, "float: left; padding-right: 10px;"); bh.appendChild(bh1); Element bh11 = doc.createElement("b"); bh1.appendChild(bh11); bh11.setInnerText("Book Hours:"); // Holder for hours bookHoursHolder = doc.createDivElement(); bh.appendChild(bookHoursHolder); }
From source file:jake2.gwt.client.GwtQuake.java
License:Open Source License
public void onModuleLoad() { // Initialize drivers. Document doc = Document.get(); doc.setTitle("GWT Quake II"); BodyElement body = doc.getBody();/* w w w . j ava 2 s . co m*/ Style style = body.getStyle(); style.setPadding(0, Unit.PX); style.setMargin(0, Unit.PX); style.setBorderWidth(0, Unit.PX); style.setProperty("height", "100%"); style.setBackgroundColor("#000"); style.setColor("#888"); boolean wireframe = ("" + Window.Location.getHash()).indexOf("wireframe") != -1; canvas = (CanvasElement) doc.createElement("canvas"); video = doc.createElement("video"); w = Window.getClientWidth(); h = Window.getClientHeight(); canvas.setWidth(w); canvas.setHeight(h); style = canvas.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style = video.getStyle(); style.setProperty("height", "100%"); style.setProperty("width", "100%"); style.setProperty("display", "none"); body.appendChild(canvas); body.appendChild(video); try { final refexport_t renderer = wireframe ? new GwtWireframeGLRenderer(canvas) : new GwtWebGLRenderer(canvas, video); Globals.re = renderer; ResourceLoader.impl = new GwtResourceLoaderImpl(); Compatibility.impl = new CompatibilityImpl(); S.impl = new GwtSound(); NET.socketFactory = new WebSocketFactoryImpl(); // Sys.impl = new Sys.SysImpl() { // public void exit(int status) { // Window.alert("Something's rotten in Denmark"); // Window.Location.assign("gameover.html"); // } // }; // Flags. Qcommon.Init(new String[] { "GQuake" }); // Enable stdout. Globals.nostdout = Cvar.Get("nostdout", "0", 0); Window.addResizeHandler(new ResizeHandler() { public void onResize(ResizeEvent event) { if (Window.getClientWidth() == w && Window.getClientHeight() == h) { return; } w = Window.getClientWidth(); h = Window.getClientHeight(); renderer.GLimp_SetMode(new Dimension(w, h), 0, false); } }); // QuakeServer.main(new String[0], new DummySNetImpl(), false); timer = new Timer() { double startTime = Duration.currentTimeMillis(); @Override public void run() { try { double curTime = Duration.currentTimeMillis(); boolean pumping = ResourceLoader.Pump(); if (pumping) { SCR.UpdateScreen2(); } else { int dt = (int) (curTime - startTime); GwtKBD.Frame(dt); Qcommon.Frame(dt); } startTime = curTime; timer.schedule(ResourceLoader.Pump() ? LOADING_DELAY : INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); } } }; timer.schedule(INTER_FRAME_DELAY); } catch (Exception e) { Compatibility.printStackTrace(e); body.setInnerHTML(NO_WEBGL_MESSAGE); } }
From source file:org.jadice.web.gwt.fontawesome.client.FontAwesome.java
License:Apache License
public Element createElement(Document document) { final Element element = document.createElement("i"); element.addClassName("fa"); element.addClassName("fa-" + styleClass); return element; }
From source file:org.jbpm.console.ng.bd.client.util.DataGridUtils.java
License:Apache License
public static com.google.gwt.dom.client.Element getCharacterMeasuringElement(String name) { Document document = Document.get(); com.google.gwt.dom.client.Element measuringElement = document.getElementById(name); if (measuringElement == null) { measuringElement = document.createElement("div"); measuringElement.setId(name);/*from ww w . j a v a 2 s . c om*/ measuringElement.getStyle().setPosition(Position.ABSOLUTE); measuringElement.getStyle().setLeft(-1000, Unit.PX); measuringElement.getStyle().setTop(-1000, Unit.PX); document.getBody().appendChild(measuringElement); } return measuringElement; }
From source file:org.openxdata.sharedlib.client.view.FormRunnerView.java
/** * Reloads the form runner view//from w w w. j a v a 2s. com * * @param formDef the form definition to load. * @param layoutXml the form widget layout xml. * @param externalSourceWidgets a list of widgets which get their data from sources * external to the xform. */ public void loadForm(FormDef formDef, String layoutXml, String javaScriptSrc, List<RuntimeWidgetWrapper> externalSourceWidgets, boolean previewMode) { FormUtil.initialize(); if (previewMode) { //Here we must be in preview mode where we need to create a new copy of the formdef //such that we don't set preview values as default formdef values. if (formDef == null) this.formDef = null; else //set the document xml which we shall need for updating the model with question answers this.formDef = XformParser.copyFormDef(formDef); } else this.formDef = formDef; tabs.clear(); if (formDef == null || layoutXml == null || layoutXml.trim().length() == 0) { addNewTab(constants.page() + "1"); return; } loadLayout(layoutXml, externalSourceWidgets, getCalcQtnMappings(this.formDef)); isValid(true); moveToFirstWidget(); com.google.gwt.dom.client.Element script = DOM.getElementById("formtools_javascript"); if (script != null) script.removeFromParent(); if (javaScriptSrc != null) { Document document = Document.get(); script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("id", "formtools_javascript"); script.appendChild(document.createTextNode(javaScriptSrc)); document.getElementsByTagName("head").getItem(0).appendChild(script); } this.externalSourceWidgets = externalSourceWidgets; externalSourceWidgetIndex = 0; if (externalSourceWidgets != null && externalSourceWidgets.size() > 0 && FormUtil.getExternalSourceUrlSuffix() != null) fillExternalSourceWidget(externalSourceWidgets.get(externalSourceWidgetIndex++), null); }
From source file:org.palaso.languageforge.client.lex.controls.gwtcanvas.impl.GWTCanvasImplIE6.java
License:Apache License
private Element createParentElement() { // TODO(jaimeyap): We should probably refactor the Widget's constructor to // take in the Document as a dependency. Document doc = Document.get(); parentElement = doc.createElement("canvas").cast(); shapeContainer = doc.createDivElement().cast(); shapeContainer.getStyle().setPosition(Position.ABSOLUTE); shapeContainer.getStyle().setOverflow(Overflow.HIDDEN); shapeContainer.getStyle().setWidth(100, Unit.PCT); shapeContainer.getStyle().setHeight(100, Unit.PCT); parentElement.appendChild(shapeContainer); ensureNamespacesAndStylesheet(doc);//from ww w .j a v a 2 s.c o m return parentElement; }