use of com.google.gwt.event.dom.client.KeyDownHandler in project gerrit by GerritCodeReview.
the class GlobalKey method dialog.
public static void dialog(final PopupPanel panel) {
initEvents();
initDialog();
assert panel.isShowing();
assert active == global;
active = new State(panel);
active.add(new HidePopupPanelCommand(0, KeyCodes.KEY_ESCAPE, panel));
panel.addCloseHandler(restoreGlobal);
panel.addDomHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
panel.hide();
}
}
}, KeyDownEvent.getType());
}
use of com.google.gwt.event.dom.client.KeyDownHandler 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.event.dom.client.KeyDownHandler in project gerrit by GerritCodeReview.
the class NpIntTextBox method init.
private void init() {
addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
int code = event.getNativeKeyCode();
onKey(event, code, code);
}
});
addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
int charCode = event.getCharCode();
int keyCode = event.getNativeEvent().getKeyCode();
onKey(event, charCode, keyCode);
}
});
}
use of com.google.gwt.event.dom.client.KeyDownHandler in project rstudio by rstudio.
the class FocusTransitionManager method register.
private void register(final Widget widget) {
if (registration_.contains(widget))
return;
registration_.add(widget);
widget.addDomHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
if (event.getNativeKeyCode() == KeyCodes.KEY_TAB) {
boolean forward = !event.isShiftKeyDown();
Widget target = get(widget, forward);
if (target == null)
return;
if (target instanceof CanFocus) {
event.stopPropagation();
event.preventDefault();
focus((CanFocus) target);
} else if (target instanceof Focusable) {
event.stopPropagation();
event.preventDefault();
focus((Focusable) target);
}
}
}
}, KeyDownEvent.getType());
}
use of com.google.gwt.event.dom.client.KeyDownHandler in project rstudio by rstudio.
the class VersionControlPage method onAddWidgets.
@Override
protected void onAddWidgets() {
NewProjectResources.Styles styles = NewProjectResources.INSTANCE.styles();
VerticalPanel urlPanel = new VerticalPanel();
urlPanel.addStyleName(styles.wizardMainColumn());
Label urlLabel = new Label("Repository URL:");
urlLabel.addStyleName(styles.wizardTextEntryLabel());
urlPanel.add(urlLabel);
txtRepoUrl_ = new TextBox();
txtRepoUrl_.addDomHandler(new KeyDownHandler() {
public void onKeyDown(KeyDownEvent event) {
handleAutoFillCheckoutDir();
}
}, KeyDownEvent.getType());
txtRepoUrl_.setWidth("100%");
urlPanel.add(txtRepoUrl_);
addWidget(urlPanel);
addSpacer();
txtUsername_ = new TextBox();
txtUsername_.setWidth("100%");
if (includeCredentials()) {
VerticalPanel usernamePanel = new VerticalPanel();
usernamePanel.addStyleName(styles.wizardMainColumn());
Label usernameLabel = new Label("Username (if required for this repository URL):");
usernameLabel.addStyleName(styles.wizardTextEntryLabel());
usernamePanel.add(usernameLabel);
usernamePanel.add(txtUsername_);
addWidget(usernamePanel);
addSpacer();
}
Label dirNameLabel = new Label("Project directory name:");
dirNameLabel.addStyleName(styles.wizardTextEntryLabel());
addWidget(dirNameLabel);
txtDirName_ = new TextBox();
txtDirName_.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
if (!event.getValue().equals(guessRepoDir()))
suppressDirNameDetection_ = true;
}
});
txtDirName_.addStyleName(styles.wizardMainColumn());
addWidget(txtDirName_);
addSpacer();
existingRepoDestDir_ = new DirectoryChooserTextBox("Create project as subdirectory of:", txtRepoUrl_);
addWidget(existingRepoDestDir_);
}
Aggregations