List of usage examples for com.google.gwt.dom.client StyleElement setInnerText
@Override public void setInnerText(String text)
From source file:burrito.client.crud.widgets.FormattedRichTextArea.java
License:Apache License
@Override protected void onAttach() { super.onAttach(); Timer cssTimer = new Timer() { @Override//w w w .j a va 2 s. co m public void run() { Document doc = IFrameElement.as(getElement()).getContentDocument(); StyleElement style = doc.createStyleElement(); style.setInnerText(CSS); HeadElement.as(Element.as(doc.getBody().getPreviousSibling())).appendChild(style); } }; cssTimer.schedule(100); }
From source file:com.google.speedtracer.client.SourceViewer.java
License:Apache License
private static void injectStyles(IFrameElement sourceFrame, String styleText) { Document iframeDocument = sourceFrame.getContentDocument(); HeadElement head = iframeDocument.getElementsByTagName("head").getItem(0).cast(); StyleElement styleTag = iframeDocument.createStyleElement(); styleTag.setInnerText(styleText); head.appendChild(styleTag);/* ww w. ja v a2 s . co m*/ }
From source file:com.qualogy.qafe.mgwt.client.main.MainController.java
License:Apache License
private void handleStyling(String css) { if ((css == null) || (css.length() == 0)) { return;//from w w w .j av a 2 s. c o m } if (isIE()) { addStyleSheet(css); } else { // Append custom css style as last thing in the Head element Element head = Document.get().getElementsByTagName("head").getItem(0); StyleElement styleElement = Document.get().createStyleElement(); styleElement.setType("text/css"); styleElement.setInnerText(css); head.appendChild(styleElement); } }
From source file:org.rstudio.core.client.widget.FontSizer.java
License:Open Source License
public static void injectStylesIntoDocument(Document doc) { StyleElement style = doc.createStyleElement(); style.setType("text/css"); style.setInnerText(styles.getText()); doc.getBody().appendChild(style);// ww w. ja v a2s. c o m }
From source file:org.rstudio.core.client.widget.FontSizer.java
License:Open Source License
public static void setNormalFontSize(Document document, double size) { size = size + BrowseCap.getFontSkew(); final String STYLE_EL_ID = "__rstudio_normal_size"; Element oldStyle = document.getElementById(STYLE_EL_ID); StyleElement style = document.createStyleElement(); style.setAttribute("type", "text/css"); style.setInnerText("." + styles.normalSize() + ", " + "." + styles.normalSize() + " td, " + "." + styles.normalSize() + " pre" + " {font-size:" + size + "pt !important;}"); document.getBody().appendChild(style); if (oldStyle != null) oldStyle.removeFromParent();/* w ww . j ava2s . c om*/ style.setId(STYLE_EL_ID); }
From source file:org.rstudio.studio.client.workbench.prefs.views.AceEditorPreview.java
License:Open Source License
@Override protected void onFrameLoaded() { isFrameLoaded_ = true;// w ww . j a v a2s . co m final Document doc = getDocument(); // NOTE: There is an interesting 'feature' in Firefox whereby an // initialized IFrame will report that it has successfully initialized the // window / underlying document (readyState is 'complete') but, in fact, // there is still some initialization left to occur and any changes made // before complete initialization will cause it to be swept out from under // our feet. To work around this, we double-check that the document we are // working with is the _same document_ after each JavaScript load // iteration. new ExternalJavaScriptLoader(getDocument(), AceResources.INSTANCE.acejs().getSafeUri().asString()) .addCallback(new Callback() { public void onLoaded() { if (getDocument() != doc) { onFrameLoaded(); return; } new ExternalJavaScriptLoader(getDocument(), AceResources.INSTANCE.acesupportjs().getSafeUri().asString()) .addCallback(new Callback() { public void onLoaded() { if (getDocument() != doc) { onFrameLoaded(); return; } final Document doc = getDocument(); final BodyElement body = doc.getBody(); if (themeUrl_ != null) setTheme(themeUrl_); if (fontSize_ != null) setFontSize(fontSize_); if (zoomLevel_ != null) setZoomLevel(zoomLevel_); body.getStyle().setMargin(0, Unit.PX); body.getStyle().setBackgroundColor("white"); StyleElement style = doc.createStyleElement(); style.setType("text/css"); style.setInnerText( ".ace_editor {\n" + "border: none !important;\n" + "}"); setFont(ThemeFonts.getFixedWidthFont()); body.appendChild(style); DivElement div = doc.createDivElement(); div.setId("editor"); div.getStyle().setWidth(100, Unit.PCT); div.getStyle().setHeight(100, Unit.PCT); div.setInnerText(code_); body.appendChild(div); FontSizer.injectStylesIntoDocument(doc); FontSizer.applyNormalFontSize(div); body.appendChild(doc.createScriptElement( "var event = require('ace/lib/event');\n" + "var Editor = require('ace/editor').Editor;\n" + "var Renderer = require('ace/virtual_renderer').VirtualRenderer;\n" + "var dom = require('ace/lib/dom');\n" + "var container = document.getElementById('editor');\n" + "var value = dom.getInnerText(container);\n" + "container.innerHTML = '';\n" + "var session = ace.createEditSession(value);\n" + "var editor = new Editor(new Renderer(container, {}));\n" + "editor.setSession(session);\n" + "var env = {document: session, editor: editor, onResize: editor.resize.bind(editor, null)};\n" + "event.addListener(window, 'resize', env.onResize);\n" + "editor.on('destory', function() { event.removeListener(window, 'resize', env.onResize); });\n" + "editor.container.env = editor.env = env;\n" + "editor.renderer.setHScrollBarAlwaysVisible(false);\n" + "editor.setHighlightActiveLine(false);\n" + "editor.setReadOnly(true);\n" + "editor.renderer.setShowGutter(false);\n" + "editor.renderer.setDisplayIndentGuides(false);\n" + "var RMode = require('mode/r').Mode;\n" + "editor.getSession().setMode(new RMode(false, editor.getSession()));")); } }); } }); }
From source file:org.rstudio.studio.client.workbench.prefs.views.AceEditorPreview.java
License:Open Source License
public void setFont(String font) { final String STYLE_EL_ID = "__rstudio_font_family"; Document document = getDocument(); Element oldStyle = document.getElementById(STYLE_EL_ID); StyleElement style = document.createStyleElement(); style.setAttribute("type", "text/css"); style.setInnerText(".ace_editor, .ace_text-layer {\n" + "font-family: " + font + " !important;\n" + "}"); document.getBody().appendChild(style); if (oldStyle != null) oldStyle.removeFromParent();/* w w w . ja v a 2s.com*/ style.setId(STYLE_EL_ID); }
From source file:org.rstudio.studio.client.workbench.prefs.views.AceEditorPreview.java
License:Open Source License
public void setZoomLevel(double zoomLevel) { zoomLevel_ = zoomLevel;//from www .j av a2s. c om if (!isFrameLoaded_) return; final String STYLE_EL_ID = "__rstudio_zoom_level"; Document document = getDocument(); Element oldStyle = document.getElementById(STYLE_EL_ID); StyleElement style = document.createStyleElement(); style.setAttribute("type", "text/css"); String zoom = Double.toString(zoomLevel); style.setInnerText(".ace_line {\n" + " -webkit-transform: scale(" + zoom + ");\n" + "}"); document.getBody().appendChild(style); if (oldStyle != null) oldStyle.removeFromParent(); style.setId(STYLE_EL_ID); }