Example usage for com.google.gwt.user.client.ui HTMLPanel add

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

Introduction

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

Prototype

@Override
public void add(Widget widget) 

Source Link

Document

Adds a child widget to the panel.

Usage

From source file:org.rstudio.studio.client.rmarkdown.ui.RmdFloatOption.java

License:Open Source License

public RmdFloatOption(RmdTemplateFormatOption option, String initialValue) {
    super(option, initialValue);
    HTMLPanel panel = new HTMLPanel("");
    defaultValue_ = Float.parseFloat(option.getDefaultValue());
    panel.add(getOptionLabelWidget());
    txtValue_ = new NumericTextBox();
    if (initialValue.equals("null"))
        txtValue_.setValue(option.getDefaultValue());
    else/*from   www  .  ja v a  2  s .c o m*/
        txtValue_.setValue(initialValue);
    txtValue_.setWidth("40px");
    txtValue_.getElement().getStyle().setMarginLeft(5, Unit.PX);
    panel.add(txtValue_);

    updateNull();

    initWidget(panel);
}

From source file:org.rstudio.studio.client.rmarkdown.ui.RmdStringOption.java

License:Open Source License

public RmdStringOption(RmdTemplateFormatOption option, String initialValue) {
    super(option, initialValue);
    defaultValue_ = option.getDefaultValue();

    HTMLPanel panel = new HTMLPanel("");
    panel.add(getOptionLabelWidget());
    txtValue_ = new TextBox();
    if (!initialValue.equals("null"))
        txtValue_.setValue(initialValue);
    txtValue_.getElement().getStyle().setDisplay(Display.BLOCK);
    txtValue_.getElement().getStyle().setMarginLeft(20, Unit.PX);
    txtValue_.getElement().getStyle().setMarginTop(3, Unit.PX);
    txtValue_.setWidth("75%");
    panel.add(txtValue_);//  www  .  j  a v a 2 s  . c  om

    updateNull();
    initWidget(panel);
}

From source file:org.rstudio.studio.client.workbench.views.environment.view.EnvironmentObjects.java

License:Open Source License

private Widget buildEmptyGridMessage() {
    HTMLPanel messagePanel = new HTMLPanel("");
    messagePanel.setStyleName(style.emptyEnvironmentPanel());
    environmentEmptyMessage_ = new Label(EMPTY_ENVIRONMENT_MESSAGE);
    environmentEmptyMessage_.setStyleName(style.emptyEnvironmentMessage());
    messagePanel.add(environmentEmptyMessage_);
    return messagePanel;
}

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ChunkPlotWidget.java

License:Open Source License

public ChunkPlotWidget(String url, NotebookPlotMetadata metadata, final Command onRenderComplete,
        ChunkOutputSize chunkOutputSize) {
    plot_ = new Image();
    url_ = url;/*  w w w .  j a v  a  2 s .  c  om*/
    metadata_ = metadata;
    chunkOutputSize_ = chunkOutputSize;

    DOM.sinkEvents(plot_.getElement(), Event.ONLOAD);
    DOM.setEventListener(plot_.getElement(), new EventListener() {
        @Override
        public void onBrowserEvent(Event event) {
            if (DOM.eventGetType(event) != Event.ONLOAD)
                return;

            // if the image is of fixed size, just clamp its width to the
            // editor surface while preserving its aspect ratio
            if (isFixedSizePlotUrl(plot_.getUrl())) {
                ImageElementEx img = plot_.getElement().cast();
                img.getStyle().setProperty("height", "auto");
                img.getStyle().setProperty("maxWidth", "100%");
            }

            plot_.setVisible(true);
            if (onRenderComplete != null)
                onRenderComplete.execute();
        }
    });

    // start loading
    plot_.setUrl(url);
    Widget root = plot_;

    if (isFixedSizePlotUrl(url)) {
        if (chunkOutputSize_ == ChunkOutputSize.Full) {
            HTMLPanel panel = new HTMLPanel("");
            panel.add(plot_);
            host_ = panel;
            root = panel;
        } else {
            // if the plot is of fixed size, emit it directly, but make it
            // initially invisible until we get sizing information (as we may 
            // have to downsample)
            plot_.setVisible(false);
        }
    } else if (chunkOutputSize_ == ChunkOutputSize.Full) {
        HTMLPanel panel = new HTMLPanel("");

        panel.getElement().getStyle().setWidth(100, Unit.PCT);

        panel.getElement().getStyle().setProperty("display", "-ms-flexbox");
        panel.getElement().getStyle().setProperty("display", "-webkit-flex");
        panel.getElement().getStyle().setProperty("display", "flex");

        panel.getElement().getStyle().setProperty("msFlexGrow", "1");
        panel.getElement().getStyle().setProperty("webkitFlexGrow", "1");
        panel.getElement().getStyle().setProperty("flexGrow", "1");

        panel.getElement().getStyle().setProperty("backgroundImage", "url(\"" + url + "\")");
        panel.getElement().getStyle().setProperty("backgroundSize", "100% 100%");

        plotDiv_ = panel;
        host_ = panel;
        root = panel;
    } else {
        // if we can scale the plot, scale it
        FixedRatioWidget fixedFrame = new FixedRatioWidget(plot_, ChunkOutputUi.OUTPUT_ASPECT,
                ChunkOutputUi.MAX_PLOT_WIDTH);
        host_ = fixedFrame;
        root = fixedFrame;
    }

    // if there's metadata to display, further wrap the widget with it
    if (metadata != null && metadata.getConditions().length() > 0) {
        // otherwise, group with metadata
        HTMLPanel outer = new HTMLPanel("");
        conditions_ = new ChunkConditionBar(metadata.getConditions(), chunkOutputSize_);
        conditions_.onEditorThemeChanged(ChunkOutputWidget.getEditorColors());
        outer.add(conditions_);
        outer.add(root);
        outer.setWidth("100%");

        if (chunkOutputSize_ == ChunkOutputSize.Full) {
            outer.getElement().getStyle().setProperty("display", "-ms-flexbox");
            outer.getElement().getStyle().setProperty("display", "-webkit-flex");
            outer.getElement().getStyle().setProperty("display", "flex");

            outer.getElement().getStyle().setProperty("msFlexDirection", "column");
            outer.getElement().getStyle().setProperty("webkitFlexDirection", "column");
            outer.getElement().getStyle().setProperty("flexDirection", "column");

            outer.getElement().getStyle().setProperty("msFlexGrow", "1");
            outer.getElement().getStyle().setProperty("webkitFlexGrow", "1");
            outer.getElement().getStyle().setProperty("flexGrow", "1");
        } else {
            outer.setHeight("100%");
        }

        root = outer;
    }

    initWidget(root);
}

From source file:org.rstudio.studio.client.workbench.views.source.editors.text.ui.NewRMarkdownDialog.java

License:Open Source License

private Widget createFormatOption(String name, String description) {
    HTMLPanel formatWrapper = new HTMLPanel("");
    formatWrapper.setStyleName(style.outputFormat());
    SafeHtmlBuilder sb = new SafeHtmlBuilder();
    sb.appendHtmlConstant("<span class=\"" + style.outputFormatName() + "\">");
    sb.appendEscaped(name);/*w ww  .  j a  v a 2 s.co  m*/
    sb.appendHtmlConstant("</span>");
    RadioButton button = new RadioButton("DefaultOutputFormat", sb.toSafeHtml().asString(), true);
    button.addStyleName(style.outputFormatChoice());
    formatOptions_.add(button);
    formatWrapper.add(button);
    Label label = new Label(description);
    label.setStyleName(style.outputFormatDetails());
    formatWrapper.add(label);
    return formatWrapper;
}

From source file:org.silverpeas.mobile.client.apps.contacts.pages.widgets.ContactItem.java

License:Open Source License

public void setData(DetailUserDTO userData) {
    if (userData.getAvatar().isEmpty()) {
        Image avatar = new Image(resources.avatar());
        avatar.getElement().removeAttribute("height");
        avatar.getElement().removeAttribute("width");
        user.add(avatar);// w w  w .ja v  a  2s.  com
    } else {
        user.add(new Image(userData.getAvatar()));
    }
    String html = userData.getFirstName() + " " + userData.getLastName() + " <span class='status'>"
            + userData.getStatus() + "</span>";
    if (userData.getConnected())
        html += "<span class='connected'></span>";
    user.add(new HTML(html));
    mail.setText(userData.geteMail());
    if (userData.geteMail() == null || userData.geteMail().isEmpty()) {
        mail.setHTML("&nbsp");
    }
    mail.setHref("mailto:" + userData.geteMail());

    int nbTel = 0;
    if (userData.getPhoneNumber() != null && !userData.getPhoneNumber().isEmpty()) {
        Anchor tel1 = new Anchor();
        tel1.setStyleName("tel-link");
        tel1.setText(userData.getPhoneNumber());
        tel1.setHref("tel:" + userData.getPhoneNumber());
        tel.add(tel1);
        nbTel++;
    }
    if (userData.getCellularPhoneNumber() != null && !userData.getCellularPhoneNumber().isEmpty()) {
        if (nbTel == 1) {
            tel.add(new InlineHTML(" | "));
        }
        Anchor tel2 = new Anchor();
        tel2.setStyleName("tel-link");
        tel2.setText(userData.getCellularPhoneNumber());
        tel2.setHref("tel:" + userData.getCellularPhoneNumber());
        tel.add(tel2);

        Anchor sms = new Anchor();
        sms.setHref("sms:" + userData.getCellularPhoneNumber());
        Image smsImg = new Image(resourcesContact.sms());
        sms.getElement().appendChild(smsImg.getElement());
        tel.add(sms);

        nbTel++;
    }
    if (userData.getFaxPhoneNumber() != null && !userData.getFaxPhoneNumber().isEmpty()) {
        if (nbTel == 2) {
            tel.add(new InlineHTML(" | "));
        }
        Anchor tel3 = new Anchor();
        tel3.setStyleName("tel-link");
        tel3.setText(userData.getFaxPhoneNumber());
        tel3.setHref("tel:" + userData.getFaxPhoneNumber());
        tel.add(tel3);
        nbTel++;
    }
    if (nbTel == 0) {
        tel.add(new InlineHTML("&nbsp;"));
    }

    for (String prop : userData.getProperties()) {

        String value = userData.getPropertieValue(prop);
        if (isPhoneNumber(value)) {
            HTMLPanel field = new HTMLPanel("");
            Anchor tel = new Anchor();
            tel.setStyleName("tel-link");
            tel.setText(value);
            tel.setHref("tel:" + value);
            field.add(tel);

            Anchor sms = new Anchor();
            sms.setHref("sms:" + userData.getCellularPhoneNumber());
            Image smsImg = new Image(resourcesContact.sms());
            sms.getElement().appendChild(smsImg.getElement());
            field.add(sms);

            container.add(field);
        } else {
            HTML field = new HTML(value);
            container.add(field);
        }
    }
}

From source file:org.zanata.webtrans.client.view.SourceContentsView.java

License:Open Source License

private DisclosurePanel getUrlWidget() {
    DisclosurePanel widget = new DisclosurePanel();
    widget.setAnimationEnabled(true);//from w  w w. j a va 2  s  .  c  o  m

    HTMLPanel header = new HTMLPanel("div", "");
    header.setStyleName("button button--small");
    header.add(new InlineHTML("<i class='i i--star l--push-right-quarter'/>"));
    header.add(new InlineLabel("Link"));
    widget.setHeader(header);

    urlTextField = new TextBox();
    urlTextField.setReadOnly(true);

    HTMLPanel content = new HTMLPanel("div", "");
    content.setStyleName("bg--pop-highest txt--meta");
    content.add(urlTextField);
    widget.setContent(content);

    widget.getHeader().getParent().setStyleName("");
    return widget;
}