Example usage for com.google.gwt.user.client Element setInnerHTML

List of usage examples for com.google.gwt.user.client Element setInnerHTML

Introduction

In this page you can find the example usage for com.google.gwt.user.client Element setInnerHTML.

Prototype

@Override
    public void setInnerHTML(String html) 

Source Link

Usage

From source file:org.thechiselgroup.biomixer.client.visualization_component.timeline.TimeLineItem.java

License:Apache License

private void updateIconElement(String iconElementID) {
    Element element = DOM.getElementById(iconElementID);

    if (element == null) {
        return;/*from  www.j  av  a 2  s.  co m*/
    }

    element.setInnerHTML("<div style='background-color: " + getColor().toRGBa() + "; border-color: "
            + getBorderColor().toRGBa() + ";' class='" + CSS_RESOURCE_ITEM_ICON + "'></div>");
}

From source file:org.uberfire.client.plugin.RuntimePluginsServiceProxyClientImpl.java

License:Apache License

private void findAndFetchContent(final String relativeUri, final String filenameExtension,
        final String fileType, final ParameterizedCommand<Collection<String>> doWhenFinished) {
    RequestBuilder rb = new RequestBuilder(RequestBuilder.GET, relativeUri);
    try {/* ww  w.j  a v  a2  s  .co m*/
        rb.sendRequest(null, new RequestCallback() {

            @Override
            public void onResponseReceived(Request request, Response response) {
                final List<String> pluginUrls = new ArrayList<String>();
                final List<String> pluginContents = new ArrayList<String>();
                final int[] contentErrors = new int[1];

                Element detachedDiv = DOM.createDiv();
                detachedDiv.setInnerHTML(response.getText());
                NodeList<com.google.gwt.dom.client.Element> links = detachedDiv.getElementsByTagName("a");
                for (int i = 0; i < links.getLength(); i++) {
                    AnchorElement aElem = (AnchorElement) links.getItem(i);

                    // DOM spec says these are already absolutized for us. Nice!
                    String href = aElem.getHref();

                    if (href.endsWith(filenameExtension)) {
                        pluginUrls.add(href);
                    }
                }

                if (pluginUrls.size() == 0) {
                    doWhenFinished.execute(Collections.<String>emptyList());
                    return;
                }

                for (final String href : pluginUrls) {
                    RequestBuilder contentRb = new RequestBuilder(RequestBuilder.GET, href);
                    try {
                        contentRb.sendRequest(null, new RequestCallback() {

                            @Override
                            public void onResponseReceived(Request request, Response response) {
                                if (response.getStatusCode() == 200) {
                                    pluginContents.add(response.getText());
                                } else {
                                    contentErrors[0]++;
                                }
                                if (pluginContents.size() >= pluginUrls.size() + contentErrors[0]) {
                                    doWhenFinished.execute(pluginContents);
                                }
                            }

                            @Override
                            public void onError(Request request, Throwable exception) {
                                logger.warn("Error in " + fileType + " content request for " + href);
                                contentErrors[0]++;
                                if (pluginContents.size() >= pluginUrls.size() + contentErrors[0]) {
                                    doWhenFinished.execute(pluginContents);
                                }
                            }
                        });
                    } catch (RequestException ex) {
                        logger.warn("Failed to send request for " + fileType + " " + href, ex);
                        contentErrors[0]++;
                        if (pluginContents.size() >= pluginUrls.size() + contentErrors[0]) {
                            doWhenFinished.execute(pluginContents);
                        }
                    }
                }
            }

            @Override
            public void onError(Request request, Throwable ex) {
                logger.warn("Error in " + fileType + " list request. Not loading JS " + fileType + "s.", ex);
                doWhenFinished.execute(Collections.<String>emptyList());
            }
        });
    } catch (RequestException ex) {
        logger.warn("Couldn't load JS " + fileType + ". Continuing without runtime " + fileType + "s.", ex);
        doWhenFinished.execute(Collections.<String>emptyList());
    }
}

From source file:rocket.widget.client.ResizablePanel.java

License:Apache License

/**
 * Prepares one of the cells that belong to the grid that is used to create
 * and display the ResizablePanel.// ww  w  .j  a v a  2  s .com
 * 
 * @param row
 * @param column
 * @param styleName
 */
protected void prepareCell(final int row, final int column, final String styleName) {
    Checker.notNull("parameter:styleName", styleName);

    final Element element = this.getGrid().getCellFormatter().getElement(row, column);
    element.setClassName(styleName);

    element.setInnerHTML(" ");
}

From source file:sf.wicklet.gwt.site.home.client.WickletGwtSiteHome.java

License:Apache License

void wikiCommentPanel(final String href, final String html) {
    new GwtBuilder() {
        void build() {
            final IGwtComplexPanel top = templatepanel(html);
            final ComplexPanel rightpanel = rightPanel.asPanel();
            rightpanel.add(top);//from w ww.  ja va 2 s .c om
            final DomCache cache = new DomCache(top.asPanel().getElement(), "id", "name");
            final Element form = cache.byId(WID.commentForm);
            final UrlParts formaction = UrlParts.parse(form.getAttribute("action"));
            final IGwtTextBox subject = textbox(cache.by("name", WID.commentSubject).get(0));
            final IGwtTextArea comment = textarea(cache.by("name", WID.commentText).get(0));
            final IGwtTextBox captcha = textbox(cache.by("name", WID.commentCaptchaText).get(0));
            final FocusHandler clearmsg = new FocusHandler() {
                @Override
                public void onFocus(final FocusEvent event) {
                    GwtDomUtil.clear(DOM.getElementById(WID.commentFeedback.toString()));
                }
            };
            top.istyle("margin: 10px").c(form(form).onsubmit(new SubmitHandler() {
                @Override
                public void onSubmit(final SubmitEvent event) {
                    event.cancel();
                    WickletAjax.ajax(WickletGwtSiteUtil.getContextUrl("/wicket/page?" + formaction.getQuery()),
                            encode(subject.getText(), comment.getText(), captcha.getText()),
                            new XmlWickletAjaxCallback() {
                                @Override
                                public void onResponseReceived(final Request request, final Response response) {
                                    if (!GwtHttp.Status.isOK(response.getStatusCode())) {
                                        showError("ERROR: Invalid response: " + response.getText());
                                        return;
                                    }
                                    final String res = response.getText();
                                    final Document doc = XMLParser.parse(res);
                                    final com.google.gwt.xml.client.Element e = doc.getDocumentElement();
                                    final String tag = e.getNodeName();
                                    if ("success".equals(tag)) {
                                        rightpanel.remove(top);
                                        rightpanel.asWidget().getElement()
                                                .setInnerHTML(GwtXmlUtil.unescXml(GwtXmlUtil.getTextUnder(e)));
                                    } else if ("feedback".equals(tag)) {
                                        final Element o = DOM.getElementById(WID.commentFeedback.toString());
                                        final String text = GwtXmlUtil.unescTextUnder(e);
                                        o.setInnerHTML(text);
                                    } else {
                                        showError("ERROR: Invalid response: " + tag);
                                    }
                                }

                                @Override
                                public void onError(final Request request, final Throwable e) {
                                    CConf.debug("ERROR: Wiki comment failed: " + request, e);
                                    showError("ERROR: Wiki comment failed");
                                }
                            });
                }
            }), subject.onfocus(clearmsg), comment.onfocus(clearmsg),
                    image(cache.byId(WID.commentCaptchaImage)), captcha.onfocus(clearmsg),
                    button(cache.byId(WID.commentSubmit)));
        }

        String encode(final String subject, final String comment, final String captcha) {
            return "" + (WID.commentSubject + "=" + URL.encodeQueryString(subject))
                    + ("&" + WID.commentText + "=" + URL.encodeQueryString(comment))
                    + ("&" + WID.commentCaptchaText + "=" + URL.encodeQueryString(captcha));
        }
    }.build();
}

From source file:uk.ac.rdg.resc.godiva.client.widgets.DialogBoxWithCloseButton.java

License:Apache License

/**
 * Makes a new caption and replace the old one.
 * /*  ww  w .  j a  v a2s . com*/
 * @param txt
 * @param w
 */
private void setCaption(String txt, Widget w) {
    captionPanel.setWidth("100%");
    captionPanel.add(new HTML(txt));
    captionPanel.add(w);
    captionPanel.setCellHorizontalAlignment(w, HasHorizontalAlignment.ALIGN_RIGHT);
    // make sure that only when you click on this icon the widget will be
    // closed!, don't make the field too width
    captionPanel.setCellWidth(w, "1%");
    captionPanel.addStyleName("Caption");

    // Get the cell element that holds the caption
    Element td = getCellElement(0, 1);

    // Remove the old caption
    td.setInnerHTML("");

    // append our horizontal panel
    td.appendChild(captionPanel.getElement());
}

From source file:us.asciiroth.editor.client.Editor.java

License:Apache License

public void setBoardFilePath(String url) {
    this.boardFilePath = url;

    Element filePath = DOM.getElementById("filePath");
    filePath.setInnerHTML((url == null) ? "<em>&lt;Not Saved&gt;</em>" : url);
}

From source file:us.asciiroth.editor.client.Editor.java

License:Apache License

public void makeUpName() {
    if (namegen == null) {
        namegen = new NameGenerator();
    }/*from  w w w  . j  av  a 2  s.  c  o m*/
    Element el = DOM.getElementById("makeName");
    el.setInnerHTML(namegen.getName());
}