From fc522d72bbdd54dc1a2626a8dbf8a50218c4d3c8 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Fri, 1 Aug 2008 04:58:25 +0000 Subject: [PATCH] - Archived documents/reports implemented - Report viewer implemented - Advanced search criteria implemented --- .../src/org/adempiere/webui/Desktop.java | 2 +- .../src/org/adempiere/webui/IDesktop.java | 1 + .../src/org/adempiere/webui/WArchive.java | 170 +++ .../org/adempiere/webui/acct/WAcctViewer.java | 12 +- .../src/org/adempiere/webui/apps/WReport.java | 50 +- .../webui/apps/form/WArchiveViewer.java | 355 ++++-- .../webui/apps/graph/WPerformanceDetail.java | 3 +- .../adempiere/webui/apps/wf/WWFActivity.java | 15 +- .../webui/component/CWindowToolbar.java | 1 + .../adempiere/webui/component/Combobox.java | 9 - .../adempiere/webui/component/Searchbox.java | 7 +- .../adempiere/webui/component/Searchbox2.java | 97 ++ .../adempiere/webui/editor/WDateEditor.java | 4 +- .../adempiere/webui/editor/WImageEditor.java | 2 +- .../adempiere/webui/editor/WSearchEditor.java | 5 +- .../webui/panel/AbstractADWindowPanel.java | 26 +- .../adempiere/webui/window/FindWindow.java | 459 +++++++- .../webui/window/WAccountDialog.java | 6 +- .../adempiere/webui/window/WEMailDialog.java | 533 +++++++++ .../webui/window/WPAttributeDialog.java | 2 +- .../adempiere/webui/window/ZkJRViewer.java | 2 +- .../webui/window/ZkReportViewer.java | 1024 ++++++++++++++++- .../webui/window/ZkReportViewerProvider.java | 6 +- 23 files changed, 2550 insertions(+), 241 deletions(-) create mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/WArchive.java create mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox2.java create mode 100644 zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java index c56e7e07d6..85a1c13ab1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/Desktop.java @@ -518,7 +518,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow); } - public void addWindow2TabPanel(Window window) + public void showWindowInTabPanel(Window window) { Tabpanel tabPanel = new Tabpanel(); window.setParent(tabPanel); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/IDesktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/IDesktop.java index 5f9da4f603..826c34614d 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/IDesktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/IDesktop.java @@ -26,4 +26,5 @@ public interface IDesktop { public void unregisterWindow(int windowNo); + public void showWindowInTabPanel(Window win); // Elaine 2008/07/30 } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/WArchive.java b/zkwebui/WEB-INF/src/org/adempiere/webui/WArchive.java new file mode 100644 index 0000000000..f20721b52b --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/WArchive.java @@ -0,0 +1,170 @@ +package org.adempiere.webui; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.logging.Level; + +import org.adempiere.webui.apps.form.WArchiveViewer; +import org.adempiere.webui.component.Window; +import org.adempiere.webui.panel.ADForm; +import org.adempiere.webui.session.SessionManager; +import org.compiere.model.MBPartner; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.Msg; +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.zul.Menuitem; +import org.zkoss.zul.Menupopup; + +/** + * Archive Button Consequences. + * Popup Menu + * + * @author Jorg Janke + * @version $Id: AArchive.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ + */ +public class WArchive implements EventListener +{ + /** + * Constructor + * @param invoker button + * @param AD_Table_ID table + * @param Record_ID record + */ + public WArchive (Component invoker, int AD_Table_ID, int Record_ID) + { + log.config("AD_Table_ID=" + AD_Table_ID + ", Record_ID=" + Record_ID); + m_AD_Table_ID = AD_Table_ID; + m_Record_ID = Record_ID; + getArchives(invoker); + } + + /** The Table */ + private int m_AD_Table_ID; + /** The Record */ + private int m_Record_ID; + + /** The Popup */ + private Menupopup m_popup = new Menupopup(); + private Menuitem m_reports = null; + private Menuitem m_reportsAll = null; + private Menuitem m_documents = null; +// private JPopupMenu m_popup = new JPopupMenu("ArchiveMenu"); + + /** Where Clause */ + StringBuffer m_where = null; + + /** Logger */ + private static CLogger log = CLogger.getCLogger (WArchive.class); + + /** + * Display Request Options - New/Existing. + * @param invoker button + */ + private void getArchives(Component invoker) + { + int reportCount = 0; + int documentCount = 0; + + m_where = new StringBuffer(); + m_where.append("(AD_Table_ID=").append(m_AD_Table_ID) + .append(" AND Record_ID=").append(m_Record_ID) + .append(")"); + // Get all for BP + if (m_AD_Table_ID == MBPartner.Table_ID) + m_where.append(" OR C_BPartner_ID=").append(m_Record_ID); + // + StringBuffer sql = new StringBuffer("SELECT IsReport, COUNT(*) FROM AD_Archive ") + .append("WHERE (AD_Table_ID=? AND Record_ID=?) "); + if (m_AD_Table_ID == MBPartner.Table_ID) + sql.append(" OR C_BPartner_ID=?"); + sql.append(" GROUP BY IsReport"); + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement (sql.toString(), null); + pstmt.setInt(1, m_AD_Table_ID); + pstmt.setInt(2, m_Record_ID); + if (m_AD_Table_ID == MBPartner.Table_ID) + pstmt.setInt(3, m_Record_ID); + rs = pstmt.executeQuery (); + while (rs.next ()) + { + if ("Y".equals(rs.getString(1))) + reportCount += rs.getInt(2); + else + documentCount += rs.getInt(2); + } + } + catch (Exception e) + { + log.log(Level.SEVERE, sql.toString(), e); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } + + // + if (documentCount > 0) + { + m_documents = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedDocuments") + + " (" + documentCount + ")"); + m_documents.addEventListener(Events.ON_CLICK, this); + m_popup.appendChild(m_documents); + } + if (reportCount > 0) + { + m_reports = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedReports") + + " (" + reportCount + ")"); + m_reports.addEventListener(Events.ON_CLICK, this); + m_popup.appendChild(m_reports); + } + // All Reports + String sql1 = "SELECT COUNT(*) FROM AD_Archive WHERE AD_Table_ID=? AND IsReport='Y'"; + int allReports = DB.getSQLValue(null, sql1, m_AD_Table_ID); + if (allReports > 0) + { + m_reportsAll = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedReportsAll") + + " (" + reportCount + ")"); + m_reportsAll.addEventListener(Events.ON_CLICK, this); + m_popup.appendChild(m_reportsAll); + } + + if (documentCount == 0 && reportCount == 0 && allReports == 0) + m_popup.appendChild(new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedNone"))); + // + + m_popup.setPage(invoker.getPage()); + m_popup.open(invoker); + } // getZoomTargets + + /** + * Listner + * @param e event + */ + public void onEvent(Event e) throws Exception + { + if (e.getTarget() instanceof Menuitem) + { + int AD_Form_ID = 118; // ArchiveViewer + Window form = ADForm.openForm(AD_Form_ID); + + WArchiveViewer av = (WArchiveViewer) form; + if (e.getTarget() == m_documents) + av.query(false, m_AD_Table_ID, m_Record_ID); + else if (e.getTarget() == m_reports) + av.query(true, m_AD_Table_ID, m_Record_ID); + else // all Reports + av.query(true, m_AD_Table_ID, 0); + + SessionManager.getAppDesktop().showWindowInTabPanel(form); + } + } +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java index 47a5e75506..21d284a235 100755 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java @@ -969,17 +969,9 @@ public class WAcctViewer extends Window implements EventListener else { Listhead listhead = table.getListhead(); - + // remove existing column header - for (int i = listhead.getChildren().size() - 1; i >= 0; i--) - { - Object o = listhead.getChildren().get(i); - if(o instanceof Listheader) - { - Listheader listheader = (Listheader) o; - listhead.removeChild(listheader); - } - } + listhead.getChildren().clear(); // add in new column header for (int i = 0; i < rmodel.getColumnCount(); i++) diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/WReport.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/WReport.java index c3fb613edc..38bc236d29 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/WReport.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/WReport.java @@ -23,7 +23,6 @@ import java.util.logging.Level; import javax.sql.RowSet; import org.adempiere.webui.component.Listbox; -import org.adempiere.webui.component.Window; import org.adempiere.webui.window.FDialog; import org.compiere.apps.ProcessCtl; import org.compiere.model.MQuery; @@ -35,14 +34,15 @@ import org.compiere.print.MPrintFormat; import org.compiere.print.ReportCtl; import org.compiere.print.ReportEngine; import org.compiere.process.ProcessInfo; -import org.compiere.util.ASyncProcess; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.KeyNamePair; +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.zul.ListModelList; +import org.zkoss.zul.Menuitem; +import org.zkoss.zul.Menupopup; /** * Base on org.compiere.print.AReport @@ -72,7 +72,7 @@ public class WReport implements EventListener { * @param parent The invoking parent window * @param WindowNo The invoking parent window number */ - public WReport (int AD_Table_ID, MQuery query, ASyncProcess parent, + public WReport (int AD_Table_ID, MQuery query, Component parent, int WindowNo) { log.config("AD_Table_ID=" + AD_Table_ID + " " + query); @@ -94,13 +94,13 @@ public class WReport implements EventListener { private MQuery m_query; /** The Popup */ private Listbox m_listbox; - private Window m_popup; + private Menupopup m_popup; /** The Option List */ private ArrayList m_list = new ArrayList(); /** Logger */ private static CLogger log = CLogger.getCLogger(AReport.class); /** The parent window for locking/unlocking during process execution */ - ASyncProcess parent; + Component parent; /** The parent window number */ int WindowNo; @@ -148,17 +148,17 @@ public class WReport implements EventListener { } // getPrintFormats private void showPopup() { - m_listbox = new Listbox(); - m_listbox.setModel(ListModelList.instance(m_list)); - m_listbox.addEventListener(Events.ON_SELECT, this); - m_listbox.setHeight("300px"); - m_popup = new Window(); - m_popup.setTitle("Select Report"); - m_popup.appendChild(m_listbox); - m_popup.setAttribute("mode", "popup"); - m_popup.setWidth("200px"); - m_popup.setPosition("center"); - AEnv.showWindow(m_popup); + m_popup = new Menupopup(); + for(int i = 0; i < m_list.size(); i++) + { + KeyNamePair pp = (KeyNamePair) m_list.get(i); + Menuitem menuitem = new Menuitem(pp.getName()); + menuitem.setValue(i + ""); + menuitem.addEventListener(Events.ON_CLICK, this); + m_popup.appendChild(menuitem); + } + m_popup.setPage(parent.getPage()); + m_popup.open(parent); } /** @@ -213,7 +213,7 @@ public class WReport implements EventListener { ProcessInfo pi = new ProcessInfo ("", pf.getJasperProcess_ID()); // Execute Process - ProcessCtl worker = ProcessCtl.process(parent, WindowNo, pi, null); + ProcessCtl worker = ProcessCtl.process(null, WindowNo, pi, null); } else { @@ -238,14 +238,10 @@ public class WReport implements EventListener { } public void onEvent(Event event) { - if (event.getTarget() == m_listbox) { - int i = m_listbox.getSelectedIndex(); - if (i >= 0 ) { - KeyNamePair pp = (KeyNamePair)m_list.get(i); - m_popup.setVisible(false); - m_popup.detach(); - launchReport (pp); - } - } + if(event.getTarget() instanceof Menuitem) + { + Menuitem mi = (Menuitem) event.getTarget(); + launchReport(m_list.get(Integer.parseInt(mi.getValue().toString()))); + } } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java index 19279e8489..fff7c7c736 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java @@ -28,20 +28,21 @@ import java.util.logging.Level; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Checkbox; -import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Datebox; +import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.ListItem; import org.adempiere.webui.component.Listbox; +import org.adempiere.webui.component.Row; +import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Tab; import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Textbox; -import org.adempiere.webui.component.VerticalBox; -import org.adempiere.webui.editor.WEditor; -import org.adempiere.webui.editor.WTableDirEditor; +import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.panel.ADForm; @@ -62,9 +63,9 @@ import org.zkoss.util.media.AMedia; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; +import org.zkoss.zul.Div; import org.zkoss.zul.Hbox; import org.zkoss.zul.Iframe; -import org.zkoss.zul.Separator; /** * Archive Viewer @@ -96,14 +97,14 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange private static CLogger log = CLogger.getCLogger(WArchiveViewer.class); - private VerticalBox queryPanel = new VerticalBox(); +// private Vbox queryPanel = new Vbox(); private Checkbox reportField = new Checkbox(); private Label processLabel = new Label(Msg.translate(Env.getCtx(), "AD_Process_ID")); private Listbox processField = new Listbox(); private Label tableLabel = new Label(Msg.translate(Env.getCtx(), "AD_Table_ID")); private Listbox tableField = new Listbox(); private Label bPartnerLabel = new Label(Msg.translate(Env.getCtx(), "C_BPartner_ID")); - private WEditor bPartnerField = null; + private WSearchEditor bPartnerField = null; private Label nameQLabel = new Label(Msg.translate(Env.getCtx(), "Name")); private Textbox nameQField = new Textbox(); private Label descriptionQLabel = new Label(Msg.translate(Env.getCtx(), "Description")); @@ -116,7 +117,7 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange private Datebox createdQFrom = new Datebox(); private Datebox createdQTo = new Datebox(); - private VerticalBox viewEnterPanel = new VerticalBox(); +// private Vbox viewEnterPanel = new Vbox(); private Button bBack = new Button(); private Button bNext = new Button(); private Label positionInfo = new Label("."); @@ -125,12 +126,12 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange private Datebox createdField = new Datebox(); private Label nameLabel = new Label(Msg.translate(Env.getCtx(), "Name")); - private Textbox nameField = new Textbox("Name"); + private Textbox nameField = new Textbox(); private Label descriptionLabel = new Label(Msg.translate(Env.getCtx(), "Description")); - private Textbox descriptionField = new Textbox("Description"); + private Textbox descriptionField = new Textbox(); private Label helpLabel = new Label(Msg.translate(Env.getCtx(), "Help")); - private Textbox helpField = new Textbox("Help"); - private ConfirmPanel confirmPanel = new ConfirmPanel(true); + private Textbox helpField = new Textbox(); + private WConfirmPanel confirmPanel = new WConfirmPanel(true); private Button updateArchive = new Button(); private Tabbox tabbox = new Tabbox(); @@ -138,6 +139,7 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange private Tabpanels tabpanels = new Tabpanels(); private Iframe iframe = new Iframe(); + private Button bRefresh = new Button(); public WArchiveViewer() { @@ -232,17 +234,16 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange MLookup lookup = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, 2762, DisplayType.Search); - bPartnerField = new WTableDirEditor(lookup, Msg.translate( + bPartnerField = new WSearchEditor(lookup, Msg.translate( Env.getCtx(), "C_BPartner_ID"), "", true, false, true); - bPartnerField.addValueChangeListner(this); } // dynInit private void reportViewer(byte[] data) { - AMedia media = new AMedia("Archive Viewer", "pdf", "application/pdf", data); iframe.setContent(media); + iframe.invalidate(); } /** @@ -253,8 +254,10 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange private void jbInit() throws Exception { tabbox.setWidth("100%"); + tabbox.setHeight("90%"); tabbox.appendChild(tabs); tabbox.appendChild(tabpanels); + tabbox.addEventListener(Events.ON_SELECT, this); processField.setMold("select"); processField.setRows(1); @@ -265,131 +268,227 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange createdByQField.setMold("select"); createdByQField.setRows(1); + updateArchive.setImage("/images/Ok24.gif"); + updateArchive.setTooltiptext("Save Archive"); + updateArchive.addEventListener(Events.ON_CLICK, this); + + bRefresh.setImage("/images/Refresh24.gif"); + bRefresh.setTooltiptext("Refresh"); + bRefresh.addEventListener(Events.ON_CLICK, this); + + bBack.setImage("/images/Parent24.gif"); + bBack.setTooltiptext("Back"); + bBack.addEventListener(Events.ON_CLICK, this); + + bNext.setImage("/images/Detail24.gif"); + bNext.setTooltiptext("Next"); + bNext.addEventListener(Events.ON_CLICK, this); + nameField.addEventListener(Events.ON_CHANGE, this); descriptionField.addEventListener(Events.ON_SELECT, this); helpField.addEventListener(Events.ON_SELECT, this); - updateArchive.addEventListener(Events.ON_CLICK, this); reportField.setLabel(Msg.translate(Env.getCtx(), "IsReport")); reportField.addEventListener(Events.ON_CLICK, this); - Hbox boxProcess = new Hbox(); - boxProcess.setWidth("100%"); - boxProcess.setWidth("30%, 70%"); - boxProcess.appendChild(processLabel); - boxProcess.appendChild(processField); - - Hbox boxBPartner = new Hbox(); - boxBPartner.setWidth("100%"); - boxBPartner.setWidths("30%, 70%"); - boxBPartner.appendChild(bPartnerLabel); - boxBPartner.appendChild(bPartnerField.getComponent()); - - Hbox boxTable = new Hbox(); - boxTable.setWidth("100%"); - boxTable.setWidths("30%, 70%"); - boxTable.appendChild(tableLabel); - boxTable.appendChild(tableField); - - Hbox boxNameQ = new Hbox(); - boxNameQ.setWidth("100%"); - boxNameQ.setWidths("30%, 70%"); - boxNameQ.appendChild(nameQLabel); - boxNameQ.appendChild(nameQField); + Grid gridQuery = new Grid(); + gridQuery.setWidth("500px"); + gridQuery.setStyle("margin:0; padding:0;"); + gridQuery.setSclass("grid-no-striped"); + gridQuery.setOddRowSclass("even"); + + Rows rows = new Rows(); + gridQuery.appendChild(rows); - Hbox boxDescritionQ = new Hbox(); - boxDescritionQ.setWidth("100%"); - boxDescritionQ.setWidths("30%, 70%"); - boxDescritionQ.appendChild(descriptionQLabel); - boxDescritionQ.appendChild(descriptionQField); + Row row = new Row(); + rows.appendChild(row); + row.setSpans("3"); + row.setAlign("right"); + row.appendChild(reportField); - Hbox boxHelpQ = new Hbox(); - boxHelpQ.setWidth("100%"); - boxHelpQ.setWidths("30%, 70%"); - boxHelpQ.appendChild(helpQLabel); - boxHelpQ.appendChild(helpQField); + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + Div div = new Div(); + div.setAlign("right"); + div.appendChild(processLabel); + row.appendChild(div); + row.appendChild(processField); + processField.setWidth("100%"); - Hbox boxCreatedBy = new Hbox(); - boxCreatedBy.setWidth("100%"); - boxCreatedBy.setWidths("30%, 70%"); - boxCreatedBy.appendChild(createdByQLabel); - boxCreatedBy.appendChild(createdByQField); + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + div = new Div(); + div.setAlign("right"); + div.appendChild(bPartnerLabel); + row.appendChild(div); + row.appendChild(bPartnerField.getComponent()); - Hbox boxCreatedQ = new Hbox(); - boxCreatedQ.setWidth("100%"); - boxCreatedQ.setWidths("30%, 35%, 35%"); - boxCreatedQ.appendChild(createdQLabel); - boxCreatedQ.appendChild(createdQFrom); - boxCreatedQ.appendChild(createdQTo); + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + div = new Div(); + div.setAlign("right"); + div.appendChild(tableLabel); + row.appendChild(div); + row.appendChild(tableField); + tableField.setWidth("100%"); - queryPanel.setWidth("50%"); - queryPanel.appendChild(reportField); - queryPanel.appendChild(boxProcess); - queryPanel.appendChild(boxBPartner); - queryPanel.appendChild(boxTable); - queryPanel.appendChild(boxNameQ); - queryPanel.appendChild(boxDescritionQ); - queryPanel.appendChild(boxHelpQ); - queryPanel.appendChild(boxCreatedBy); - queryPanel.appendChild(boxCreatedQ); + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + div = new Div(); + div.setAlign("right"); + div.appendChild(nameQLabel); + row.appendChild(div); + row.appendChild(nameQField); + nameQField.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + div = new Div(); + div.setAlign("right"); + div.appendChild(descriptionQLabel); + row.appendChild(div); + row.appendChild(descriptionQField); + descriptionQField.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + div = new Div(); + div.setAlign("right"); + div.appendChild(helpQLabel); + row.appendChild(div); + row.appendChild(helpQField); + helpQField.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2"); + div = new Div(); + div.setAlign("right"); + div.appendChild(createdByQLabel); + row.appendChild(div); + row.appendChild(createdByQField); + createdByQField.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + div = new Div(); + div.setAlign("right"); + div.appendChild(createdQLabel); + row.appendChild(div); + row.appendChild(createdQFrom); + createdQFrom.setWidth("100%"); + row.appendChild(createdQTo); + createdQTo.setWidth("100%"); + + div = new Div(); + div.setAlign("center"); + div.appendChild(gridQuery); Tabpanel tabQueryPanel = new Tabpanel(); - tabQueryPanel.appendChild(queryPanel); - + tabQueryPanel.appendChild(div); + Tab tabQuery = new Tab("Query"); tabpanels.appendChild(tabQueryPanel); tabs.appendChild(tabQuery); + + Grid gridView = new Grid(); + gridView.setStyle("margin:0; padding:0;"); + gridView.setSclass("grid-no-striped"); + gridView.setOddRowSclass("even"); + + rows = new Rows(); + gridView.appendChild(rows); + + row = new Row(); + rows.appendChild(row); + row.setSpans("1, 2, 1"); + div = new Div(); + div.setAlign("left"); + div.appendChild(bBack); + row.appendChild(div); + div = new Div(); + div.setAlign("center"); + div.appendChild(positionInfo); + row.appendChild(div); + div = new Div(); + div.setAlign("right"); + div.appendChild(bNext); + row.appendChild(div); - bBack.addEventListener(Events.ON_CLICK, this); - bNext.addEventListener(Events.ON_CLICK, this); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(createdByLabel); + createdByLabel.setWidth("100%"); - Hbox boxViewEnter = new Hbox(); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(createdByField); + createdByField.setWidth("100%"); - bBack.setImage("/images/Parent24.gif"); - bNext.setImage("/images/Detail24.gif"); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + div = new Div(); + div.setAlign("right"); + div.appendChild(createdField); + row.appendChild(div); - boxViewEnter.setWidth("100%"); - boxViewEnter.setWidths("10%, 80%, 10%"); - boxViewEnter.appendChild(bBack); - boxViewEnter.appendChild(positionInfo); - boxViewEnter.appendChild(bNext); - - Hbox boxCreatedByV = new Hbox(); - boxCreatedByV.setWidth("100%"); - boxCreatedByV.setWidths("30%, 50%, 20%"); - boxCreatedByV.appendChild(createdByLabel); - boxCreatedByV.appendChild(createdByField); - boxCreatedByV.appendChild(createdField); - - Hbox boxName = new Hbox(); - boxName.setWidth("100%"); - boxName.setWidths("40%, 60%"); - boxName.appendChild(nameLabel); - boxName.appendChild(nameField); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(nameLabel); + nameLabel.setWidth("100%"); - Hbox boxDescription = new Hbox(); - boxDescription.setWidth("100%"); - boxDescription.setWidths("40%, 60%"); - boxDescription.appendChild(descriptionLabel); - boxDescription.appendChild(descriptionField); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(nameField); + nameField.setWidth("100%"); - Hbox boxHelp = new Hbox(); - boxHelp.setWidth("100%"); - boxHelp.setWidths("40%, 60%"); - boxHelp.appendChild(helpLabel); - boxHelp.appendChild(helpField); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(descriptionLabel); + descriptionLabel.setWidth("100%"); - updateArchive.setImage("/images/Ok24.gif"); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(descriptionField); + descriptionField.setRows(3); + descriptionField.setWidth("100%"); - viewEnterPanel.setWidth("100%"); - viewEnterPanel.appendChild(boxViewEnter); - viewEnterPanel.appendChild(boxCreatedByV); - viewEnterPanel.appendChild(boxName); - viewEnterPanel.appendChild(boxDescription); - viewEnterPanel.appendChild(boxHelp); - viewEnterPanel.appendChild(updateArchive); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(helpLabel); + helpLabel.setWidth("100%"); + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + row.appendChild(helpField); + helpField.setRows(3); + helpField.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("4"); + div = new Div(); + div.setAlign("right"); + div.appendChild(bRefresh); + div.appendChild(updateArchive); + row.appendChild(div); + createdByField.setEnabled(false); createdField.setEnabled(false); @@ -398,24 +497,28 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange Tabpanel tabViewPanel = new Tabpanel(); Hbox boxViewSeparator = new Hbox(); boxViewSeparator.setWidth("100%"); - boxViewSeparator.setWidths("50%, 50%"); + boxViewSeparator.setHeight("100%"); + boxViewSeparator.setWidths("70%, 30%"); boxViewSeparator.appendChild(iframe); - boxViewSeparator.appendChild(viewEnterPanel); + boxViewSeparator.appendChild(gridView); tabViewPanel.appendChild(boxViewSeparator); tabs.appendChild(tabView); tabpanels.appendChild(tabViewPanel); - confirmPanel.addActionListener(Events.ON_CLICK, this); + confirmPanel.addEventListener(this); updateQDisplay(); iframe.setId("reportFrame"); - iframe.setHeight("100%"); + int height = Double.valueOf(SessionManager.getAppDesktop().getClientInfo().desktopHeight * 0.8).intValue(); + height = height - 50; + iframe.setHeight(height + "px"); iframe.setWidth("100%"); + iframe.setAutohide(true); - this.setWidth("900px"); + this.setWidth("100%"); + this.setHeight("100%"); this.appendChild(tabbox); - this.appendChild(new Separator()); this.appendChild(confirmPanel); } @@ -425,9 +528,9 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange if (e.getTarget() == updateArchive) cmd_updateArchive(); - else if (confirmPanel.getButton("Cancel").equals(e.getTarget())) + else if (e.getName().equals(WConfirmPanel.A_CANCEL)) SessionManager.getAppDesktop().removeWindow(); - else if (confirmPanel.getButton("Ok").equals(e.getTarget())) + else if (e.getName().equals(WConfirmPanel.A_OK)) { if (tabbox.getSelectedIndex() == 1) SessionManager.getAppDesktop().removeWindow(); @@ -440,6 +543,13 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange updateVDisplay(false); else if (e.getTarget() == bNext) updateVDisplay(true); + else if (e.getTarget() == bRefresh) + iframe.invalidate(); + else if (e.getTarget() instanceof Tab) + { + if(tabbox.getSelectedIndex() == 1) + iframe.invalidate(); + } } public void valueChange(ValueChangeEvent evt) @@ -758,7 +868,8 @@ public class WArchiveViewer extends ADForm implements EventListener, ValueChange log.info("Length=" + m_archives.length); // Display - //this.setSelectedIndex(1); + tabbox.setSelectedIndex(1); + m_index = 1; updateVDisplay(false); } // cmd_query diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java index e48826221a..4c615a5280 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java @@ -1,6 +1,5 @@ package org.adempiere.webui.apps.graph; -import org.adempiere.webui.Desktop; import org.adempiere.webui.component.Window; import org.adempiere.webui.session.SessionManager; import org.compiere.model.MGoal; @@ -29,6 +28,6 @@ public class WPerformanceDetail extends Window WBarGraph barPanel = new WBarGraph(goal); appendChild(barPanel); - ((Desktop) SessionManager.getAppDesktop()).addWindow2TabPanel(this); + SessionManager.getAppDesktop().showWindowInTabPanel(this); } // PerformanceDetail } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java index bf1fad6596..5907885831 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/wf/WWFActivity.java @@ -7,7 +7,6 @@ import java.util.logging.Level; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Button; -import org.adempiere.webui.component.ComboItem; import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.Grid; import org.adempiere.webui.component.Label; @@ -40,6 +39,7 @@ import org.zkoss.zk.ui.event.Events; import org.zkoss.zkex.zul.Borderlayout; import org.zkoss.zkex.zul.Center; import org.zkoss.zkex.zul.South; +import org.zkoss.zul.Comboitem; import org.zkoss.zul.Div; import org.zkoss.zul.Hbox; @@ -444,8 +444,8 @@ public class WWFActivity extends ADForm implements EventListener ValueNamePair[] values = MRefList.getList(Env.getCtx(), 319, false); // _YesNo for(int i = 0; i < values.length; i++) { - ComboItem item = new ComboItem(values[i].getName(), values[i].getValue()); - fAnswerList.appendChild(item); + Comboitem ci = fAnswerList.appendItem(values[i].getName()); + ci.setId(values[i].getValue()); } // fAnswerList.setModel(new DefaultComboBoxModel(values)); fAnswerList.setVisible(true); @@ -455,8 +455,8 @@ public class WWFActivity extends ADForm implements EventListener ValueNamePair[] values = MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false); for(int i = 0; i < values.length; i++) { - ComboItem item = new ComboItem(values[i].getName(), values[i].getValue()); - fAnswerList.appendChild(item); + Comboitem ci = fAnswerList.appendItem(values[i].getName()); + ci.setId(values[i].getValue()); } // fAnswerList.setModel(new DefaultComboBoxModel(values)); fAnswerList.setVisible(true); @@ -649,8 +649,9 @@ public class WWFActivity extends ADForm implements EventListener { // ValueNamePair pp = (ValueNamePair)fAnswerList.getSelectedItem(); // value = pp.getValue(); - ComboItem item = fAnswerList.getSelectedItem(); - value = (String) item.getValue(); + int index = fAnswerList.getSelectedIndex(); + if(index >= 0) + value = fAnswerList.getItemAtIndex(index).getId(); } if (value == null || value.length() == 0) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java index 88ab54e8e5..aa3ab9e9a2 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java @@ -268,6 +268,7 @@ public class CWindowToolbar extends FToolbar implements EventListener btnActiveWorkflows.setDisabled(false); // Elaine 2008/07/17 btnRequests.setDisabled(false); // Elaine 2008/07/22 btnProductInfo.setDisabled(false); // Elaine 2008/07/22 + btnArchive.setDisabled(false); // Elaine 2008/07/28 configureKeyMap(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java index ad84595e98..a7effc6bfc 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Combobox.java @@ -40,13 +40,4 @@ public class Combobox extends org.zkoss.zul.Combobox item.setParent(this); return item; } - - // Elaine 2008/07/22 - public ComboItem getSelectedItem() - { - Comboitem item = super.getSelectedItem(); - if(item == null) return null; - return new ComboItem(item.getLabel(), (String) item.getValue()); - } - // } \ No newline at end of file diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java index e0bac7a3e4..b75cc06953 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox.java @@ -21,9 +21,8 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import org.zkoss.zk.ui.event.EventListener; -import org.zkoss.zul.Hbox; -public class Searchbox extends Hbox +public class Searchbox extends Panel//Hbox { private static final long serialVersionUID = 1L; private PropertyChangeSupport m_propertyChangeListeners = new PropertyChangeSupport(this); @@ -49,11 +48,13 @@ public class Searchbox extends Hbox private void initComponents() { txt = new Textbox(); - txt.setWidth("100%"); +// txt.setWidth("100%"); btn = new Button(); btn.setHeight("98%"); appendChild(txt); appendChild(btn); + + this.setStyle("display: inline-block"); } public Textbox getTextBox() diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox2.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox2.java new file mode 100644 index 0000000000..b7fb72e366 --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/Searchbox2.java @@ -0,0 +1,97 @@ +/****************************************************************************** + * Product: Posterita Ajax UI * + * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * + * 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. * + * For the text or an alternative of this public license, you may reach us * + * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * + * or via info@posterita.org or http://www.posterita.org/ * + *****************************************************************************/ + +package org.adempiere.webui.component; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; + +import org.zkoss.zk.ui.event.EventListener; + +public class Searchbox2 extends Bandbox +{ + private static final long serialVersionUID = 1L; + private PropertyChangeSupport m_propertyChangeListeners = new PropertyChangeSupport(this); +// private Textbox txt; +// private Button btn; + + public Searchbox2() + { + initComponents(); + } + + public Searchbox2(String text) + { + initComponents(); + setText(text); + } + + public void setButtonImage(String imageSrc) + { + this.setImage(imageSrc); + } + + private void initComponents() + { +// txt = new Textbox(); +// txt.setWidth("100%"); +// btn = new Button(); +// btn.setHeight("98%"); +// appendChild(txt); +// appendChild(btn); + } + +// public void setText(String value) +// { +// txt.setText(value); +// } + +// public String getText() +// { +// return txt.getText(); +// } + + public void setEnabled(boolean enabled) + { + setReadonly(!enabled); +// txt.setReadonly(!enabled); +// btn.setEnabled(enabled); + } + + public boolean isEnabled() + { + return !isReadonly(); +// return txt.isReadonly(); + } + + public boolean addEventListener(String evtnm, EventListener listener) + { + return super.addEventListener(evtnm, listener); +// if("onClick".equals(evtnm)) +// { +// return btn.addEventListener(evtnm, listener); +// } +// else +// { +// return txt.addEventListener(evtnm, listener); +// } + } + public synchronized void addPropertyChangeListener(PropertyChangeListener l) + { + m_propertyChangeListeners.addPropertyChangeListener(l); + } +} diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java index d247e4dc24..575a054368 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WDateEditor.java @@ -95,7 +95,9 @@ public class WDateEditor extends WEditor @Override public String getDisplay() { - return null; + // Elaine 2008/07/29 + return getComponent().getText(); + // } @Override diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java index 43ecc19ca8..ef468d68ed 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WImageEditor.java @@ -125,7 +125,7 @@ public class WImageEditor extends WEditor log.fine(m_mImage.toString()); getComponent().setLabel(m_mImage.getName()); if (m_mImage.getDescription() != null) - getComponent().setTooltip(m_mImage.getDescription()); + getComponent().setTooltiptext(m_mImage.getDescription()); } @Override diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java index c3f81bd902..2cd49b062e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/editor/WSearchEditor.java @@ -130,6 +130,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value popupMenu = new WEditorPopupMenu(true, true, true, true); (getComponent().getTextBox()).setContext(popupMenu.getId()); +// getComponent().setContext(popupMenu.getId()); if (columnName.equals("C_BPartner_ID")) { @@ -200,7 +201,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value } @Override - public void propertyChange(PropertyChangeEvent evt) + public void propertyChange(PropertyChangeEvent evt) { if ("FieldValue".equals(evt.getPropertyName())) { @@ -514,7 +515,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value // Result if (result != null) { - log.config(gridField.getColumnName() + " - Result = " + result.toString() + " (" + result.getClass().getName() + ")"); +// log.config(gridField.getColumnName() + " - Result = " + result.toString() + " (" + result.getClass().getName() + ")"); // make sure that value is in cache lookup.getDirect(result, false, true); actionCombo (result); // data binding diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index 58855182af..e9577c52c7 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -20,6 +20,7 @@ package org.adempiere.webui.panel; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.webui.WArchive; import org.adempiere.webui.WRequest; import org.adempiere.webui.WZoomAcross; import org.adempiere.webui.apps.AEnv; @@ -473,11 +474,11 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To return true; } - private void find() - { - MQuery mquery = new MQuery(curTab.getAD_Table_ID()); - - } +// private void find() +// { +// MQuery mquery = new MQuery(curTab.getAD_Table_ID()); +// +// } public void onEvent(Event event) { @@ -1007,7 +1008,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To infoName, infoDisplay); } - new WReport (curTab.getAD_Table_ID(), query, null, curWindowNo); + new WReport (curTab.getAD_Table_ID(), query, toolbar.getEvent().getTarget(), curWindowNo); } @@ -1074,6 +1075,19 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To InfoPanel.showProduct(0); } // + + // Elaine 2008/07/28 + public void onArchive() + { + if (toolbar.getEvent() != null) + { + if (curTab.getRecord_ID() <= 0) + return; + + new WArchive(toolbar.getEvent().getTarget(), curTab.getAD_Table_ID(), curTab.getRecord_ID()); + } + } + // /************************************************************************** * Start Button Process diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index 2bb5efed94..b4359ae89f 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -30,8 +30,10 @@ import java.util.Iterator; import java.util.List; import java.util.Vector; import java.util.logging.Level; +import java.util.regex.Pattern; import org.adempiere.webui.component.Button; +import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.Label; import org.adempiere.webui.component.ListCell; import org.adempiere.webui.component.ListHead; @@ -45,6 +47,7 @@ import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WNumberEditor; +import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.editor.WStringEditor; import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.editor.WebEditorFactory; @@ -55,6 +58,7 @@ import org.compiere.model.GridField; import org.compiere.model.MProduct; import org.compiere.model.MQuery; import org.compiere.model.MRole; +import org.compiere.model.MUserQuery; import org.compiere.model.X_AD_Column; import org.compiere.util.AdempiereSystemError; import org.compiere.util.CLogger; @@ -67,6 +71,7 @@ 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.zul.Comboitem; import org.zkoss.zul.Hbox; import org.zkoss.zul.Vbox; @@ -97,6 +102,8 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe private Textbox fieldName; private Textbox fieldValue; // + private Combobox fQueryName; + // private Listbox advancedPanel; /** container of Simple Window contents */ private Vbox contentSimple; @@ -125,7 +132,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe private boolean hasName = false; private boolean hasDescription = false; /** Line in Simple Content */ - private int sLine = 6; +// private int sLine = 6; /** Value 2(to) */ private boolean m_valueToColumn; /** Between selected */ @@ -140,7 +147,22 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe public static final int TABNO = 99; /** Length of Fields on first tab */ public static final int FIELDLENGTH = 20; - + + private int m_AD_Tab_ID = 1; + private MUserQuery[] userQueries; + + /** Index ColumnName = 0 */ + public static final int INDEX_COLUMNNAME = 0; + /** Index Operator = 1 */ + public static final int INDEX_OPERATOR = 1; + /** Index Value = 2 */ + public static final int INDEX_VALUE = 2; + /** Index Value2 = 3 */ + public static final int INDEX_VALUE2 = 3; + + private static final String FIELD_SEPARATOR = "<^>"; + private static final String SEGMENT_SEPARATOR = "<~>"; + /** * FindPanel Constructor * @param targetWindowNo targetWindowNo @@ -171,15 +193,18 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe initPanel(); initFind(); initFindAdvanced(); + if (m_total < minRecords) { return; } this.setBorder("normal"); - this.setWidth("550px"); + this.setWidth("700px"); this.setTitle(Msg.getMsg(Env.getCtx(), "Find").replaceAll("&", "") + ": " + title); - this.setAttribute("mode", "modal"); + this.setAttribute("modal", Boolean.TRUE); +// this.setAttribute("mode", "modal"); this.setClosable(true); + this.setSizable(true); } /** * initialise lookup record tab @@ -300,6 +325,23 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe btnDelete.setSrc("/images/Delete24.gif"); btnDelete.addEventListener(Events.ON_CLICK, this); + ToolBarButton btnSave = new ToolBarButton(); + btnSave.setAttribute("name","btnSaveAdv"); + btnSave.setSrc("/images/Save24.gif"); + btnSave.addEventListener(Events.ON_CLICK, this); + + fQueryName = new Combobox(); + fQueryName.setTooltiptext(Msg.getMsg(Env.getCtx(),"QueryName")); + fQueryName.setReadonly(false); + + //user query + userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID); + for (int i = 0; i < userQueries.length; i++) + fQueryName.appendItem(userQueries[i].getName()); + fQueryName.setValue(""); + + fQueryName.addEventListener(Events.ON_SELECT, this); + Button btnOk = new Button(); btnOk.setName("btnOkAdv"); btnOk.setSrc("/images/Ok24.gif"); @@ -318,6 +360,8 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe ToolBar toolBar = new ToolBar(); toolBar.appendChild(btnNew); toolBar.appendChild(btnDelete); + toolBar.appendChild(fQueryName); + toolBar.appendChild(btnSave); toolBar.setWidth("100%"); Hbox confirmPanel = new Hbox(); @@ -329,19 +373,23 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe listhead.setSizable(true); ListHeader lstHColumn = new ListHeader(); +<<<<<<< .mine + lstHColumn.setLabel("Column"); +======= lstHColumn.setLabel(Msg.translate(Env.getCtx(), "AD_Column_ID")); lstHColumn.setWidth("100px"); +>>>>>>> .r5927 ListHeader lstHOperator = new ListHeader(); lstHOperator.setLabel(Msg.getMsg(Env.getCtx(), "Operator")); ListHeader lstHQueryValue = new ListHeader(); lstHQueryValue.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue")); - lstHQueryValue.setWidth("200px"); + lstHQueryValue.setWidth("210px"); ListHeader lstHQueryTo = new ListHeader(); lstHQueryTo.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue2")); - lstHQueryTo.setWidth("200px"); + lstHQueryTo.setWidth("210px"); listhead.appendChild(lstHColumn); listhead.appendChild(lstHOperator); @@ -446,12 +494,12 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe private void createFields() { ListItem listItem = new ListItem(); + listItem.setWidth("100%"); Listbox listColumn = new Listbox(); listColumn.setId("listColumn"+listItem.getId()); listColumn.setName("listColumn"); listColumn.setMold("select"); - listColumn.setWidth("150px"); listColumn.setRows(0); listColumn.addEventListener(Events.ON_SELECT,this); @@ -459,12 +507,11 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe listOperator.setId("listOperator"+listItem.getId()); listOperator.setName("listOperator"); listOperator.setMold("select"); - listOperator.setWidth("50px"); listOperator.setRows(0); listOperator.addEventListener(Events.ON_SELECT,this); setValues(listColumn, listOperator); - + ListCell cellColumn = new ListCell(); cellColumn.appendChild(listColumn); cellColumn.setId("cellColumn"+listItem.getId()); @@ -483,10 +530,9 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe listItem.appendChild(cellOperator); listItem.appendChild(cellQueryFrom); listItem.appendChild(cellQueryTo); - + advancedPanel.appendChild(listItem); - advancedPanel.setSelectedItem(listItem); - + advancedPanel.setSelectedItem(listItem); } // createFields /** * sets the list of values of column and operator listboxes @@ -494,6 +540,11 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe * @param listOperator operator **/ private void setValues(Listbox listColumn, Listbox listOperator) + { + setValues(listColumn, listOperator, null); + } + + private void setValues(Listbox listColumn, Listbox listOperator, String[] fields) { // 0 = Columns ArrayList items = new ArrayList(); @@ -518,20 +569,51 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe items.toArray(cols); Arrays.sort(cols); // sort alpha - listColumn.appendItem("","" ); - for (ValueNamePair item: cols) - { - listColumn.appendItem(item.getName(), item.getValue()); - } - listColumn.setSelectedIndex(0); - ValueNamePair[] op = MQuery.OPERATORS; - for (ValueNamePair item: op) + if(fields == null) { - listOperator.appendItem(item.getName(), item.getValue()); + listColumn.appendItem("","" ); + for (ValueNamePair item: cols) + listColumn.appendItem(item.getName(), item.getValue()); + listColumn.setSelectedIndex(0); + + for (ValueNamePair item: op) + listOperator.appendItem(item.getName(), item.getValue()); + listOperator.setSelectedIndex(0); + } + else + { + String columnName = fields.length > INDEX_COLUMNNAME ? fields[INDEX_COLUMNNAME] : ""; + String operator = fields.length > INDEX_OPERATOR ? fields[INDEX_OPERATOR] : ""; + + boolean selected = false; + listColumn.appendItem("",""); + for (int i = 0; i < cols.length; i++) + { + ValueNamePair item = cols[i]; + ListItem li = listColumn.appendItem(item.getName(), item.getValue()); + if(item.getValue().equals(columnName)) + { + listColumn.setSelectedItem(li); + selected = true; + } + } + if(!selected) listColumn.setSelectedIndex(0); + + selected = false; + for (int i = 0; i < op.length; i++) + { + ValueNamePair item = op[i]; + ListItem li = listOperator.appendItem(item.getName(), item.getValue()); + if(item.getValue().equals(operator)) + { + listOperator.setSelectedItem(li); + selected = true; + } + } + if(!selected) listOperator.setSelectedIndex(0); } - listOperator.setSelectedIndex(0); } // setValues /** @@ -604,6 +686,12 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe addRowEditor(componentFrom, (ListCell)row.getFellow("cellQueryFrom"+row.getId())); addRowEditor(componentTo,(ListCell)row.getFellow("cellQueryTo"+row.getId())); } + else if (event.getTarget() == fQueryName) + { + int index = fQueryName.getSelectedIndex(); + if(index < 0) return; + parseUserQuery(userQueries[index]); + } } // else if ("onClick".equals(event.getName())) { @@ -619,11 +707,15 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe else if ("btnDeleteAdv".equals(button.getAttribute("name").toString())) { - int index = advancedPanel.getSelectedIndex(); advancedPanel.getSelectedItem().detach(); advancedPanel.setSelectedIndex(--index); } + + else if ("btnSaveAdv".equals(button.getAttribute("name").toString())) + { + cmd_save(true); + } } // Confirm panel actions else if(event.getTarget() instanceof Button) @@ -686,6 +778,298 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe } // onEvent + private void parseUserQuery(MUserQuery userQuery) + { + String code = userQuery.getCode(); + String[] segments = code.split(Pattern.quote(SEGMENT_SEPARATOR)); + + List rowList = advancedPanel.getChildren(); + for (int rowIndex = rowList.size() - 1; rowIndex >= 1; rowIndex--) + rowList.remove(rowIndex); + + for (int i = 0; i < segments.length; i++) + { + String[] fields = segments[i].split(Pattern.quote(FIELD_SEPARATOR)); + + ListItem listItem = new ListItem(); + listItem.setWidth("100%"); + + Listbox listColumn = new Listbox(); + listColumn.setId("listColumn"+listItem.getId()); + listColumn.setName("listColumn"); + listColumn.setMold("select"); + listColumn.setRows(0); + listColumn.addEventListener(Events.ON_SELECT,this); + + Listbox listOperator = new Listbox(); + listOperator.setId("listOperator"+listItem.getId()); + listOperator.setName("listOperator"); + listOperator.setMold("select"); + listOperator.setRows(0); + listOperator.addEventListener(Events.ON_SELECT,this); + + setValues(listColumn, listOperator, fields); + + ListCell cellColumn = new ListCell(); + cellColumn.appendChild(listColumn); + cellColumn.setId("cellColumn"+listItem.getId()); + + ListCell cellOperator = new ListCell(); + cellOperator.appendChild(listOperator); + cellOperator.setId("cellOperator"+listItem.getId()); + + ListCell cellQueryFrom = new ListCell(); + cellQueryFrom.setId("cellQueryFrom"+listItem.getId()); + + ListCell cellQueryTo = new ListCell(); + cellQueryTo.setId("cellQueryTo"+listItem.getId()); + + listItem.appendChild(cellColumn); + listItem.appendChild(cellOperator); + listItem.appendChild(cellQueryFrom); + listItem.appendChild(cellQueryTo); + + String columnName = listColumn.getSelectedItem().getValue().toString(); + String value = fields.length > INDEX_VALUE ? fields[INDEX_VALUE] : ""; + if(value.length() > 0) + { + cellQueryFrom.appendChild(parseString(getTargetMField(columnName), value)); + } + + String value2 = fields.length > INDEX_VALUE2 ? fields[INDEX_VALUE2] : ""; + if(value2.length() > 0) + { + cellQueryTo.appendChild(parseString(getTargetMField(columnName), value2)); + } + + advancedPanel.appendChild(listItem); +// advancedPanel.setSelectedItem(listItem); + } + + advancedPanel.invalidate(); + } + + /** + * Parse String + * @param field column + * @param in value + * @return data type corected value + */ + private Label parseString(GridField field, String in) + { + if (in == null) + return null; + int dt = field.getDisplayType(); + try + { + if (field.isKey()) + m_editor = new WNumberEditor(field); + else + m_editor = WebEditorFactory.getEditor(field, true); + if (m_editor == null) + m_editor = new WStringEditor(field); + + // Return Integer + if (dt == DisplayType.Integer + || (DisplayType.isID(dt) && field.getColumnName().endsWith("_ID"))) + { + int i = Integer.parseInt(in); + m_editor.setValue(new Integer(i)); + } + // Return BigDecimal + else if (DisplayType.isNumeric(dt)) + { + m_editor.setValue(DisplayType.getNumberFormat(dt).parse(in)); + } + // Return Timestamp + else if (DisplayType.isDate(dt)) + { + long time = 0; + try + { + time = DisplayType.getDateFormat_JDBC().parse(in).getTime(); + m_editor.setValue(new Timestamp(time)); + } + catch (Exception e) + { + log.log(Level.SEVERE, in + "(" + in.getClass() + ")" + e); + time = DisplayType.getDateFormat(dt).parse(in).getTime(); + } + + m_editor.setValue(new Timestamp(time)); + } + else if (dt == DisplayType.YesNo) + m_editor.setValue(Boolean.valueOf(in)); + else + m_editor.setValue(in); + + Label label = new Label(); + if(m_editor instanceof WSearchEditor) + { + WSearchEditor se = (WSearchEditor) m_editor; + String display = se.getGridField().getLookup().getDisplay(m_editor.getValue().toString()); + label.setValue(display); + } + else + { + label.setValue(m_editor.getDisplay()); + } + label.setAttribute("value", m_editor.getValue()); + return label; + } + catch (Exception ex) + { + log.log(Level.SEVERE, "Object=" + in, ex); + return null; + } + + } // parseValue + + private void cmd_save(boolean saveQuery) + { +// advancedTable.stopEditor(true); + // + m_query = new MQuery(m_tableName); + StringBuffer code = new StringBuffer(); + + List rowList = advancedPanel.getChildren(); + + for (int rowIndex = 1; rowIndex < rowList.size() ; rowIndex++) + { + // Column + ListItem row = (ListItem)rowList.get(rowIndex); + Listbox column = (Listbox)row.getFellow("listColumn"+row.getId()); + if (column == null) + continue; + String ColumnName = column.getSelectedItem().getValue().toString(); + String infoName = column.toString(); + // + GridField field = getTargetMField(ColumnName); + if(field == null) continue; // Elaine 2008/07/29 + boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID()); + String ColumnSQL = field.getColumnSQL(false); + // Op + Listbox op = (Listbox)row.getFellow("listOperator"+row.getId()); + if (op == null) + continue; + String Operator = op.getSelectedItem().getValue().toString(); + + // Value ****** + ListCell cellQueryFrom = (ListCell)row.getFellow("cellQueryFrom"+row.getId()); + // Elaine 2008/07/29 + if(!(cellQueryFrom.getChildren().get(0) instanceof Label)) + continue; + // + Label labelFrom = (Label)(cellQueryFrom.getChildren().get(0)); + Object value = labelFrom.getAttribute("value"); + if (value == null) + continue; + Object parsedValue = parseValue(field, value); + if (parsedValue == null) + continue; + String infoDisplay = value.toString(); + if (field.isLookup()) + infoDisplay = field.getLookup().getDisplay(value); + else if (field.getDisplayType() == DisplayType.YesNo) + infoDisplay = Msg.getMsg(Env.getCtx(), infoDisplay); + // Value2 ****** + Object value2 = null; + if (MQuery.OPERATORS[MQuery.BETWEEN_INDEX].equals(op)) + { + ListCell cellQueryTo = (ListCell)row.getFellow("cellQueryTo"+row.getId()); + // Elaine 2008/07/29 + if(!(cellQueryTo.getChildren().get(0) instanceof Label)) + continue; + // + Label labelTo = (Label)(cellQueryTo.getChildren().get(0)); + value2 = labelTo.getAttribute("value"); + if (value2 == null) + continue; + Object parsedValue2 = parseValue(field, value2); + String infoDisplay_to = value2.toString(); + if (parsedValue2 == null) + continue; + m_query.addRangeRestriction(ColumnSQL, parsedValue, parsedValue2, + infoName, infoDisplay, infoDisplay_to); + } + else if (isProductCategoryField && MQuery.OPERATORS[MQuery.EQUAL_INDEX].equals(op)) { + if (!(parsedValue instanceof Integer)) { + continue; + } + m_query + + .addRestriction(getSubCategoryWhereClause(((Integer) parsedValue).intValue())); + } + else + m_query.addRestriction(ColumnSQL, Operator, parsedValue, + infoName, infoDisplay); + + if (code.length() > 0) + code.append(SEGMENT_SEPARATOR); + code.append(ColumnName) + .append(FIELD_SEPARATOR) + .append(Operator) + .append(FIELD_SEPARATOR) + .append(value.toString()) + .append(FIELD_SEPARATOR) + .append(value2 != null ? value2.toString() : ""); + } + String selected = fQueryName.getValue(); + if (selected != null && saveQuery) { + String name = selected; + MUserQuery uq = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID, name); + if (uq == null && code.length() > 0) + { + uq = new MUserQuery (Env.getCtx(), 0, null); + uq.setName (name); + uq.setAD_Tab_ID(m_AD_Tab_ID); //red1 UserQuery [ 1798539 ] taking in new field from Compiere + uq.setAD_User_ID(Env.getAD_User_ID(Env.getCtx())); //red1 - [ 1798539 ] missing in Compiere delayed source :-) + } + else if (uq != null && code.length() == 0) + { + if (uq.delete(true)) + { + FDialog.info (m_targetWindowNo, this, "Deleted", name); + refreshUserQueries(); + } + else + FDialog.warn (m_targetWindowNo, this, "DeleteError", name); + return; + } + else + return; + uq.setCode (code.toString()); + uq.setAD_Table_ID (m_AD_Table_ID); + // + if (uq.save()) + { + FDialog.info (m_targetWindowNo, this, "Saved", name); + refreshUserQueries(); + } + else + FDialog.warn (m_targetWindowNo, this, "SaveError", name); + } + } // cmd_save + + private void refreshUserQueries() + { + String value = fQueryName.getValue(); + userQueries = MUserQuery.get(Env.getCtx(), m_AD_Tab_ID); + fQueryName.getItems().clear(); + boolean selected = false; + for (int i = 0; i < userQueries.length; i++) + { + Comboitem ci = fQueryName.appendItem(userQueries[i].getName()); + if(value.equals(userQueries[i].getName())) + { + fQueryName.setSelectedItem(ci); + selected = true; + } + } + + if(!selected) fQueryName.setValue(""); + } + /** * retrieve the columnName of the Column item selected * @param label label @@ -734,7 +1118,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe listcell.setLabel(""); listcell.getChildren().clear(); listcell.appendChild(component); - } // addComponent /** @@ -797,12 +1180,15 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe // Create Editor GridField field = getTargetMField(columnName); // log.fine( "Field=" + field.toStringX()); + if(field == null) return new Label(""); + if (field.isKey()) m_editor = new WNumberEditor(field); else m_editor = WebEditorFactory.getEditor(field, true); if (m_editor == null) m_editor = new WStringEditor(field); + field.addPropertyChangeListener(m_editor); m_editor.addValueChangeListner(this); m_editor.setValue(null); @@ -966,6 +1352,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe String infoName = column.toString(); // GridField field = getTargetMField(ColumnName); + if(field == null) continue; // Elaine 2008/07/29 boolean isProductCategoryField = isProductCategoryField(field.getAD_Column_ID()); String ColumnSQL = field.getColumnSQL(false); // Op @@ -976,6 +1363,10 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe // Value ****** ListCell cellQueryFrom = (ListCell)row.getFellow("cellQueryFrom"+row.getId()); + // Elaine 2008/07/29 + if(!(cellQueryFrom.getChildren().get(0) instanceof Label)) + continue; + // Label labelFrom = (Label)(cellQueryFrom.getChildren().get(0)); Object value = labelFrom.getAttribute("value"); if (value == null) @@ -992,6 +1383,10 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe if (MQuery.OPERATORS[MQuery.BETWEEN_INDEX].equals(op)) { ListCell cellQueryTo = (ListCell)row.getFellow("cellQueryTo"+row.getId()); + // Elaine 2008/07/29 + if(!(cellQueryTo.getChildren().get(0) instanceof Label)) + continue; + // Label labelTo = (Label)(cellQueryTo.getChildren().get(0)); Object value2 = labelTo.getAttribute("value"); if (value2 == null) @@ -1286,10 +1681,22 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe WEditor editor = (WEditor)evt.getSource(); // Editor component Component component = editor.getComponent(); - ListCell listcell = (ListCell)component.getParent(); - Label label = new Label(evt.getNewValue().toString()); + + // Elaine 2008/07/29 + Label label = new Label(); + if(evt.getSource() instanceof WSearchEditor) + { + WSearchEditor se = (WSearchEditor) evt.getSource(); + String display = se.getGridField().getLookup().getDisplay(evt.getNewValue().toString()); + label.setValue(display); + } + else + { + label.setValue(editor.getDisplay()); + } label.setAttribute("value", evt.getNewValue()); + // listcell.appendChild(label); listcell.removeChild(component); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java index 972adbb7a0..543435bde9 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java @@ -170,13 +170,13 @@ public final class WAccountDialog extends Window toolBar.setStyle("border: none; margin: 5px"); bSave.setImage("images/Save24.gif"); - bSave.setTooltip(Msg.getMsg(Env.getCtx(),"AccountNewUpdate")); + bSave.setTooltiptext(Msg.getMsg(Env.getCtx(),"AccountNewUpdate")); bSave.addEventListener(Events.ON_CLICK, this); bRefresh.setImage("images/Refresh24.gif"); - bRefresh.setTooltip(Msg.getMsg(Env.getCtx(),"Refresh")); + bRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(),"Refresh")); bRefresh.addEventListener(Events.ON_CLICK, this); bIgnore.setImage("images/Ignore24.gif"); - bIgnore.setTooltip(Msg.getMsg(Env.getCtx(),"Ignore")); + bIgnore.setTooltiptext(Msg.getMsg(Env.getCtx(),"Ignore")); bIgnore.addEventListener(Events.ON_CLICK, this); // toolBar.appendChild(bRefresh); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java new file mode 100644 index 0000000000..fa14acc654 --- /dev/null +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java @@ -0,0 +1,533 @@ +/****************************************************************************** + * Product: Adempiere ERP & CRM Smart Business Solution * + * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. * + * 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. * + * For the text or an alternative of this public license, you may reach us * + * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA * + * or via info@compiere.org or http://www.compiere.org/license.html * + * Contributor(s): * + *****************************************************************************/ +package org.adempiere.webui.window; + +import java.beans.PropertyVetoException; +import java.io.File; +import java.util.StringTokenizer; +import java.util.logging.Level; + +import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.Label; +import org.adempiere.webui.component.Row; +import org.adempiere.webui.component.Rows; +import org.adempiere.webui.component.Textbox; +import org.adempiere.webui.component.WConfirmPanel; +import org.adempiere.webui.component.WStatusBar; +import org.adempiere.webui.component.Window; +import org.adempiere.webui.editor.WSearchEditor; +import org.adempiere.webui.event.ValueChangeEvent; +import org.adempiere.webui.event.ValueChangeListener; +import org.compiere.model.Lookup; +import org.compiere.model.MClient; +import org.compiere.model.MLookupFactory; +import org.compiere.model.MUser; +import org.compiere.model.MUserMail; +import org.compiere.util.CLogger; +import org.compiere.util.DisplayType; +import org.compiere.util.EMail; +import org.compiere.util.Env; +import org.compiere.util.Msg; +import org.zkoss.zk.ui.event.Event; +import org.zkoss.zk.ui.event.EventListener; +import org.zkoss.zkex.zul.Borderlayout; +import org.zkoss.zkex.zul.Center; +import org.zkoss.zkex.zul.South; +import org.zkoss.zul.Div; +import org.zkoss.zul.Separator; + +/** + * EMail Dialog + * + * @author Jorg Janke + * @version $Id: EMailDialog.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $ + * + * globalqss: integrate phib fixing bug reported here + * http://sourceforge.net/tracker/index.php?func=detail&aid=1568765&group_id=176962&atid=879332 + * + * phib - fixing bug [ 1568765 ] Close email dialog button broken + * + * globalqss - Carlos Ruiz - implement CC - FR [ 1754879 ] Enhancements on sending e-mail + * + */ +public class WEMailDialog extends Window implements EventListener, ValueChangeListener +{ + private static final long serialVersionUID = 1L; + + /** + * EMail Dialog + * @param owner calling window + * @param title title + * @param from from + * @param to to + * @param subject subject + * @param message message + * @param attachment optional attachment + */ + public WEMailDialog (Window owner, String title, MUser from, String to, + String subject, String message, File attachment) + { + super(); + this.setTitle(title); + this.setWidth("500px"); + this.setHeight("500px"); + this.setClosable(true); + this.setBorder("normal"); + this.setStyle("position:absolute"); + + commonInit(from, to, subject, message, attachment); + } // EmailDialog + + /** + * Common Init + * @param from from + * @param to to + * @param subject subject + * @param message message + * @param attachment optional attachment + */ + private void commonInit (MUser from, String to, + String subject, String message, File attachment) + { + m_client = MClient.get(Env.getCtx()); + try + { + int WindowNo = 0; + int AD_Column_ID = 0; + Lookup lookup = MLookupFactory.get (Env.getCtx(), WindowNo, + AD_Column_ID, DisplayType.Search, + Env.getLanguage(Env.getCtx()), "AD_User_ID", 0, false, + "EMail IS NOT NULL"); + + fUser = new WSearchEditor(lookup, "AD_User_ID", "", false, false, true); + fUser.addValueChangeListner(this); + fCcUser = new WSearchEditor(lookup, "AD_User_ID", "", false, false, true); + fCcUser.addValueChangeListner(this); + jbInit(); + } + catch(Exception ex) + { + log.log(Level.SEVERE, "EMailDialog", ex); + } + set(from, to, subject, message); + setAttachment(attachment); + AEnv.showCenterScreen(this); + } // commonInit + + + /** Client */ + private MClient m_client = null; + /** Sender */ + private MUser m_from = null; + /** Primary Recipient */ + private MUser m_user = null; + /** Cc Recipient */ + private MUser m_ccuser = null; + // + private String m_to; + private String m_cc; + private String m_subject; + private String m_message; + /** File to be optionally attached */ + private File m_attachFile; + /** Logger */ + private static CLogger log = CLogger.getCLogger(WEMailDialog.class); + +// private CPanel mainPanel = new CPanel(); +// private BorderLayout mainLayout = new BorderLayout(); +// private CPanel headerPanel = new CPanel(); +// private GridBagLayout headerLayout = new GridBagLayout(); + private Textbox fFrom = new Textbox();//20); + private Textbox fTo = new Textbox();//20); + private Textbox fCc = new Textbox();//20); + private WSearchEditor fUser = null; + private WSearchEditor fCcUser = null; + private Textbox fSubject = new Textbox();//40); + private Label lFrom = new Label(); + private Label lTo = new Label(); + private Label lCc = new Label(); + private Label lSubject = new Label(); + private Label lAttachment = new Label(); + private Textbox fAttachment = new Textbox();//40); + private Textbox fMessage = new Textbox(); + private WConfirmPanel confirmPanel = new WConfirmPanel(true); + private WStatusBar statusBar = new WStatusBar(); + + /** + * Static Init + */ + void jbInit() throws Exception + { + lFrom.setValue(Msg.getMsg(Env.getCtx(), "From") + ":"); + lTo.setValue(Msg.getMsg(Env.getCtx(), "To") + ":"); + lCc.setValue(Msg.getMsg(Env.getCtx(), "Cc") + ":"); + lSubject.setValue(Msg.getMsg(Env.getCtx(), "Subject") + ":"); + lAttachment.setValue(Msg.getMsg(Env.getCtx(), "Attachment") + ":"); + fFrom.setReadonly(true); + statusBar.setStatusDB(null); + // + + Grid grid = new Grid(); + grid.setWidth("480px"); + grid.setStyle("margin:0; padding:0; position: absolute; align: center; valign: center;"); + grid.setSclass("grid-no-striped"); + grid.setOddRowSclass("even"); + + Rows rows = new Rows(); + grid.appendChild(rows); + + Row row = new Row(); + rows.appendChild(row); + Div div = new Div(); + div.setAlign("right"); + div.appendChild(lFrom); + row.appendChild(div); + row.appendChild(fFrom); + fFrom.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + div = new Div(); + div.setAlign("right"); + div.appendChild(lTo); + row.appendChild(div); + row.appendChild(fUser.getComponent()); + fUser.getComponent().setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.appendChild(new Label("")); + row.appendChild(fTo); + fTo.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + div = new Div(); + div.setAlign("right"); + div.appendChild(lCc); + row.appendChild(div); + row.appendChild(fCcUser.getComponent()); + fCcUser.getComponent().setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.appendChild(new Label("")); + row.appendChild(fCc); + fCc.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("2"); + row.appendChild(new Separator()); + + row = new Row(); + rows.appendChild(row); + div = new Div(); + div.setAlign("right"); + div.appendChild(lSubject); + row.appendChild(div); + row.appendChild(fSubject); + fSubject.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("2"); + row.appendChild(new Separator()); + + row = new Row(); + rows.appendChild(row); + div = new Div(); + div.setAlign("right"); + div.appendChild(lAttachment); + row.appendChild(div); + row.appendChild(fAttachment); + fAttachment.setWidth("100%"); + + row = new Row(); + rows.appendChild(row); + row.setSpans("2"); + row.appendChild(fMessage); + fMessage.setWidth("100%"); + fMessage.setRows(10); + + row = new Row(); + rows.appendChild(row); + row.setSpans("2"); + row.appendChild(confirmPanel); + confirmPanel.addEventListener(this); + + Borderlayout layout = new Borderlayout(); + layout.setWidth("490px"); + layout.setHeight("470px"); + layout.setStyle("background-color: white; position: absolute;"); + + Center center = new Center(); + center.appendChild(grid); + layout.appendChild(center); + center.setStyle("background-color: white"); + + South south = new South(); + south.appendChild(statusBar); + statusBar.setWidth("100%"); + layout.appendChild(south); + south.setStyle("background-color: white"); + + this.appendChild(layout); + } // jbInit + + /** + * Set all properties + */ + public void set (MUser from, String to, String subject, String message) + { + // Content + setFrom(from); + setTo(to); + setSubject(subject); + setMessage(message); + // + statusBar.setStatusLine(m_client.getSMTPHost()); + } // set + + /** + * Set Address + */ + public void setTo(String newTo) + { + m_to = newTo; + fTo.setText(m_to); + } // setTo + + /** + * Set CC Address + */ + public void setCc(String newCc) + { + m_cc = newCc; + fCc.setText(m_cc); + } // setCc + + /** + * Get Address + */ + public String getTo() + { + m_to = fTo.getText(); + return m_to; + } // getTo + + /** + * Get CC Address + */ + public String getCc() + { + m_cc = fCc.getText(); + return m_cc; + } // getCc + + /** + * Set Sender + */ + public void setFrom(MUser newFrom) + { + m_from = newFrom; + if (newFrom == null + || !newFrom.isEMailValid() + || !newFrom.isCanSendEMail()) + { +// confirmPanel.getOKButton().setEnabled(false); + fFrom.setText("**Invalid**"); + } + else + fFrom.setText(m_from.getEMail()); + } // setFrom + + /** + * Get Sender + */ + public MUser getFrom() + { + return m_from; + } // getFrom + + /** + * Set Subject + */ + public void setSubject(String newSubject) + { + m_subject = newSubject; + fSubject.setText(m_subject); + } // setSubject + + /** + * Get Subject + */ + public String getSubject() + { + m_subject = fSubject.getText(); + return m_subject; + } // getSubject + + /** + * Set Message + */ + public void setMessage(String newMessage) + { + m_message = newMessage; + fMessage.setText(m_message); +// fMessage.setCaretPosition(0); + } // setMessage + + /** + * Get Message + */ + public String getMessage() + { + m_message = fMessage.getText(); + return m_message; + } // getMessage + + /** + * Set Attachment + */ + public void setAttachment (File attachment) + { + m_attachFile = attachment; + if (attachment == null) + { + lAttachment.setVisible(false); + fAttachment.setVisible(false); + } + else + { + lAttachment.setVisible(true); + fAttachment.setVisible(true); + fAttachment.setText(attachment.getName()); + fAttachment.setReadonly(true); + } + } // setAttachment + + /** + * Get Attachment + */ + public File getAttachment() + { + return m_attachFile; + } // getAttachment + + /************************************************************************** + * Action Listener - Send email + */ + public void onEvent(Event event) throws Exception { + if (event.getName().equals(WConfirmPanel.A_CANCEL)) + onClose(); + + if (getTo() == null || getTo().length() == 0) + { + return; + } + // Send + if (event.getName().equals(WConfirmPanel.A_OK)) + { +// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); +// confirmPanel.getOKButton().setEnabled(false); + + StringTokenizer st = new StringTokenizer(getTo(), " ,;", false); + String to = st.nextToken(); + EMail email = m_client.createEMail(getFrom(), to, getSubject(), getMessage()); + String status = "Check Setup"; + if (email != null) + { + while (st.hasMoreTokens()) + email.addTo(st.nextToken()); + // cc + StringTokenizer stcc = new StringTokenizer(getCc(), " ,;", false); + while (stcc.hasMoreTokens()) + { + String cc = stcc.nextToken(); + if (cc != null && cc.length() > 0) + email.addCc(cc); + } + // Attachment + if (m_attachFile != null && m_attachFile.exists()) + email.addAttachment(m_attachFile); + status = email.send(); + // + if (m_user != null) + new MUserMail(m_user, m_user.getAD_User_ID(), email).save(); + if (email.isSentOK()) + { + FDialog.info(0, this, "MessageSent"); + onClose(); + } + else + FDialog.error(0, this, "MessageNotSent", status); + } + else + FDialog.error(0, this, "MessageNotSent", status); + // +// confirmPanel.getOKButton().setEnabled(false); +// setCursor(Cursor.getDefaultCursor()); + } + else if (event.getName().equals(WConfirmPanel.A_CANCEL)) + onClose(); + } + + /** + * Vetoable Change - User selected + * @param evt + * @throws PropertyVetoException + */ + public void valueChange(ValueChangeEvent evt) { + WSearchEditor source = (WSearchEditor) evt.getSource(); + Object value = evt.getNewValue(); + + log.info("Value=" + value); + + if (value == null) + { + return; + } + + if (source.equals(fUser)) { + // fUser + if (value == null) + fTo.setText(""); + if (value instanceof Integer) + { + int AD_User_ID = ((Integer)value).intValue(); + m_user = MUser.get(Env.getCtx(), AD_User_ID); + fTo.setValue(m_user.getEMail()); + } + } else { + // fCcUser + if (value == null) + fCc.setText(""); + if (value instanceof Integer) + { + int AD_User_ID = ((Integer)value).intValue(); + m_ccuser = MUser.get(Env.getCtx(), AD_User_ID); + fCc.setValue(m_ccuser.getEMail()); + } + } + + return; + } + +} // VEMailDialog \ No newline at end of file diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java index 2d2d2c8c9d..8a1385684c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java @@ -430,7 +430,7 @@ public class WPAttributeDialog extends Window implements EventListener label.setStyle("font-weight: bold"); if (attribute.getDescription() != null) - label.setTooltip(attribute.getDescription()); + label.setTooltiptext(attribute.getDescription()); Row row = new Row(); row.setParent(rows); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java index a53f6655ef..86309fc2e1 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java @@ -33,7 +33,7 @@ public class ZkJRViewer extends Window { toolbar.setHeight("26px"); Toolbarbutton button = new Toolbarbutton(); button.setImage("/images/Print24.gif"); - button.setTooltip("Print"); + button.setTooltiptext("Print"); toolbar.appendChild(button); row.appendChild(toolbar); rows.appendChild(row); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 7f1e9a46d3..376cbe0a21 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -16,55 +16,257 @@ *****************************************************************************/ package org.adempiere.webui.window; +import java.awt.Point; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.StringWriter; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Properties; +import java.util.logging.Level; + +import org.adempiere.pdf.Document; +import org.adempiere.webui.apps.AEnv; +import org.adempiere.webui.component.ComboItem; +import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.Grid; +import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; +import org.adempiere.webui.component.WConfirmPanel; import org.adempiere.webui.component.Window; +import org.adempiere.webui.panel.StatusBarPanel; import org.adempiere.webui.session.SessionManager; +import org.compiere.model.GridField; +import org.compiere.model.MArchive; +import org.compiere.model.MClient; +import org.compiere.model.MQuery; +import org.compiere.model.MRole; +import org.compiere.model.MUser; +import org.compiere.print.AReport; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; +import org.compiere.print.View; +import org.compiere.util.CLogger; +import org.compiere.util.DB; +import org.compiere.util.Env; +import org.compiere.util.KeyNamePair; +import org.compiere.util.Msg; +import org.compiere.util.ValueNamePair; import org.zkoss.util.media.AMedia; +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.MouseEvent; +import org.zkoss.zul.Comboitem; +import org.zkoss.zul.Div; +import org.zkoss.zul.Filedownload; +import org.zkoss.zul.Hbox; import org.zkoss.zul.Iframe; +import org.zkoss.zul.Menuitem; +import org.zkoss.zul.Menupopup; +import org.zkoss.zul.Separator; import org.zkoss.zul.Toolbar; import org.zkoss.zul.Toolbarbutton; +import org.zkoss.zul.Vbox; /** + * Print View Frame + * + * @author Jorg Janke + * @version $Id: Viewer.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ + * globalqss: integrate phib contribution from + * http://sourceforge.net/tracker/index.php?func=detail&aid=1566335&group_id=176962&atid=879334 + * globalqss: integrate Teo Sarca bug fixing + * Colin Rooney 2007/03/20 RFE#1670185 & BUG#1684142 + * Extend security to Info queries + * + * @author Teo Sarca, SC ARHIPAC SERVICE SRL + *
  • FR [ 1762466 ] Add "Window" menu to report viewer. + *
  • FR [ 1894640 ] Report Engine: Excel Export support * * @author Low Heng Sin - * - */public class ZkReportViewer extends Window { + */ +public class ZkReportViewer extends Window implements EventListener { - private ReportEngine report; + private static final long serialVersionUID = 1L; + + /** Window No */ + private int m_WindowNo; + /** Print Context */ + private Properties m_ctx; + /** Page No */ +// private int m_pageNo = 1; + /** Max Page Number */ +// private int m_pageMax = 1; + /** View Pane */ + private View m_viewPanel; + /** Setting Values */ + private boolean m_setting = false; + /** Report Engine */ + private ReportEngine m_reportEngine; + /** Drill Down/Across */ + private boolean m_drillDown = true; + /** Table ID */ + private int m_AD_Table_ID = 0; + private boolean m_isCanExport; + + private MQuery m_ddQ = null; + private MQuery m_daQ = null; + private Menuitem m_ddM = null; + private Menuitem m_daM = null; - public ZkReportViewer(ReportEngine re, String title) { - this.report = re; - this.setTitle(title); - init(); + /** Logger */ + private static CLogger log = CLogger.getCLogger(ZkReportViewer.class); + + // +// private CPanel northPanel = new CPanel(); +// private JScrollPane centerScrollPane = new JScrollPane(); + private StatusBarPanel statusBar = new StatusBarPanel(); +// private JMenuBar menuBar = new JMenuBar(); + private Toolbar toolBar = new Toolbar(); +// private Toolbarbutton bPrint = new Toolbarbutton(); + private Toolbarbutton bSendMail = new Toolbarbutton(); +// private Toolbarbutton bPageSetup = new Toolbarbutton(); + private Toolbarbutton bArchive = new Toolbarbutton(); +// private BorderLayout northLayout = new BorderLayout(); + private Toolbarbutton bCustomize = new Toolbarbutton(); +// private Toolbarbutton bEnd = new Toolbarbutton(); + private Toolbarbutton bFind = new Toolbarbutton(); + private Toolbarbutton bExport = new Toolbarbutton(); + private Combobox comboReport = new Combobox(); +// private Toolbarbutton bPrevious = new Toolbarbutton(); +// private Toolbarbutton bNext = new Toolbarbutton(); +// private SpinnerNumberModel spinnerModel = new SpinnerNumberModel(1,1,100,1); +// private JSpinner spinner = new JSpinner(spinnerModel); + private Label labelDrill = new Label(); + private Combobox comboDrill = new Combobox(); + + private Toolbarbutton bRefresh = new Toolbarbutton(); + private Iframe iframe; + + private Window winExportFile = null; + private WConfirmPanel confirmPanel = new WConfirmPanel(true); + private Combobox cboType = new Combobox(); + private ArrayList fileTypes = new ArrayList(); + + /** + * Static Layout + * @throws Exception + */ + public ZkReportViewer(ReportEngine re, String title) { + super(); +// this.setTitle(title); +// setClosable(true); + + log.info(""); +// m_WindowNo = Env.createWindowNo(this); + m_reportEngine = re; + m_AD_Table_ID = re.getPrintFormat().getAD_Table_ID(); + if (!MRole.getDefault().isCanReport(m_AD_Table_ID)) + { + FDialog.error(m_WindowNo, this, "AccessCannotReport", m_reportEngine.getName()); + this.onClose(); + } + m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID); + try + { + m_viewPanel = re.getView(); + m_ctx = m_reportEngine.getCtx(); + jbInit(); + dynInit(); + if (!m_viewPanel.isArchivable()) + log.warning("Cannot archive Document"); + } + catch(Exception e) + { + log.log(Level.SEVERE, "", e); + FDialog.error(m_WindowNo, this, "LoadError", e.getLocalizedMessage()); + this.onClose(); + } } - private void init() { + private void jbInit() { Grid grid = new Grid(); grid.setWidth("100%"); Rows rows = new Rows(); Row row = new Row(); - Toolbar toolbar = new Toolbar(); - toolbar.setHeight("26px"); - Toolbarbutton button = new Toolbarbutton(); - button.setImage("/images/Print24.gif"); - button.setTooltip("Print"); - toolbar.appendChild(button); - row.appendChild(toolbar); + + toolBar.setHeight("26px"); + + labelDrill.setValue(Msg.getMsg(m_ctx, "Drill") + ": "); + toolBar.appendChild(labelDrill); + + comboDrill.setTooltiptext(Msg.getMsg(m_ctx, "Drill")); + toolBar.appendChild(comboDrill); + + toolBar.appendChild(new Separator("vertical")); + + comboReport.setTooltiptext(Msg.translate(m_ctx, "AD_PrintFormat_ID")); + toolBar.appendChild(comboReport); + + bCustomize.setImage("/images/Preference24.gif"); + bCustomize.setTooltiptext("Customize Report"); + toolBar.appendChild(bCustomize); + bCustomize.addEventListener(Events.ON_CLICK, this); + + bFind.setImage("/images/Find24.gif"); + bFind.setTooltiptext("Lookup Record"); + toolBar.appendChild(bFind); + bFind.addEventListener(Events.ON_CLICK, this); + + toolBar.appendChild(new Separator("vertical")); + +// bPrint.setImage("/images/Print24.gif"); +// bPrint.setTooltiptext("Print"); +// toolBar.appendChild(bPrint); +// bPrint.addEventListener(Events.ON_CLICK, this); +// +// toolBar.appendChild(new Separator("vertical")); + + bSendMail.setImage("/images/SendMail24.gif"); + bSendMail.setTooltiptext("Send Mail"); + toolBar.appendChild(bSendMail); + bSendMail.addEventListener(Events.ON_CLICK, this); + + bArchive.setImage("/images/Archive24.gif"); + bArchive.setTooltiptext("Archived Documents/Reports"); + toolBar.appendChild(bArchive); + bArchive.addEventListener(Events.ON_CLICK, this); + + if (m_isCanExport) + { + bExport.setImage("/images/ExportX24.gif"); + bExport.setTooltiptext("Export"); + toolBar.appendChild(bExport); + bExport.addEventListener(Events.ON_CLICK, this); + } + + toolBar.appendChild(new Separator("vertical")); + + bRefresh.setImage("/images/Refresh24.gif"); + bRefresh.setTooltiptext("Refresh"); + toolBar.appendChild(bRefresh); + bRefresh.addEventListener(Events.ON_CLICK, this); + + row.appendChild(toolBar); rows.appendChild(row); row = new Row(); - Iframe iframe = new Iframe(); + iframe = new Iframe(); iframe.setId("reportFrame"); int height = Double.valueOf(SessionManager.getAppDesktop().getClientInfo().desktopHeight * 0.85).intValue(); height = height - 30; iframe.setHeight(height + "px"); iframe.setWidth("100%"); - AMedia media = new AMedia(getTitle(), "pdf", "application/pdf", report.createPDFData()); + AMedia media = new AMedia(getTitle(), "pdf", "application/pdf", m_reportEngine.createPDFData()); iframe.setContent(media); + iframe.setAutohide(true); + iframe.addEventListener(Events.ON_CLICK, this); + iframe.addEventListener(Events.ON_RIGHT_CLICK, this); row.appendChild(iframe); rows.appendChild(row); @@ -73,4 +275,792 @@ import org.zkoss.zul.Toolbarbutton; this.setBorder("normal"); } + + /** + * Dynamic Init + */ + private void dynInit() + { + fillComboReport(m_reportEngine.getPrintFormat().get_ID()); + + // fill Drill Options (Name, TableName) + Comboitem ci = comboDrill.appendItem(""); + String sql = "SELECT t.AD_Table_ID, t.TableName, e.PrintName, NULLIF(e.PO_PrintName,e.PrintName) " + + "FROM AD_Column c " + + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" + + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" + + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" + + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName) " + + "WHERE c.AD_Table_ID=? AND c.IsKey='Y' " + + "ORDER BY 3"; + boolean trl = !Env.isBaseLanguage(Env.getCtx(), "AD_Element"); + if (trl) + sql = "SELECT t.AD_Table_ID, t.TableName, et.PrintName, NULLIF(et.PO_PrintName,et.PrintName) " + + "FROM AD_Column c" + + " INNER JOIN AD_Column used ON (c.ColumnName=used.ColumnName)" + + " INNER JOIN AD_Table t ON (used.AD_Table_ID=t.AD_Table_ID AND t.IsView='N' AND t.AD_Table_ID <> c.AD_Table_ID)" + + " INNER JOIN AD_Column cKey ON (t.AD_Table_ID=cKey.AD_Table_ID AND cKey.IsKey='Y')" + + " INNER JOIN AD_Element e ON (cKey.ColumnName=e.ColumnName)" + + " INNER JOIN AD_Element_Trl et ON (e.AD_Element_ID=et.AD_Element_ID) " + + "WHERE c.AD_Table_ID=? AND c.IsKey='Y'" + + " AND et.AD_Language=? " + + "ORDER BY 3"; + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, m_reportEngine.getPrintFormat().getAD_Table_ID()); + if (trl) + pstmt.setString(2, Env.getAD_Language(Env.getCtx())); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + { + String tableName = rs.getString(2); + String name = rs.getString(3); + String poName = rs.getString(4); + if (poName != null) + name += "/" + poName; + ci = comboDrill.appendItem(name); + ci.setId(tableName); + } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql, e); + } + if (comboDrill.getItemCount() == 1) + { + labelDrill.setVisible(false); + comboDrill.setVisible(false); + } + else + comboDrill.addEventListener(Events.ON_CHANGE, this); + + revalidate(); + } // dynInit + + /** + * Fill ComboBox comboReport (report options) + * @param AD_PrintFormat_ID item to be selected + */ + private void fillComboReport(int AD_PrintFormat_ID) + { + comboReport.removeEventListener(Events.ON_CHANGE, this); + comboReport.getItems().clear(); + KeyNamePair selectValue = null; + // fill Report Options + String sql = MRole.getDefault().addAccessSQL( + "SELECT AD_PrintFormat_ID, Name, Description " + + "FROM AD_PrintFormat " + + "WHERE AD_Table_ID=? " + //Added Lines by Armen + + "AND IsActive='Y' " + //End of Added Lines + + "ORDER BY Name", + "AD_PrintFormat", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO); + int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, AD_Table_ID); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + { + KeyNamePair pp = new KeyNamePair(rs.getInt(1), rs.getString(2)); + Comboitem ci = comboReport.appendItem(pp.getName()); + ci.setId(pp.getKey() + ""); + if (rs.getInt(1) == AD_PrintFormat_ID) + { + selectValue = pp; + if(selectValue != null) + comboReport.setSelectedItem(ci); + } + } + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql, e); + } + StringBuffer sb = new StringBuffer("** ").append(Msg.getMsg(m_ctx, "NewReport")).append(" **"); + KeyNamePair pp = new KeyNamePair(-1, sb.toString()); + Comboitem ci = comboReport.appendItem(pp.getName()); + ci.setId(pp.getKey() + ""); +// if (selectValue != null) +// comboReport.setSelectedItem(selectValue); + comboReport.addEventListener(Events.ON_CHANGE, this); + } // fillComboReport + + /** + * Revalidate settings after change of environment + */ + private void revalidate() + { +// m_pageMax = m_viewPanel.getPageCount(); +// spinnerModel.setMaximum(new Integer(m_pageMax)); + + // Report Info + setTitle(Msg.getMsg(m_ctx, "Report") + ": " + m_reportEngine.getName() + " " + Env.getHeader(m_ctx, 0)); + StringBuffer sb = new StringBuffer (); + sb.append(m_viewPanel.getPaper().toString(m_ctx)) + .append(" - ").append(Msg.getMsg(m_ctx, "DataCols")).append("=") + .append(m_reportEngine.getColumnCount()) + .append(", ").append(Msg.getMsg(m_ctx, "DataRows")).append("=") + .append(m_reportEngine.getRowCount()); + statusBar.setStatusLine(sb.toString()); + // +// setPage(m_pageNo); + } // revalidate + + /** + * Dispose + */ + public void onClose() + { + Env.clearWinContext(m_WindowNo); + m_reportEngine = null; + m_viewPanel = null; + m_ctx = null; + super.onClose(); + } // dispose + + public void onEvent(Event event) throws Exception { + + if(event.getName().equals(WConfirmPanel.A_CANCEL)) + winExportFile.onClose(); + else if(event.getName().equals(WConfirmPanel.A_OK)) + exportFile(); + else if(event.getName().equals(Events.ON_CLICK) || event.getName().equals(Events.ON_CHANGE)) + actionPerformed(event); + else if(event.getName().equals(Events.ON_RIGHT_CLICK)) + mouse_clicked(event, true); + } + + /************************************************************************** + * Action Listener + * @param e event + */ + public void actionPerformed (Event e) + { + if (m_setting) + return; +// String cmd = e.getActionCommand(); +// log.config(cmd); +// this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + // +// if (e.getSource() == comboZoom) +// cmd_zoom(); +// else + if (e.getTarget() == comboReport) + cmd_report(); + else if (e.getTarget() == comboDrill) + cmd_drill(); +// else if (cmd.equals("First")) +// setPage(1); +// else if (cmd.equals("PreviousPage") || cmd.equals("Previous")) +// setPage(m_pageNo-1); +// else if (cmd.equals("NextPage") || cmd.equals("Next")) +// setPage(m_pageNo+1); +// else if (cmd.equals("Last")) +// setPage(m_pageMax); + else if (e.getTarget() == bFind) + cmd_find(); + else if (e.getTarget() == bExport) + cmd_export(); +// else if (e.getTarget() == bPrint) +// cmd_print(); + else if (e.getTarget() == bSendMail) + cmd_sendMail(); + else if (e.getTarget() == bArchive) + cmd_archive(); + else if (e.getTarget() == bCustomize) + cmd_customize(); +// else if (cmd.equals("PageSetup")) +// cmd_pageSetup(); +// else if (cmd.equals("Translate")) +// cmd_translate(); +// else if (cmd.equals("End")) +// onClose(); + else if (e.getTarget() == bRefresh) + iframe.invalidate(); + // + else if (e.getTarget() == m_ddM) + cmd_window(m_ddQ); + else if (e.getTarget() == m_daM) + cmd_window(m_daQ); + // + else if (!e.getTarget().getId().equals("reportFrame")) + mouse_clicked(e, false); + +// else if (!AEnv.actionPerformed(e.getActionCommand(), m_WindowNo, this)) +// log.log(Level.SEVERE, "unknown action=" + e.getActionCommand()); +// +// this.setCursor(Cursor.getDefaultCursor()); + } // actionPerformed + + /************************************************************************** + * (Re)Set Drill Accross Cursor + */ + private void cmd_drill() + { + m_drillDown = comboDrill.getSelectedIndex() < 1; // -1 or 0 +// if (m_drillDown) +// setCursor(Cursor.getDefaultCursor()); +// else +// setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } // cmd_drill + + /** + * Mouse clicked + * @param e event + * @param rightClick true if right click + */ + private void mouse_clicked (Event e, boolean rightClick) + { + MouseEvent me = (MouseEvent) e; + Point point = new Point(me.getX(), me.getY()); + + if (rightClick) + { + m_ddQ = m_viewPanel.getDrillDown(point); + m_daQ = m_viewPanel.getDrillAcross(point); + m_ddM = null; + m_daM = null; + if (m_ddQ == null && m_daQ == null) + return; + // Create Menu + Menupopup pop = new Menupopup(); +// Icon wi = Env.getImageIcon("mWindow.gif"); + if (m_ddQ != null) + { + m_ddM = new Menuitem(m_ddQ.getDisplayName(Env.getCtx())); + m_ddM.setTooltiptext(m_ddQ.toString()); + m_ddM.addEventListener(Events.ON_CLICK, this); + pop.appendChild(m_ddM); + } + if (m_daQ != null) + { + m_daM = new Menuitem(m_ddQ.getDisplayName(Env.getCtx())); + m_daM.setTooltiptext(m_daQ.toString()); + m_daM.addEventListener(Events.ON_CLICK, this); + pop.appendChild(m_daM); + } + pop.open(me.getX(), me.getY()); + return; + } + +// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + if (m_drillDown) + { + MQuery query = m_viewPanel.getDrillDown(point); + if (query != null) + { + log.info("Drill Down: " + query.getWhereClause(true)); + executeDrill(query); + } + } + else if (comboDrill.getValue() != null && comboDrill.getValue().length() > 0) + { + int index = comboDrill.getSelectedIndex(); + if(index >= 0) + { + Comboitem ci = comboDrill.getItemAtIndex(index); + MQuery query = m_viewPanel.getDrillAcross(point); + if (query != null) + { + query.setTableName(ci.getId()); + log.info("Drill Accross: " + query.getWhereClause(true)); + executeDrill(query); + } + } + + } + cmd_drill(); // setCursor + } // mouse_clicked + + /** + * Execute Drill to Query + * @param query query + */ + private void executeDrill (MQuery query) + { + int AD_Table_ID = AReport.getAD_Table_ID(query.getTableName()); + if (!MRole.getDefault().isCanReport(AD_Table_ID)) + { + FDialog.error(m_WindowNo, this, "AccessCannotReport", query.getTableName()); + return; + } + if (AD_Table_ID != 0) + new AReport (AD_Table_ID, null, query); + else + log.warning("No Table found for " + query.getWhereClause(true)); + } // executeDrill + + /** + * Open Window + * @param query query + */ + private void cmd_window (MQuery query) + { + if (query == null) + return; + AEnv.zoom(query); + } // cmd_window + + /************************************************************************** + * Print Report + */ +// private void cmd_print() +// { +// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); +// m_reportEngine.getPrintInfo().setWithDialog(true); +// m_reportEngine.print(); +// cmd_drill(); // setCursor +// } // cmd_print + + /** + * Send Mail + */ + private void cmd_sendMail() + { + String to = ""; + MUser from = MUser.get(Env.getCtx(), Env.getAD_User_ID(Env.getCtx())); + String subject = m_reportEngine.getName(); + String message = ""; + File attachment = null; + + try + { + attachment = File.createTempFile("mail", ".pdf"); + m_reportEngine.getPDF(attachment); + } + catch (Exception e) + { + log.log(Level.SEVERE, "", e); + } + + WEMailDialog emd = new WEMailDialog (this, + Msg.getMsg(Env.getCtx(), "SendMail"), + from, to, subject, message, attachment); + } // cmd_sendMail + + /** + * Archive Report directly + */ + private void cmd_archive () + { + boolean success = false; + byte[] data = Document.getPDFAsArray(m_reportEngine.getLayout().getPageable(false)); // No Copy + if (data != null) + { + MArchive archive = new MArchive (Env.getCtx(), m_reportEngine.getPrintInfo(), null); + archive.setBinaryData(data); + success = archive.save(); + } + if (success) + FDialog.info(m_WindowNo, this, "Archived"); + else + FDialog.error(m_WindowNo, this, "ArchiveError"); + } // cmd_archive + + /** + * Export + */ + private void cmd_export() + { + log.config(""); + if (!m_isCanExport) + { + FDialog.error(m_WindowNo, this, "AccessCannotExport", getTitle()); + return; + } + + if(winExportFile == null) + { + winExportFile = new Window(); + winExportFile.setTitle(Msg.getMsg(m_ctx, "Export") + ": " + getTitle()); + winExportFile.setWidth("400px"); + winExportFile.setClosable(true); + winExportFile.setBorder("normal"); + winExportFile.setStyle("position:absolute"); + + cboType.getItems().clear(); + + fileTypes.clear(); + fileTypes.add(new ValueNamePair("ps", "ps" + " - " + Msg.getMsg(m_ctx, "FilePS"))); + fileTypes.add(new ValueNamePair("xml", "xml" + " - " + Msg.getMsg(m_ctx, "FileXML"))); + fileTypes.add(new ValueNamePair("pdf", "pdf" + " - " + Msg.getMsg(m_ctx, "FilePDF"))); + fileTypes.add(new ValueNamePair("html", "html" + " - " + Msg.getMsg(m_ctx, "FileHTML"))); + fileTypes.add(new ValueNamePair("txt", "txt" + " - " + Msg.getMsg(m_ctx, "FileTXT"))); + fileTypes.add(new ValueNamePair("ssv", "ssv" + " - " + Msg.getMsg(m_ctx, "FileSSV"))); + fileTypes.add(new ValueNamePair("csv", "csv" + " - " + Msg.getMsg(m_ctx, "FileCSV"))); + fileTypes.add(new ValueNamePair("xls", "xls" + " - " + Msg.getMsg(m_ctx, "FileXLS"))); + + for(int i = 0; i < fileTypes.size(); i++) + cboType.appendItem(fileTypes.get(i).getName()); + cboType.setSelectedIndex(2); + + Hbox hb = new Hbox(); + Div div = new Div(); + div.setAlign("right"); + div.appendChild(new Label("Files of Type: ")); + hb.appendChild(div); + hb.appendChild(cboType); + cboType.setWidth("100%"); + + Vbox vb = new Vbox(); + vb.setWidth("390px"); + winExportFile.appendChild(vb); + vb.appendChild(hb); + vb.appendChild(confirmPanel); + confirmPanel.addEventListener(this); + } + + AEnv.showCenterScreen(winExportFile); + + cmd_drill(); // setCursor + } // cmd_export + + private void exportFile() + { + try + { + int index = cboType.getSelectedIndex(); + if(index < 0) + { + FDialog.error(m_WindowNo, winExportFile, "FileInvalidExtension"); + return; + } + + String ext = fileTypes.get(index).getValue(); + + byte[] data = null; + + if (ext.equals("pdf")) + { + data = m_reportEngine.createPDFData(); + } + else if (ext.equals("ps")) + { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + m_reportEngine.createPS(baos); + data = baos.toByteArray(); + } + else if (ext.equals("xml")) + { + StringWriter sw = new StringWriter(); + m_reportEngine.createXML(sw); + data = sw.getBuffer().toString().getBytes(); + } + else if (ext.equals("csv") || ext.equals("ssv")) + { + StringWriter sw = new StringWriter(); + m_reportEngine.createCSV(sw, ',', m_reportEngine.getPrintFormat().getLanguage()); + data = sw.getBuffer().toString().getBytes(); + } + else if (ext.equals("txt")) + { + StringWriter sw = new StringWriter(); + m_reportEngine.createCSV(sw, '\t', m_reportEngine.getPrintFormat().getLanguage()); + data = sw.getBuffer().toString().getBytes(); + } + else if (ext.equals("html") || ext.equals("htm")) + { + StringWriter sw = new StringWriter(); + m_reportEngine.createHTML(sw, false, m_reportEngine.getPrintFormat().getLanguage()); + data = sw.getBuffer().toString().getBytes(); + } + else if (ext.equals("xls")) + { + StringWriter sw = new StringWriter(); + m_reportEngine.createXML(sw); + data = sw.getBuffer().toString().getBytes(); + } + else + { + FDialog.error(m_WindowNo, winExportFile, "FileInvalidExtension"); + return; + } + + winExportFile.onClose(); + AMedia media = new AMedia(getTitle() + "." + ext, null, "application/octet-stream", (byte[]) data); + Filedownload.save(media); + } + catch (Exception e) + { + log.log(Level.SEVERE, "Failed to export content.", e); + } + } + + /** + * Report Combo - Start other Report or create new one + */ + private void cmd_report() + { + int ind = comboReport.getSelectedIndex(); + if(ind < 0) return; + + Comboitem ci = comboReport.getItemAtIndex(ind); + Object pp = ci.getId(); + if (pp == null) + return; + // +// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + MPrintFormat pf = null; + int AD_PrintFormat_ID = Integer.valueOf(pp.toString()); + + // create new + if (AD_PrintFormat_ID == -1) + { + int AD_ReportView_ID = m_reportEngine.getPrintFormat().getAD_ReportView_ID(); + if (AD_ReportView_ID != 0) + { + String name = m_reportEngine.getName(); + int index = name.lastIndexOf('_'); + if (index != -1) + name = name.substring(0,index); + pf = MPrintFormat.createFromReportView(m_ctx, AD_ReportView_ID, name); + } + else + { + int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); + pf = MPrintFormat.createFromTable(m_ctx, AD_Table_ID); + } + if (pf != null) + fillComboReport(pf.get_ID()); + else + return; + } + else + pf = MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true); + + // Get Language from previous - thanks Gunther Hoppe + if (m_reportEngine.getPrintFormat() != null) + { + pf.setLanguage(m_reportEngine.getPrintFormat().getLanguage()); // needs to be re-set - otherwise viewer will be blank + pf.setTranslationLanguage(m_reportEngine.getPrintFormat().getLanguage()); + } + m_reportEngine.setPrintFormat(pf); + revalidate(); + + cmd_drill(); // setCursor + } // cmd_report + + /** + * Query Report + */ + private void cmd_find() + { +// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + int AD_Table_ID = m_reportEngine.getPrintFormat().getAD_Table_ID(); + + String title = null; + String tableName = null; + + // Get Find Tab Info + String sql = "SELECT t.AD_Tab_ID " + // ,w.Name, t.Name, w.IsDefault, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID) + + "FROM AD_Tab t" + + " INNER JOIN AD_Window w ON (t.AD_Window_ID=w.AD_Window_ID)" + + " INNER JOIN AD_Table tt ON (t.AD_Table_ID=tt.AD_Table_ID) " + + "WHERE tt.AD_Table_ID=? " + + "ORDER BY w.IsDefault DESC, t.SeqNo, ABS (tt.AD_Window_ID-t.AD_Window_ID)"; + int AD_Tab_ID = DB.getSQLValue(null, sql, AD_Table_ID); + // ASP + MClient client = MClient.get(Env.getCtx()); + String ASPFilter = ""; + if (client.isUseASP()) + ASPFilter = + " AND ( AD_Tab_ID IN ( " + // Just ASP subscribed tabs for client " + + " SELECT w.AD_Tab_ID " + + " FROM ASP_Tab w, ASP_Level l, ASP_ClientLevel cl " + + " WHERE w.ASP_Level_ID = l.ASP_Level_ID " + + " AND cl.AD_Client_ID = " + client.getAD_Client_ID() + + " AND cl.ASP_Level_ID = l.ASP_Level_ID " + + " AND w.IsActive = 'Y' " + + " AND l.IsActive = 'Y' " + + " AND cl.IsActive = 'Y' " + + " AND w.ASP_Status = 'S') " // Show + + " OR AD_Tab_ID IN ( " + // + show ASP exceptions for client + + " SELECT AD_Tab_ID " + + " FROM ASP_ClientException ce " + + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() + + " AND ce.IsActive = 'Y' " + + " AND ce.AD_Tab_ID IS NOT NULL " + + " AND ce.AD_Field_ID IS NULL " + + " AND ce.ASP_Status = 'S') " // Show + + " ) " + + " AND AD_Tab_ID NOT IN ( " + // minus hide ASP exceptions for client + + " SELECT AD_Tab_ID " + + " FROM ASP_ClientException ce " + + " WHERE ce.AD_Client_ID = " + client.getAD_Client_ID() + + " AND ce.IsActive = 'Y' " + + " AND ce.AD_Tab_ID IS NOT NULL " + + " AND ce.AD_Field_ID IS NULL " + + " AND ce.ASP_Status = 'H')"; // Hide + // + sql = "SELECT Name, TableName FROM AD_Tab_v WHERE AD_Tab_ID=? " + ASPFilter; + if (!Env.isBaseLanguage(Env.getCtx(), "AD_Tab")) + sql = "SELECT Name, TableName FROM AD_Tab_vt WHERE AD_Tab_ID=?" + + " AND AD_Language='" + Env.getAD_Language(Env.getCtx()) + "' " + ASPFilter; + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, AD_Tab_ID); + ResultSet rs = pstmt.executeQuery(); + // + if (rs.next()) + { + title = rs.getString(1); + tableName = rs.getString(2); + } + // + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql, e); + } + + GridField[] findFields = null; + if (tableName != null) + findFields = GridField.createFields(m_ctx, m_WindowNo, 0, AD_Tab_ID); + + if (findFields == null) // No Tab for Table exists + bFind.setVisible(false); +// bFind.setEnabled(false); + else + { + FindWindow find = new FindWindow(m_WindowNo, title, AD_Table_ID, tableName,"", findFields, 1); + find.setVisible(true); + AEnv.showWindow(find); + m_reportEngine.setQuery(find.getQuery()); + find = null; + revalidate(); + } + cmd_drill(); // setCursor + } // cmd_find + + /** + * Call Customize + */ + private void cmd_customize() + { +// AWindow win = new AWindow (); +// new AWindowListener (win, this); // forwards Window Events + int AD_Window_ID = 240; // hardcoded + int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); +// win.initWindow(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID)); +// AEnv.addToWindowManager(win); +// AEnv.showCenterScreen(win); + AEnv.zoom(AD_Window_ID, MQuery.getEqualQuery("AD_PrintFormat_ID", AD_PrintFormat_ID)); + // see windowStateChanged for applying change + } // cmd_customize + + /** + * Window State Listener for Customize Window + * @param e event + */ +/* public void windowStateChanged (WindowEvent e) + { + // The Customize Window was closed + if (e.getID() == WindowEvent.WINDOW_CLOSED && m_reportEngine != null) + { +// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + log.info("Re-read PrintFormat"); + int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); + Language language = m_reportEngine.getPrintFormat().getLanguage(); + MPrintFormat pf = MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true); + pf.setLanguage (language); // needs to be re-set - otherwise viewer will be blank + pf.setTranslationLanguage (language); + m_reportEngine.setPrintFormat(pf); + revalidate(); + cmd_drill(); // setCursor + } + } // windowStateChanged +*/ + + /** + * Show Translation Dialog. + * Translate base table entry, will be copied to trl tables if not multi-lingual + */ +/* private void cmd_translate() + { + ArrayList list = new ArrayList(); + ValueNamePair pp = null; + String sql = "SELECT Name, AD_Language FROM AD_Language WHERE IsSystemLanguage='Y' ORDER BY 1"; + try + { + PreparedStatement pstmt = DB.prepareStatement(sql, null); + ResultSet rs = pstmt.executeQuery(); + while (rs.next()) + list.add(new ValueNamePair (rs.getString(2), rs.getString(1))); + rs.close(); + pstmt.close(); + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql, e); + } + if (list.size() == 0) + { + FDialog.warn(m_WindowNo, this, "NoTranslation", ""); + return; + } + + // Dialog + String title = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", true); + String message = Msg.getMsg(Env.getCtx(), "PrintFormatTrl", false); + int choice = JOptionPane.showOptionDialog + (this, message, title, + JOptionPane.OK_OPTION, JOptionPane.QUESTION_MESSAGE, null, + list.toArray(), null); + if (choice == JOptionPane.CLOSED_OPTION) + return; + + pp = (ValueNamePair)list.get(choice); + String AD_Language = pp.getValue(); + int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); + log.config(AD_Language + " - AD_PrintFormat_ID=" + AD_PrintFormat_ID); + StringBuffer sb = new StringBuffer(); + // English + if (Language.isBaseLanguage (AD_Language)) + { + sb.append("UPDATE AD_PrintFormatItem pfi " + + "SET Name = (SELECT e.Name FROM AD_Element e, AD_Column c" + + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)," + + "PrintName = (SELECT e.PrintName FROM AD_Element e, AD_Column c" + + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " + + "WHERE AD_PrintFormat_ID=").append(AD_PrintFormat_ID).append( + " AND EXISTS (SELECT * FROM AD_Element e, AD_Column c" + + " WHERE e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)"); + } + else + { + AD_Language = "'" + AD_Language + "'"; + sb.append("UPDATE AD_PrintFormatItem pfi " + + "SET Name = (SELECT e.Name FROM AD_Element_Trl e, AD_Column c" + + " WHERE e.AD_Language=").append(AD_Language).append( + " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID), " + + "PrintName = (SELECT e.PrintName FROM AD_Element_Trl e, AD_Column c" + + " WHERE e.AD_Language=").append(AD_Language).append( + " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID) " + + "WHERE AD_PrintFormat_ID=").append(AD_PrintFormat_ID).append( + " AND EXISTS (SELECT * FROM AD_Element_Trl e, AD_Column c" + + " WHERE e.AD_Language=").append(AD_Language).append( + " AND e.AD_Element_ID=c.AD_Element_ID AND c.AD_Column_ID=pfi.AD_Column_ID)"); + } + int count = DB.executeUpdate(sb.toString(), null); + log.config("Count=" + count); + // + m_reportEngine.setPrintFormat(MPrintFormat.get (Env.getCtx(), AD_PrintFormat_ID, true)); + revalidate(); + } // cmd_translate +*/ } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java index 3640a97745..55f7cf0356 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/window/ZkReportViewerProvider.java @@ -16,8 +16,8 @@ *****************************************************************************/ package org.adempiere.webui.window; -import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.compiere.print.ReportEngine; import org.compiere.print.ReportViewerProvider; @@ -33,6 +33,8 @@ public class ZkReportViewerProvider implements ReportViewerProvider { viewer.setAttribute("mode", "overlapped"); viewer.setClosable(true); viewer.setWidth("95%"); - AEnv.showWindow(viewer); + + SessionManager.getAppDesktop().showWindowInTabPanel(viewer); +// AEnv.showWindow(viewer); } } \ No newline at end of file