From b4fa3b4c34f99d1187b9b6377ebd56204a22a714 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 2 Nov 2012 16:50:41 +0800 Subject: [PATCH] IDEMPIERE-231 Zk6: Improve the tablet experience. Remove tablet related code that's not applicable for zk 6.5 --- .../adempiere/webui/adwindow/ADTabpanel.java | 9 -- .../adempiere/webui/adwindow/GridView.java | 3 - .../webui/dashboard/DPFavourites.java | 29 +--- .../webui/dashboard/DPRecentItems.java | 27 +--- .../webui/desktop/DefaultDesktop.java | 12 +- .../webui/event/TouchEventHelper.java | 126 +----------------- .../adempiere/webui/event/TouchEvents.java | 27 ---- .../webui/panel/AbstractMenuPanel.java | 12 +- .../org/adempiere/webui/panel/LoginPanel.java | 2 +- .../org/adempiere/webui/panel/MenuPanel.java | 12 +- .../webui/panel/WRC1DisplayFieldsPanel.java | 5 - .../webui/panel/WRC5SummaryFieldsPanel.java | 5 - 12 files changed, 8 insertions(+), 261 deletions(-) delete mode 100644 org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEvents.java diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java index 97daf0ea17..29f0a5fde2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java @@ -311,11 +311,6 @@ DataStatusListener, IADTabpanel formContainer = layout; treePanel.getTree().addEventListener(Events.ON_SELECT, this); - if (AEnv.isTablet()) - { - LayoutUtils.addSclass("tablet-scrolling", west); - LayoutUtils.addSclass("tablet-scrolling", center); - } } else { @@ -353,10 +348,6 @@ DataStatusListener, IADTabpanel formContainer = div; } - if (AEnv.isTablet()) - { - LayoutUtils.addSclass("tablet-scrolling", div); - } } this.appendChild(listPanel); listPanel.setVisible(false); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java index 94be466242..7ce709fd33 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java @@ -521,9 +521,6 @@ public class GridView extends Vbox implements EventListener gridFooter.setVisible(false); } - if (AEnv.isTablet()) { - TouchEventHelper.addTabletScrollingFix(listbox); - } } private void updateModel() { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java index 478411deb9..a639ed12ba 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPFavourites.java @@ -16,8 +16,6 @@ package org.adempiere.webui.dashboard; import java.util.Enumeration; import org.adempiere.webui.adwindow.ADWindow; -import org.adempiere.webui.apps.AEnv; -import org.adempiere.webui.event.TouchEventHelper; import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.window.FDialog; @@ -56,8 +54,6 @@ import org.zkoss.zul.Vbox; */ public class DPFavourites extends DashboardPanel implements EventListener { - private static final String ON_ADD_TAP_EVENT_LISTENER = "onAddTapEventListener"; - private static final String NODE_ID_ATTR = "Node_ID"; /** @@ -153,20 +149,7 @@ public class DPFavourites extends DashboardPanel implements EventListener btnFavItem.addEventListener(Events.ON_CLICK, this); btnFavItem.addEventListener(Events.ON_DROP, this); btnFavItem.setSclass("menu-href"); - - if (AEnv.isTablet()) - { - if (getPage() != null) - { - TouchEventHelper.addOnTapEventListener(btnFavItem, this); - } - else - { - btnFavItem.addEventListener(ON_ADD_TAP_EVENT_LISTENER, this); - Events.echoEvent(new Event(ON_ADD_TAP_EVENT_LISTENER, btnFavItem, null)); - } - } - + if (addNewBtn) { Toolbarbutton newBtn = new Toolbarbutton(null, "/images/New10.png"); @@ -212,11 +195,7 @@ public class DPFavourites extends DashboardPanel implements EventListener Component comp = event.getTarget(); String eventName = event.getName(); - if (eventName.equals(TouchEventHelper.ON_TAP)) - { - doOnClick(comp); - } - else if(eventName.equals(Events.ON_CLICK) && !TouchEventHelper.isIgnoreClick(comp)) + if(eventName.equals(Events.ON_CLICK)) { doOnClick(comp); } @@ -245,10 +224,6 @@ public class DPFavourites extends DashboardPanel implements EventListener } } } - else if (eventName.equals(ON_ADD_TAP_EVENT_LISTENER)) - { - TouchEventHelper.addOnTapEventListener(event.getTarget(), this); - } // } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java index b448c52798..c764bff879 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPRecentItems.java @@ -15,9 +15,6 @@ package org.adempiere.webui.dashboard; import java.util.List; -import org.adempiere.webui.apps.AEnv; -import org.adempiere.webui.event.TouchEventHelper; -import org.adempiere.webui.event.TouchEvents; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ServerPushTemplate; import org.compiere.model.MQuery; @@ -47,8 +44,6 @@ import org.zkoss.zul.Vbox; */ public class DPRecentItems extends DashboardPanel implements EventListener { - private static final String ON_ADD_TAP_EVENT_LISTENER = "onAddTapEventListener"; - private static final String AD_RECENT_ITEM_ID_ATTR = "AD_RecentItem_ID"; /** @@ -115,11 +110,7 @@ public class DPRecentItems extends DashboardPanel implements EventListener= maxri) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java index 3b179bdc5f..f792f2855e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java @@ -190,13 +190,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria //register as 0 registerWindow(homeTab); - dashboardController.render(homeTab, this, true); - - if (AEnv.isTablet()) - { - homeTab.addEventListener("onAddTabletScrolling", this); - Events.echoEvent("onAddTabletScrolling", homeTab, null); - } + dashboardController.render(homeTab, this, true); } public void onEvent(Event event) @@ -217,10 +211,6 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria } } } - else if (eventName.equals("onAddTabletScrolling")) - { - LayoutUtils.addSclass("tablet-scrolling", homeTab); - } } public void onServerPush(ServerPushTemplate template) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEventHelper.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEventHelper.java index 92004f7bcd..4e6b92b6b8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEventHelper.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEventHelper.java @@ -13,12 +13,7 @@ *****************************************************************************/ package org.adempiere.webui.event; -import org.adempiere.webui.apps.AEnv; import org.zkoss.zk.au.out.AuScript; -import org.zkoss.zk.ui.Component; -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.util.Clients; import org.zkoss.zul.Grid; @@ -26,130 +21,11 @@ import org.zkoss.zul.Grid; * @author hengsin * */ -public class TouchEventHelper implements TouchEvents, EventListener { +public class TouchEventHelper { - private static final String TOUCH_LISTENER_INIT = "touch.listener.init"; private static final String TABLET_SCROLLING_FIX_INIT = "tablet.scrolling.fix.init"; - private static final String TOUCH_TAP_TIME = "touch.tap.time"; - private Component touchStart = null; - private long touchStartTime = 0; - private Component touchEnd = null; - private long touchEndTime = 0; - private Component component; - /** - * - */ - private TouchEventHelper(Component component) { - component.addEventListener(ON_TOUCH_START, this); - component.addEventListener(ON_TOUCH_END, this); - addClientTouchListener(component); - this.component = component; - } - - /** - * add client side listener to enable the touchstart, touchmove and touchend event - * @param component - */ - public static void addClientTouchListener(Component component) { - Boolean b = (Boolean) component.getAttribute(TOUCH_LISTENER_INIT); - if (b != null && b.booleanValue()) - return; - - StringBuilder touchScript = new StringBuilder(); - touchScript.append("var widget = zk.Widget.$('") - .append(component.getUuid()).append("');"); - touchScript.append("jq(widget.$n()).bind('touchstart',"); - touchScript.append("function(e){"); - touchScript.append("var widget = zk.Widget.$('"); - touchScript.append(component.getUuid()).append("');"); - touchScript.append("var zEvent = new zk.Event(widget, 'onTouchstart', {altKey: e.altKey, ctrlKey: e.ctrlKey, metaKey: e.metaKey," + - "rotation: e.rotation, scale: e.scale, shiftKey: e.shiftKey}, {toServer: true});"); - touchScript.append("zAu.send(zEvent);"); - touchScript.append("});"); - - touchScript.append("jq(widget.$n()).bind('touchend',"); - touchScript.append("function(e){"); - touchScript.append("var widget = zk.Widget.$('"); - touchScript.append(component.getUuid()).append("');"); - touchScript.append("var zEvent = new zk.Event(widget, 'onTouchend', {altKey: e.altKey, ctrlKey: e.ctrlKey, metaKey: e.metaKey," + - "rotation: e.rotation, scale: e.scale, shiftKey: e.shiftKey}, {toServer: true});"); - touchScript.append("zAu.send(zEvent);"); - touchScript.append("});"); - Clients.response(new AuScript(component, touchScript.toString())); - - touchScript.append("jq(widget.$n()).bind('touchmove',"); - touchScript.append("function(event){"); - touchScript.append("var widget = zk.Widget.$('"); - touchScript.append(component.getUuid()).append("');"); - touchScript.append("var zEvent = new zk.Event(widget, 'onTouchmove', {altKey: e.altKey, ctrlKey: e.ctrlKey, metaKey: e.metaKey," + - "rotation: e.rotation, scale: e.scale, shiftKey: e.shiftKey}, {toServer: true});"); - touchScript.append("zAu.send(zEvent);"); - touchScript.append("});"); - Clients.response(new AuScript(component, touchScript.toString())); - - component.setAttribute(TOUCH_LISTENER_INIT, Boolean.TRUE); - } - - private void registerTouchStart(Event event) { - touchStart = event.getTarget(); - touchStartTime = System.currentTimeMillis(); - } - - private void registerTouchEnd(Event event) { - touchEnd = event.getTarget(); - touchEndTime = System.currentTimeMillis(); - } - - private boolean isTap() { - return touchStart != null && touchStart == touchEnd && (touchEndTime - touchStartTime) < 500; - } - - @Override - public void onEvent(Event event) throws Exception { - if (event.getName().equals(ON_TOUCH_START)) { - registerTouchStart(event); - } else if (event.getName().equals(ON_TOUCH_END)) { - registerTouchEnd(event); - if (isTap()) { - reset(); - Events.sendEvent(component, new Event(ON_TAP, component, null)); - component.setAttribute(TOUCH_TAP_TIME, System.currentTimeMillis()); - } - } - } - - private void reset() { - touchStart = null; - touchEnd = null; - touchStartTime = 0; - touchEndTime = 0; - } - - /** - * add OnTap event hook - * @param component - * @param listener - */ - public static void addOnTapEventListener(Component component, EventListener listener) { - new TouchEventHelper(component); - component.addEventListener(ON_TAP, listener); - } - - /** - * - * @param component - * @return true if onClick should be ignore ( replace by onTap ) - */ - public static boolean isIgnoreClick(Component component) { - Boolean b = (Boolean) component.getAttribute(TOUCH_LISTENER_INIT); - if (b != null && b.booleanValue() && AEnv.isTablet()) - return true; - else - return false; - } - /** * iPad: Use client side listener to workaround the issue that grid header doesn't scroll together with body. * Outstanding Issues: Frozen not working. diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEvents.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEvents.java deleted file mode 100644 index feb916cffd..0000000000 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/event/TouchEvents.java +++ /dev/null @@ -1,27 +0,0 @@ -/****************************************************************************** - * Copyright (C) 2012 Heng Sin Low * - * Copyright (C) 2012 Trek Global * - * This program is free software; you can redistribute it and/or modify it * - * under the terms version 2 of the GNU General Public License as published * - * by the Free Software Foundation. This program is distributed in the hope * - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied * - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * - * See the GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License along * - * with this program; if not, write to the Free Software Foundation, Inc., * - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - *****************************************************************************/ -package org.adempiere.webui.event; - -/** - * - * @author hengsin - * - */ -public interface TouchEvents { - - public final static String ON_TOUCH_START = "onTouchstart"; - public final static String ON_TOUCH_END = "onTouchend"; - public final static String ON_TOUCH_MOVE = "onTouchmove"; - public final static String ON_TAP = "onTap"; -} diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java index 605a23e996..ece46840cf 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/AbstractMenuPanel.java @@ -21,9 +21,6 @@ import java.util.Enumeration; import java.util.Properties; import org.adempiere.webui.adwindow.ADWindow; -import org.adempiere.webui.apps.AEnv; -import org.adempiere.webui.event.TouchEventHelper; -import org.adempiere.webui.event.TouchEvents; import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.session.SessionManager; import org.compiere.model.GridTab; @@ -240,9 +237,6 @@ public abstract class AbstractMenuPanel extends Panel implements EventListener // Code assumes Database version {0}, but Database has Version {1}. String msg = Msg.getMsg(ctx, AD_Message); // complete message msg = MessageFormat.format(msg, new Object[] {Adempiere.DB_VERSION, version}); - throw new ApplicationException(msg); +// throw new ApplicationException(msg); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java index f22f6d573e..58148b0f27 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuPanel.java @@ -21,11 +21,8 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Properties; -import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.event.MenuListener; -import org.adempiere.webui.event.TouchEventHelper; -import org.adempiere.webui.event.TouchEvents; import org.adempiere.webui.exception.ApplicationException; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.TreeUtils; @@ -219,9 +216,6 @@ public class MenuPanel extends Panel implements EventListener link.addEventListener(Events.ON_CLICK, this); link.setSclass("menu-href"); - if (AEnv.isTablet()) { - TouchEventHelper.addOnTapEventListener(link, this); - } } } } @@ -240,11 +234,7 @@ public class MenuPanel extends Panel implements EventListener { Component comp = event.getTarget(); String eventName = event.getName(); - if (eventName.equals(TouchEvents.ON_TAP)) - { - doOnClick(comp); - } - else if (eventName.equals(Events.ON_CLICK) && !TouchEventHelper.isIgnoreClick(comp)) + if (eventName.equals(Events.ON_CLICK)) { doOnClick(comp); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java index 0e1a498f56..1ca8d4ff5e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC1DisplayFieldsPanel.java @@ -84,11 +84,6 @@ public class WRC1DisplayFieldsPanel extends WRCTabPanel implements EventListener wind.appendChild(div); this.appendChild(wind); - if (AEnv.isTablet()) - { - LayoutUtils.addSclass("tablet-scrolling", div); - } - Columns columns = new Columns(); grid.appendChild(columns); Column cols[] = new Column[2*RENDER_IN_COLUMNS]; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC5SummaryFieldsPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC5SummaryFieldsPanel.java index c46a045c3d..461dbb5162 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC5SummaryFieldsPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC5SummaryFieldsPanel.java @@ -72,11 +72,6 @@ public class WRC5SummaryFieldsPanel extends WRCTabPanel implements EventListener wind.appendChild(div); this.appendChild(wind); - if (AEnv.isTablet()) - { - LayoutUtils.addSclass("tablet-scrolling", div); - } - Columns columns = new Columns(); grid.appendChild(columns); Column cols[] = new Column[RENDER_IN_COLUMNS];