IDEMPIERE-231 Zk6: Improve the tablet experience. Remove tablet related code that's not applicable for zk 6.5

This commit is contained in:
Heng Sin Low 2012-11-02 16:50:41 +08:00
parent 2bc50c1c30
commit b4fa3b4c34
12 changed files with 8 additions and 261 deletions

View File

@ -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);

View File

@ -521,9 +521,6 @@ public class GridView extends Vbox implements EventListener<Event>
gridFooter.setVisible(false);
}
if (AEnv.isTablet()) {
TouchEventHelper.addTabletScrollingFix(listbox);
}
}
private void updateModel() {

View File

@ -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<Event> {
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<Event>
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<Event>
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<Event>
}
}
}
else if (eventName.equals(ON_ADD_TAP_EVENT_LISTENER))
{
TouchEventHelper.addOnTapEventListener(event.getTarget(), this);
}
//
}

View File

@ -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<Event> {
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<Event
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);
}
@ -137,10 +128,6 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
}
}
}
else if (eventName.equals(ON_ADD_TAP_EVENT_LISTENER))
{
TouchEventHelper.addOnTapEventListener(event.getTarget(), this);
}
}
private void doOnClick(Component comp) {
@ -203,18 +190,6 @@ public class DPRecentItems extends DashboardPanel implements EventListener<Event
btnrecentItem.addEventListener(Events.ON_CLICK, this);
btnrecentItem.addEventListener(Events.ON_DROP, this);
btnrecentItem.setSclass("menu-href");
if (AEnv.isTablet())
{
if (getPage() != null)
{
TouchEventHelper.addOnTapEventListener(btnrecentItem, this);
}
else
{
btnrecentItem.addEventListener(ON_ADD_TAP_EVENT_LISTENER, this);
Events.echoEvent(new Event(ON_ADD_TAP_EVENT_LISTENER, btnrecentItem, null));
}
}
riShown++;
if (riShown >= maxri)

View File

@ -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)

View File

@ -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<Event> {
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<Event> 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.

View File

@ -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";
}

View File

@ -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<E
link.addEventListener(Events.ON_CLICK, this);
link.setSclass("menu-href");
if (AEnv.isTablet()) {
TouchEventHelper.addOnTapEventListener(link, this);
}
treeitem.getTreerow().setDraggable("favourite"); // Elaine 2008/07/24
}
@ -253,11 +247,7 @@ public abstract class AbstractMenuPanel extends Panel implements EventListener<E
{
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);
}

View File

@ -575,7 +575,7 @@ public class LoginPanel extends Window implements EventListener<Event>
// 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);
}
}

View File

@ -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<Event>
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<Event>
{
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);
}

View File

@ -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];

View File

@ -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];