From 4552a67fa3d82017a32be8712ffac8d0f4bb0ab5 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 1 Mar 2013 18:29:04 +0800 Subject: [PATCH] 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. --- .../webui/adwindow/ADWindowContent.java | 23 +++++++++++++++++++ .../adempiere/webui/adwindow/BreadCrumb.java | 8 +++++++ 2 files changed, 31 insertions(+) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java index 0ba7d6f870..06e3b8c507 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java @@ -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() { + @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(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java index be4f37c88c..c7c4b1bf16 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/BreadCrumb.java @@ -705,6 +705,14 @@ public class BreadCrumb extends Div implements EventListener { } } + public boolean isPreviousEnabled() { + return !btnPrevious.isDisabled(); + } + + public boolean isNextEnabled() { + return !btnNext.isDisabled(); + } + class RecordLink extends A { private static final long serialVersionUID = 3793489614175751401L;