import com.google.gwtexpui.globalkey.client.KeyCommand;
import com.google.gwtexpui.globalkey.client.KeyCommandSet;
class JumpKeys {
static void register(final Widget body) {
final KeyCommandSet jumps = new KeyCommandSet();
jumps.add(new KeyCommand(0, 'o', Gerrit.C.jumpAllOpen()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("status:open"));
}
});
jumps.add(new KeyCommand(0, 'm', Gerrit.C.jumpAllMerged()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("status:merged"));
}
});
jumps.add(new KeyCommand(0, 'a', Gerrit.C.jumpAllAbandoned()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("status:abandoned"));
}
});
if (Gerrit.isSignedIn()) {
jumps.add(new KeyCommand(0, 'i', Gerrit.C.jumpMine()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.MINE);
}
});
jumps.add(new KeyCommand(0, 'd', Gerrit.C.jumpMineDrafts()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("is:draft"));
}
});
jumps.add(new KeyCommand(0, 'c', Gerrit.C.jumpMineDraftComments()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("has:draft"));
}
});
jumps.add(new KeyCommand(0, 'w', Gerrit.C.jumpMineWatched()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("is:watched status:open"));
}
});
jumps.add(new KeyCommand(0, 's', Gerrit.C.jumpMineStarred()) {
@Override
public void onKeyPress(final KeyPressEvent event) {
Gerrit.display(PageLinks.toChangeQuery("is:starred"));
}
});
}
final KeyCommandSet jumping = new KeyCommandSet(Gerrit.C.sectionJumping());
jumping.add(new CompoundKeyCommand(0, 'g', "", jumps));
GlobalKey.add(body, jumping);
}