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

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

Introduction

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

Prototype

public Element getElementById(String id) 

Source Link

Document

Finds an Element element within this panel by its id.

Usage

From source file:com.gwtmodel.table.view.binder.impl.CreateBinderWidget.java

License:Apache License

private void buildWidget(Widget w, BinderWidget bw) {
    setWAttribute(w, bw);/* w  ww .j  a v  a  2s  .  c  o m*/
    if (bw.getwList().isEmpty())
        return;
    if (!(w instanceof HasWidgets))
        Utils.errAlertB(LogT.getT().BinderCannotHaveWidgets(bw.getType().name()));
    HTMLPanel h;
    HasWidgets hw;
    if (w instanceof HTMLPanel) {
        h = (HTMLPanel) w;
        hw = null;
    } else {
        hw = (HasWidgets) w;
        h = null;
    }

    bw.getwList().forEach(c -> {
        Widget child = constructEmptyWidget(c);
        buildWidget(child, c);
        Element ee = h.getElementById(c.getId());
        if (ee == null)
            Utils.errAlert(LogT.getT().BinderCannotFindWidget(c.getId()));

        if (h != null) {
            // String html = h.toString();
            try {
                h.addAndReplaceElement(child, ee);
            } catch (NoSuchElementException e) {
                Utils.errAlert(c.getId(), bw.getContentHtml(), e);
            }
        } else
            hw.add(child);
    });

}

From source file:com.gwtmodel.table.view.binder.impl.SetWidgetAttribute.java

License:Apache License

@Override
public void runAction(Widget w, String action, String param, HTMLPanel panel) {
    WidgetTypes wType = widgetToType(w);
    if (IConsts.WIDGETACTIONOPEN.equals(action)) {
        if (wType != WidgetTypes.PaperToast)
            Utils.errAlertB(widgetToType(w).toString(), LogT.getT().ActionSupportedOnlyForWidget(action,
                    WidgetTypes.PaperTab.name(), wType.name()));
        PaperToast p = (PaperToast) w;/*from  w  w w.  ja va 2s. c o  m*/
        p.open();
        return;
    }
    if (IAttrName.ATTRLISTENON.equals(action)) {
        if (wType != WidgetTypes.VaadinContextMenu)
            Utils.errAlertB(widgetToType(w).toString(), LogT.getT().ActionSupportedOnlyForWidget(action,
                    WidgetTypes.VaadinContextMenu.name(), wType.name()));
        Element e;
        Widget we = FormUtil.findWidgetByFieldId(panel, param);
        if (we != null)
            e = we.getElement();
        else
            e = panel.getElementById(param);
        if (e == null)
            Utils.errAlertB(LogT.getT().CannotFindElementForAction(action, param));
        VaadinContextMenu me = (VaadinContextMenu) w;
        me.setListenOn(e);
        return;
    }
    Utils.errAlertB(widgetToType(w).toString(),
            LogT.getT().InvalidWidgetAction(action, IConsts.WIDGETACTIONOPEN + " " + IAttrName.ATTRLISTENON));
}

From source file:com.gwtmodel.table.view.util.CreateFormView.java

License:Apache License

public static void setHtml(HTMLPanel pa, final List<FormField> fList, BinderWidget bw) {
    // TODO: debug only
    String h = pa.toString();//from www . j av  a2s .c  o m
    IEditWidget eFactory = EditWidgetFactory.getGwtE();
    IGetStandardMessage iMess = GwtGiniInjector.getI().getStandardMessage();
    IGetCustomValues c = GwtGiniInjector.getI().getCustomValues();
    boolean addId = CUtil.EqNS(c.getCustomValue(IGetCustomValues.HTMLPANELADDID), IGetCustomValues.VALUEYES);

    for (FormField d : fList) {
        String htmlId = d.getELine().getHtmlName();
        if (CUtil.EmptyS(htmlId)) {
            continue;
        }
        Widget w = d.getELine().getGWidget();
        // in case of label always visible
        if (d.getFormProp().isLabel())
            w.setVisible(true);

        replaceId(pa, htmlId, w, addId);
        if (d.getFormProp().isLabel())
            continue;

        String labelId = IConsts.LABELPREFIX + htmlId;
        if (pa.getElementById(labelId) != null) {
            IFormLineView v = eFactory.constructLabelField(d.getFie(), null, iMess.getMessage(d.getPLabel()));
            replace(pa, labelId, v.getGWidget());
        }

        String labelFor = IConsts.LABELFORPREFIX + htmlId;
        if (pa.getElementById(labelFor) != null) {
            IFormLineView v = eFactory.constructLabelFor(d.getFie(), null, iMess.getMessage(d.getPLabel()));
            replace(pa, labelFor, v.getGWidget());
        }

    }

    // try to replace widgets
    replaceBinder(pa, (id, w) -> {
        fList.stream().filter(f -> f.getELine().getV().getId().equals(id))
                .forEach(f -> f.getELine().replaceWidget(w));
    });

}

From source file:com.jythonui.client.dialog.util.StandardDialog.java

License:Apache License

static void dialog(IEventBus iBus, int a, String[] pars) {
    HTMLPanel ha = iBinder.create(M.getStandw()[a]);
    PaperDialog p = PolymerUtil.findPaperDialog(M.getBinders()[a], ha);
    Label header = (Label) PolymerUtil.findandverifyWidget(M.getBinders()[a], ha, "header", Label.class);
    String[] butt = null;// w w  w .j  ava2 s.  c o m
    switch (a) {
    case OKDIALOG:
        butt = new String[] { "ok" };
        break;
    case YESNODIALOG:
        butt = new String[] { "yes", "no" };
        break;
    }

    for (String b : butt) {
        PaperButton ok = (PaperButton) PolymerUtil.findandverifyWidget(M.getBinders()[a], ha, b,
                PaperButton.class);
        ok.getPolymerElement().addEventListener("click", event -> {
            if (!CUtil.EmptyS(pars[2]))
                iBus.publish(new StandardDialogEvent(), new StandardDialogResult(pars[2], b.equals("yes")));
            p.close();
        });

    }

    if (!CUtil.EmptyS(pars[1]))
        header.setText(pars[1]);
    Element e = ha.getElementById("content");
    assert e != null;
    e.removeAllChildren();
    HTML html = new HTML(pars[0]);
    e.insertFirst(html.getElement());
    popupDraw(p, ha, null);
}

From source file:com.palantir.gerrit.gerritci.ui.client.JobPanels.java

License:Apache License

public static HTMLPanel showJob(JenkinsJob j) {
    String name = j.getName();//from  w  ww.  ja  va2 s.c om
    HTMLPanel p = new HTMLPanel("");
    if (j.getType().equals("cron"))
        p = new HTMLPanel(GerritCiPlugin.cronPanel.toString());
    else if (j.getType().equals("publish"))
        p = new HTMLPanel(GerritCiPlugin.publishJobPanel.toString());
    else if (j.getType().equals("verify"))
        p = new HTMLPanel(GerritCiPlugin.verifyJobPanel.toString());
    else
        return null;
    TextBox jobName = new TextBox();
    jobName.setName("jobName");
    jobName.setText(name);
    jobName.setVisible(false);
    Label jobNameLabel = new Label("Job Id: " + name);
    p.addAndReplaceElement(jobNameLabel, "jobIdLabel");
    p.add(jobName);
    TextBox jobType = new TextBox();
    jobType.setName("jobType");
    jobType.setText(j.getType());
    jobType.setVisible(false);
    p.add(jobType);

    int numOfParams = j.getItems().length();

    for (int i = 0; i < numOfParams; i++) {
        JobParam jp = j.getItems().get(i);
        String field = jp.getField();
        String value = jp.getVal();
        if (field.endsWith("Enabled")) {
            CheckBox cb = new CheckBox();
            cb.setName(field);
            cb.setValue(Boolean.valueOf(value));
            if (p.getElementById(field) != null)
                p.addAndReplaceElement(cb, field);
            else {
                cb.setVisible(false);
                p.add(cb);
            }
        } else {
            TextBox tb = new TextBox();
            tb.setName(field);
            tb.setText(makeXMLReadeable(value));
            if (p.getElementById(field) != null)
                p.addAndReplaceElement(tb, field);
            else {
                tb.setVisible(false);
                p.add(tb);
            }
        }
    }
    p.setVisible(true);
    return p;
}

From source file:com.polymerui.client.binder.impl.CreateBinderWidget.java

License:Apache License

private void buildWidget(Widget w, BinderWidget bw) {
    setWAttribute(w, bw);/*from  ww w  . j  a v a 2s .  co m*/
    if (bw.getwList().isEmpty())
        return;
    if (!(w instanceof HasWidgets))
        Utils.errAlertB(M.M().BinderCannotHaveWidgets(bw.getType().name()));
    HTMLPanel h;
    HasWidgets hw;
    if (w instanceof HTMLPanel) {
        h = (HTMLPanel) w;
        hw = null;
    } else {
        hw = (HasWidgets) w;
        h = null;
    }

    bw.getwList().forEach(c -> {
        Widget child = constructEmptyWidget(c);
        buildWidget(child, c);
        Element ee = h.getElementById(c.getId());
        String html = h.toString();
        if (ee == null)
            Utils.errAlertB(M.M().BinderCannotFindWidget(c.getId()));

        if (h != null) {
            try {
                h.addAndReplaceElement(child, ee);
            } catch (NoSuchElementException e) {
                Utils.errAlert(c.getId(), bw.getContentHtml(), e);
            }
        } else
            hw.add(child);
    });

}

From source file:com.polymerui.client.binder.impl.SetWidgetAttribute.java

License:Apache License

@Override
public void runAction(Widget w, String action, String param, HTMLPanel panel) {
    WidgetTypes wType = widgetToType(w);
    if (IConsts.WIDGETACTIONOPEN.equals(action)) {
        if (wType != WidgetTypes.PaperToast)
            Utils.errAlertB(widgetToType(w).toString(),
                    M.M().ActionSupportedOnlyForWidget(action, WidgetTypes.PaperTab.name(), wType.name()));
        PaperToast p = (PaperToast) w;//from ww w  .  j ava 2s.  c o m
        p.open();
        return;
    }
    if (IAttrName.ATTRLISTENON.equals(action)) {
        if (wType != WidgetTypes.VaadinContextMenu)
            Utils.errAlertB(widgetToType(w).toString(), M.M().ActionSupportedOnlyForWidget(action,
                    WidgetTypes.VaadinContextMenu.name(), wType.name()));
        Element e;
        Widget we = PolymerUtil.findWidgetByFieldId(panel, param);
        if (we != null)
            e = we.getElement();
        else
            e = panel.getElementById(param);
        if (e == null)
            Utils.errAlertB(M.M().CannotFindElementForAction(action, param));
        VaadinContextMenu me = (VaadinContextMenu) w;
        me.setListenOn(e);
        return;
    }
    Utils.errAlertB(widgetToType(w).toString(),
            M.M().InvalidWidgetAction(action, IConsts.WIDGETACTIONOPEN + " " + IAttrName.ATTRLISTENON));
}

From source file:org.bonitasoft.forms.client.view.controller.FormPagesViewController.java

License:Open Source License

/**
 * Insert the widget in the page/*from  ww  w .  j av  a 2  s.  c  o  m*/
 *
 * @param pageHTMLPanel
 *            the HTMLPanel
 * @param formWidgetData
 *            the widget definition
 * @param widget
 *            the widget to insert
 * @param containerStyle
 *            the style to apply to the container
 */
protected void insertWidget(final HTMLPanel pageHTMLPanel, final ReducedFormWidget formWidgetData,
        final Widget widget, final String containerStyle) {
    if (formWidgetData.isDisplayCondition()) {
        final Element widgetParentElement = pageHTMLPanel.getElementById(formWidgetData.getId());
        final String widgetStyle;
        if (formWidgetData.getStyle() != null && formWidgetData.getStyle().length() > 0) {
            widgetStyle = containerStyle + " " + formWidgetData.getStyle();
        } else {
            widgetStyle = containerStyle;
        }
        if (widgetParentElement != null) {
            pageHTMLPanel.add(widget, widgetParentElement);
            widgetParentElement.addClassName(widgetStyle);
        } else {
            Window.alert(
                    "An element with id " + formWidgetData.getId() + " is missing from the page template.");
        }
    }
}

From source file:org.jboss.as.console.client.domain.topology.TopologyView.java

License:Open Source License

@Override
public void updateHosts(SortedSet<ServerGroup> groups, final int index) {
    // validation
    HtmlGenerator html = new HtmlGenerator();
    if (groups == null || groups.isEmpty()) {
        // no server/groups available ...
        Hint blank = new Hint("No server available!");
        container.clear();//from  w  ww. j av  a 2s.c o  m
        container.insert(blank, 0);
        return;
    }

    // initialization
    assignColors(groups);
    List<HostInfo> hosts = groups.first().getHosts();
    this.hostSize = hosts.size();
    this.visibleHosts = min(TopologyPresenter.VISIBLE_HOSTS_COLUMNS, hostSize);
    this.hostIndex = index;
    this.hostIndex = max(0, this.hostIndex);
    this.hostIndex = min(this.hostIndex, this.hostSize - 1);
    int endIndex = min(this.hostIndex + TopologyPresenter.VISIBLE_HOSTS_COLUMNS, hostSize);

    // start table and add columns
    html.startTable().appendHtmlConstant("<colgroup>");
    int columnWidth = HOSTS_COLUMNS / (endIndex - this.hostIndex);
    html.appendColumn(SERVER_GROUPS_COLUMN);
    for (int i = this.hostIndex; i < endIndex; i++) {
        html.appendColumn(columnWidth);
    }
    html.appendHtmlConstant("</colgroup>");

    // first row contains host names
    html.appendHtmlConstant(
            "<thead><tr><th class='cellTableHeader'>Hosts&nbsp;&rarr;<br/>Groups&nbsp;&darr;</th>");
    for (int i = this.hostIndex; i < endIndex; i++) {
        HostInfo host = hosts.get(i);
        html.appendHost(host);
    }
    html.appendHtmlConstant("</tr></thead>");

    // remaining rows contain server groups and server instances
    html.appendHtmlConstant("<tbody>");
    for (ServerGroup group : groups) {
        for (int serverIndex = 0; serverIndex < group.maxServersPerHost; serverIndex++) {
            html.appendHtmlConstant("<tr>");
            if (serverIndex == 0) {
                html.appendServerGroup(group);
            }
            for (int i = this.hostIndex; i < endIndex; i++) {
                HostInfo host = hosts.get(i);
                List<ServerInstance> servers = group.serversPerHost.get(host);
                if (servers.isEmpty() || serverIndex >= servers.size()) {
                    html.emptyCell();
                } else {
                    html.appendServer(group, host.getName(), servers.get(serverIndex));
                }
            }
            html.appendHtmlConstant("</tr>");
        }
    }
    html.appendHtmlConstant("</tbody>").endTable();

    // create html panel and register events
    HTMLPanel panel = html.createPanel();
    for (String id : html.getLifecycleIds()) {
        com.google.gwt.user.client.Element element = panel.getElementById(id);
        if (element != null) {
            DOM.setEventListener(element, lifecycleLinkListener);
            DOM.sinkEvents(element, ONCLICK);
        }
    }
    if (container.getWidgetCount() == 2) {
        container.remove(0);
    }
    {
        container.clear();
    }

    container.insert(panel, 0);

    container.add(pager);

    // update navigation
    RowCountChangeEvent.fire(display, hostSize, true);
}

From source file:org.kaaproject.kaa.sandbox.web.client.mvp.view.settings.ChangeKaaHostViewImpl.java

License:Apache License

@Override
protected void initCenterPanel() {

    VerticalPanel mainPanel = new VerticalPanel();
    mainPanel.getElement().getStyle().setWidth(75, Unit.PCT);

    CaptionPanel kaaHostPanel = new CaptionPanel(Utils.constants.kaaHostIp());
    kaaHostPanel.setWidth(FULL_WIDTH);//from ww w  .j  a  v  a  2  s .c  o  m
    kaaHostPanel.getElement().getStyle().setMarginBottom(20, Unit.PX);
    changeHostPanel = new FlexTable();
    changeHostPanel.setCellSpacing(10);
    changeHostPanel.getColumnFormatter().setWidth(0, "230px");
    changeHostPanel.getColumnFormatter().setWidth(1, "150px");
    changeHostPanel.getColumnFormatter().setWidth(2, FULL_WIDTH);
    int row = 0;

    String changeHostMessage = "<div>" + Utils.messages.changeKaaHostMessagePt1()
            + " <b><span id=ip></span></b>" + ".<br>" + Utils.messages.changeKaaHostMessagePt2() + "</div>";

    HTMLPanel changeKaaHostHtmlPanel = new HTMLPanel(changeHostMessage);
    ipSpan = changeKaaHostHtmlPanel.getElementById("ip");

    changeKaaHostHtmlPanel.addStyleName(Utils.sandboxStyle.descriptionLabel());
    changeKaaHostHtmlPanel.getElement().getStyle().setProperty("textAlign", "justify");
    changeKaaHostHtmlPanel.getElement().getStyle().setMarginBottom(20, Unit.PX);
    changeHostPanel.setWidget(row, 0, changeKaaHostHtmlPanel);
    changeHostPanel.getFlexCellFormatter().setColSpan(row++, 0, 3);
    kaaHost = new TextBox();
    kaaHost.setWidth("200px");
    kaaHost.getElement().getStyle().setMarginRight(20, Unit.PX);
    changeHostPanel.setWidget(row, 0, kaaHost);
    changeKaaHostButton = new Button(Utils.constants.update());
    changeHostPanel.setWidget(row, 1, changeKaaHostButton);

    kaaHostPanel.add(changeHostPanel);
    mainPanel.add(kaaHostPanel);

    CaptionPanel kaaLogsPanel = new CaptionPanel(Utils.constants.kaaServerLogs());
    kaaLogsPanel.setWidth(FULL_WIDTH);
    logsPanel = new FlexTable();
    logsPanel.setCellSpacing(10);
    logsPanel.getColumnFormatter().setWidth(0, "100px");
    logsPanel.getColumnFormatter().setWidth(1, "20px");
    logsPanel.getColumnFormatter().setWidth(2, "110px");
    logsPanel.getColumnFormatter().setWidth(3, "150px");
    logsPanel.getColumnFormatter().setWidth(4, FULL_WIDTH);

    row = 0;
    HTML getLogsLabel = new HTML(Utils.messages.logsMessage());
    getLogsLabel.addStyleName(Utils.sandboxStyle.descriptionLabel());
    getLogsLabel.getElement().getStyle().setProperty("textAlign", "justify");
    getLogsLabel.getElement().getStyle().setPaddingBottom(20, Style.Unit.PX);
    logsPanel.setWidget(row, 0, getLogsLabel);
    logsPanel.getFlexCellFormatter().setColSpan(row++, 0, 5);

    levelListBox = new ValueListBox<>();
    levelListBox.setWidth("100px");
    for (LogLevel level : LogLevel.values()) {
        levelListBox.setValue(level);
    }
    logsPanel.setWidget(row, 0, levelListBox);

    oldLogsCheckBox = new CheckBox();
    oldLogsCheckBox.setWidth("20px");
    oldLogsCheckBox.addStyleName(Utils.avroUiStyle.legendCheckBox());
    logsPanel.setWidget(row, 1, oldLogsCheckBox);

    HTML checkBoxLabel = new HTML(Utils.constants.cleanUpOldLogfiles());
    checkBoxLabel.addStyleName(Utils.avroUiStyle.legendCheckBox());
    checkBoxLabel.setWidth("90px");
    logsPanel.setWidget(row, 2, checkBoxLabel);

    changeLogLevelButton = new Button(Utils.constants.update());
    logsPanel.setWidget(row++, 3, changeLogLevelButton);

    getLogsButton = new Button(Utils.constants.downloadLogs());
    getLogsButton.getElement().getStyle().setMarginTop(20, Unit.PX);
    logsPanel.setWidget(row, 0, getLogsButton);
    logsPanel.getFlexCellFormatter().setColSpan(row, 0, 5);

    kaaLogsPanel.add(logsPanel);
    mainPanel.add(kaaLogsPanel);
    detailsPanel.add(mainPanel);
}