Example usage for com.google.gwt.user.client.ui Frame wrap

List of usage examples for com.google.gwt.user.client.ui Frame wrap

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Frame wrap.

Prototype

public static Frame wrap(Element element) 

Source Link

Document

Creates a Frame widget that wraps an existing <frame> element.

Usage

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped */
public static Widget elementToWidget(Element e, String typ) {
    Widget result = null;//from ww  w .  j  a  v  a  2  s  . c  om
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:com.eduworks.gwt.client.pagebuilder.PageAssembler.java

License:Apache License

/** preserves event handlers on element to be wrapped  */
public static Widget elementToWidget(String elementName, String typ) {
    Widget result = null;//from w w w.j  a va 2  s . c o m
    Element e = DOM.getElementById(elementName);
    if (e != null) {
        int eventsSunk = DOM.getEventsSunk(e);
        EventListener el = DOM.getEventListener(e);
        if (typ == TEXT)
            result = TextBox.wrap(e);
        else if (typ == TEXT_AREA)
            result = TextArea.wrap(e);
        else if (typ == PASSWORD)
            result = PasswordTextBox.wrap(e);
        else if (typ == LABEL)
            result = Label.wrap(e);
        else if (typ == A)
            result = Anchor.wrap(e);
        else if (typ == SELECT)
            result = ListBox.wrap(e);
        else if (typ == IMAGE)
            result = Image.wrap(e);
        else if (typ == HIDDEN)
            result = Hidden.wrap(e);
        else if (typ == FILE)
            result = FileUpload.wrap(e);
        else if (typ == FORM)
            result = FormPanel.wrap(e, true);
        else if (typ == FRAME)
            result = Frame.wrap(e);
        else if (typ == SUBMIT)
            result = SubmitButton.wrap(e);
        else if (typ == BUTTON)
            result = Button.wrap(e);
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
        DOM.sinkEvents(e, eventsSunk);
        DOM.setEventListener(e, el);
    } else {
        if (typ == TEXT)
            result = new TextBox();
        else if (typ == TEXT_AREA)
            result = new TextArea();
        else if (typ == PASSWORD)
            result = new PasswordTextBox();
        else if (typ == LABEL)
            result = new Label();
        else if (typ == A)
            result = new Anchor();
        else if (typ == IMAGE)
            result = new Image();
        else if (typ == SELECT)
            result = new ListBox();
        else if (typ == HIDDEN)
            result = new Hidden();
        else if (typ == FILE)
            result = new FileUpload();
        else if (typ == FORM)
            result = new FormPanel();
        else if (typ == FRAME)
            result = new Frame();
        else if (typ == SUBMIT)
            result = new SubmitButton();
        else if (typ == BUTTON)
            result = new Button();
        else if (typ == CHECK_BOX)
            result = SimpleCheckBox.wrap(e);
    }
    return result;
}

From source file:org.nuxeo.opensocial.container.client.presenter.AppPresenter.java

License:Open Source License

@SuppressWarnings("unused")
private void resizeOpenSocialWebContent(String frameId, int height) {
    Element frame = getOpenSocialFrameById(frameId);
    if (frame != null) {
        Frame uiFrame = Frame.wrap(frame);
        uiFrame.setHeight(height + "px");
    }// ww w  .j  ava2s  .  com
}

From source file:org.nuxeo.opensocial.container.client.presenter.AppPresenter.java

License:Open Source License

@SuppressWarnings("unused")
private void refreshOpenSocialWebContent(String frameId) {
    Element frame = getOpenSocialFrameById(frameId);
    if (frame != null) {
        Frame uiFrame = Frame.wrap(frame);
        uiFrame.setUrl(uiFrame.getUrl());
    }/*from   w  w  w . ja  v  a 2s.  c o  m*/
}

From source file:org.pentaho.gwt.widgets.client.utils.FrameUtils.java

License:Open Source License

/**
 * Loops through all iframe object on the document. Used when reference to Frame is not available.
 * /*  w ww . ja v a2  s .c  o m*/
 * @param visible
 */
public static void toggleEmbedVisibility(boolean visible) {
    Element[] frames = new Element[0];
    try {
        frames = ElementUtils.getElementsByTagName("iframe"); //$NON-NLS-1$
    } catch (ClassCastException cce) {
        // ignore class cast exceptions in here, they are happening in hosted mode for Elements
        //ignore
    }
    for (Element ele : frames) {
        Frame f = null;

        // Attempt to find a previously GWT-wrapped frame instance in our timer collection
        Object[] tmap = timers.entrySet().toArray();
        for (int i = 0; i < tmap.length; i++) {
            @SuppressWarnings("unchecked")
            Map.Entry<Frame, FrameTimer> t = (Map.Entry<Frame, FrameTimer>) tmap[i];
            if (t.getKey().getElement() == ele) {
                // found an already wrapped instance
                f = t.getKey();
            }
        }

        if (f == null) {
            f = Frame.wrap(ele);
        }
        setEmbedVisibility(f, visible);
    }
}

From source file:ru.codeinside.gses.vaadin.client.VJsonFormIntegration.java

License:Mozilla Public License

private Frame createFrameWrap() {
    if (browserElement == null) {
        return null;
    }/*from   ww  w .ja  v  a2  s . c o  m*/
    Frame frameWrap = Frame.wrap(browserElement);
    frameWrap.addLoadHandler(new LoadHandler() {
        @Override
        public void onLoad(LoadEvent event) {
            Scheduler.get().scheduleFixedDelay(new Scheduler.RepeatingCommand() {
                @Override
                public boolean execute() {
                    IFrameElement formFrame = IFrameElement.as(browserElement);
                    Document formDoc = formFrame.getContentDocument();
                    if (formDoc == null) {
                        return true;
                    }
                    NodeList<com.google.gwt.dom.client.Element> elements;
                    elements = formDoc.getElementsByTagName("input");
                    for (int i = 0; i < elements.getLength(); i++) {
                        InputElement input = InputElement.as(elements.getItem(i));
                        if ("button".equalsIgnoreCase(input.getType())) {
                            input.setDisabled(true);
                        } else {
                            input.setReadOnly(true);
                        }
                    }
                    elements = formDoc.getElementsByTagName("button");
                    for (int i = 0; i < elements.getLength(); i++) {
                        ButtonElement button = ButtonElement.as(elements.getItem(i));
                        button.setDisabled(true);
                    }
                    elements = formDoc.getElementsByTagName("select");
                    for (int i = 0; i < elements.getLength(); i++) {
                        SelectElement select = SelectElement.as(elements.getItem(i));
                        select.setDisabled(true);
                    }
                    elements = formDoc.getElementsByTagName("textarea");
                    for (int i = 0; i < elements.getLength(); i++) {
                        TextAreaElement textArea = TextAreaElement.as(elements.getItem(i));
                        textArea.setReadOnly(true);
                    }
                    return false;
                }
            }, 99);
        }
    });
    return frameWrap;
}