Example usage for com.google.gwt.user.client.ui HTML HTML

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

Introduction

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

Prototype

public HTML(String html, boolean wordWrap) 

Source Link

Document

Creates an HTML widget with the specified contents, optionally treating it as HTML, and optionally disabling word wrapping.

Usage

From source file:cc.alcina.framework.gwt.client.widget.FlowTabBar.java

License:Apache License

/**
 * Creates an empty tab bar.//w  w  w. ja v  a 2  s .c  om
 */
public FlowTabBar() {
    initWidget(panel2);
    sinkEvents(Event.ONCLICK);
    setStyleName("gwt-TabBar");
    // Add a11y role "tablist"
    Accessibility.setRole(panel2.getElement(), Accessibility.ROLE_TABLIST);
    // panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
    HTML first = new HTML(" ", true), rest = new HTML(" ", true);
    first.setStyleName("gwt-TabBarFirst");
    rest.setStyleName("gwt-TabBarRest");
    first.setHeight("100%");
    rest.setHeight("100%");
    first.setVisible(false);
    rest.setVisible(false);
    panel2.add(first);
    panel2.add(rest);
    first.setHeight("100%");
    // panel.setCellHeight(first, "100%");
    // panel.setCellWidth(rest, "100%");
}

From source file:com.appspot.socialinquirer.client.SocialInquirer.java

License:Apache License

public void onModuleLoad() {
    final EventBus eventBus = clientFactory.getEventBus();
    final PlaceController placeController = clientFactory.getPlaceController();
    final UserRpcServiceAsync userService = clientFactory.getUserService();
    final EverScribeConstants constants = clientFactory.getConstants();
    GWT.runAsync(new RunAsyncCallback() {
        public void onFailure(Throwable caught) {
            UiUtils.showErrorDialog(constants, constants.errorCodeDownloadFailed());
        }/* w  w w . j  a v  a 2s  .c  o  m*/

        public void onSuccess() {

            // Start ActivityManager for the main widget with our
            // ActivityMapper
            ActivityMapper activityMapper = new AppActivityMapper(clientFactory);
            ActivityManager activityManager = new ActivityManager(activityMapper, eventBus);
            // TODO-NM: Fix this.
            activityManager.setDisplay(appWidget);

            // Start PlaceHistoryHandler with our PlaceHistoryMapper
            final AppPlaceHistoryMapper historyMapper = GWT.create(AppPlaceHistoryMapper.class);
            final PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper);

            userService.getRandomQuote(new AsyncCallback<String>() {

                @Override
                public void onFailure(Throwable caught) {
                    RootPanel.get("quots").add(new HTML(
                            "<p>There is nothing more powerful than an idea whose time has come.</p>", true));
                }

                @Override
                public void onSuccess(String result) {
                    RootPanel.get("quots").add(new HTML("<p>" + result + "</p>", true));
                }
            });

            userService.getCurrentUser(new AsyncCallback<User>() {

                @Override
                public void onFailure(Throwable caught) {
                    MenuBar menu = createMenuBar(constants, null);

                    RootPanel.get("menu").add(menu);

                    RootPanel.get("content").add(appWidget);
                    // RootPanel.get("loginPanel").add(new HTML("<a
                    // href=\"/Auth?command=EvernoteAuth\"
                    // class=\"login\">Login with Evernote</a>"));

                    // handle exception;
                    historyHandler.register(placeController, eventBus, homePlace);
                    // Goes to place represented on URL or default place
                    historyHandler.handleCurrentHistory();
                }

                @Override
                public void onSuccess(User result) {
                    RootPanel.get("content").add(appWidget);

                    if (result != null) {
                        MenuBar menu = createMenuBar(constants, result);

                        RootPanel.get("menu").add(menu);
                        clientFactory.setUser(result);
                        historyHandler.register(placeController, eventBus, homePlace);
                    } else {
                        MenuBar menu = createMenuBar(constants, null);

                        RootPanel.get("menu").add(menu);
                        historyHandler.register(placeController, eventBus, homePlace);
                    }
                    // Goes to place represented on URL or default place
                    historyHandler.handleCurrentHistory();
                }
            });
        }
    });
    SearchUtils.loadSearchApi(new Runnable() {
        public void run() {
        }
    });
}

From source file:com.google.caliper.cloud.client.BenchmarkDataViewer.java

License:Apache License

public void rebuildResultsTable() {
    if (plainText) {
        Label label = new Label();
        label.setStyleName("plaintext");
        label.setText(gridToString(toGrid()));

        resultsDiv.clear();/*from   w w  w. ja v  a  2  s  .  co m*/
        resultsDiv.add(label);
        resultsDiv.add(new PlainTextEditor().getWidget());
        HTML dash = new HTML(" - ", false);
        dash.setStyleName("inline");
        resultsDiv.add(dash);
        resultsDiv.add(new SnapshotCreator().getWidget());
        return;
    }

    FlexTable table = new FlexTable();
    table.setStyleName("data");
    int r = 0;
    int c = 0;
    int evenRowMod = 0;

    // results header #1: cValue variables
    if (cVariable != null) {
        evenRowMod = 1;
        table.insertRow(r);
        table.getRowFormatter().setStyleName(r, "valueRow");
        table.getRowFormatter().addStyleName(r, "headerRow");

        table.addCell(r);
        table.getFlexCellFormatter().setColSpan(r, 0, rVariables.size());
        c++;
        for (Value cValue : cValues) {
            table.addCell(r);
            table.getFlexCellFormatter().setColSpan(r, c, 3);
            table.getCellFormatter().setStyleName(r, c, "parameterKey");

            Widget contents = newVariableLabel(cVariable, cValue.getLabel(), rVariables.size());
            contents.setStyleName("valueHeader");

            table.setWidget(r, c++, contents);
        }
        r++;
    }

    // results header 2: rValue variables, followed by "nanos/barchart" column pairs
    c = 0;
    table.insertRow(r);
    table.getRowFormatter().setStyleName(r, "evenRow");
    table.getRowFormatter().addStyleName(r, "headerRow");
    for (Variable variable : rVariables) {
        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c, newVariableLabel(variable, variable.getName(), c));
        c++;
    }
    for (Value unused : cValues) {
        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, newUnitLabel(unitMap.get(selectedType).trim()));

        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, newRuntimeLabel());

        table.addCell(r);
        table.getCellFormatter().setStyleName(r, c, "parameterKey");
        table.setWidget(r, c++, new InlineLabel("%"));
    }
    r++;

    Key key = newDefaultKey();
    for (RowsIterator rows = new RowsIterator(rVariables); rows.nextRow();) {
        rows.updateKey(key);

        table.insertRow(r);
        table.getRowFormatter().setStyleName(r, r % 2 == evenRowMod ? "evenRow" : "oddRow");
        c = 0;
        for (int v = 0, size = rVariables.size(); v < size; v++) {
            table.addCell(r);
            table.setWidget(r, c++, new Label(rows.getRValue(v).getLabel()));
        }

        for (Value value : cValues) {
            table.addCell(r);
            table.addCell(r);

            if (cVariable != null) {
                key.set(cVariable, value);
            }

            final Datapoint datapoint = keysToDatapoints.get(key);
            table.getCellFormatter().setStyleName(r, c, "numericCell");
            table.getCellFormatter().setStyleName(r, c + 1, "bar");
            table.getCellFormatter().setStyleName(r, c + 2, "numericCell");
            MeasurementSet measurementSet;
            if (datapoint != null
                    && (measurementSet = datapoint.scenarioResults.getMeasurementSet(selectedType)) != null) {
                double rawMedian = getMedian(selectedType, measurementSet);
                String displayedValue = numberFormatMap.get(selectedType)
                        .format(rawMedian / divideByMap.get(selectedType));
                Anchor valueAnchor = new Anchor(displayedValue, false);
                valueAnchor.setStyleName("subtleLink");
                valueAnchor.setStyleName("nanos", true);

                final DialogBox eventLogPopup = new DialogBox(true);
                eventLogPopup.setText("");

                valueAnchor.addClickHandler(new ClickHandler() {
                    public void onClick(ClickEvent clickEvent) {
                        // Do this lazily since it takes quite a bit of time to render these popups for all
                        // the scenarios shown, and quite often they won't even be used.
                        if (eventLogPopup.getText().isEmpty()) {
                            eventLogPopup.setText("Event Log");
                            String eventLog = datapoint.scenarioResults.getEventLog(selectedType);
                            if (eventLog == null || eventLog.isEmpty()) {
                                eventLog = "No event log recorded.";
                            }
                            FlowPanel panel = new FlowPanel();
                            for (String line : eventLog.split("\n")) {
                                panel.add(new Label(line));
                            }
                            panel.setStyleName("eventLog");
                            eventLogPopup.add(panel);
                        }
                        eventLogPopup.center();
                        eventLogPopup.show();
                    }
                });

                table.setWidget(r, c, valueAnchor);
                table.setWidget(r, c + 1, newBar(datapoint.style, measurementSet, value));
                table.setWidget(r, c + 2, newPercentOfReferencePointLabel(rawMedian, value));
            } else {
                table.setWidget(r, c, new Label(""));
                table.setWidget(r, c + 1, new Label(""));
                table.setWidget(r, c + 2, new Label(""));
            }
            c += 3;
        }

        r++;
    }
    resultsDiv.clear();
    resultsDiv.add(table);
    resultsDiv.add(new PlainTextEditor().getWidget());
    HTML dash = new HTML(" - ", false);
    dash.setStyleName("inline");
    resultsDiv.add(dash);
    resultsDiv.add(new SnapshotCreator().getWidget());
}

From source file:com.google.gwt.examples.HTMLExample.java

License:Apache License

public void onModuleLoad() {
    // Create a Label and an HTML widget.
    Label lbl = new Label("This is just text.  It will not be interpreted " + "as <html>.");

    HTML html = new HTML("This is <b>HTML</b>.  It will be interpreted as such if you specify "
            + "the <span style='font-family:fixed'>asHTML</span> flag.", true);

    // Add them to the root panel.
    VerticalPanel panel = new VerticalPanel();
    panel.add(lbl);/*from   w  w w  .j  a  va2  s  .  co  m*/
    panel.add(html);
    RootPanel.get().add(panel);
}