Example usage for com.google.gwt.user.client.ui InlineHTML setHTML

List of usage examples for com.google.gwt.user.client.ui InlineHTML setHTML

Introduction

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

Prototype

public void setHTML(String html) 

Source Link

Document

Sets the label's content to the given HTML.

Usage

From source file:ch.takoyaki.email.html.client.ui.generic.ClosableTabLayoutPanel.java

License:Open Source License

private void renameAction(final IsWidget content, final FlowPanel hpanel, final InlineHTML titlew,
        final Widget closeButton) {
    hpanel.clear();/*from  w  w  w. ja  v a2s.  com*/
    final TextBox tb = new TextBox();
    tb.addStyleName("tabrename");
    final String originalText = titlew.getText();
    tb.setText(originalText);

    tb.addKeyDownHandler(new KeyDownHandler() {

        @Override
        public void onKeyDown(KeyDownEvent event) {

            boolean enterPressed = KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode();
            boolean escapePressed = KeyCodes.KEY_ESCAPE == event.getNativeEvent().getKeyCode();

            if (enterPressed) {
                if (renameTabEventHandler != null) {
                    if (renameTabEventHandler.onRename(ClosableTabLayoutPanel.this,
                            getTab().getWidgetIndex(content), originalText, tb.getText())) {
                        titlew.setText(tb.getText());
                    } else {
                        titlew.setHTML(originalText);
                    }
                } else {
                    titlew.setText(tb.getText());
                }
            }
            if (escapePressed) {
                titlew.setHTML(originalText);
            }

            if (enterPressed || escapePressed) {
                hpanel.clear();
                hpanel.add(titlew);
                hpanel.add(closeButton);
            }
        }
    });
    hpanel.add(tb);
    tb.selectAll();
    titlew.setHTML("");
}

From source file:com.achow101.bctalkaccountpricer.client.Bitcointalk_Account_Pricer.java

License:Open Source License

/**
 * This is the entry point method./*w  ww  . j av  a  2s.co m*/
 */
public void onModuleLoad() {

    // Add Gui stuff      
    final Button sendButton = new Button("Estimate Price");
    final TextBox nameField = new TextBox();
    nameField.setText("User ID/Token");
    final Label errorLabel = new Label();
    final Label uidLabel = new Label();
    final Label usernameLabel = new Label();
    final Label postsLabel = new Label();
    final Label activityLabel = new Label();
    final Label potActivityLabel = new Label();
    final Label postQualityLabel = new Label();
    final Label trustLabel = new Label();
    final Label priceLabel = new Label();
    final Label loadingLabel = new Label();
    final Label tokenLabel = new Label();
    final InlineHTML estimateShareLabel = new InlineHTML();
    final InlineHTML reportTimeStamp = new InlineHTML();
    final RadioButton radioNormal = new RadioButton("merch", "Normal");
    final RadioButton radioMerchant = new RadioButton("merch", "Merchant");

    // We can add style names to widgets
    sendButton.addStyleName("sendButton");
    radioNormal.setValue(true);
    radioMerchant.setValue(false);

    // Add the nameField and sendButton to the RootPanel
    // Use RootPanel.get() to get the entire body element
    RootPanel.get("nameFieldContainer").add(nameField);
    RootPanel.get("sendButtonContainer").add(sendButton);
    RootPanel.get("errorLabelContainer").add(errorLabel);
    RootPanel.get("uidLabelContainer").add(uidLabel);
    RootPanel.get("usernameLabelContainer").add(usernameLabel);
    RootPanel.get("postsLabelContainer").add(postsLabel);
    RootPanel.get("activityLabelContainer").add(activityLabel);
    RootPanel.get("potActivityLabelContainer").add(potActivityLabel);
    RootPanel.get("postQualityLabelContainer").add(postQualityLabel);
    RootPanel.get("trustLabelContainer").add(trustLabel);
    RootPanel.get("priceLabelContainer").add(priceLabel);
    RootPanel.get("loadingLabelContainer").add(loadingLabel);
    RootPanel.get("tokenLabelContainer").add(tokenLabel);
    RootPanel.get("tokenShareLabelContainer").add(estimateShareLabel);
    RootPanel.get("radioNormalContainer").add(radioNormal);
    RootPanel.get("radioMerchantContainer").add(radioMerchant);
    RootPanel.get("reportTimeStamp").add(reportTimeStamp);

    // Create activity breakdown panel
    final VerticalPanel actPanel = new VerticalPanel();
    final FlexTable actTable = new FlexTable();
    actPanel.add(actTable);
    RootPanel.get("activityBreakdown").add(actPanel);

    // Create posts breakdown panel
    final VerticalPanel postsPanel = new VerticalPanel();
    final FlexTable postsTable = new FlexTable();
    postsPanel.add(postsTable);
    RootPanel.get("postsBreakdown").add(postsPanel);

    // Create addresses breakdown panel
    final VerticalPanel addrPanel = new VerticalPanel();
    final FlexTable addrTable = new FlexTable();
    postsPanel.add(addrTable);
    RootPanel.get("addrBreakdown").add(addrTable);

    // Focus the cursor on the name field when the app loads
    nameField.setFocus(true);
    nameField.selectAll();

    // Create a handler for the sendButton and nameField
    class MyHandler implements ClickHandler, KeyUpHandler {
        /**
         * Fired when the user clicks on the sendButton.
         */
        public void onClick(ClickEvent event) {

            // Add request to queue
            addToQueue();
        }

        /**
         * Fired when the user types in the nameField.
         */
        public void onKeyUp(KeyUpEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                addToQueue();
            }
        }

        // Adds the request to server queue
        private void addToQueue() {

            // Clear previous output
            uidLabel.setText("");
            usernameLabel.setText("");
            postsLabel.setText("");
            activityLabel.setText("");
            potActivityLabel.setText("");
            postQualityLabel.setText("");
            trustLabel.setText("");
            priceLabel.setText("");
            sendButton.setEnabled(false);
            errorLabel.setText("");
            loadingLabel.setText("");
            tokenLabel.setText("");
            estimateShareLabel.setText("");
            reportTimeStamp.setText("");
            actTable.removeAllRows();
            postsTable.removeAllRows();
            addrTable.removeAllRows();

            // Create and add request
            request = new QueueRequest();
            request.setMerchant(radioMerchant.getValue());
            if (nameField.getText().matches("^[0-9]+$"))
                request.setUid(Integer.parseInt(escapeHtml(nameField.getText())));
            else {
                request.setToken(escapeHtml(nameField.getText()));
                request.setOldReq();
            }

            final String urlPath = com.google.gwt.user.client.Window.Location.getPath();
            final String host = com.google.gwt.user.client.Window.Location.getHost();
            final String protocol = com.google.gwt.user.client.Window.Location.getProtocol();
            final String url = protocol + "//" + host + urlPath + "?token=";

            // Request check loop
            Timer requestTimer = new Timer() {
                public void run() {
                    // send request to server
                    pricingService.queueServer(request, new AsyncCallback<QueueRequest>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            errorLabel.setText("Request Queuing failed. Please try again.");
                            sendButton.setEnabled(true);
                            pricingService.removeRequest(request, null);
                            cancel();
                        }

                        @Override
                        public void onSuccess(QueueRequest result) {

                            if (result.getQueuePos() == -3) {
                                loadingLabel.setText(
                                        "Please wait for your previous request to finish and try again");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else if (result.getQueuePos() == -2) {
                                loadingLabel.setText("Please wait 2 minutes before requesting again.");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else if (result.getQueuePos() == -4) {
                                loadingLabel.setText("Invalid token");
                                sendButton.setEnabled(true);
                                cancel();
                            }

                            else {
                                tokenLabel.setText("Your token is " + result.getToken());
                                estimateShareLabel.setHTML("Share this estimate: <a href=\"" + url
                                        + result.getToken() + "\">" + url + result.getToken() + "</a>");
                                if (!result.isProcessing() && !result.isDone()) {
                                    loadingLabel.setText("Please wait. You are number " + result.getQueuePos()
                                            + " in the queue.");
                                }
                                if (result.isProcessing()) {
                                    loadingLabel.setText("Request is processing. Please wait.");
                                }
                                if (result.isDone()) {
                                    // Clear other messages
                                    errorLabel.setText("");
                                    loadingLabel.setText("");

                                    // Output results
                                    uidLabel.setText(result.getResult()[0]);
                                    usernameLabel.setText(result.getResult()[1]);
                                    postsLabel.setText(result.getResult()[2]);
                                    activityLabel.setText(result.getResult()[3]);
                                    potActivityLabel.setText(result.getResult()[4]);
                                    postQualityLabel.setText(result.getResult()[5]);
                                    trustLabel.setText(result.getResult()[6]);
                                    priceLabel.setText(result.getResult()[7]);
                                    int indexOfLastAct = 0;
                                    int startAddrIndex = 0;
                                    for (int i = 8; i < result.getResult().length; i++) {
                                        if (result.getResult()[i].equals("<b>Post Sections Breakdown</b>")) {
                                            indexOfLastAct = i;
                                            break;
                                        }
                                        actTable.setHTML(i - 8, 0, result.getResult()[i]);
                                    }
                                    for (int i = indexOfLastAct; i < result.getResult().length; i++) {
                                        if (result.getResult()[i]
                                                .contains("<b>Addresses posted in non-quoted text</b>")) {
                                            startAddrIndex = i;
                                            break;
                                        }
                                        postsTable.setHTML(i - indexOfLastAct, 0, result.getResult()[i]);
                                    }
                                    if (!result.isMerchant()) {
                                        for (int i = startAddrIndex; i < result.getResult().length; i++) {
                                            addrTable.setHTML(i - startAddrIndex, 0, result.getResult()[i]);
                                        }
                                    }

                                    // Set the right radio
                                    radioMerchant.setValue(result.isMerchant());
                                    radioNormal.setValue(!result.isMerchant());

                                    // Report the time stamp
                                    DateTimeFormat fmt = DateTimeFormat.getFormat("MMMM dd, yyyy, hh:mm:ss a");
                                    Date completedDate = new Date(1000L * result.getCompletedTime());
                                    Date expireDate = new Date(
                                            1000L * (result.getCompletedTime() + result.getExpirationTime()));
                                    reportTimeStamp
                                            .setHTML("<i>Report generated at " + fmt.format(completedDate)
                                                    + " and expires at " + fmt.format(expireDate) + "</i>");

                                    // Kill the timer after everything is done
                                    cancel();
                                }
                                request = result;
                                request.setPoll(true);
                                sendButton.setEnabled(true);
                            }
                        }
                    });
                }
            };
            requestTimer.scheduleRepeating(2000);

        }
    }

    // Add a handler to send the name to the server
    MyHandler handler = new MyHandler();
    sendButton.addClickHandler(handler);
    nameField.addKeyUpHandler(handler);

    // Check the URL for URL parameters
    String urlTokenParam = com.google.gwt.user.client.Window.Location.getParameter("token");
    if (!urlTokenParam.isEmpty()) {
        nameField.setText(urlTokenParam);
        handler.addToQueue();
    }
}

From source file:org.gatein.management.gadget.client.Application.java

License:Open Source License

/**
 * Create the user management content tab
 *
 * @return a {@code Widget} for the user management tab
 *///  www. ja v a2  s.co  m
private Widget getUserManagementTab() {
    AbsolutePanel userManagementPanel = new AbsolutePanel();
    userManagementPanel.setSize("855px", "304px");

    DecoratorPanel decoratorPanelEast = new DecoratorPanel();
    userManagementPanel.add(decoratorPanelEast, 0, 10);
    decoratorPanelEast.setSize("245px", "295px");

    AbsolutePanel absolutePanelEast = new AbsolutePanel();
    decoratorPanelEast.setWidget(absolutePanelEast);
    absolutePanelEast.setSize("235px", "285px");

    Label lblNewLabel = new Label("Enter a username :");
    lblNewLabel.setDirectionEstimator(true);
    absolutePanelEast.add(lblNewLabel, 10, 10);
    lblNewLabel.setSize("205px", "29px");

    final SuggestBox suggestBox = new SuggestBox(new RPCSuggestOracle());
    absolutePanelEast.add(suggestBox, 10, 45);
    suggestBox.setSize("210px", "21px");

    final InlineHTML userHeader = new InlineHTML("Select user");
    userHeader.setStyleName("header-style");
    final HTML userDetails = new HTML("No user selected", true);
    final Button exportBtn = new Button("Export site");

    Button showUserbtn = new Button("Show", new ClickHandler() {

        public void onClick(ClickEvent event) {
            String username = suggestBox.getValue();
            gtnService.getUserSite(getPortalContainerName(), username, new AsyncCallback<TreeNode>() {

                public void onFailure(Throwable caught) {
                    exportBtn.setEnabled(false);
                    userHeader.setHTML("Failed to access remote server");
                    userDetails.setHTML(caught.getMessage());
                }

                public void onSuccess(TreeNode node) {
                    if (node.isExportable()) {
                        exportBtn.setEnabled(true);
                        Application.this.exportHref = DOWNLOAD_ACTION_URL + "?pc=" + getPortalContainerName()
                                + "&ownerType=" + node.getType() + "&ownerId=" + node.getSiteName();
                    } else {
                        exportBtn.setEnabled(false);
                        Application.this.exportHref = "#";
                    }

                    userHeader.setHTML("&raquo; User site &raquo; " + node.getSiteName());
                    userDetails.setHTML(node.getNodeInfo());
                }
            });
        }
    });
    absolutePanelEast.add(showUserbtn, 69, 251);

    DecoratorPanel decoratorPanelCenter = new DecoratorPanel();
    userManagementPanel.add(decoratorPanelCenter, 251, 10);
    decoratorPanelCenter.setSize("584px", "295px");

    AbsolutePanel absolutePanelCenter = new AbsolutePanel();
    absolutePanelCenter.setSize("587px", "285px");
    decoratorPanelCenter.setWidget(absolutePanelCenter);

    exportBtn.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            frame.setUrl(exportHref);
        }
    });
    exportBtn.setEnabled(false);
    absolutePanelCenter.add(exportBtn, 10, 251);

    absolutePanelCenter.add(userHeader, 10, 10);
    userHeader.setSize("567px", "29px");

    absolutePanelCenter.add(userDetails, 10, 101);
    userDetails.setSize("567px", "144px");

    InlineHTML nlnhtmlNewInlinehtml = new InlineHTML("<hr />");
    absolutePanelCenter.add(nlnhtmlNewInlinehtml, 10, 45);
    nlnhtmlNewInlinehtml.setSize("567px", "2px");

    return userManagementPanel;
}

From source file:org.gwtopenmaps.demo.openlayers.client.examples.format.xml.XMLFormatExample.java

License:Apache License

@Override
public void buildPanel() {
    contentPanel.add(new HTML("Shows the use of the OpenLayers XML format class<br/>"
            + "OpenLayers has a very simple XML format class (OpenLayers.Format.XML) "
            + "that can be used to read/write XML docs. The methods available on the "
            + "XML format (or parser if you like) allow for reading and writing of "
            + "the various XML flavors used by the library - in particular the vector "
            + "data formats. It is by no means intended to be a full-fledged XML toolset. "
            + "Additional methods will be added only as needed elsewhere in the library.<br/>"
            + "This page loads an XML document and demonstrates a few of the methods available in the parser."));

    final Label outputValue = new Label();

    HorizontalPanel panel = new HorizontalPanel();

    Label statusLabel = new Label("Status : ");
    final InlineHTML statusLabelValue = new InlineHTML();
    statusLabelValue.setHTML("<strong>XML document loaded</strong>.");
    panel.add(statusLabel);/*from w ww  .  j  a  va  2  s. c  om*/
    panel.add(statusLabelValue);

    contentPanel.add(panel);

    contentPanel.add(new HTML("<p>After the XML document loads, see the result "
            + "of a few of the methods below. Assume that you start with the " + "following code: <br/>"
            + "var format = new OpenLayers.Format.XML();</p>" + "Sample methods"));

    VerticalPanel vp = new VerticalPanel();

    GwtOpenLayersULComponent uLComponent = new GwtOpenLayersULComponent();

    HorizontalPanel wp = new HorizontalPanel();
    Anchor write = new Anchor();
    write.setHTML("format.write()");
    wp.add(write);
    wp.add(new Label(" - write the XML doc as text"));
    write.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            outputValue.setText(xmlFormat.write(baseEl));
        }
    });

    uLComponent.add(wp);

    HorizontalPanel ebyTagNames = new HorizontalPanel();
    Anchor tagNames = new Anchor();
    tagNames.setHTML("format.getElementsByTagNameNS()");
    ebyTagNames.add(tagNames);
    ebyTagNames.add(new Label(" - get all gml:MultiPolygon"));
    tagNames.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            NodeList elements = xmlFormat.getElementsByTagNameNS(baseEl.getDocumentElement(),
                    "http://www.opengis.net/gml", "MultiPolygon");
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < elements.getLength(); i++) {
                builder.append(xmlFormat.write(elements.getItem(i)));
            }
            outputValue.setText(builder.toString());
        }
    });

    uLComponent.add(ebyTagNames);

    HorizontalPanel hasAttributePanel = new HorizontalPanel();
    Anchor hasAttAnchor = new Anchor();
    hasAttAnchor.setHTML("format.hasAttributeNS()");
    hasAttributePanel.add(hasAttAnchor);
    hasAttributePanel.add(new Label(" - test to see schemaLocation "
            + "attribute exists in the http://www.w3.org/2001/XMLSchema-instance namespace"));
    hasAttAnchor.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            outputValue.setText(String.valueOf(xmlFormat.hasAttributeNS(baseEl.getDocumentElement(),
                    "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation")));
        }
    });

    uLComponent.add(hasAttributePanel);

    vp.add(uLComponent);

    HorizontalPanel getAttrNodeNSPanel = new HorizontalPanel();
    Anchor getAttrNodeNSAnchor = new Anchor();
    getAttrNodeNSAnchor.setHTML("format.getAttributeNodeNS()");
    getAttrNodeNSPanel.add(getAttrNodeNSAnchor);
    getAttrNodeNSPanel.add(new Label(
            " - get schemaLocation attribute in " + "the http://www.w3.org/2001/XMLSchema-instance namespace"));
    getAttrNodeNSAnchor.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            Element e = xmlFormat.getAttributeNodeNS(baseEl.getDocumentElement(),
                    "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation");
            outputValue.setText(e.getNodeName() + " = " + e.getNodeValue());
        }
    });

    uLComponent.add(getAttrNodeNSPanel);

    HorizontalPanel getAttrNSHorizontalPanel = new HorizontalPanel();
    Anchor getAttrNSAnchor = new Anchor();
    getAttrNSAnchor.setHTML("format.getAttributeNS()");
    getAttrNSHorizontalPanel.add(getAttrNSAnchor);
    getAttrNSHorizontalPanel.add(new Label(" - get schemaLocation "
            + "attribute value in the http://www.w3.org/2001/" + "XMLSchema-instance namespace"));
    getAttrNSAnchor.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            outputValue.setText(xmlFormat.getAttributeNS(baseEl.getDocumentElement(),
                    "http://www.w3.org/2001/XMLSchema-instance", "schemaLocation"));
        }
    });

    uLComponent.add(getAttrNSHorizontalPanel);

    HorizontalPanel createElNSPanel = new HorizontalPanel();
    Anchor createElNSAnchor = new Anchor();
    createElNSAnchor.setHTML("format.createElementNS()");
    createElNSPanel.add(createElNSAnchor);
    createElNSPanel.add(new Label(" - create a foo:TestNode element" + " (and append it to the doc)"));
    createElNSAnchor.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            Element e = xmlFormat.createElementNS("http://bar.com/foo", "foo:TestNode");
            baseEl.getDocumentElement().appendChild(e);
            outputValue.setText(xmlFormat.write(baseEl));
        }
    });

    uLComponent.add(createElNSPanel);

    HorizontalPanel createTextNodePanel = new HorizontalPanel();
    Anchor createTextNodeAnchor = new Anchor();
    createTextNodeAnchor.setHTML("format.createTextNode()");
    createTextNodePanel.add(createTextNodeAnchor);
    createTextNodePanel.add(new Label(" - create a text node" + " (and append it to the doc)"));
    createTextNodeAnchor.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            Element e = xmlFormat.createTextNode("test text ");
            baseEl.getDocumentElement().appendChild(e);
            outputValue.setText(xmlFormat.write(baseEl));
        }
    });

    uLComponent.add(createTextNodePanel);

    contentPanel.add(vp);
    contentPanel.add(new InlineHTML("<strong>Output</strong> :"));
    contentPanel.add(outputValue);

    initWidget(contentPanel);
}