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;
}
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);
}
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();
}
Aggregations