IDEMPIERE-231 Zk6: Improve the tablet experience. Implement record navigation gesture on the toolbar and breadcrumb area. Swipe right - next record, swipe left - previous record, swipe down - goes to detail record and swipe up - goes to parent record.

This commit is contained in:
Heng Sin Low 2013-03-01 18:29:04 +08:00
parent ae88ddd369
commit 4552a67fa3
2 changed files with 31 additions and 0 deletions

View File

@ -38,6 +38,7 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.KeyEvent;
import org.zkoss.zk.ui.event.SwipeEvent;
import org.zkoss.zul.Div;
import org.zkoss.zul.Tab;
import org.zkoss.zul.Vlayout;
@ -91,6 +92,28 @@ public class ADWindowContent extends AbstractADWindowContent
breadCrumb.setToolbarListener(this);
breadCrumb.setId("breadCrumb");
div.appendChild(breadCrumb);
div.addEventListener(Events.ON_SWIPE, new EventListener<SwipeEvent>() {
@Override
public void onEvent(SwipeEvent event) throws Exception {
if ("right".equals(event.getSwipeDirection())) {
if (breadCrumb.isNextEnabled()) {
onNext();
}
} else if ("left".equals(event.getSwipeDirection())) {
if (breadCrumb.isPreviousEnabled()) {
onPrevious();
}
} else if ("up".equals(event.getSwipeDirection())) {
if (!toolbar.getButton("ParentRecord").isDisabled()) {
onParentRecord();
}
} else if ("down".equals(event.getSwipeDirection())) {
if (!toolbar.getButton("DetailRecord").isDisabled()) {
onDetailRecord();
}
}
}
});
//status bar
Div south = new Div();

View File

@ -705,6 +705,14 @@ public class BreadCrumb extends Div implements EventListener<Event> {
}
}
public boolean isPreviousEnabled() {
return !btnPrevious.isDisabled();
}
public boolean isNextEnabled() {
return !btnNext.isDisabled();
}
class RecordLink extends A {
private static final long serialVersionUID = 3793489614175751401L;