IDEMPIERE-231 Zk6: Improve the tablet experience. Fixed scrolling for home page and ad window ( form and grid ). Fixed can't click on grid row to select current record at ad window. Added file link at the bottom of report preview window as a workaround for iframe scrolling issue at iPad.
This commit is contained in:
parent
88d682a2d1
commit
5e3c87abce
|
@ -334,6 +334,7 @@ public class GridPanel extends Borderlayout implements EventListener
|
||||||
|
|
||||||
Center center = new Center();
|
Center center = new Center();
|
||||||
center.appendChild(listbox);
|
center.appendChild(listbox);
|
||||||
|
LayoutUtils.addSclass("mobile-scrolling", center);
|
||||||
this.appendChild(center);
|
this.appendChild(center);
|
||||||
|
|
||||||
if (pageSize > 0)
|
if (pageSize > 0)
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
||||||
colIndex ++;
|
colIndex ++;
|
||||||
|
|
||||||
Div div = new Div();
|
Div div = new Div();
|
||||||
String divStyle = "border: none; width: 100%; height: 100%;";
|
String divStyle = "border: none; width: 100%; height: 100%; cursor: pointer;";
|
||||||
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
|
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
|
||||||
if (column.isVisible()) {
|
if (column.isVisible()) {
|
||||||
Component component = getDisplayComponent(rowIndex, currentValues[i], gridField[i]);
|
Component component = getDisplayComponent(rowIndex, currentValues[i], gridField[i]);
|
||||||
|
@ -406,6 +406,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
|
||||||
div.addEventListener(Events.ON_CLICK, rowListener);
|
div.addEventListener(Events.ON_CLICK, rowListener);
|
||||||
div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
|
div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
|
||||||
row.addEventListener(Events.ON_CLICK, rowListener);
|
row.addEventListener(Events.ON_CLICK, rowListener);
|
||||||
|
row.setStyle("cursor:pointer");
|
||||||
row.appendChild(div);
|
row.appendChild(div);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import java.io.Serializable;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.adempiere.util.ServerContext;
|
import org.adempiere.util.ServerContext;
|
||||||
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.apps.BusyDialog;
|
import org.adempiere.webui.apps.BusyDialog;
|
||||||
import org.adempiere.webui.component.Tabpanel;
|
import org.adempiere.webui.component.Tabpanel;
|
||||||
import org.adempiere.webui.component.ToolBarButton;
|
import org.adempiere.webui.component.ToolBarButton;
|
||||||
|
@ -181,11 +182,14 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
{
|
{
|
||||||
|
|
||||||
homeTab.getChildren().clear();
|
homeTab.getChildren().clear();
|
||||||
|
homeTab.addEventListener("onAddMobileScrolling", this);
|
||||||
|
|
||||||
//register as 0
|
//register as 0
|
||||||
registerWindow(homeTab);
|
registerWindow(homeTab);
|
||||||
|
|
||||||
dashboardController.render(homeTab, this);
|
dashboardController.render(homeTab, this);
|
||||||
|
|
||||||
|
Events.echoEvent("onAddMobileScrolling", homeTab, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onEvent(Event event)
|
public void onEvent(Event event)
|
||||||
|
@ -206,6 +210,10 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (eventName.equals("onAddMobileScrolling"))
|
||||||
|
{
|
||||||
|
LayoutUtils.addSclass("mobile-scrolling", homeTab);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServerPush(ServerPushTemplate template)
|
public void onServerPush(ServerPushTemplate template)
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.adempiere.webui.component.Tabpanel;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
import org.adempiere.webui.panel.ADForm;
|
import org.adempiere.webui.panel.ADForm;
|
||||||
import org.adempiere.webui.part.WindowContainer;
|
import org.adempiere.webui.part.WindowContainer;
|
||||||
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.adempiere.webui.window.ADWindow;
|
import org.adempiere.webui.window.ADWindow;
|
||||||
import org.adempiere.webui.window.WTask;
|
import org.adempiere.webui.window.WTask;
|
||||||
import org.compiere.model.MQuery;
|
import org.compiere.model.MQuery;
|
||||||
|
@ -110,6 +111,7 @@ public abstract class TabbedDesktop extends AbstractDesktop {
|
||||||
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId);
|
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId);
|
||||||
|
|
||||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||||
|
tabPanel.setPage(SessionManager.getAppDesktop().getComponent().getPage());
|
||||||
if (adWindow.createPart(tabPanel) != null) {
|
if (adWindow.createPart(tabPanel) != null) {
|
||||||
preOpenNewTab();
|
preOpenNewTab();
|
||||||
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
|
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
|
||||||
|
@ -130,6 +132,7 @@ public abstract class TabbedDesktop extends AbstractDesktop {
|
||||||
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId, query);
|
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId, query);
|
||||||
|
|
||||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||||
|
tabPanel.setPage(SessionManager.getAppDesktop().getComponent().getPage());
|
||||||
if (adWindow.createPart(tabPanel) != null) {
|
if (adWindow.createPart(tabPanel) != null) {
|
||||||
preOpenNewTab();
|
preOpenNewTab();
|
||||||
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
|
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
|
||||||
|
|
|
@ -222,11 +222,19 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
|
||||||
|
|
||||||
formComponent = layout;
|
formComponent = layout;
|
||||||
treePanel.getTree().addEventListener(Events.ON_SELECT, this);
|
treePanel.getTree().addEventListener(Events.ON_SELECT, this);
|
||||||
|
|
||||||
|
LayoutUtils.addSclass("mobile-scrolling", west);
|
||||||
|
LayoutUtils.addSclass("mobile-scrolling", center);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.appendChild(grid);
|
Div div = new Div();
|
||||||
formComponent = grid;
|
div.setStyle("width:100%;height:100%;border:none;margin:none;padding:none");
|
||||||
|
div.appendChild(grid);
|
||||||
|
this.appendChild(div);
|
||||||
|
formComponent = div;
|
||||||
|
|
||||||
|
LayoutUtils.addSclass("mobile-scrolling", div);
|
||||||
}
|
}
|
||||||
this.appendChild(listPanel);
|
this.appendChild(listPanel);
|
||||||
listPanel.setVisible(false);
|
listPanel.setVisible(false);
|
||||||
|
|
|
@ -26,6 +26,8 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
import org.adempiere.exceptions.AdempiereException;
|
import org.adempiere.exceptions.AdempiereException;
|
||||||
import org.adempiere.pdf.Document;
|
import org.adempiere.pdf.Document;
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
|
@ -62,11 +64,14 @@ import org.compiere.util.Env;
|
||||||
import org.compiere.util.KeyNamePair;
|
import org.compiere.util.KeyNamePair;
|
||||||
import org.compiere.util.Msg;
|
import org.compiere.util.Msg;
|
||||||
import org.zkoss.util.media.AMedia;
|
import org.zkoss.util.media.AMedia;
|
||||||
|
import org.zkoss.util.media.Media;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.Executions;
|
import org.zkoss.zk.ui.Executions;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zk.ui.event.Events;
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zk.ui.ext.render.DynamicMedia;
|
||||||
|
import org.zkoss.zul.A;
|
||||||
import org.zkoss.zul.Borderlayout;
|
import org.zkoss.zul.Borderlayout;
|
||||||
import org.zkoss.zul.Center;
|
import org.zkoss.zul.Center;
|
||||||
import org.zkoss.zul.North;
|
import org.zkoss.zul.North;
|
||||||
|
@ -77,10 +82,13 @@ import org.zkoss.zul.Iframe;
|
||||||
import org.zkoss.zul.Listitem;
|
import org.zkoss.zul.Listitem;
|
||||||
import org.zkoss.zul.Menuitem;
|
import org.zkoss.zul.Menuitem;
|
||||||
import org.zkoss.zul.Separator;
|
import org.zkoss.zul.Separator;
|
||||||
|
import org.zkoss.zul.South;
|
||||||
import org.zkoss.zul.Tab;
|
import org.zkoss.zul.Tab;
|
||||||
import org.zkoss.zul.Toolbar;
|
import org.zkoss.zul.Toolbar;
|
||||||
import org.zkoss.zul.Toolbarbutton;
|
import org.zkoss.zul.Toolbarbutton;
|
||||||
import org.zkoss.zul.Vbox;
|
import org.zkoss.zul.Vbox;
|
||||||
|
import org.zkoss.zul.impl.Utils;
|
||||||
|
import org.zkoss.zul.impl.XulElement;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -100,7 +108,7 @@ import org.zkoss.zul.Vbox;
|
||||||
*
|
*
|
||||||
* @author Low Heng Sin
|
* @author Low Heng Sin
|
||||||
*/
|
*/
|
||||||
public class ZkReportViewer extends Window implements EventListener, ITabOnCloseHandler {
|
public class ZkReportViewer extends Window implements EventListener<Event>, ITabOnCloseHandler {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -147,6 +155,11 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
private Listbox cboType = new Listbox();
|
private Listbox cboType = new Listbox();
|
||||||
private Checkbox summary = new Checkbox();
|
private Checkbox summary = new Checkbox();
|
||||||
|
|
||||||
|
private AMedia media;
|
||||||
|
private int mediaVersion = 0;
|
||||||
|
|
||||||
|
private A reportLink;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Static Layout
|
* Static Layout
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -154,6 +167,8 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
public ZkReportViewer(ReportEngine re, String title) {
|
public ZkReportViewer(ReportEngine re, String title) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
setPage(SessionManager.getAppDesktop().getComponent().getPage());
|
||||||
|
|
||||||
log.info("");
|
log.info("");
|
||||||
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
|
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
|
||||||
Env.setContext(re.getCtx(), m_WindowNo, "_WinInfo_IsReportViewer", "Y");
|
Env.setContext(re.getCtx(), m_WindowNo, "_WinInfo_IsReportViewer", "Y");
|
||||||
|
@ -189,6 +204,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
this.setStyle("width: 100%; height: 100%; position: absolute; border:none; padding:none; margin:none;");
|
this.setStyle("width: 100%; height: 100%; position: absolute; border:none; padding:none; margin:none;");
|
||||||
|
|
||||||
toolBar.setHeight("26px");
|
toolBar.setHeight("26px");
|
||||||
|
toolBar.setWidth("100%");
|
||||||
|
|
||||||
previewType.setMold("select");
|
previewType.setMold("select");
|
||||||
previewType.appendItem("PDF", "PDF");
|
previewType.appendItem("PDF", "PDF");
|
||||||
|
@ -277,10 +293,18 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
layout.appendChild(center);
|
layout.appendChild(center);
|
||||||
iframe = new Iframe();
|
iframe = new Iframe();
|
||||||
iframe.setId("reportFrame");
|
iframe.setId("reportFrame");
|
||||||
iframe.addEventListener(Events.ON_CLICK, this);
|
|
||||||
iframe.addEventListener(Events.ON_RIGHT_CLICK, this);
|
|
||||||
center.appendChild(iframe);
|
center.appendChild(iframe);
|
||||||
|
|
||||||
|
South south = new South();
|
||||||
|
south.setHeight("22px");
|
||||||
|
layout.appendChild(south);
|
||||||
|
reportLink = new A();
|
||||||
|
reportLink.setTarget("_blank");
|
||||||
|
Div linkDiv = new Div();
|
||||||
|
linkDiv.setStyle("width:100%; height: 20px");
|
||||||
|
linkDiv.appendChild(reportLink);
|
||||||
|
south.appendChild(linkDiv);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
renderReport();
|
renderReport();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -291,7 +315,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
|
|
||||||
this.setBorder("normal");
|
this.setBorder("normal");
|
||||||
|
|
||||||
this.addEventListener("onZoom", new EventListener() {
|
this.addEventListener("onZoom", new EventListener<Event>() {
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
if (event instanceof ZoomEvent) {
|
if (event instanceof ZoomEvent) {
|
||||||
|
@ -304,7 +328,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addEventListener(DrillEvent.ON_DRILL_ACROSS, new EventListener() {
|
this.addEventListener(DrillEvent.ON_DRILL_ACROSS, new EventListener<Event>() {
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
if (event instanceof DrillEvent) {
|
if (event instanceof DrillEvent) {
|
||||||
|
@ -323,7 +347,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.addEventListener(DrillEvent.ON_DRILL_DOWN, new EventListener() {
|
this.addEventListener(DrillEvent.ON_DRILL_DOWN, new EventListener<Event>() {
|
||||||
|
|
||||||
public void onEvent(Event event) throws Exception {
|
public void onEvent(Event event) throws Exception {
|
||||||
if (event instanceof DrillEvent) {
|
if (event instanceof DrillEvent) {
|
||||||
|
@ -339,7 +363,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderReport() throws Exception {
|
private void renderReport() throws Exception {
|
||||||
AMedia media = null;
|
media = null;
|
||||||
Listitem selected = previewType.getSelectedItem();
|
Listitem selected = previewType.getSelectedItem();
|
||||||
if (selected == null || "PDF".equals(selected.getValue())) {
|
if (selected == null || "PDF".equals(selected.getValue())) {
|
||||||
String path = System.getProperty("java.io.tmpdir");
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
|
@ -350,7 +374,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
}
|
}
|
||||||
File file = File.createTempFile(prefix, ".pdf", new File(path));
|
File file = File.createTempFile(prefix, ".pdf", new File(path));
|
||||||
m_reportEngine.createPDF(file);
|
m_reportEngine.createPDF(file);
|
||||||
media = new AMedia(getTitle(), "pdf", "application/pdf", file, true);
|
media = new AMedia(file.getName(), "pdf", "application/pdf", file, true);
|
||||||
} else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
|
} else if ("HTML".equals(previewType.getSelectedItem().getValue())) {
|
||||||
String path = System.getProperty("java.io.tmpdir");
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
String prefix = makePrefix(m_reportEngine.getName());
|
String prefix = makePrefix(m_reportEngine.getName());
|
||||||
|
@ -360,7 +384,7 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
}
|
}
|
||||||
File file = File.createTempFile(prefix, ".html", new File(path));
|
File file = File.createTempFile(prefix, ".html", new File(path));
|
||||||
m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", this.getUuid()));
|
m_reportEngine.createHTML(file, false, AEnv.getLanguage(Env.getCtx()), new HTMLExtension(Executions.getCurrent().getContextPath(), "rp", this.getUuid()));
|
||||||
media = new AMedia(getTitle(), "html", "text/html", file, false);
|
media = new AMedia(file.getName(), "html", "text/html", file, false);
|
||||||
} else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
|
} else if ("XLS".equals(previewType.getSelectedItem().getValue())) {
|
||||||
String path = System.getProperty("java.io.tmpdir");
|
String path = System.getProperty("java.io.tmpdir");
|
||||||
String prefix = makePrefix(m_reportEngine.getName());
|
String prefix = makePrefix(m_reportEngine.getName());
|
||||||
|
@ -370,10 +394,21 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
}
|
}
|
||||||
File file = File.createTempFile(prefix, ".xls", new File(path));
|
File file = File.createTempFile(prefix, ".xls", new File(path));
|
||||||
m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
|
m_reportEngine.createXLS(file, AEnv.getLanguage(Env.getCtx()));
|
||||||
media = new AMedia(getTitle(), "xls", "application/vnd.ms-excel", file, true);
|
media = new AMedia(file.getName(), "xls", "application/vnd.ms-excel", file, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Events.echoEvent("onPreviewReport", this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onPreviewReport() {
|
||||||
|
mediaVersion++;
|
||||||
|
String url = Utils.getDynamicMediaURI(this, mediaVersion, media.getName(), media.getFormat());
|
||||||
iframe.setContent(media);
|
iframe.setContent(media);
|
||||||
|
HttpServletRequest request = (HttpServletRequest) Executions.getCurrent().getNativeRequest();
|
||||||
|
if (url.startsWith(request.getContextPath() + "/"))
|
||||||
|
url = url.substring((request.getContextPath() + "/").length());
|
||||||
|
reportLink.setHref(url);
|
||||||
|
reportLink.setLabel(media.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private String makePrefix(String name) {
|
private String makePrefix(String name) {
|
||||||
|
@ -999,4 +1034,19 @@ public class ZkReportViewer extends Window implements EventListener, ITabOnClose
|
||||||
int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID();
|
int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID();
|
||||||
AEnv.zoom(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID));
|
AEnv.zoom(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID));
|
||||||
} // cmd_customize
|
} // cmd_customize
|
||||||
|
|
||||||
|
//-- ComponentCtrl --//
|
||||||
|
public Object getExtraCtrl() {
|
||||||
|
return new ExtraCtrl();
|
||||||
|
}
|
||||||
|
/** A utility class to implement {@link #getExtraCtrl}.
|
||||||
|
* It is used only by component developers.
|
||||||
|
*/
|
||||||
|
protected class ExtraCtrl extends XulElement.ExtraCtrl
|
||||||
|
implements DynamicMedia {
|
||||||
|
//-- DynamicMedia --//
|
||||||
|
public Media getMedia(String pathInfo) {
|
||||||
|
return media;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -525,3 +525,18 @@ img.z-group-img-close {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<%-- Tablet --%>
|
||||||
|
.mobile-scrolling {
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
<%-- Tab --%>
|
||||||
|
.z-tab-close {
|
||||||
|
top:4px;
|
||||||
|
margin-right:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.z-tab-hm-close {
|
||||||
|
padding-right:18px;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue