use of com.google.gwt.event.dom.client.KeyPressEvent in project perun by CESNET.
the class SuggestBox method addEventsToTextBox.
private void addEventsToTextBox() {
class TextBoxEvents extends HandlesAllKeyEvents implements ValueChangeHandler<String> {
public void onKeyDown(KeyDownEvent event) {
switch(event.getNativeKeyCode()) {
case KeyCodes.KEY_DOWN:
display.moveSelectionDown();
break;
case KeyCodes.KEY_UP:
display.moveSelectionUp();
break;
case KeyCodes.KEY_ENTER:
case KeyCodes.KEY_TAB:
Suggestion suggestion = display.getCurrentSelection();
if (suggestion == null) {
display.hideSuggestions();
} else {
setNewSelection(suggestion);
}
break;
}
delegateEvent(SuggestBox.this, event);
}
public void onKeyPress(KeyPressEvent event) {
delegateEvent(SuggestBox.this, event);
}
public void onKeyUp(KeyUpEvent event) {
// After every user key input, refresh the popup's suggestions.
refreshSuggestions();
delegateEvent(SuggestBox.this, event);
}
public void onValueChange(ValueChangeEvent<String> event) {
delegateEvent(SuggestBox.this, event);
}
}
TextBoxEvents events = new TextBoxEvents();
events.addKeyHandlersTo(box);
box.addValueChangeHandler(events);
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class PagedSingleListScreen method onInitUI.
@Override
protected void onInitUI() {
super.onInitUI();
prev = new Hyperlink(Util.C.pagedChangeListPrev(), true, "");
prev.setVisible(false);
next = new Hyperlink(Util.C.pagedChangeListNext(), true, "");
next.setVisible(false);
table = new ChangeTable() {
{
keysNavigation.add(new DoLinkCommand(0, 'p', Util.C.changeTablePagePrev(), prev), new DoLinkCommand(0, 'n', Util.C.changeTablePageNext(), next));
keysNavigation.add(new DoLinkCommand(0, '[', Util.C.changeTablePagePrev(), prev), new DoLinkCommand(0, ']', Util.C.changeTablePageNext(), next));
keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadSearch()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(getToken());
}
});
}
};
section = new ChangeTable.Section();
table.addSection(section);
table.setSavePointerId(anchorPrefix);
add(table);
final HorizontalPanel buttons = new HorizontalPanel();
buttons.setStyleName(Gerrit.RESOURCES.css().changeTablePrevNextLinks());
buttons.add(prev);
buttons.add(next);
add(buttons);
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class ChangeScreen method registerKeys.
@Override
public void registerKeys() {
super.registerKeys();
KeyCommandSet keysNavigation = new KeyCommandSet(Gerrit.C.sectionNavigation());
keysNavigation.add(new KeyCommand(0, 'u', Util.C.upToChangeList()) {
@Override
public void onKeyPress(KeyPressEvent event) {
Gerrit.displayLastChangeList();
}
});
keysNavigation.add(new KeyCommand(0, 'R', Util.C.keyReloadChange()) {
@Override
public void onKeyPress(KeyPressEvent event) {
Gerrit.display(PageLinks.toChange(changeId));
}
});
keysNavigation.add(new KeyCommand(0, 'n', Util.C.keyNextPatchSet()) {
@Override
public void onKeyPress(KeyPressEvent event) {
gotoSibling(1);
}
}, new KeyCommand(0, 'p', Util.C.keyPreviousPatchSet()) {
@Override
public void onKeyPress(KeyPressEvent event) {
gotoSibling(-1);
}
});
handlers.add(GlobalKey.add(this, keysNavigation));
KeyCommandSet keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
keysAction.add(new KeyCommand(0, 'a', Util.C.keyPublishComments()) {
@Override
public void onKeyPress(KeyPressEvent event) {
if (Gerrit.isSignedIn()) {
onReply(null);
} else {
Gerrit.doSignIn(getToken());
}
}
});
keysAction.add(new KeyCommand(0, 'x', Util.C.keyExpandAllMessages()) {
@Override
public void onKeyPress(KeyPressEvent event) {
onExpandAll(null);
}
});
keysAction.add(new KeyCommand(0, 'z', Util.C.keyCollapseAllMessages()) {
@Override
public void onKeyPress(KeyPressEvent event) {
onCollapseAll(null);
}
});
keysAction.add(new KeyCommand(0, 's', Util.C.changeTableStar()) {
@Override
public void onKeyPress(KeyPressEvent event) {
if (Gerrit.isSignedIn()) {
star.setValue(!star.getValue(), true);
} else {
Gerrit.doSignIn(getToken());
}
}
});
keysAction.add(new KeyCommand(0, 'c', Util.C.keyAddReviewers()) {
@Override
public void onKeyPress(KeyPressEvent event) {
if (Gerrit.isSignedIn()) {
reviewers.onOpenForm();
} else {
Gerrit.doSignIn(getToken());
}
}
});
keysAction.add(new KeyCommand(0, 't', Util.C.keyEditTopic()) {
@Override
public void onKeyPress(KeyPressEvent event) {
if (Gerrit.isSignedIn()) {
// differentiate F5 from 't' by checking the charCode(F5=0, t=116).
if (event.getNativeEvent().getCharCode() == 0) {
Window.Location.reload();
return;
}
if (topic.canEdit()) {
topic.onEdit();
}
} else {
Gerrit.doSignIn(getToken());
}
}
});
handlers.add(GlobalKey.add(this, keysAction));
files.registerKeys();
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class Header method setupNav.
private KeyCommand setupNav(InlineHyperlink link, char key, String help, FileInfo info) {
if (info != null) {
final String url = url(info);
link.setTargetHistoryToken(url);
link.setTitle(PatchUtil.M.fileNameWithShortcutKey(FileInfo.getFileName(info.path()), Character.toString(key)));
KeyCommand k = new KeyCommand(0, key, help) {
@Override
public void onKeyPress(KeyPressEvent event) {
Gerrit.display(url);
}
};
keys.add(k);
if (link == prev) {
hasPrev = true;
} else {
hasNext = true;
}
return k;
}
link.getElement().getStyle().setVisibility(Visibility.HIDDEN);
keys.add(new UpToChangeCommand(patchSetId, 0, key));
return null;
}
use of com.google.gwt.event.dom.client.KeyPressEvent in project gerrit by GerritCodeReview.
the class DiffScreen method registerKeys.
@Override
public void registerKeys() {
super.registerKeys();
keysNavigation.add(new UpToChangeCommand(revision, 0, 'u'));
keysNavigation.add(new NoOpKeyCommand(0, 'j', PatchUtil.C.lineNext()), new NoOpKeyCommand(0, 'k', PatchUtil.C.linePrev()));
keysNavigation.add(new NoOpKeyCommand(0, 'n', PatchUtil.C.chunkNext()), new NoOpKeyCommand(0, 'p', PatchUtil.C.chunkPrev()));
keysNavigation.add(new NoOpKeyCommand(KeyCommand.M_SHIFT, 'n', PatchUtil.C.commentNext()), new NoOpKeyCommand(KeyCommand.M_SHIFT, 'p', PatchUtil.C.commentPrev()));
keysNavigation.add(new NoOpKeyCommand(KeyCommand.M_CTRL, 'f', Gerrit.C.keySearch()));
keysAction = new KeyCommandSet(Gerrit.C.sectionActions());
keysAction.add(new NoOpKeyCommand(0, KeyCodes.KEY_ENTER, PatchUtil.C.expandComment()));
keysAction.add(new NoOpKeyCommand(0, 'o', PatchUtil.C.expandComment()));
keysAction.add(new NoOpKeyCommand(KeyCommand.M_SHIFT, 'o', PatchUtil.C.expandAllCommentsOnCurrentLine()));
if (Gerrit.isSignedIn()) {
keysAction.add(new KeyCommand(0, 'r', PatchUtil.C.toggleReviewed()) {
@Override
public void onKeyPress(KeyPressEvent event) {
header.toggleReviewed().run();
}
});
keysAction.add(new NoOpKeyCommand(KeyCommand.M_CTRL | KeyCommand.M_ALT, 'e', Gerrit.C.keyEditor()));
}
keysAction.add(new KeyCommand(KeyCommand.M_SHIFT, 'm', PatchUtil.C.markAsReviewedAndGoToNext()) {
@Override
public void onKeyPress(KeyPressEvent event) {
header.reviewedAndNext().run();
}
});
keysAction.add(new KeyCommand(0, 'a', PatchUtil.C.openReply()) {
@Override
public void onKeyPress(KeyPressEvent event) {
upToChange(true).run();
}
});
keysAction.add(new KeyCommand(0, ',', PatchUtil.C.showPreferences()) {
@Override
public void onKeyPress(KeyPressEvent event) {
prefsAction.show();
}
});
if (getIntraLineStatus() == DiffInfo.IntraLineStatus.OFF || getIntraLineStatus() == DiffInfo.IntraLineStatus.OK) {
keysAction.add(new KeyCommand(0, 'i', PatchUtil.C.toggleIntraline()) {
@Override
public void onKeyPress(KeyPressEvent event) {
toggleShowIntraline();
}
});
}
if (Gerrit.isSignedIn()) {
keysAction.add(new NoOpKeyCommand(0, 'c', PatchUtil.C.commentInsert()));
keysComment = new KeyCommandSet(PatchUtil.C.commentEditorSet());
keysComment.add(new NoOpKeyCommand(KeyCommand.M_CTRL, 's', PatchUtil.C.commentSaveDraft()));
keysComment.add(new NoOpKeyCommand(0, KeyCodes.KEY_ESCAPE, PatchUtil.C.commentCancelEdit()));
} else {
keysComment = null;
}
}
Aggregations