Java 类com.google.gwt.dom.client.IFrameElement 实例源码

项目:cuba    文件:CubaFileDownloaderConnector.java   
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);
        iframe.setTabIndex(-1);
        iframe.setSrc(url);
        RootPanel.getBodyElement().appendChild(iframe);

        Timer removeTimer = new Timer() {
            @Override
            public void run() {
                iframe.removeFromParent();
            }
        };
        removeTimer.schedule(60 * 1000);
    }
}
项目:Wiab.pro    文件:GadgetWidgetUi.java   
private void buildIFrame(String gadgetName, String width, String height) {
  gadgetIframe.getElement().setId(gadgetName);

  IFrameElement iframe = getIframeElement();
  iframe.setAttribute("vspace", "0");
  iframe.setAttribute("hspace", "0");
  iframe.setAttribute("frameBorder", "no");
  iframe.setAttribute("moduleId", gadgetName);
  iframe.setAttribute("display", "block");
  // TODO(user): scrolling policy/settings for the wave gadgets.
  iframe.setScrolling("no");

  //remove default style
  gadgetIframe.removeStyleName("gwt-Frame");
  gadgetIframe.addStyleName(CSS.gadgetIframe());

  if (width != null) {
    gadgetFrame.setWidth(width);
  }
  if (height != null) {
    gadgetFrame.setHeight(height);
  }

  iframeDiv.add(gadgetIframe);
}
项目:gwt-backbone    文件:History.java   
/**
 * Gets the true hash value. Cannot use location.hash directly due to bug
 * in Firefox where location.hash will always be decoded.
 *
 * @param iframe
 * @return
 */
public String getHash(IFrameElement iframe) {
    RegExp re = RegExp.compile("#(.*)$");
    String href = location.getHref();

    if(iframe != null) {
        href = getIFrameUrl(iframe);
    }

    MatchResult result = re.exec(href);
    return result != null && result.getGroupCount() > 1 ? result.getGroup(1) : "";
}
项目:gwt-backbone    文件:History.java   
private void updateHash(IFrameElement iFrame, String fragment, boolean replace) {
    if(replace) {
        String locationHref = location.getHref();
        if(iFrame != null) {
            locationHref = getIFrameUrl(iFrame);
        }

        String href = locationHref.replaceAll("(javascript:|#).*$", "");

        if(iFrame != null) {
            replaceFrameLocation(iFrame, href + '#' + fragment);
        } else {
            location.replace(href + '#' + fragment);
        }
    } else {
        // Some browsers require that `hash` contains a leading #.
        String hash = '#' + fragment;

        if(iFrame != null) {
            updateFrameLocationHash(iFrame, hash);
        } else {
            location.setHash(hash);
        }
    }
}
项目:sigmah    文件:HelpView.java   
/**
 * {@inheritDoc}
 */
@Override
public void initialize() {

    iframe = IFrameElement.as(DOM.createIFrame());

    final SimplePanel panel = new SimplePanel();
    panel.addStyleName(CSS_HELP_CONTENT);
    panel.getElement().appendChild(iframe);

    final ScrollPanel mainPanel = new ScrollPanel(panel);
    mainPanel.getElement().setId(ID_HELP);
    mainPanel.setAlwaysShowScrollBars(false);

    initPopup(mainPanel);

}
项目:Wiab.pro    文件:CajolerFacade.java   
private static IFrameElement createCajaFrame() {
  IFrameElement cajaFrame = Document.get().createIFrameElement();
  cajaFrame.setFrameBorder(0);
  cajaFrame.setAttribute("width", "0");
  cajaFrame.setAttribute("height", "0");
  Document.get().getBody().appendChild(cajaFrame);
  Document cajaFrameDoc = cajaFrame.getContentDocument();
  cajaFrameDoc.getBody().appendChild(
      cajaFrameDoc.createScriptElement(RESOURCES.supportingJs().getText()));
  cajaFrameDoc.getBody().appendChild(
      cajaFrameDoc.createScriptElement(RESOURCES.taming().getText()));
  return cajaFrame;
}
项目:wte4j    文件:TemplateUploadFormPanel.java   
private void initIFrame() {
    final Frame iframe = new Frame("javascript:\"\"");
    iframe.getElement().setAttribute("name", id);
    iframe.getElement().setAttribute("style", "position:absolute;width:0;height:0;border:0");
    iframe.addLoadHandler(new LoadHandler() {
        @Override
        public void onLoad(LoadEvent arg0) {
            String content = IFrameElement.as(iframe.getElement()).getContentDocument().getBody().getInnerHTML();
            if (content != null && !"".equals(content))
                formPanel.fireEvent(new SubmitCompleteEvent(content) {
                });
        }
    });
    flowPanel.add(iframe);
}
项目:dataworks-zeus    文件:DataxWidget.java   
private final native void fillIframe(IFrameElement iframe, String content) /*-{
  var doc = iframe.document;

  if(iframe.contentDocument)
    doc = iframe.contentDocument; // For NS6
  else if(iframe.contentWindow)
    doc = iframe.contentWindow.document; // For IE5.5 and IE6

   // Put the content in the iframe
  doc.open();
  doc.writeln(content);
  doc.close();
}-*/;
项目:dataworks-zeus    文件:HomeWidget.java   
private final native void fillIframe(IFrameElement iframe, String content) /*-{
  var doc = iframe.document;

  if(iframe.contentDocument)
    doc = iframe.contentDocument; // For NS6
  else if(iframe.contentWindow)
    doc = iframe.contentWindow.document; // For IE5.5 and IE6

   // Put the content in the iframe
  doc.open();
  doc.writeln(content);
  doc.close();
}-*/;
项目:dataworks-zeus    文件:UserWidget.java   
private final native void fillIframe(IFrameElement iframe, String content) /*-{
  var doc = iframe.document;

  if(iframe.contentDocument)
    doc = iframe.contentDocument; // For NS6
  else if(iframe.contentWindow)
    doc = iframe.contentWindow.document; // For IE5.5 and IE6

   // Put the content in the iframe
  doc.open();
  doc.writeln(content);
  doc.close();
}-*/;
项目:gwt-backbone    文件:History.java   
private native void applyFrameInitialHash(IFrameElement frame, String fragment) /*-{
    var body = document.body;

    // Using `appendChild` will throw on IE < 9 if the document is not ready.
    var iWindow = body.insertBefore(frame, body.firstChild).contentWindow;
    iWindow.document.open();
    iWindow.document.close();
    iWindow.location.hash = '#' + fragment;
}-*/;
项目:dom-distiller    文件:VimeoExtractor.java   
@Override
public WebEmbed extract(Element e) {
    if (e == null || !relevantTags.contains(e.getTagName())) {
        return null;
    }
    String src = IFrameElement.as(e).getSrc();
    if (!DomUtil.hasRootDomain(src, "player.vimeo.com")) {
        return null;
    }

    // Get specific attributes about the Vimeo embed.
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setHref(src);
    String path = anchor.getPropertyString("pathname");

    Map<String, String> paramMap =
            DomUtil.splitUrlParams(anchor.getPropertyString("search").substring(1));

    String id = getVimeoIdFromPath(path);
    if (id == null) {
        return null;
    }

    if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) {
        LogUtil.logToConsole("Vimeo embed extracted:");
        LogUtil.logToConsole("    ID:    " + id);
    }

    return new WebEmbed(e, "vimeo", id, paramMap);
}
项目:dom-distiller    文件:TwitterExtractor.java   
/**
 * 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.
 */
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);
}
项目:zeus3    文件:DataxWidget.java   
private final native void fillIframe(IFrameElement iframe, String content) /*-{
  var doc = iframe.document;

  if(iframe.contentDocument)
    doc = iframe.contentDocument; // For NS6
  else if(iframe.contentWindow)
    doc = iframe.contentWindow.document; // For IE5.5 and IE6

   // Put the content in the iframe
  doc.open();
  doc.writeln(content);
  doc.close();
}-*/;
项目:zeus3    文件:HomeWidget.java   
private final native void fillIframe(IFrameElement iframe, String content) /*-{
  var doc = iframe.document;

  if(iframe.contentDocument)
    doc = iframe.contentDocument; // For NS6
  else if(iframe.contentWindow)
    doc = iframe.contentWindow.document; // For IE5.5 and IE6

   // Put the content in the iframe
  doc.open();
  doc.writeln(content);
  doc.close();
}-*/;
项目:hexa.tools    文件:IFrame.java   
public IFrame( String url )
{
    Element iframe = DOM.createIFrame();
    iFrame = IFrameElement.as( iframe );

    setElement( iframe );

    setSrc( url );
}
项目:hexa.tools    文件:IFrame.java   
public IFrame()
{
    Element iframe = DOM.createIFrame();
    iFrame = IFrameElement.as( iframe );

    setElement( iframe );
}
项目:incubator-wave    文件:CajolerFacade.java   
private static IFrameElement createCajaFrame() {
  IFrameElement cajaFrame = Document.get().createIFrameElement();
  cajaFrame.setFrameBorder(0);
  cajaFrame.setAttribute("width", "0");
  cajaFrame.setAttribute("height", "0");
  Document.get().getBody().appendChild(cajaFrame);
  Document cajaFrameDoc = cajaFrame.getContentDocument();
  cajaFrameDoc.getBody().appendChild(
      cajaFrameDoc.createScriptElement(RESOURCES.supportingJs().getText()));
  cajaFrameDoc.getBody().appendChild(
      cajaFrameDoc.createScriptElement(RESOURCES.taming().getText()));
  return cajaFrame;
}
项目:incubator-wave    文件:GadgetWidgetUi.java   
private void buildIFrame(String gadgetName) {
  gadgetIframe.getElement().setId(gadgetName);

  int height = 0;
  switch (throbberState) {
    case SMALL:
      gadgetIframe.addStyleName(CSS.loadingGadgetSmallThrobber());
      height = Resources.RESOURCES.loadingGadgetSmall().getHeight();
      break;
    case LARGE:
      gadgetIframe.addStyleName(CSS.loadingGadgetLargeThrobber());
      height = Resources.RESOURCES.loadingGadgetLarge().getHeight();
      break;
  }

  IFrameElement iframe = getIframeElement();
  iframe.setAttribute("vspace", "0");
  iframe.setAttribute("hspace", "0");
  iframe.setAttribute("frameBorder", "no");
  iframe.setAttribute("moduleId", gadgetName);
  iframe.setAttribute("display", "block");
  iframe.setAttribute("height", height + "px");
  // TODO(user): scrolling policy/settings for the wave gadgets.
  iframe.setScrolling("no");

  //remove default style
  gadgetIframe.removeStyleName("gwt-Frame");
  gadgetIframe.addStyleName(CSS.gadgetIframe());

  iframeDiv.add(gadgetIframe);
}
项目:swarm    文件:InlineFrameSandbox.java   
private native boolean registerLocalApi_native(IFrameElement iframe, String apiNamespace)
/*-{
        function isSameDomain(iframe)
        {
            var html = null;
            try { 
              // deal with older browsers
              var doc = iframe.contentDocument || iframe.contentWindow.document;
              html = doc.body.innerHTML;
            } catch(err){
              // do nothing
            }

            return(html !== null);
        }

        if( isSameDomain(iframe) )
        {
            iframe.contentWindow.bh = $wnd.bh;
            iframe.contentWindow.alert = $wnd[apiNamespace+'_alert'];

            return true;
        }
        else
        {
            return false;
        }           
}-*/;
项目:gwtmockito    文件:GwtMockitoTest.java   
@Test
@SuppressWarnings("unused")
public void shouldAllowOnlyJavascriptCastsThatAreValidJavaCasts() {
  // Casts to ancestors should be legal
  JavaScriptObject o = Document.get().createDivElement().cast();
  Node n = Document.get().createDivElement().cast();
  DivElement d = Document.get().createDivElement().cast();

  // Casts to sibling elements shouldn't be legal (even though they are in javascript)
  try {
    IFrameElement i = Document.get().createDivElement().cast();
    fail("Exception not thrown");
  } catch (ClassCastException expected) {}
}
项目:document-management-system    文件:RichTextToolbar.java   
/** 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;
    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();
}
项目:walkaround    文件:UploadFormPopup.java   
/**
 * Gets a property of the iframe's window. Setting such properties is how the
 * iframe communicates back with this window.
 */
private static native String getFrameProperty(IFrameElement frame, String property)
/*-{
  return frame.contentWindow[property];
}-*/;
项目:Wiab.pro    文件:CajolerFacade.java   
private static CajolerFacade create() {
  IFrameElement cajaFrame = createCajaFrame();
  CajoleService service = new HttpCajoleService();
  return new CajolerFacade(service, cajaFrame);
}
项目:Wiab.pro    文件:CajolerFacade.java   
private CajolerFacade(CajoleService service, IFrameElement cajaFrame) {
  this.cajoleService = service;
  this.cajaFrame = cajaFrame;
}
项目:dataworks-zeus    文件:DataxWidget.java   
public void setContent(String html){
    fillIframe((IFrameElement)getElement().cast(), html);
}
项目:dataworks-zeus    文件:HomeWidget.java   
public void setContent(String html){
    fillIframe((IFrameElement)getElement().cast(), html);
}
项目:dataworks-zeus    文件:UserWidget.java   
public void setContent(String html){
    fillIframe((IFrameElement)getElement().cast(), html);
}
项目:gwt-backbone    文件:History.java   
private native void replaceFrameLocation(IFrameElement frame, String s) /*-{
    if(frame.contentWindow) {
        frame.contentWindow.location.replace(s);
    }
}-*/;
项目:gwt-backbone    文件:History.java   
private native void updateFrameLocationHash(IFrameElement frame, String hash) /*-{
    if(frame.contentWindow) {
        frame.contentWindow.location.hash = hash;
    }
}-*/;
项目:gwt-backbone    文件:History.java   
private native String openAndCloseIFrameDocument(IFrameElement frame) /*-{
    if(frame.document) {
        frame.document.open()
        frame.document.close();
    }
}-*/;
项目:gwt-backbone    文件:History.java   
private native String getIFrameUrl(IFrameElement frame) /*-{
    return frame.contentWindow !== undefined ? frame.contentWindow.location.href : "";
}-*/;
项目:dom-distiller    文件:YouTubeExtractor.java   
@Override
public WebEmbed extract(Element e) {
    if (e == null || !relevantTags.contains(e.getTagName())) {
        return null;
    }
    String src = null;
    if ("IFRAME".equals(e.getTagName())) {
        src = IFrameElement.as(e).getSrc();
    } else if ("OBJECT".equals(e.getTagName())) {
        // Deprecated way to embed youtube.
        // Ref: https://www.w3.org/blog/2008/09/howto-insert-youtube-video/
        //      http://xahlee.info/js/html_embed_video.html
        ObjectElement o = ObjectElement.as(e);
        if (o.getAttribute("type").equals("application/x-shockwave-flash")) {
            src = o.getAttribute("data");
        } else {
            NodeList<Element> params = DomUtil.querySelectorAll(e, "param[name=\"movie\"]");
            if (params.getLength() == 1) {
                src = params.getItem(0).getAttribute("value");
            }
        }
    }
    if (src == null) {
        return null;
    }
    if (!DomUtil.hasRootDomain(src, "youtube.com")) {
        return null;
    }

    // Get specific attributes about the YouTube embed.
    int paramLoc = src.indexOf("?");
    if (paramLoc < 0) {
        // Wrong syntax like "http://www.youtube.com/v/<video-id>&param=value" has been
        // observed in the wild. Youtube seems to be resilient.
        paramLoc = src.indexOf("&");
    }
    if (paramLoc < 0) {
        paramLoc = src.length();
    }
    String path = src.substring(0, paramLoc);

    Map<String, String> paramMap =
            DomUtil.splitUrlParams(src.substring(paramLoc + 1));

    String id = getYouTubeIdFromPath(path);
    if (id == null) {
        return null;
    }

    if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) {
        LogUtil.logToConsole("YouTube embed extracted:");
        LogUtil.logToConsole("    ID:    " + id);
    }

    return new WebEmbed(e, "youtube", id, paramMap);
}
项目:dom-distiller    文件:TestUtil.java   
public static IFrameElement createIframe() {
    return Document.get().createIFrameElement();
}
项目:dom-distiller    文件:EmbedExtractorTest.java   
public void testRenderedTwitterExtractor() {
    IFrameElement twitter = TestUtil.createIframe();
    // Add iframe to body so its document is generated.
    mBody.appendChild(twitter);

    // This string represents a very simplified version of the twitter iframe embed structure.
    String iframeStructure =
            "<div class=\"media-forward root standalone-tweet ltr\"" +
                "data-iframe-title=\"Embedded Tweet\"" +
                "data-scribe=\"page:tweet\">" +
                "<blockquote data-tweet-id=\"1234567890\"" +
                    "data-scribe=\"section:subject\">" +
                    "<div class=\"cards-base cards-multimedia customisable-border\"" +
                        "data-scribe=\"component:card\"" +
                        "data-video-content-id=\"0987654321\">" +
                    "</div>" +
                    "<div class=\"header\">" +
                    "</div>" +
                    "<div class=\"content\" data-scribe=\"component:tweet\">" +
                    "</div>" +
                    "<div class=\"footer\" data-scribe=\"component:footer\">" +
                    "</div>" +
                "</blockquote>" +
            "</div>";

    twitter.getContentDocument().getBody().setInnerHTML(iframeStructure);

    EmbedExtractor extractor = new TwitterExtractor();
    WebEmbed result = (WebEmbed) extractor.extract(twitter);

    // Check twitter specific attributes - namely twitter id
    assertNotNull(result);
    assertEquals("twitter", result.getType());
    assertEquals("1234567890", result.getId());

    // Begin negative test:
    IFrameElement notTwitter = TestUtil.createIframe();
    mBody.appendChild(notTwitter);
    notTwitter.getContentDocument().getBody().setInnerHTML(
            iframeStructure.replaceAll("blockquote", "div"));

    result = (WebEmbed) extractor.extract(notTwitter);
    assertNull(result);

    // Test no important twitter content.
    notTwitter = TestUtil.createIframe();
    mBody.appendChild(notTwitter);
    notTwitter.getContentDocument().getBody().setInnerHTML(
            iframeStructure.replaceAll("data-tweet-id", "data-bad-id"));

    result = (WebEmbed) extractor.extract(notTwitter);
    assertNull(result);
}
项目:zeus3    文件:DataxWidget.java   
public void setContent(String html){
    fillIframe((IFrameElement)getElement().cast(), html);
}
项目:zeus3    文件:HomeWidget.java   
public void setContent(String html){
    fillIframe((IFrameElement)getElement().cast(), html);
}