IDEMPIERE-231 Zk6: Improve the tablet experience. UI feedback for record navigation gesture.

This commit is contained in:
Heng Sin Low 2013-03-06 16:56:04 +08:00
parent ba0ef7c3bf
commit 7cbf260bf9
2 changed files with 35 additions and 8 deletions

View File

@ -27,11 +27,13 @@ import java.util.Properties;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.session.SessionManager;
import org.compiere.model.X_AD_CtxHelp;
import org.compiere.util.CLogger;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
@ -39,6 +41,7 @@ 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.zk.ui.util.Clients;
import org.zkoss.zul.Div;
import org.zkoss.zul.Tab;
import org.zkoss.zul.Vlayout;
@ -96,20 +99,36 @@ public class ADWindowContent extends AbstractADWindowContent
@Override
public void onEvent(SwipeEvent event) throws Exception {
if ("right".equals(event.getSwipeDirection())) {
if (breadCrumb.isNextEnabled()) {
onNext();
ToolBarButton nextBtn = breadCrumb.getNextButton();
if (!nextBtn.isDisabled()) {
nextBtn.setDisabled(true);
String script = "var w=zk.Widget.$('#"+nextBtn.getUuid()+"');" +
"w.fire('onClick',null,{toServer:true});";
Clients.response(new AuScript(script));
}
} else if ("left".equals(event.getSwipeDirection())) {
if (breadCrumb.isPreviousEnabled()) {
onPrevious();
ToolBarButton previousBtn = breadCrumb.getPreviousButton();
if (!previousBtn.isDisabled()) {
previousBtn.setDisabled(true);
String script = "var w=zk.Widget.$('#"+previousBtn.getUuid()+"');" +
"w.fire('onClick',null,{toServer:true});";
Clients.response(new AuScript(script));
}
} else if ("up".equals(event.getSwipeDirection())) {
if (!toolbar.getButton("ParentRecord").isDisabled()) {
onParentRecord();
ToolBarButton parentBtn = toolbar.getButton("ParentRecord");
if (!parentBtn.isDisabled()) {
parentBtn.setDisabled(true);
String script = "var w=zk.Widget.$('#"+parentBtn.getUuid()+"');" +
"w.fire('onClick',null,{toServer:true});";
Clients.response(new AuScript(script));
}
} else if ("down".equals(event.getSwipeDirection())) {
if (!toolbar.getButton("DetailRecord").isDisabled()) {
onDetailRecord();
ToolBarButton detailBtn = toolbar.getButton("DetailRecord");
if (!detailBtn.isDisabled()) {
detailBtn.setDisabled(true);
String script = "var w=zk.Widget.$('#"+detailBtn.getUuid()+"');" +
"w.fire('onClick',null,{toServer:true});";
Clients.response(new AuScript(script));
}
}
}

View File

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