Example usage for com.google.gwt.dom.client IFrameElement as

List of usage examples for com.google.gwt.dom.client IFrameElement as

Introduction

In this page you can find the example usage for com.google.gwt.dom.client IFrameElement as.

Prototype

public static IFrameElement as(Element elem) 

Source Link

Document

Assert that the given Element is compatible with this class and automatically typecast it.

Usage

From source file:burrito.client.crud.widgets.FormattedRichTextArea.java

License:Apache License

@Override
protected void onAttach() {
    super.onAttach();

    Timer cssTimer = new Timer() {
        @Override/*from w w  w . j  a  va2 s .  c  om*/
        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:ch.unifr.pai.mindmap.client.components.websearch.ProxyLayoutPanel.java

License:Apache License

/**
 * @return the original URL (without proxy prefix) of the current web page within the frame.
 *//* w ww.  jav  a2  s. co  m*/
private String getCurrentFrameUrl() {
    return IFrameElement.as(frame.getElement()).getContentDocument().getURL()
            .substring(proxyUrlPrefix().length());

}

From source file:ch.unifr.pai.twice.widgets.mpbrowser.client.MPBrowser.java

License:Apache License

private void updateScrollBar() {
    Document d = IFrameElement.as(frame.getElement()).getContentDocument();
    boolean scrollVertical = d.getBody().getScrollHeight() > frame.getOffsetHeight();
    boolean scrollHorizontal = d.getBody().getScrollWidth() > frame.getOffsetWidth();
    scrollDown.setEnabled(scrollVertical);
    scrollUp.setEnabled(scrollVertical);
    scrollBar.getElement().getStyle().setBackgroundColor(scrollVertical ? "lightgrey" : "lightgrey");
}

From source file:ch.unifr.pai.twice.widgets.mpbrowser.client.MPBrowser.java

License:Apache License

private void updateScrollBar2() {
    Document d = IFrameElement.as(frame2.getElement()).getContentDocument();
    boolean scrollVertical = d.getBody().getScrollHeight() > frame2.getOffsetHeight();
    boolean scrollHorizontal = d.getBody().getScrollWidth() > frame2.getOffsetWidth();
    scrollDown2.setEnabled(scrollVertical);
    scrollUp2.setEnabled(scrollVertical);
    scrollBar2.getElement().getStyle().setBackgroundColor(scrollVertical ? "lightgrey" : "lightgrey");
}

From source file:ch.unifr.pai.twice.widgets.mpbrowser.client.MPBrowser.java

License:Apache License

@Override
public void onModuleLoad() {
    multiCursor.start();//  w  w w.  j  a  va  2 s . co  m
    scrollBar.getElement().getStyle().setBackgroundColor("lightgrey");
    scrollBar.addNorth(scrollUp, 30);
    scrollBar.addSouth(scrollDown, 30);
    scrollBar.add(new HTML());
    textBox.setWidth("100%");
    navig.add(backward);
    navig.add(forward);
    navig.setCellWidth(backward, "50px");
    navig.setCellWidth(forward, "50px");
    navig.add(textBox);
    navig.setWidth("100%");
    Storage s = Storage.getSessionStorageIfSupported();
    if (s != null) {
        String type = s.getItem("ch.unifr.pai.mice.deviceType");
        if (type == null || !type.equals("multicursor")) {
            s.setItem("ch.unifr.pai.mice.deviceType", "multicursor");
        }
    }
    frame.setUrl(GWT.getHostPageBaseURL() + "http://www.google.ch");
    frame.setHeight("100%");
    frame.setWidth("100%");
    frame.getElement().setAttribute("scrolling", "no");
    frame.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            if (frame.getUrl() != null && !frame.getUrl().startsWith(GWT.getHostPageBaseURL())) {
                frame.setUrl(GWT.getHostPageBaseURL() + frame.getUrl());
                updateScrollBar();
            }
            Document d = IFrameElement.as(frame.getElement()).getContentDocument();
            textBox.setValue(d.getURL());
        }
    });
    scrollBar2.getElement().getStyle().setBackgroundColor("lightgrey");
    scrollBar2.addNorth(scrollUp2, 30);
    scrollBar2.addSouth(scrollDown2, 30);
    scrollBar2.add(new HTML());
    textBox2.setWidth("100%");
    navig2.add(backward2);
    navig2.add(forward2);
    navig2.setCellWidth(backward2, "50px");
    navig2.setCellWidth(forward2, "50px");
    navig2.add(textBox2);
    navig2.setWidth("100%");

    frame2.setUrl(GWT.getHostPageBaseURL() + "http://www.google.ch");
    frame2.setHeight("100%");
    frame2.setWidth("100%");
    frame2.getElement().setAttribute("scrolling", "no");
    frame2.addLoadHandler(new LoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            if (frame2.getUrl() != null && !frame2.getUrl().startsWith(GWT.getHostPageBaseURL())) {
                frame2.setUrl(GWT.getHostPageBaseURL() + frame2.getUrl());
                updateScrollBar2();
            }
            Document d = IFrameElement.as(frame2.getElement()).getContentDocument();
            textBox2.setValue(d.getURL());
        }
    });

    DockLayoutPanel p = new DockLayoutPanel(Unit.PX);
    p.addNorth(navig, 25);
    p.addEast(scrollBar, 30);
    p.add(frame);
    browserSplit.addNorth(p, 500);

    DockLayoutPanel p2 = new DockLayoutPanel(Unit.PX);
    p2.addNorth(navig2, 25);
    p2.addEast(scrollBar2, 30);
    p2.add(frame2);
    browserSplit.add(p2);

    RootLayoutPanel.get().add(browserSplit);
}

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);/*from   ww w. java 2  s  .  c om*/

    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
 *///from   ww  w  .  j  av  a2s .com
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// w w  w  .j  a  va 2s .  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.ikon.frontend.client.widget.richtext.RichTextToolbar.java

License:Open Source License

/** Constructor of the Toolbar **/
public RichTextToolbar(final RichTextArea richtext) {
    //Initialize the main-panel
    outer = new VerticalPanel();

    //Initialize the two inner panels
    topPanel = new HorizontalPanel();
    bottomPanel = new HorizontalPanel();
    topPanel.setStyleName("RichTextToolbar");
    bottomPanel.setStyleName("RichTextToolbar");

    //Save the reference to the RichText area we refer to and get the interfaces to the stylings

    styleText = richtext;/* www . j  ava 2  s.co m*/
    styleTextFormatter = styleText.getFormatter();

    //Set some graphical options, so this toolbar looks how we like it.
    topPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);
    bottomPanel.setHorizontalAlignment(HorizontalPanel.ALIGN_LEFT);

    //Add the two inner panels to the main panel
    outer.add(topPanel);
    outer.add(bottomPanel);

    //Some graphical stuff to the main panel and the initialisation of the new widget
    outer.setStyleName("RichTextToolbar");
    initWidget(outer);

    //
    evHandler = new EventHandler();

    //Add KeyUp and Click-Handler to the RichText, so that we can actualize the toolbar if neccessary
    styleText.addKeyUpHandler(evHandler);
    styleText.addClickHandler(evHandler);

    // Changing styles
    IFrameElement e = IFrameElement.as(richtext.getElement());
    e.setSrc("iframe_richtext.html");
    e.setFrameBorder(0); // removing frame border

    richTextPopup = new RichTextPopup(this);
    richTextPopup.setWidth("300px");
    richTextPopup.setHeight("50px");
    richTextPopup.setStyleName("okm-Popup");

    //Now lets fill the new toolbar with life
    buildTools();
}

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 ww  w.  j a v  a2s. c  o 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);
}