Example usage for com.google.gwt.query.client.plugins.widgets WidgetsUtils replaceOrAppend

List of usage examples for com.google.gwt.query.client.plugins.widgets WidgetsUtils replaceOrAppend

Introduction

In this page you can find the example usage for com.google.gwt.query.client.plugins.widgets WidgetsUtils replaceOrAppend.

Prototype

private static void replaceOrAppend(Element oldElement, Element newElement) 

Source Link

Document

If the oldElement is a td, th, li tags, the new element will replaced its content.

Usage

From source file:gwtquery.plugins.enhance.client.gwt.ButtonWidgetFactory.java

License:Apache License

public Button create(Element e) {
    Button button = new Button();
    button.getElement().setInnerText(e.getInnerText());

    if ("button".equalsIgnoreCase(e.getTagName())) {
        copyAttributes((ButtonElement) e.cast(), (ButtonElement) button.getElement().cast());
    }/*from  w  w  w .  ja  v  a2s.c o m*/

    WidgetsUtils.replaceOrAppend(e, button);
    return button;
}

From source file:gwtquery.plugins.enhance.client.gwt.CheckBoxWidgetFactory.java

License:Apache License

public CheckBox create(Element e) {

    CheckBox checkBox = new CheckBox(e.getInnerText());
    if ("input".equalsIgnoreCase(e.getTagName())) {
        copyAttributes((InputElement) e.cast(), (InputElement) checkBox.getElement().cast());
    }/*from   w ww . j  a  v  a 2  s .  c  om*/
    WidgetsUtils.replaceOrAppend(e, checkBox);
    return checkBox;

}

From source file:gwtquery.plugins.enhance.client.gwt.DateBoxWidgetFactory.java

License:Apache License

public DateBox create(Element e) {
    String v = null;/* w  ww  .  j a  v a2s  . c  o m*/
    if ($(e).filter("input[type='text']").size() == 1) {
        v = GQuery.$(e).val();
    } else {
        v = GQuery.$(e).text();
    }
    if (v != null) {
        DateBox w = create(v);
        WidgetsUtils.replaceOrAppend(e, w);
        return w;
    }
    return null;
}

From source file:gwtquery.plugins.enhance.client.gwt.DecoratorPanelWidgetFactory.java

License:Apache License

public DecoratorPanel create(Element e) {

    DecoratorPanel decoratorPanel = new DecoratorPanel();

    WidgetsUtils.replaceOrAppend(e, decoratorPanel);

    decoratorPanel.add(new WidgetsHtmlPanel(e));

    return decoratorPanel;
}

From source file:gwtquery.plugins.enhance.client.gwt.DisclosurePanelWidgetFactory.java

License:Apache License

public DisclosurePanel create(Element e) {

    String headerValue = "";
    /*if (options.getHeaderTitle() != null){
      headerValue = options.getHeaderTitle();
    }else{*//*from w  w w  . j a  va  2  s. co m*/
    headerValue = $(options.getHeaderSelector(), e).first().remove().text();
    //}

    DisclosurePanel disclosurePanel = new DisclosurePanel();
    disclosurePanel.setHeader(new Label(headerValue));

    WidgetsUtils.replaceOrAppend(e, disclosurePanel);

    disclosurePanel.add(new WidgetsHtmlPanel(e));

    return disclosurePanel;
}

From source file:gwtquery.plugins.enhance.client.gwt.ListBoxWidgetFactory.java

License:Apache License

public ListBox create(Element e) {

    ListBox listBox = new ListBox(options.isMultipleSelect());
    if (WidgetsUtils.matchesTags(e, "select")) {
        copyAttributes((SelectElement) e.cast(), (SelectElement) listBox.getElement().cast());
    }/*ww  w  . j  a  v  a  2s .co  m*/

    GQuery itemsList = getItemsList(e);
    for (Element item : itemsList.elements()) {
        listBox.addItem(item.getInnerText());
    }

    WidgetsUtils.replaceOrAppend(e, listBox);
    return listBox;
}

From source file:gwtquery.plugins.enhance.client.gwt.RadioButtonWidgetFactory.java

License:Apache License

public RadioButton create(Element e) {
    resolveName(e);//from   www. j ava2s.  c o  m

    RadioButton radioButton = new RadioButton(radioName);
    if ("input".equalsIgnoreCase(e.getTagName())) {
        copyAttributes((InputElement) e, (InputElement) radioButton.getElement().cast());
    } else {
        radioButton.setText(e.getInnerText());
    }

    WidgetsUtils.replaceOrAppend(e, radioButton);

    return radioButton;

}

From source file:gwtquery.plugins.enhance.client.gwt.RichTextWidgetFactory.java

License:Apache License

public RichTextArea create(Element e) {
    String v = null;//from   w w w  .  j a v a2s  . co m
    if ("textarea".equalsIgnoreCase(e.getTagName())) {
        v = $(e).val();
    } else if (WidgetsUtils.matchesTags(e, "div", "span")) {
        v = $(e).html();
    }
    if (v != null) {
        RichTextArea w = create(v);
        WidgetsUtils.replaceOrAppend(e, w);
        return w;
    }
    return null;
}

From source file:gwtquery.plugins.enhance.client.gwt.StackPanelWidgetFactory.java

License:Apache License

public StackPanel create(Element e) {
    StackPanel stackPanel = options.isDecorated() ? new DecoratedStackPanel() : new StackPanel();

    WidgetsUtils.replaceOrAppend(e, stackPanel);

    GQuery contents = $(options.getContentSelector(), e);
    GQuery headers = $(options.getHeaderSelector(), e);

    for (int i = 0; i < contents.length(); i++) {
        Element content = contents.get(i);
        Element header = headers.get(i);

        Widget contentWidget = $(content).widget();
        if (contentWidget == null) {
            contentWidget = new WidgetsHtmlPanel(content);
        }/* w  w w  .jav  a  2  s .c om*/

        stackPanel.add(contentWidget, header != null ? header.getInnerText() : "Undefined");

    }

    return stackPanel;
}

From source file:gwtquery.plugins.enhance.client.gwt.SuggestBoxWidgetFactory.java

License:Apache License

public SuggestBox create(Element e) {

    SuggestOracle suggestOracle = createOracle(e);

    if ($(e).filter("input[type='text']").length() > 0) {
        return SuggestBox.wrap(suggestOracle, e);
    }//from   www. j av  a  2  s  .  c  o m

    SuggestBox sbox = new SuggestBox(suggestOracle);
    WidgetsUtils.replaceOrAppend(e, sbox);

    return sbox;
}