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

public void add(Widget widget, String id) 

Source Link

Document

Adds a child widget to the panel, contained within the HTML element specified by a given id.

Usage

From source file:org.spiffyui.hellospiffyauth.client.Index.java

License:Apache License

@Override
public void onModuleLoad() {
    /*// w  ww  .  j  a v a  2s.  c o  m
    This is where we load our module and create our dynamic controls.  The MainHeader
    displays our title bar at the top of our page.
     */
    final MainHeader header = new MainHeader();
    header.setHeaderTitle("Hello Spiffy Auth!");
    Anchor logout = new Anchor("Logout", "#");
    logout.getElement().setId("header_logout");
    header.setLogout(logout);
    if (!Index.userLoggedIn()) {
        logout.setVisible(false);
        header.setWelcomeString("");
    } else {
        /*
         * The SampleAuthServer combines the username and a UUID as the token
         */
        String token = RESTility.getUserToken();
        JSUtil.println(RESTility.getUsername());
        String name = token.substring(0, token.indexOf('-'));

        header.setWelcomeString("Welcome " + name);
    }
    logout.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            event.preventDefault();
            doLogout();
        }
    });
    /*
    The main footer shows our message at the bottom of the page.
     */
    MainFooter footer = new MainFooter();
    footer.setFooterString(
            "HelloSpiffyAuth was built with the <a href=\"http://www.spiffyui.org\">Spiffy UI Framework</a>");

    /*
    This HTMLPanel holds most of our content.
    MainPanel_html was built in the HTMLProps task from MainPanel.html, which allows you to use large passages of html
    without having to string escape them.
     */
    HTMLPanel panel = new HTMLPanel(STRINGS.MainPanel_html()) {
        @Override
        public void onLoad() {
            super.onLoad();
            /*
            Let's set focus into the text field when the page first loads
             */
            m_text.setFocus(true);
        }
    };

    RootPanel.get("mainContent").add(panel);

    /*
    These dynamic controls add interactivity to our page.
     */
    panel.add(m_longMessage, "longMsg");
    panel.add(m_text, "nameField");
    final Button button = new Button("Submit");
    panel.add(button, "submitButton");

    button.addClickHandler(this);
    m_text.addKeyPressHandler(this);

    RESTility.addLoginListener(new RESTLoginCallBack() {

        @Override
        public void onLoginSuccess() {
            if (RESTility.getUserToken() == null) {
                return;
            }
            header.setWelcomeString("Welcome " + RESTility.getUsername());
            JSUtil.bounce("#" + MainHeader.HEADER_ACTIONS_BLOCK, 5, 500, 30);
            JSUtil.show("#header_logout", "fast");
        }

        @Override
        public void loginPrompt() {
            //do nothing
        }
    });
}

From source file:org.spiffyui.hellospiffygradle.client.Index.java

License:Apache License

@Override
public void onModuleLoad() {
    /*//from   w w  w.  ja  v  a2  s  .  co m
     This is where we load our module and create our dynamic controls.  The MainHeader
     displays our title bar at the top of our page.
     */
    MainHeader header = new MainHeader();
    header.setHeaderTitle("Hello Spiffy Gradle!");

    /*
     The main footer shows our message at the bottom of the page.
     */
    MainFooter footer = new MainFooter();
    footer.setFooterString(
            "Hello Spiffy Gradle was built with the <a href=\"http://www.spiffyui.org\">Spiffy UI Framework</a>");

    /*
     This HTMLPanel holds most of our content.
     MainPanel_html was built in the HTMLProps task from MainPanel.html, which allows you to use large passages of html
     without having to string escape them.
     */
    HTMLPanel panel = new HTMLPanel(STRINGS.MainPanel_html()) {
        @Override
        public void onLoad() {
            super.onLoad();
            /*
             Let's set focus into the text field when the page first loads
             */
            m_text.setFocus(true);
        }
    };

    RootPanel.get("mainContent").add(panel);

    /*
     These dynamic controls add interactivity to our page.
     */
    panel.add(m_longMessage, "longMsg");
    m_text.getElement().setAttribute("autoFocus", "");
    panel.add(m_text, "nameField");
    final Button button = new Button("Submit");
    panel.add(button, "submitButton");

    button.addClickHandler(this);
    m_text.addKeyPressHandler(this);

}

From source file:org.spiffyui.hellospiffylocalization.client.Index.java

License:Apache License

@Override
public void onModuleLoad() {
    /*/*ww  w  .  j av  a  2  s  .  c  o  m*/
     We need to set the title from a localized string
     */
    Window.setTitle(PROJ_STRINGS.hello());

    /*
     This is where we load our module and create our dynamic controls.  The MainHeader
     displays our title bar at the top of our page.
     */
    MainHeader header = new MainHeader();
    header.setHeaderTitle(PROJ_STRINGS.hello());

    /*
     The main footer shows our message at the bottom of the page.
     */
    MainFooter footer = new MainFooter();
    footer.setFooterString(PROJ_STRINGS.footer());

    /*
     This HTMLPanel holds most of our content.
     MainPanel_html was built in the HTMLProps task from MainPanel.html, which allows you to use large passages of html
     without having to string escape them.
     */
    HTMLPanel panel = new HTMLPanel(STRINGS.MainPanel_html()) {
        @Override
        public void onLoad() {
            super.onLoad();
            /*
             Let's set focus into the text field when the page first loads
             */
            m_text.setFocus(true);
        }
    };

    RootPanel.get("mainContent").add(panel);

    /*
     These dynamic controls add interactivity to our page.
     */
    panel.add(m_longMessage, "longMsg");
    panel.add(m_text, "nameField");
    final Button button = new Button(PROJ_STRINGS.submit());
    panel.add(button, "submitButton");

    button.addClickHandler(this);
    m_text.addKeyPressHandler(this);

}

From source file:org.spiffyui.hellospiffymavenplugin.client.Index.java

License:Apache License

@Override
public void onModuleLoad() {
    /*/*  www .j  a  va  2 s. co  m*/
     This is where we load our module and create our dynamic controls.  The MainHeader
     displays our title bar at the top of our page.
     */
    MainHeader header = new MainHeader();
    header.setHeaderTitle("Hello Spiffy HelloSpiffyMavenPlugin!");

    /*
     The main footer shows our message at the bottom of the page.
     */
    MainFooter footer = new MainFooter();
    footer.setFooterString(
            "HelloSpiffyMavenPlugin was built with the <a href=\"http://www.spiffyui.org\">Spiffy UI Framework</a>");

    /*
     This HTMLPanel holds most of our content.
     MainPanel_html was built in the HTMLProps task from MainPanel.html, which allows you to use large passages of html
     without having to string escape them.
     */
    HTMLPanel panel = new HTMLPanel(STRINGS.MainPanel_html()) {
        @Override
        public void onLoad() {
            super.onLoad();
            /*
             Let's set focus into the text field when the page first loads
             */
            m_text.setFocus(true);
        }
    };

    RootPanel.get("mainContent").add(panel);

    /*
     These dynamic controls add interactivity to our page.
     */
    panel.add(m_longMessage, "longMsg");
    panel.add(m_text, "nameField");
    final Button button = new Button("Submit");
    panel.add(button, "submitButton");

    button.addClickHandler(this);
    m_text.addKeyPressHandler(this);

}

From source file:org.spiffyui.hellospiffyoauth.client.Index.java

License:Apache License

@Override
public void onModuleLoad() {
    /*/*www  .  j a v  a2s  .  c  om*/
    This is where we load our module and create our dynamic controls.  The MainHeader
    displays our title bar at the top of our page.
     */
    final MainHeader header = new MainHeader();
    header.setHeaderTitle("Hello Spiffy OAuth!");
    /*
    The main footer shows our message at the bottom of the page.
     */
    MainFooter footer = new MainFooter();
    footer.setFooterString(
            "HelloSpiffyOAuth was built with the <a href=\"http://www.spiffyui.org\">Spiffy UI Framework</a>");

    HTMLPanel panel = new HTMLPanel(STRINGS.MainPanel_html());

    RootPanel.get("mainContent").add(panel);

    /*
    Add the auth and contact buttons
     */

    panel.add(m_accessButton, "AuthButton");
    m_accessButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            requestAccess();
        }
    });

    panel.add(m_contactsButton, "GetButton");
    m_contactsButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            getContacts();
        }
    });

    if (!userLoggedIn()) {
        header.setWelcomeString("");
        m_accessButton.setFocus(true);
        m_contactsButton.setEnabled(false);
    } else {
        header.setWelcomeString("You have a token!");
        m_contactsButton.setEnabled(true);
        m_contactsButton.setFocus(true);
    }

}

From source file:org.spiffyui.mvsb.samples.client.Index.java

License:Apache License

private void addSingleValued(HTMLPanel panel) {
    final MultivalueSuggestBox msb = new MultivalueSuggestBox(
            new MultivalueSuggestRESTHelper("TotalSize", "Options", "DisplayName", "Value") {

                @Override//  w  w  w  . ja v  a2 s  .  c om
                public String buildUrl(String q, int indexFrom, int indexTo) {
                    return "multivaluesuggestboxexample/colors?q=" + q + "&indexFrom=" + indexFrom + "&indexTo="
                            + indexTo;
                }
            }, false);

    panel.add(msb, "singleValued");

    createShowValuesButton(panel, msb, "singleValued");
}

From source file:org.spiffyui.mvsb.samples.client.Index.java

License:Apache License

/**
 * Add a button to the panel for showing values of the suggest box
 * @param panel - HTMLPanel to add to/*from  w w  w. j a v a  2s. co  m*/
 * @param msb - the suggest box
 * @param containerId - where to add the button
 */
private void createShowValuesButton(HTMLPanel panel, final MultivalueSuggestBoxBase msb, String containerId) {
    final Button b = new Button("Show values");
    panel.add(b, containerId);
    b.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            showValues(msb, b);
        }
    });
}

From source file:org.spiffyui.mvsb.samples.client.Index.java

License:Apache License

private void addMultiValued(HTMLPanel panel) {
    final MultivalueSuggestBox msb = new MultivalueSuggestBox(
            new MultivalueSuggestRESTHelper("TotalSize", "Options", "DisplayName", "Value") {

                @Override//  w w  w  .java 2  s.com
                public String buildUrl(String q, int indexFrom, int indexTo) {
                    return "multivaluesuggestboxexample/colors?q=" + q + "&indexFrom=" + indexFrom + "&indexTo="
                            + indexTo;
                }
            }, true);

    /*
     * have a default value of Electric Lime
     */
    Map<String, String> valueMap = new HashMap<String, String>();
    valueMap.put("Electric Lime", "#CEFF1D");
    msb.setValueMap(valueMap);

    panel.add(msb, "multiValued");

    createShowValuesButton(panel, msb, "multiValued");
}

From source file:org.spiffyui.mvsb.samples.client.Index.java

License:Apache License

private void addMultiValuedFancy(HTMLPanel panel) {
    final FancyAutocompleter msb = new FancyAutocompleter(
            new MultivalueSuggestRESTHelper("TotalSize", "Options", "DisplayName", "Value") {

                @Override/* www. j a  v a  2  s  .c o m*/
                public String buildUrl(String q, int indexFrom, int indexTo) {
                    return "multivaluesuggestboxexample/colors?q=" + q + "&indexFrom=" + indexFrom + "&indexTo="
                            + indexTo;
                }
            }, true);
    msb.getFeedback().addStyleName("msg-feedback");
    msb.setPageSize(8); //since each value takes up more space, let's cut the size.

    panel.add(msb, "multiValuedFancy");

    createShowValuesButton(panel, msb, "multiValuedFancy");

}

From source file:org.spiffyui.mvsb.samples.client.Index.java

License:Apache License

private void addLocalValues(HTMLPanel panel) {
    final LocalSuggestBox msb = new LocalSuggestBox(true);
    panel.add(msb, "localValues");

    createShowValuesButton(panel, msb, "localValues");
}