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

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

Introduction

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

Prototype

public void setSrc(@IsSafeUri String src) 

Source Link

Document

A URI designating the initial frame contents.

Usage

From source file:com.google.speedtracer.client.SourceViewer.java

License:Apache License

/**
 * Creates an instance of the SourceViewer and invokes the passed in callback
 * when the iFrame is loaded with the target source.
 * //from ww w.  ja  va2  s .  c o m
 * We first load the proxy html page. This proxy page uses cross site XHR
 * enabled by Chrome extensions to fetch and format the target source. Once
 * the target source is loaded, we consider the viewer initialized.
 * 
 * @param parent the parent container element we will attach the SourceViewer
 *          to.
 * @param resources the ClientBundle instance for this class.
 * @param initializedCallback the {@link SourceViewerInitializedCallback} that
 *          we pass the loaded SourceViewer to.
 */
public static void create(Element parent, final Resources resources,
        final SourceViewerInitializedCallback initializedCallback) {
    Document document = parent.getOwnerDocument();
    // Create the iframe within which we will load the source.
    final IFrameElement sourceFrame = document.createIFrameElement();
    Element frameWrapper = document.createDivElement();
    frameWrapper.setClassName(resources.sourceViewerCss().frameWrapper());
    frameWrapper.appendChild(sourceFrame);

    final Element baseElement = document.createDivElement();
    final Element headerElem = document.createDivElement();
    headerElem.setClassName(resources.sourceViewerCss().header());
    baseElement.appendChild(headerElem);

    // IFrame must be attached to fire onload.
    baseElement.appendChild(frameWrapper);
    parent.appendChild(baseElement);
    Event.addEventListener("load", sourceFrame, new EventListener() {
        public void handleEvent(Event event) {
            // The source fetcher should be loaded. Lets now point it at the source
            // we want to load.
            SourceViewer sourceViewer = new SourceViewer(baseElement, headerElem, sourceFrame, resources);
            initializedCallback.onSourceViewerInitialized(sourceViewer);
        }
    });

    sourceFrame.setSrc(Chrome.getExtension().getUrl("monitor/SourceFetcher.html"));
}

From source file:com.haulmont.cuba.web.toolkit.ui.client.downloader.CubaFileDownloaderConnector.java

License:Apache License

public void downloadFileById(String resourceId) {
    final String url = getResourceUrl(resourceId);
    if (url != null && !url.isEmpty()) {
        final IFrameElement iframe = Document.get().createIFrameElement();

        Style style = iframe.getStyle();
        style.setVisibility(Style.Visibility.HIDDEN);
        style.setHeight(0, Style.Unit.PX);
        style.setWidth(0, Style.Unit.PX);

        iframe.setFrameBorder(0);/*from  ww  w  .  ja  va 2 s  . c  o  m*/
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}

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;/*from w  w w .j av  a  2  s . com*/
    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.cruxframework.crux.core.client.screen.views.ViewHandlers.java

License:Apache License

/**
 * /*from  www .jav a  2 s .  c o m*/
 */
private static void prepareHistoryFrame() {
    if (!historyFrameInitialized) {
        Element body = RootPanel.getBodyElement();
        IFrameElement historyFrame = DOM.createIFrame().cast();
        historyFrame.setSrc("javascript:''");
        historyFrame.setId("__gwt_historyFrame");
        historyFrame.getStyle().setProperty("position", "absolute");
        historyFrame.getStyle().setProperty("width", "0");
        historyFrame.getStyle().setProperty("height", "0");
        historyFrame.getStyle().setProperty("border", "0");
        body.appendChild(historyFrame);
        History.fireCurrentHistoryState();
        historyFrameInitialized = true;
    }
}