SideBySide2: Move [,] event handling into header

The header object knows how to manage the navigation. Instead of
digging into there from anonymous Runnables in SideBySide2, let
Header create the Runnable, hiding some of the inner details of
Header from the event binding code.

This shortens the event binding code for a CM3 a bit more, making
the table of key bindings slightly easier to read.

Change-Id: Ia3c999f37001c51d5c36d8eaff02f8bdc725773a
This commit is contained in:
Shawn Pearce
2013-12-19 08:34:57 -08:00
parent 08ff593446
commit c3cb35877f
2 changed files with 25 additions and 18 deletions

View File

@@ -255,12 +255,29 @@ class Header extends Composite {
}
}
boolean hasPrev() {
return hasPrev;
}
boolean hasNext() {
return hasNext;
Runnable navigate(Direction dir) {
switch (dir) {
case PREV:
return new Runnable() {
@Override
public void run() {
(hasPrev ? prev : up).go();
}
};
case NEXT:
return new Runnable() {
@Override
public void run() {
(hasNext ? next : up).go();
}
};
default:
return new Runnable() {
@Override
public void run() {
}
};
}
}
String getNextPath() {