List of usage examples for com.google.gwt.dom.client IFrameElement getContentDocument
public final Document getContentDocument()
From source file:com.dianaui.universal.core.client.ui.gwt.RichTextArea.java
License:Apache License
public void injectStyle(String css) { IFrameElement iframe = IFrameElement.as(getElement()); StyleElement style = iframe.getContentDocument().createStyleElement(); style.setPropertyString("language", "text/css"); style.setType("text/css"); setStyleContent(style, css);/* w w w .j a v a 2 s . c o m*/ iframe.getContentDocument().getElementsByTagName("head").getItem(0).appendChild(style); }
From source file:com.dianaui.universal.core.client.ui.RichTextToolbar.java
License:Apache License
/** * Creates a new toolbar that drives the given rich text area. * * @param richText the rich text area to be controlled *//*w ww . ja v a 2 s . c o m*/ public RichTextToolbar(final RichTextArea richText) { initWidget(binder.createAndBindUi(this)); richText.addInitializeHandler(new InitializeHandler() { @Override public void onInitialize(InitializeEvent event) { IFrameElement iframe = IFrameElement.as(richText.getElement()); iframe.getContentDocument().getBody().getStyle().setMargin(0, Style.Unit.PX); iframe.getContentDocument().getBody().getStyle().setPadding(0, Style.Unit.PX); } }); this.richText = richText; richText.setHTML("<div></div>"); EventHandler handler = new EventHandler(); boldButton.addClickHandler(handler); italicButton.addClickHandler(handler); underlineButton.addClickHandler(handler); subscriptButton.addClickHandler(handler); superscriptButton.addClickHandler(handler); justifyLeftButton.addClickHandler(handler); justifyCenterButton.addClickHandler(handler); justifyRightButton.addClickHandler(handler); strikethroughButton.addClickHandler(handler); indentButton.addClickHandler(handler); outdentButton.addClickHandler(handler); hrButton.addClickHandler(handler); olButton.addClickHandler(handler); ulButton.addClickHandler(handler); imageButton.addClickHandler(handler); linkButton.addClickHandler(handler); unlinkButton.addClickHandler(handler); removeFormatButton.addClickHandler(handler); undoButton.addClickHandler(handler); redoButton.addClickHandler(handler); // We only use these handlers for updating status, so don't hook them up // unless at least basic editing is supported. richText.addKeyUpHandler(handler); richText.addClickHandler(handler); }
From source file:com.ephesoft.gxt.rv.client.widget.ExternalAppDialog.java
License:Open Source License
private void addLoadHandler() { externalAppFrame.addLoadHandler(new LoadHandler() { @Override//from w w w .j av a2 s . co m public void onLoad(LoadEvent event) { IFrameElement iframeElement = IFrameElement.as(externalAppFrame.getElement()); Document contentDocument = iframeElement.getContentDocument(); if (null != contentDocument) { String title = contentDocument.getTitle(); if (StringUtil.isNullOrEmpty(title)) { ExternalAppDialog.this.setHeadingHtml(externalAppFrame.getUrl()); } else { ExternalAppDialog.this.setHeadingHtml(title); } } } }); }
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);/* ww w . j a v a 2 s.c om*/ head.appendChild(styleTag); }
From source file:com.pronoiahealth.olhie.client.widgets.DownloadFrame.java
License:Open Source License
/** * Create the LoadHandler to observe the Frame. Errors from the server will * get sent back to the frame./*ww w. j av a2 s.c om*/ */ @PostConstruct private void postConstruct() { // Create a load handler to watch for errors. loadHandler = new LoadHandler() { @Override public void onLoad(LoadEvent event) { IFrameElement elem = ((IFrameElement) iFrame.getElement().cast()); Document doc = elem.getContentDocument(); if (doc != null) { if (doc.getBody() != null) { String str = doc.getBody().getInnerHTML(); if (str != null && str.length() > 0) { clientErrorEvent.fire(new ClientErrorEvent(str)); } } } } }; }
From source file:cz.filmtit.client.subgestbox.PosteditBox.java
License:Open Source License
public PosteditBox(TimedChunk chunk, TranslationWorkspace workspace, int tabIndex) { this.chunk = chunk; this.workspace = workspace; if (this.workspace == null) { Gui.log("workspace for subgestbox is null!!!"); }/*w w w .ja v a 2 s .c om*/ this.subgestBox = null; this.setHeight("36px"); this.setHTML(posteditBoxHTML("")); this.addFocusHandler(this.workspace.posteditHandler); this.addKeyDownHandler(this.workspace.posteditHandler); this.addKeyUpHandler(this.workspace.posteditHandler); this.setTabIndex(tabIndex); this.addStyleName("posteditwidth"); final RichTextArea richtext = this; richtext.addInitializeHandler(new InitializeHandler() { public void onInitialize(InitializeEvent ie) { IFrameElement fe = (IFrameElement) richtext.getElement().cast(); Style s = fe.getContentDocument().getBody().getStyle(); s.setProperty("fontFamily", "Arial Unicode MS,Arial,sans-serif"); s.setProperty("fontSize", "small"); s.setColor("#333"); } }); }
From source file:cz.filmtit.client.subgestbox.SubgestBox.java
License:Open Source License
/** * Primary constructor for the SubgestBox. * * @param chunk - the source chunk of the underlying TranslationResult * @param workspace - the TranslationWorkspace in which this SubgestBox * operates/*w w w . j a v a 2 s.co m*/ * @param tabIndex - intended tabIndex within the workspace */ public SubgestBox(TimedChunk chunk, TranslationWorkspace workspace, int tabIndex) { this.chunk = chunk; this.translationResult = new TranslationResult(chunk); this.workspace = workspace; if (this.workspace == null) { Gui.log("workspace for subgestbox is null!!!"); } this.posteditBox = null; this.setHeight("36px"); this.setHTML(subgestBoxHTML("")); this.addFocusHandler(this.workspace.subgestHandler); this.addKeyDownHandler(this.workspace.subgestHandler); this.addKeyUpHandler(this.workspace.subgestHandler); this.setTabIndex(tabIndex); if (workspace.isPosteditOn()) { this.addStyleName("posteditwidth"); } else { this.addStyleName("subgest_fullwidth"); } final RichTextArea richtext = this; richtext.addInitializeHandler(new InitializeHandler() { public void onInitialize(InitializeEvent ie) { IFrameElement fe = (IFrameElement) richtext.getElement().cast(); Style s = fe.getContentDocument().getBody().getStyle(); s.setProperty("fontFamily", "Arial Unicode MS,Arial,sans-serif"); s.setProperty("fontSize", "small"); s.setColor("#333"); } }); }
From source file:org.chromium.distiller.extractors.embeds.TwitterExtractor.java
License:Open Source License
/** * Handle a Twitter embed that has already been rendered. * @param e The root element of the embed (should be an "iframe"). * @return EmbeddedElement object representing the embed or null. *//*from www.j ava 2s. co m*/ private WebEmbed handleRendered(Element e) { // Twitter embeds are blockquote tags operated on by some javascript. if (!"IFRAME".equals(e.getTagName())) { return null; } IFrameElement iframe = IFrameElement.as(e); // If the iframe has no "src" attribute, explore further. if (!iframe.getSrc().isEmpty()) { return null; } Document iframeDoc = iframe.getContentDocument(); if (iframeDoc == null) { return null; } // The iframe will contain a blockquote element that has information including tweet id. NodeList blocks = iframeDoc.getElementsByTagName("blockquote"); if (blocks.getLength() < 1) { return null; } Element tweetBlock = Element.as(blocks.getItem(0)); String id = tweetBlock.getAttribute("data-tweet-id"); if (id.isEmpty()) { return null; } return new WebEmbed(e, "twitter", id, null); }
From source file:org.drools.guvnor.client.asseteditor.drools.modeldriven.ui.CustomFormPopUp.java
License:Apache License
private Element getExternalFrameElement(String id) { IFrameElement iframe = IFrameElement.as(this.externalFrame.getElement()); return iframe.getContentDocument().getElementById(id); }
From source file:org.jahia.ajax.gwt.client.widget.content.compare.VersionViewer.java
License:Open Source License
/** * Get html//from w ww . j a va 2s .c o m * * @return */ public String getInnerHTML() { IFrameElement frameElement = IFrameElement.as(currentFrame.getElement()); Document document = frameElement.getContentDocument(); BodyElement ele = document.getBody(); if (ele != null) { return ele.getInnerHTML(); } // it may happens if the iframe is not yet loaded return null; }