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

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

Introduction

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

Prototype

protected FocusWidget(Element elem) 

Source Link

Document

Creates a new focus widget that wraps the specified browser element.

Usage

From source file:org.cruxframework.crux.widgets.client.tabcontainer.FlapController.java

License:Apache License

/**
 * @param tabs/* ww w. j  a  va2 s  .  c  om*/
 * @param tabId
 * @param tabLabel
 * @param closeable
 */
public FlapController(final TabContainer tabs, final String tabId, String tabLabel, boolean asHTML,
        boolean closeable) {
    this.closeable = closeable;
    HorizontalPanel flap = new HorizontalPanel();

    initWidget(flap);

    flap.setSpacing(0);

    if (asHTML) {
        title = new HTML(tabLabel);
    } else {
        title = new Label(tabLabel);
    }
    title.setStyleName("flapLabel");
    flap.add(title);

    if (closeable) {
        closeButton = new FocusWidget(new Label(" ").getElement()) {
        };

        closeButton.setStyleName("flapCloseButton");
        closeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                event.stopPropagation();
                tabs.closeView(tabId, false);
            }
        });

        closeButton.addKeyDownHandler(new KeyDownHandler() {
            public void onKeyDown(KeyDownEvent event) {
                if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                    event.stopPropagation();
                    tabs.closeView(tabId, false);
                }
            }
        });

        closeButton.setVisible(closeable);

        Screen.ensureDebugId(closeButton, tabs.getElement().getId() + "_" + tabId + "_close_btn");

        flap.add(closeButton);
    }
}