Search in sources :

Example 1 with FocusPanel

use of com.google.gwt.user.client.ui.FocusPanel in project gwt-test-utils by gwt-test-utils.

the class FocusPanelTest method beforeFocusPanelTest.

@Before
public void beforeFocusPanelTest() {
    child = new Label("focus panel's child widget");
    panel = new FocusPanel(child);
    test = false;
}
Also used : Label(com.google.gwt.user.client.ui.Label) FocusPanel(com.google.gwt.user.client.ui.FocusPanel) Before(org.junit.Before)

Example 2 with FocusPanel

use of com.google.gwt.user.client.ui.FocusPanel in project gerrit by GerritCodeReview.

the class Gerrit method whoAmI.

private static void whoAmI(boolean canLogOut) {
    AccountInfo account = getUserAccount();
    final UserPopupPanel userPopup = new UserPopupPanel(account, canLogOut, true);
    final FlowPanel userSummaryPanel = new FlowPanel();
    class PopupHandler implements KeyDownHandler, ClickHandler {

        private void showHidePopup() {
            if (userPopup.isShowing() && userPopup.isVisible()) {
                userPopup.hide();
            } else {
                userPopup.showRelativeTo(userSummaryPanel);
            }
        }

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

        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                showHidePopup();
                event.preventDefault();
            }
        }
    }
    final PopupHandler popupHandler = new PopupHandler();
    final InlineLabel l = new InlineLabel(FormatUtil.name(account));
    l.setStyleName(RESOURCES.css().menuBarUserName());
    final AvatarImage avatar = new AvatarImage(account, 26, false);
    avatar.setStyleName(RESOURCES.css().menuBarUserNameAvatar());
    userSummaryPanel.setStyleName(RESOURCES.css().menuBarUserNamePanel());
    userSummaryPanel.add(l);
    userSummaryPanel.add(avatar);
    // "BLACK DOWN-POINTING SMALL TRIANGLE"
    userSummaryPanel.add(new InlineLabel(" ▾"));
    userPopup.addAutoHidePartner(userSummaryPanel.getElement());
    FocusPanel fp = new FocusPanel(userSummaryPanel);
    fp.setStyleName(RESOURCES.css().menuBarUserNameFocusPanel());
    fp.addKeyDownHandler(popupHandler);
    fp.addClickHandler(popupHandler);
    menuRight.add(fp);
}
Also used : KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) InlineLabel(com.google.gwt.user.client.ui.InlineLabel) FocusPanel(com.google.gwt.user.client.ui.FocusPanel) AccountInfo(com.google.gerrit.client.info.AccountInfo)

Example 3 with FocusPanel

use of com.google.gwt.user.client.ui.FocusPanel in project gwt-test-utils by gwt-test-utils.

the class FocusPanelTest method click_EmptyPanel.

@Test
public void click_EmptyPanel() {
    // Given
    panel = new FocusPanel();
    panel.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            test = true;
        }
    });
    // When
    Browser.click(panel);
    // Then
    assertThat(test).isTrue();
}
Also used : FocusPanel(com.google.gwt.user.client.ui.FocusPanel) Test(org.junit.Test)

Aggregations

FocusPanel (com.google.gwt.user.client.ui.FocusPanel)3 AccountInfo (com.google.gerrit.client.info.AccountInfo)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)1 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)1 Label (com.google.gwt.user.client.ui.Label)1 Before (org.junit.Before)1 Test (org.junit.Test)1