From e647070a609bd87b5b7697013627231d3aabb8e2 Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Sat, 14 Jul 2012 11:53:38 +0300 Subject: [PATCH 01/13] IDEMPIERE-339 - Improve Info Product Window (transplanted from bfbf103ae59f8e2cec4ad9508aefdae11b41f6e9) --- .../org/compiere/apps/search/InfoProduct.java | 75 ++++++++++++++----- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java index 21dc2e3a55..dde2c5ea31 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java @@ -873,9 +873,34 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener public void actionPerformed (ActionEvent e) { // don't requery if fieldValue and fieldName are empty - if ((e.getSource() == pickWarehouse || e.getSource() == pickPriceList) - && (fieldValue.getText().length() == 0 && fieldName.getText().length() == 0)) - return; + if (e.getSource() == pickWarehouse || e.getSource() == pickPriceList) + { + // IDEMPIERE-337 - Improve Info Product Window + boolean execute = true; + if (fieldValue.getText().length() == 0 && fieldName.getText().length() == 0 && p_table.getRowCount() == 0) + execute = false; + p_table.setRowCount(0); + ((DefaultTableModel)p_table.getModel()).setColumnCount(0); + int M_Warehouse_ID = ((KeyNamePair)pickWarehouse.getSelectedItem()).getKey(); + // Create Grid + StringBuffer where = new StringBuffer(); + where.append("p.IsActive='Y'"); + if (M_Warehouse_ID != 0) + where.append(" AND p.IsSummary='N'"); + // dynamic Where Clause + if (p_whereClause != null && p_whereClause.length() > 0) + where.append(" AND ") // replace fully qualified name with alias + .append(Util.replace(p_whereClause, "M_Product.", "p.")); + // + p_table.removeMouseListener(this); + prepareTable(getProductLayout(), + s_productFrom, + where.toString(), + ""); + p_table.setShowTotals(false); + if (!execute) + return; + } // Product Attribute Search if (e.getSource().equals(m_InfoPAttributeButton)) @@ -906,7 +931,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener // super.actionPerformed(e); } // actionPerformed - + /** * Enable PAttribute if row selected/changed */ @@ -1053,33 +1078,47 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener */ protected Info_Column[] getProductLayout() { - if (s_productLayout != null && s_productLayoutRole == MRole.getDefault().getAD_Role_ID()) - return s_productLayout; + // IDEMPIERE-337 + //if (s_productLayout != null && s_productLayoutRole == MRole.getDefault().getAD_Role_ID()) + // return s_productLayout; // s_productLayout = null; s_productLayoutRole = MRole.getDefault().getAD_Role_ID(); + // IDEMPIERE_337 + int M_Warehouse_ID = 0; + KeyNamePair warehouse = (KeyNamePair)pickWarehouse.getSelectedItem(); + M_Warehouse_ID = warehouse.getKey(); + int M_PriceList_ID = 0; + KeyNamePair pricelist = (KeyNamePair)pickPriceList.getSelectedItem(); + M_PriceList_ID = pricelist.getKey(); + ArrayList list = new ArrayList(); - list.add(new Info_Column(" ", "p.M_Product_ID", IDColumn.class, !p_multiSelection)); + list.add(new Info_Column(" ", "DISTINCT p.M_Product_ID", IDColumn.class, !p_multiSelection)); list.add(new Info_Column(Msg.translate(Env.getCtx(), "Discontinued").substring(0, 1), "p.Discontinued", Boolean.class)); list.add(new Info_Column(Msg.translate(Env.getCtx(), "Value"), "p.Value", String.class)); list.add(new Info_Column(Msg.translate(Env.getCtx(), "Name"), "p.Name", String.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyAvailable"), "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyAvailable(p.M_Product_ID,?,0) end AS QtyAvailable", Double.class, true, true, null)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false)) + // IDEMPIERE-337 + if (M_Warehouse_ID != 0) + list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyAvailable"), "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyAvailable(p.M_Product_ID,?,0) end AS QtyAvailable", Double.class, true, true, null)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false) && M_PriceList_ID != 0) list.add(new Info_Column(Msg.translate(Env.getCtx(), "PriceList"), "bomPriceList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList", BigDecimal.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false)) + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && M_PriceList_ID !=0) list.add(new Info_Column(Msg.translate(Env.getCtx(), "PriceStd"), "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd", BigDecimal.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyOnHand"), "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyOnHand(p.M_Product_ID,?,0) end AS QtyOnHand", Double.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyReserved"), "bomQtyReserved(p.M_Product_ID,?,0) AS QtyReserved", Double.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyOrdered"), "bomQtyOrdered(p.M_Product_ID,?,0) AS QtyOrdered", Double.class)); - if (isUnconfirmed()) + if (M_Warehouse_ID != 0) { - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyUnconfirmed"), "(SELECT SUM(c.TargetQty) FROM M_InOutLineConfirm c INNER JOIN M_InOutLine il ON (c.M_InOutLine_ID=il.M_InOutLine_ID) INNER JOIN M_InOut i ON (il.M_InOut_ID=i.M_InOut_ID) WHERE c.Processed='N' AND i.M_Warehouse_ID=? AND il.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmed", Double.class)); - list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyUnconfirmedMove"), "(SELECT SUM(c.TargetQty) FROM M_MovementLineConfirm c INNER JOIN M_MovementLine ml ON (c.M_MovementLine_ID=ml.M_MovementLine_ID) INNER JOIN M_Locator l ON (ml.M_LocatorTo_ID=l.M_Locator_ID) WHERE c.Processed='N' AND l.M_Warehouse_ID=? AND ml.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmedMove", Double.class)); + list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyOnHand"), "case when p.IsBOM='N' and (p.ProductType!='I' OR p.IsStocked='N') then to_number(get_Sysconfig('QTY_TO_SHOW_FOR_SERVICES', '99999', p.ad_client_id, 0), '99999999999') else bomQtyOnHand(p.M_Product_ID,?,0) end AS QtyOnHand", Double.class)); + list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyReserved"), "bomQtyReserved(p.M_Product_ID,?,0) AS QtyReserved", Double.class)); + list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyOrdered"), "bomQtyOrdered(p.M_Product_ID,?,0) AS QtyOrdered", Double.class)); + if (isUnconfirmed()) + { + list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyUnconfirmed"), "(SELECT SUM(c.TargetQty) FROM M_InOutLineConfirm c INNER JOIN M_InOutLine il ON (c.M_InOutLine_ID=il.M_InOutLine_ID) INNER JOIN M_InOut i ON (il.M_InOut_ID=i.M_InOut_ID) WHERE c.Processed='N' AND i.M_Warehouse_ID=? AND il.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmed", Double.class)); + list.add(new Info_Column(Msg.translate(Env.getCtx(), "QtyUnconfirmedMove"), "(SELECT SUM(c.TargetQty) FROM M_MovementLineConfirm c INNER JOIN M_MovementLine ml ON (c.M_MovementLine_ID=ml.M_MovementLine_ID) INNER JOIN M_Locator l ON (ml.M_LocatorTo_ID=l.M_Locator_ID) WHERE c.Processed='N' AND l.M_Warehouse_ID=? AND ml.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmedMove", Double.class)); + } } - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false) && M_PriceList_ID != 0) list.add(new Info_Column(Msg.translate(Env.getCtx(), "Margin"), "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin", BigDecimal.class)); list.add(new Info_Column(Msg.translate(Env.getCtx(), "Vendor"), "bp.Name", String.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false) && M_PriceList_ID != 0) list.add(new Info_Column(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit", BigDecimal.class)); list.add(new Info_Column(Msg.translate(Env.getCtx(), "IsInstanceAttribute"), "pa.IsInstanceAttribute", Boolean.class)); s_productLayout = new Info_Column[list.size()]; From d35b4f46c3d5f12d99f7cec96dada89b4a637b6f Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Sun, 15 Jul 2012 23:13:59 +0300 Subject: [PATCH 02/13] IDEMPIERE-339 - Improve Info Product Window (transplanted from f5fa85ae357ada71deaf73ebeca7b787e9ca1a43) --- .../org/compiere/apps/search/InfoProduct.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java index dde2c5ea31..5974a20a1f 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java @@ -192,6 +192,10 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener private int m_M_Product_ID = 0; int mWindowNo = 0; //End - fer_luck @ centuryon + + //IDEMPIERE-339 + MiniTable productpriceTbl = new MiniTable(); + String m_sqlProductprice; /** Search Button */ private CButton m_InfoPAttributeButton = new CButton(Env.getImageIcon("PAttribute16.gif")); @@ -351,13 +355,37 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener m_tableAtp.setRowSelectionAllowed(false); m_tableAtp.setMultiSelection(false); + //IDEMPIERE-339 + ArrayList list = new ArrayList(); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceListVersion"), "plv.Name", String.class)); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "ValidFrom"), "plv.ValidFrom", Timestamp.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceList"), "bomPriceList(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceList", Double.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "bomPriceStd(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceStd", Double.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Margin"), "bomPriceStd(pp.M_Product_ID, pp.M_PriceList_Version_ID)-bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS Margin", Double.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceLimit", Double.class)); + ColumnInfo[] s_layoutProductPrice = new ColumnInfo[list.size()]; + list.toArray(s_layoutProductPrice); + s_sqlFrom = "M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID"; + s_sqlWhere = "pp.M_Product_ID = ? AND plv.IsActive = 'Y' AND pp.IsActive = 'Y'"; + m_sqlProductprice = productpriceTbl.prepareTable(s_layoutProductPrice, s_sqlFrom, s_sqlWhere, false, "pp") + " ORDER BY plv.ValidFrom DESC"; + productpriceTbl.setRowSelectionAllowed(false); + productpriceTbl.setMultiSelection(false); + productpriceTbl.addMouseListener(this); + productpriceTbl.getSelectionModel().addListSelectionListener(this); + productpriceTbl.autoSize(); + CTabbedPane jTab = new CTabbedPane(); jTab.addTab(Msg.translate(Env.getCtx(), "Warehouse"), new JScrollPane(warehouseTbl)); jTab.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 250 : 105)); jTab.addTab(Msg.translate(Env.getCtx(), "Description"), new JScrollPane(fieldDescription)); jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl)); jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl)); - jTab.addTab (Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp)); + jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp)); + jTab.addTab(Msg.getMsg(Env.getCtx(), "Price"), new JScrollPane(productpriceTbl)); jTab.addChangeListener(this); tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110)); tablePanel.add(jTab); @@ -465,6 +493,24 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener rs = null; pstmt = null; } initAtpTab(M_Warehouse_ID); + + // IDEMPIERE-339 + sql = m_sqlProductprice; + log.finest(sql); + try { + pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, m_M_Product_ID); + rs = pstmt.executeQuery(); + productpriceTbl.loadTable(rs); + rs.close(); + } catch (Exception e) { + log.log(Level.WARNING, sql, e); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } } // refresh //End - fer_luck @ centuryon From 71b4f04a6200f2aba37098142f31624c7e9d5433 Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Mon, 16 Jul 2012 22:55:06 +0300 Subject: [PATCH 03/13] IDEMPIERE-339 - Improve Info Product Window, fix exception when logging in with no warehouse (transplanted from 326acd1094974d6d00a5571fddfa8bd805dcf16a) --- .../src/org/compiere/apps/search/InfoProduct.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java index 5974a20a1f..5bf28a15a3 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java @@ -543,10 +543,15 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener setPriceListVersion (M_PriceList_Version_ID); // Create Grid + String orderBy = null; StringBuffer where = new StringBuffer(); where.append("p.IsActive='Y'"); if (M_Warehouse_ID != 0) + { where.append(" AND p.IsSummary='N'"); + orderBy = "QtyAvailable DESC"; + } + // dynamic Where Clause if (p_whereClause != null && p_whereClause.length() > 0) where.append(" AND ") // replace fully qualified name with alias @@ -555,7 +560,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener prepareTable(getProductLayout(), s_productFrom, where.toString(), - "QtyAvailable DESC"); + orderBy); p_table.setShowTotals(false); // pickWarehouse.addActionListener(this); From 999f0b9972280ed37eb086cc3b47b88ffb88fad6 Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Tue, 17 Jul 2012 12:54:44 +0300 Subject: [PATCH 04/13] IDEMPIERE-339 - Improve Info Product Window, fix translation (transplanted from 6e37d3b8527e62970450c853f589dd7eb8b51edd) --- .../src/org/compiere/apps/search/InfoProduct.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java index 5bf28a15a3..e535b4a359 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java @@ -385,7 +385,7 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener jTab.addTab(Msg.translate(Env.getCtx(), "Substitute_ID"), new JScrollPane(substituteTbl)); jTab.addTab(Msg.translate(Env.getCtx(), "RelatedProduct_ID"), new JScrollPane(relatedTbl)); jTab.addTab(Msg.getMsg(Env.getCtx(), "ATP"), new JScrollPane(m_tableAtp)); - jTab.addTab(Msg.getMsg(Env.getCtx(), "Price"), new JScrollPane(productpriceTbl)); + jTab.addTab(Msg.translate(Env.getCtx(), "Price"), new JScrollPane(productpriceTbl)); jTab.addChangeListener(this); tablePanel.setPreferredSize(new Dimension(INFO_WIDTH, SCREEN_HEIGHT > 600 ? 255 : 110)); tablePanel.add(jTab); From 3133906baea8b2fc39443d0b501b5967f47be7a3 Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Tue, 17 Jul 2012 12:58:14 +0300 Subject: [PATCH 05/13] IDEMPIERE-337 - Improve Info Product Window (transplanted from 170c74757e81dd14f8c8862b7d937f10eeba6bc3) --- .../webui/panel/InfoProductPanel.java | 208 ++++++++++++++++-- 1 file changed, 188 insertions(+), 20 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java index fd72d27eda..111713bfb2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java @@ -134,6 +134,10 @@ public class InfoProductPanel extends InfoPanel implements EventListener int mWindowNo = 0; // + //IDEMPIERE-337 + WListbox productpriceTbl = ListboxFactory.newDataTable(); + String m_sqlProductprice; + /** Search Button */ private Button m_InfoPAttributeButton = new Button(); /** Instance Button */ @@ -160,7 +164,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener private String m_pAttributeWhere = null; private int m_C_BPartner_ID = 0; - + /** * Standard Constructor * @param WindowNo window no @@ -413,6 +417,27 @@ public class InfoProductPanel extends InfoPanel implements EventListener //Available to Promise Tab m_tableAtp.setMultiSelection(false); + //IDEMPIERE-337 + ArrayList list = new ArrayList(); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceListVersion"), "plv.Name", String.class)); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "ValidFrom"), "plv.ValidFrom", Timestamp.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceList"), "bomPriceList(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceList", Double.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "bomPriceStd(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceStd", Double.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Margin"), "bomPriceStd(pp.M_Product_ID, pp.M_PriceList_Version_ID)-bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS Margin", Double.class)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(pp.M_Product_ID, pp.M_PriceList_Version_ID) AS PriceLimit", Double.class)); + ColumnInfo[] s_layoutProductPrice = new ColumnInfo[list.size()]; + list.toArray(s_layoutProductPrice); + s_sqlFrom = "M_ProductPrice pp INNER JOIN M_PriceList_Version plv ON pp.M_PriceList_Version_ID = plv.M_PriceList_Version_ID"; + s_sqlWhere = "pp.M_Product_ID = ? AND plv.IsActive = 'Y' AND pp.IsActive = 'Y'"; + m_sqlProductprice = productpriceTbl.prepareTable(s_layoutProductPrice, s_sqlFrom, s_sqlWhere, false, "pp") + " ORDER BY plv.ValidFrom DESC"; + productpriceTbl.setMultiSelection(false); + productpriceTbl.autoSize(); + productpriceTbl.getModel().addTableModelListener(this); + tabbedPane.setHeight("100%"); Tabpanels tabPanels = new Tabpanels(); tabbedPane.appendChild(tabPanels); @@ -455,6 +480,13 @@ public class InfoProductPanel extends InfoPanel implements EventListener desktopTabPanel.setHeight("100%"); desktopTabPanel.appendChild(m_tableAtp); tabPanels.appendChild(desktopTabPanel); + + tab = new Tab(Msg.translate(Env.getCtx(), "Price")); + tabs.appendChild(tab); + desktopTabPanel = new Tabpanel(); + desktopTabPanel.setHeight("100%"); + desktopTabPanel.appendChild(productpriceTbl); + tabPanels.appendChild(desktopTabPanel); // int height = SessionManager.getAppDesktop().getClientInfo().desktopHeight * 90 / 100; int width = SessionManager.getAppDesktop().getClientInfo().desktopWidth * 80 / 100; @@ -526,6 +558,79 @@ public class InfoProductPanel extends InfoPanel implements EventListener }); } + /** + * IDEMPIERE-337 + * Override InfoPanel.testCount() to allow counting distinct rows + * + */ + @Override + protected boolean testCount() { + long start = System.currentTimeMillis(); + String dynWhere = getSQLWhere(); + + int M_Warehouse_ID = 0; + ListItem listitem = pickWarehouse.getSelectedItem(); + if (listitem != null) + M_Warehouse_ID = (Integer)listitem.getValue(); + + StringBuffer where = new StringBuffer(); + where.append("p.IsActive='Y'"); + if (M_Warehouse_ID != 0) + where.append(" AND p.IsSummary='N'"); + // dynamic Where Clause + if (p_whereClause != null && p_whereClause.length() > 0) + where.append(" AND ") // replace fully qalified name with alias + .append(Util.replace(p_whereClause, "M_Product.", "p.")); + + StringBuffer sqlMain = new StringBuffer("SELECT "); + int colIndex = 0; + ColumnInfo[] layout = getProductLayout(); + for (colIndex = 0; colIndex < layout.length; colIndex++) + { + if (colIndex > 0) + sqlMain.append(", "); + sqlMain.append(layout[colIndex].getColSQL()); + if (layout[colIndex].isKeyPairCol()) + sqlMain.append(",").append(layout[colIndex].getKeyPairColSQL()); + } + + sqlMain.append(" FROM ").append(s_productFrom); + sqlMain.append(" WHERE ").append(where); + + if (dynWhere.length() > 0) + sqlMain.append(dynWhere); + + String countSql = Msg.parseTranslation(Env.getCtx(), sqlMain.toString()); // Variables + countSql = MRole.getDefault().addAccessSQL (countSql, getTableName(), + MRole.SQL_FULLYQUALIFIED, MRole.SQL_RO); + String sqlCount = "SELECT COUNT(*) FROM (" + countSql + ") AS ProductInfo"; + + log.finer(sqlCount); + m_count = -1; + + try + { + PreparedStatement pstmt = DB.prepareStatement(sqlCount, null); + setParameters (pstmt, false); + ResultSet rs = pstmt.executeQuery(); + + if (rs.next()) + m_count = rs.getInt(1); + + rs.close(); + pstmt.close(); + } + catch (Exception e) + { + log.log(Level.SEVERE, sqlCount, e); + m_count = -2; + } + + log.fine("#" + m_count + " - " + (System.currentTimeMillis()-start) + "ms"); + + return true; + } + @Override protected void insertPagingComponent() { North north = new North(); @@ -605,6 +710,24 @@ public class InfoProductPanel extends InfoPanel implements EventListener rs = null; pstmt = null; } initAtpTab(M_Warehouse_ID); + + //IDEMPIERE-337 + sql = m_sqlProductprice; + log.fine(sql); + try { + pstmt = DB.prepareStatement(sql, null); + pstmt.setInt(1, m_M_Product_ID); + rs = pstmt.executeQuery(); + productpriceTbl.loadTable(rs); + rs.close(); + } catch (Exception e) { + log.log(Level.WARNING, sql, e); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } } // refresh /** @@ -628,10 +751,14 @@ public class InfoProductPanel extends InfoPanel implements EventListener setPriceListVersion (M_PriceList_Version_ID); // Create Grid + String orderBy = null; StringBuffer where = new StringBuffer(); where.append("p.IsActive='Y'"); if (M_Warehouse_ID != 0) + { where.append(" AND p.IsSummary='N'"); + orderBy = "QtyAvailable DESC"; + } // dynamic Where Clause if (p_whereClause != null && p_whereClause.length() > 0) where.append(" AND ") // replace fully qalified name with alias @@ -640,7 +767,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener prepareTable(getProductLayout(), s_productFrom, where.toString(), - "QtyAvailable DESC"); + orderBy); } // initInfo @@ -1119,33 +1246,49 @@ public class InfoProductPanel extends InfoPanel implements EventListener */ protected ColumnInfo[] getProductLayout() { - if (s_productLayout != null && s_productLayoutRole == MRole.getDefault().getAD_Role_ID()) - return s_productLayout; + // IDEMPIERE-337 - zkwebui - Improve Info Product window + //if (s_productLayout != null && s_productLayoutRole == MRole.getDefault().getAD_Role_ID()) + // return s_productLayout; // s_productLayout = null; s_productLayoutRole = MRole.getDefault().getAD_Role_ID(); + int M_Warehouse_ID = 0; + ListItem listitem = pickWarehouse.getSelectedItem(); + if (listitem != null) + M_Warehouse_ID = (Integer)listitem.getValue(); + int M_PriceList_ID = 0; + listitem = pickPriceList.getSelectedItem(); + if (listitem != null) + M_PriceList_ID = (Integer)listitem.getValue(); + + ArrayList list = new ArrayList(); - list.add(new ColumnInfo(" ", "p.M_Product_ID", IDColumn.class)); + list.add(new ColumnInfo(" ", "DISTINCT p.M_Product_ID", IDColumn.class)); list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Discontinued").substring(0, 1), "p.Discontinued", Boolean.class)); list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Value"), "p.Value", String.class)); list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Name"), "p.Name", String.class)); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "bomQtyAvailable(p.M_Product_ID,?,0) AS QtyAvailable", Double.class, true, true, null)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false)) + // IDEMPIERE-337 + if (M_Warehouse_ID != 0) + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyAvailable"), "bomQtyAvailable(p.M_Product_ID,?,0) AS QtyAvailable", Double.class, true, true, null)); + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3027/*PriceList*/, false) && M_PriceList_ID != 0) list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceList"), "bomPriceList(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceList", BigDecimal.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false)) + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && M_PriceList_ID != 0) list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceStd"), "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceStd", BigDecimal.class)); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "bomQtyOnHand(p.M_Product_ID,?,0) AS QtyOnHand", Double.class)); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "bomQtyReserved(p.M_Product_ID,?,0) AS QtyReserved", Double.class)); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "bomQtyOrdered(p.M_Product_ID,?,0) AS QtyOrdered", Double.class)); - if (isUnconfirmed()) + if (M_Warehouse_ID != 0) { - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyUnconfirmed"), "(SELECT SUM(c.TargetQty) FROM M_InOutLineConfirm c INNER JOIN M_InOutLine il ON (c.M_InOutLine_ID=il.M_InOutLine_ID) INNER JOIN M_InOut i ON (il.M_InOut_ID=i.M_InOut_ID) WHERE c.Processed='N' AND i.M_Warehouse_ID=? AND il.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmed", Double.class)); - list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyUnconfirmedMove"), "(SELECT SUM(c.TargetQty) FROM M_MovementLineConfirm c INNER JOIN M_MovementLine ml ON (c.M_MovementLine_ID=ml.M_MovementLine_ID) INNER JOIN M_Locator l ON (ml.M_LocatorTo_ID=l.M_Locator_ID) WHERE c.Processed='N' AND l.M_Warehouse_ID=? AND ml.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmedMove", Double.class)); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOnHand"), "bomQtyOnHand(p.M_Product_ID,?,0) AS QtyOnHand", Double.class)); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyReserved"), "bomQtyReserved(p.M_Product_ID,?,0) AS QtyReserved", Double.class)); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyOrdered"), "bomQtyOrdered(p.M_Product_ID,?,0) AS QtyOrdered", Double.class)); + if (isUnconfirmed()) + { + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyUnconfirmed"), "(SELECT SUM(c.TargetQty) FROM M_InOutLineConfirm c INNER JOIN M_InOutLine il ON (c.M_InOutLine_ID=il.M_InOutLine_ID) INNER JOIN M_InOut i ON (il.M_InOut_ID=i.M_InOut_ID) WHERE c.Processed='N' AND i.M_Warehouse_ID=? AND il.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmed", Double.class)); + list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "QtyUnconfirmedMove"), "(SELECT SUM(c.TargetQty) FROM M_MovementLineConfirm c INNER JOIN M_MovementLine ml ON (c.M_MovementLine_ID=ml.M_MovementLine_ID) INNER JOIN M_Locator l ON (ml.M_LocatorTo_ID=l.M_Locator_ID) WHERE c.Processed='N' AND l.M_Warehouse_ID=? AND ml.M_Product_ID=p.M_Product_ID) AS QtyUnconfirmedMove", Double.class)); + } } - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3028/*PriceStd*/, false) && MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false) && M_PriceList_ID != 0) list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Margin"), "bomPriceStd(p.M_Product_ID, pr.M_PriceList_Version_ID)-bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS Margin", BigDecimal.class)); list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "Vendor"), "bp.Name", String.class)); - if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false)) + if (MRole.getDefault().isColumnAccess(251 /*M_ProductPrice*/, 3029/*PriceLimit*/, false) && M_PriceList_ID != 0) list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "PriceLimit"), "bomPriceLimit(p.M_Product_ID, pr.M_PriceList_Version_ID) AS PriceLimit", BigDecimal.class)); list.add(new ColumnInfo(Msg.translate(Env.getCtx(), "IsInstanceAttribute"), "pa.IsInstanceAttribute", Boolean.class)); s_productLayout = new ColumnInfo[list.size()]; @@ -1179,10 +1322,35 @@ public class InfoProductPanel extends InfoPanel implements EventListener // Elaine 2008/12/16 // don't requery if fieldValue and fieldName are empty - if ((e.getTarget() == pickWarehouse || e.getTarget() == pickPriceList) - && (fieldValue.getText().length() == 0 && fieldName.getText().length() == 0)) - return; - // + // IDEMPIERE-337 - zkwebui - Improve Info Product window + if (e.getTarget() == pickWarehouse || e.getTarget() == pickPriceList) + { + boolean execute = true; + if (fieldValue.getText().length() == 0 && fieldName.getText().length() == 0 && contentPanel.getRowCount() == 0) + execute = false; + // Remove existing headers + contentPanel.getListhead().detach(); + // Create Grid + int M_Warehouse_ID = 0; + ListItem listitem = pickWarehouse.getSelectedItem(); + if (listitem != null) + M_Warehouse_ID = (Integer)listitem.getValue(); + StringBuffer where = new StringBuffer(); + where.append("p.IsActive='Y'"); + if (M_Warehouse_ID != 0) + where.append(" AND p.IsSummary='N'"); + // dynamic Where Clause + if (p_whereClause != null && p_whereClause.length() > 0) + where.append(" AND ") // replace fully qalified name with alias + .append(Util.replace(p_whereClause, "M_Product.", "p.")); + // + prepareTable(getProductLayout(), + s_productFrom, + where.toString(), + ""); + if (!execute) + return; + } if(component == m_InfoPAttributeButton) { From fc14420374ea5974f4d5ff3c9461e51c4618cb4d Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 17 Jul 2012 22:57:07 -0700 Subject: [PATCH 06/13] minor peer review for IDEMPIERE-337 and IDEMPIERE-339 --- .../src/org/compiere/apps/search/InfoProduct.java | 6 ++---- .../org/adempiere/webui/panel/InfoProductPanel.java | 11 +++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java index e535b4a359..9a22c64ccd 100644 --- a/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java +++ b/org.adempiere.ui.swing/src/org/compiere/apps/search/InfoProduct.java @@ -80,9 +80,9 @@ import org.jdesktop.swingx.JXTaskPane; public class InfoProduct extends Info implements ActionListener, ChangeListener { /** - * + * */ - private static final long serialVersionUID = 2076229793041196087L; + private static final long serialVersionUID = -2119729271332154941L; /** * Standard Constructor @@ -152,7 +152,6 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener /** Array of Column Info */ private static Info_Column[] s_productLayout = null; - private static int s_productLayoutRole = -1; private static int INDEX_NAME = 0; private static int INDEX_PATTRIBUTE = 0; @@ -1134,7 +1133,6 @@ public class InfoProduct extends Info implements ActionListener, ChangeListener // return s_productLayout; // s_productLayout = null; - s_productLayoutRole = MRole.getDefault().getAD_Role_ID(); // IDEMPIERE_337 int M_Warehouse_ID = 0; KeyNamePair warehouse = (KeyNamePair)pickWarehouse.getSelectedItem(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java index 111713bfb2..3ad013b70d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoProductPanel.java @@ -94,9 +94,10 @@ import org.zkoss.zul.South; public class InfoProductPanel extends InfoPanel implements EventListener { /** - * + * */ - private static final long serialVersionUID = 6804975825156657866L; + private static final long serialVersionUID = 3728242035878883637L; + private Label lblValue = new Label(); private Textbox fieldValue = new Textbox(); private Label lblName = new Label(); @@ -152,7 +153,6 @@ public class InfoProductPanel extends InfoPanel implements EventListener /** Array of Column Info */ private static ColumnInfo[] s_productLayout = null; - private static int s_productLayoutRole = -1; private static int INDEX_NAME = 0; private static int INDEX_PATTRIBUTE = 0; @@ -537,7 +537,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener this.setHeight(height + "px"); } - contentPanel.addActionListener(new EventListener() { + contentPanel.addActionListener(new EventListener() { public void onEvent(Event event) throws Exception { int row = contentPanel.getSelectedRow(); if (row >= 0) { @@ -579,7 +579,7 @@ public class InfoProductPanel extends InfoPanel implements EventListener where.append(" AND p.IsSummary='N'"); // dynamic Where Clause if (p_whereClause != null && p_whereClause.length() > 0) - where.append(" AND ") // replace fully qalified name with alias + where.append(" AND ") // replace fully qualified name with alias .append(Util.replace(p_whereClause, "M_Product.", "p.")); StringBuffer sqlMain = new StringBuffer("SELECT "); @@ -1251,7 +1251,6 @@ public class InfoProductPanel extends InfoPanel implements EventListener // return s_productLayout; // s_productLayout = null; - s_productLayoutRole = MRole.getDefault().getAD_Role_ID(); int M_Warehouse_ID = 0; ListItem listitem = pickWarehouse.getSelectedItem(); if (listitem != null) From 00f842dd6722ecd14e7e8e216edd866b3271483f Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Tue, 10 Jul 2012 13:29:45 +0300 Subject: [PATCH 07/13] IDEMPIERE-335 - Send Jasper Report email (transplanted from 5f33b56d79d04e5bba96d938c65e650e4516001a) --- .../src/org/compiere/model/MInOut.java | 18 +++++++++++++++++ .../src/org/compiere/model/MInvoice.java | 18 +++++++++++++++++ .../src/org/compiere/model/MOrder.java | 20 +++++++++++++++++-- .../src/org/compiere/model/MRfQResponse.java | 18 +++++++++++++++++ 4 files changed, 72 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index ee2282bced..b2a6f65556 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -26,9 +26,12 @@ import java.util.Properties; import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; import org.compiere.process.DocAction; import org.compiere.process.DocumentEngine; +import org.compiere.process.ProcessInfo; +import org.compiere.process.ServerProcessCtl; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -616,6 +619,21 @@ public class MInOut extends X_M_InOut implements DocAction ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.SHIPMENT, getM_InOut_ID(), get_TrxName()); if (re == null) return null; + MPrintFormat format = re.getPrintFormat(); + // We have a Jasper Print Format + // ============================== + if(format.getJasperProcess_ID() > 0) + { + ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); + pi.setRecord_ID ( getC_Order_ID() ); + pi.setIsBatch(true); + + ServerProcessCtl.process(null, pi, null); + + return pi.getPDFReport(); + } + // Standard Print Format (Non-Jasper) + // ================================== return re.getPDF(file); } // createPDF diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 93aef95cfb..5356bb14da 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -30,9 +30,12 @@ import java.util.logging.Level; import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.BPartnerNoAddressException; import org.adempiere.exceptions.DBException; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; import org.compiere.process.DocAction; import org.compiere.process.DocumentEngine; +import org.compiere.process.ProcessInfo; +import org.compiere.process.ServerProcessCtl; import org.compiere.util.CCache; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -1272,6 +1275,21 @@ public class MInvoice extends X_C_Invoice implements DocAction ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.INVOICE, getC_Invoice_ID(), get_TrxName()); if (re == null) return null; + MPrintFormat format = re.getPrintFormat(); + // We have a Jasper Print Format + // ============================== + if(format.getJasperProcess_ID() > 0) + { + ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); + pi.setRecord_ID ( getC_Order_ID() ); + pi.setIsBatch(true); + + ServerProcessCtl.process(null, pi, null); + + return pi.getPDFReport(); + } + // Standard Print Format (Non-Jasper) + // ================================== return re.getPDF(file); } // createPDF diff --git a/org.adempiere.base/src/org/compiere/model/MOrder.java b/org.adempiere.base/src/org/compiere/model/MOrder.java index bac0dab99e..4e6f71c603 100644 --- a/org.adempiere.base/src/org/compiere/model/MOrder.java +++ b/org.adempiere.base/src/org/compiere/model/MOrder.java @@ -30,15 +30,16 @@ import java.util.Vector; import java.util.logging.Level; import java.util.regex.Pattern; -import javax.mail.internet.AddressException; - import org.adempiere.exceptions.AdempiereException; import org.adempiere.exceptions.BPartnerNoBillToAddressException; import org.adempiere.exceptions.BPartnerNoShipToAddressException; import org.adempiere.exceptions.FillMandatoryException; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; import org.compiere.process.DocAction; import org.compiere.process.DocumentEngine; +import org.compiere.process.ProcessInfo; +import org.compiere.process.ServerProcessCtl; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -618,6 +619,21 @@ public class MOrder extends X_C_Order implements DocAction ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.ORDER, getC_Order_ID(), get_TrxName()); if (re == null) return null; + MPrintFormat format = re.getPrintFormat(); + // We have a Jasper Print Format + // ============================== + if(format.getJasperProcess_ID() > 0) + { + ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); + pi.setRecord_ID ( getC_Order_ID() ); + pi.setIsBatch(true); + + ServerProcessCtl.process(null, pi, null); + + return pi.getPDFReport(); + } + // Standard Print Format (Non-Jasper) + // ================================== return re.getPDF(file); } // createPDF diff --git a/org.adempiere.base/src/org/compiere/model/MRfQResponse.java b/org.adempiere.base/src/org/compiere/model/MRfQResponse.java index fb3da3156a..2368dba740 100644 --- a/org.adempiere.base/src/org/compiere/model/MRfQResponse.java +++ b/org.adempiere.base/src/org/compiere/model/MRfQResponse.java @@ -25,7 +25,10 @@ import java.util.ArrayList; import java.util.Properties; import java.util.logging.Level; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; +import org.compiere.process.ProcessInfo; +import org.compiere.process.ServerProcessCtl; import org.compiere.util.DB; import org.compiere.util.EMail; import org.compiere.util.Env; @@ -286,6 +289,21 @@ public class MRfQResponse extends X_C_RfQResponse ReportEngine re = ReportEngine.get (getCtx(), ReportEngine.RFQ, getC_RfQResponse_ID()); if (re == null) return null; + MPrintFormat format = re.getPrintFormat(); + // We have a Jasper Print Format + // ============================== + if(format.getJasperProcess_ID() > 0) + { + ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); + pi.setRecord_ID ( getC_Order_ID() ); + pi.setIsBatch(true); + + ServerProcessCtl.process(null, pi, null); + + return pi.getPDFReport(); + } + // Standard Print Format (Non-Jasper) + // ================================== return re.getPDF(file); } // getPDF From 42fbf81e8ee02d41fe2d0216fa2b6bb40e04ffb8 Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Wed, 11 Jul 2012 17:53:24 +0300 Subject: [PATCH 08/13] IDEMPIERE-335 - Send Jasper Report email (transplanted from 914c39015d963ae2f9d51bb2b9f3a18bf5a42678) --- org.adempiere.base/src/org/compiere/model/MInOut.java | 2 +- org.adempiere.base/src/org/compiere/model/MInvoice.java | 2 +- org.adempiere.base/src/org/compiere/model/MRfQResponse.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MInOut.java b/org.adempiere.base/src/org/compiere/model/MInOut.java index b2a6f65556..c6e367d8e7 100644 --- a/org.adempiere.base/src/org/compiere/model/MInOut.java +++ b/org.adempiere.base/src/org/compiere/model/MInOut.java @@ -625,7 +625,7 @@ public class MInOut extends X_M_InOut implements DocAction if(format.getJasperProcess_ID() > 0) { ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); - pi.setRecord_ID ( getC_Order_ID() ); + pi.setRecord_ID ( getM_InOut_ID() ); pi.setIsBatch(true); ServerProcessCtl.process(null, pi, null); diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index 5356bb14da..0ead4329e0 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1281,7 +1281,7 @@ public class MInvoice extends X_C_Invoice implements DocAction if(format.getJasperProcess_ID() > 0) { ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); - pi.setRecord_ID ( getC_Order_ID() ); + pi.setRecord_ID ( getC_Invoice_ID() ); pi.setIsBatch(true); ServerProcessCtl.process(null, pi, null); diff --git a/org.adempiere.base/src/org/compiere/model/MRfQResponse.java b/org.adempiere.base/src/org/compiere/model/MRfQResponse.java index 2368dba740..0e3b12964b 100644 --- a/org.adempiere.base/src/org/compiere/model/MRfQResponse.java +++ b/org.adempiere.base/src/org/compiere/model/MRfQResponse.java @@ -295,7 +295,7 @@ public class MRfQResponse extends X_C_RfQResponse if(format.getJasperProcess_ID() > 0) { ProcessInfo pi = new ProcessInfo ("", format.getJasperProcess_ID()); - pi.setRecord_ID ( getC_Order_ID() ); + pi.setRecord_ID ( getC_RfQResponse_ID() ); pi.setIsBatch(true); ServerProcessCtl.process(null, pi, null); From bb8239152c62a45f276e208de991b079ba521dfe Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Tue, 10 Jul 2012 20:43:19 +0300 Subject: [PATCH 09/13] IDEMPIERE-214 - Schedular does not work with Jasper reports (transplanted from 56ae246dc7cc02cbee0ec8ff89c51d86f97cb2a6) --- org.adempiere.server/META-INF/MANIFEST.MF | 4 ++- .../server/org/compiere/server/Scheduler.java | 27 ++++++++++++++----- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/org.adempiere.server/META-INF/MANIFEST.MF b/org.adempiere.server/META-INF/MANIFEST.MF index 7789c61e06..3a7af57e93 100644 --- a/org.adempiere.server/META-INF/MANIFEST.MF +++ b/org.adempiere.server/META-INF/MANIFEST.MF @@ -4,7 +4,9 @@ Bundle-Name: org.adempiere.server Bundle-SymbolicName: org.adempiere.server;singleton:=true Bundle-Version: 1.0.0.qualifier Require-Bundle: org.adempiere.base;bundle-version="1.0.0", - org.eclipse.equinox.app;bundle-version="1.3.0" + org.eclipse.equinox.app;bundle-version="1.3.0", + org.adempiere.report.jasper;bundle-version="1.0.0", + org.adempiere.report.jasper.library;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Web-ContextPath: / Bundle-ClassPath: WEB-INF/lib/jardiff.jar, diff --git a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java index 1dd9b86db5..519090cdcf 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java @@ -38,9 +38,11 @@ import org.compiere.model.MScheduler; import org.compiere.model.MSchedulerLog; import org.compiere.model.MSchedulerPara; import org.compiere.model.MUser; +import org.compiere.print.MPrintFormat; import org.compiere.print.ReportEngine; import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfoUtil; +import org.compiere.process.ServerProcessCtl; import org.compiere.util.DisplayType; import org.compiere.util.Env; import org.compiere.util.TimeUtil; @@ -217,12 +219,25 @@ public class Scheduler extends AdempiereServer File report = null; if (isReport) { // Report - ReportEngine re = ReportEngine.get(m_schedulerctx, pi); - if (re == null) - return "Cannot create Report AD_Process_ID=" + process.getAD_Process_ID() - + " - " + process.getName(); - report = re.getPDF(); - + if(process.getJasperReport() != null) + { + ProcessInfo jasperpi = new ProcessInfo ("", process.getAD_Process_ID()); + jasperpi.setIsBatch(true); + ServerProcessCtl.process(null, jasperpi, null); + report = jasperpi.getPDFReport(); + } + // Standard Print Format (Non-Jasper) + // ================================== + else + { + // We have a Jasper Print Format + // ============================== + ReportEngine re = ReportEngine.get(m_schedulerctx, pi); + if (re == null) + return "Cannot create Report AD_Process_ID=" + process.getAD_Process_ID() + + " - " + process.getName(); + report = re.getPDF(); + } } if (notice) { From f7cf69bc609b6c2c467c58862046f1165ed024da Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Wed, 11 Jul 2012 18:10:28 +0300 Subject: [PATCH 10/13] IDEMPIERE-214 - Schedular does not work with Jasper reports (transplanted from f99f4696caa2faf52654c81630c7a7aac7fca3f3) --- .../main/server/org/compiere/server/Scheduler.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java index 519090cdcf..9445539277 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/Scheduler.java @@ -219,20 +219,22 @@ public class Scheduler extends AdempiereServer File report = null; if (isReport) { // Report - if(process.getJasperReport() != null) + ReportEngine re = ReportEngine.get(m_schedulerctx, pi); + + if(process.getJasperReport() != null + || (re != null && re.getPrintFormat().getJasperProcess_ID() > 0)) { + // We have a Jasper Print Format + // ============================== ProcessInfo jasperpi = new ProcessInfo ("", process.getAD_Process_ID()); jasperpi.setIsBatch(true); ServerProcessCtl.process(null, jasperpi, null); report = jasperpi.getPDFReport(); } - // Standard Print Format (Non-Jasper) - // ================================== else { - // We have a Jasper Print Format - // ============================== - ReportEngine re = ReportEngine.get(m_schedulerctx, pi); + // Standard Print Format (Non-Jasper) + // ================================== if (re == null) return "Cannot create Report AD_Process_ID=" + process.getAD_Process_ID() + " - " + process.getName(); From 78cda240f6ef8ccbd538d2088b90115e753e2787 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Wed, 18 Jul 2012 07:00:55 -0700 Subject: [PATCH 11/13] related to IDEMPIERE-337 / as suggested by NMicoud on weekly iDempiere meeting - drop the & from the info product link --- .../adempiere/webui/dashboard/DPViews.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPViews.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPViews.java index 59412bb72c..d903f0d438 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPViews.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/dashboard/DPViews.java @@ -20,6 +20,7 @@ import org.adempiere.webui.window.InfoSchedule; import org.compiere.model.MRole; import org.compiere.util.Env; import org.compiere.util.Msg; +import org.compiere.util.Util; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -53,7 +54,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Product()) { ToolBarButton btnViewItem = new ToolBarButton("InfoProduct"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoProduct")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoProduct"))); btnViewItem.setImage("/images/InfoProduct16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -61,7 +62,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_BPartner()) { ToolBarButton btnViewItem = new ToolBarButton("InfoBPartner"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoBPartner")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoBPartner"))); btnViewItem.setImage("/images/InfoBPartner16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -69,7 +70,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isShowAcct() && MRole.getDefault().isAllow_Info_Account()) { ToolBarButton btnViewItem = new ToolBarButton("InfoAccount"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoAccount")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoAccount"))); btnViewItem.setImage("/images/InfoAccount16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -77,7 +78,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Schedule()) { ToolBarButton btnViewItem = new ToolBarButton("InfoSchedule"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoSchedule")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoSchedule"))); btnViewItem.setImage("/images/InfoSchedule16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -86,7 +87,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Order()) { ToolBarButton btnViewItem = new ToolBarButton("InfoOrder"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoOrder")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoOrder"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -94,7 +95,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Invoice()) { ToolBarButton btnViewItem = new ToolBarButton("InfoInvoice"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoInvoice")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoInvoice"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -102,7 +103,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_InOut()) { ToolBarButton btnViewItem = new ToolBarButton("InfoInOut"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoInOut")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoInOut"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -110,7 +111,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Payment()) { ToolBarButton btnViewItem = new ToolBarButton("InfoPayment"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoPayment")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoPayment"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -118,7 +119,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_CashJournal()) { ToolBarButton btnViewItem = new ToolBarButton("InfoCashLine"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoCashLine")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoCashLine"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -126,7 +127,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Resource()) { ToolBarButton btnViewItem = new ToolBarButton("InfoAssignment"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoAssignment")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoAssignment"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); @@ -134,7 +135,7 @@ public class DPViews extends DashboardPanel implements EventListener { if (MRole.getDefault().isAllow_Info_Asset()) { ToolBarButton btnViewItem = new ToolBarButton("InfoAsset"); - btnViewItem.setLabel(Msg.getMsg(Env.getCtx(), "InfoAsset")); + btnViewItem.setLabel(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "InfoAsset"))); btnViewItem.setImage("/images/Info16.png"); btnViewItem.addEventListener(Events.ON_CLICK, this); vbox.appendChild(btnViewItem); From 301ce178bbc202f34222752a11a9fb6591be5c0f Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Mon, 16 Jul 2012 05:52:45 +0300 Subject: [PATCH 12/13] IDEMPIERE-320 - Make Swing CTextArea consistent with ZK (transplanted from 994a9b5493ddba3c2a10e64ccf7377d8ae69b398) --- .../oracle/850_IDEMPIERE-320.sql | 5 ++ .../postgresql/850_IDEMPIERE-320.sql | 6 ++ .../src/org/compiere/swing/CTextArea.java | 72 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 migration/360lts-release/oracle/850_IDEMPIERE-320.sql create mode 100644 migration/360lts-release/postgresql/850_IDEMPIERE-320.sql diff --git a/migration/360lts-release/oracle/850_IDEMPIERE-320.sql b/migration/360lts-release/oracle/850_IDEMPIERE-320.sql new file mode 100644 index 0000000000..7228984d46 --- /dev/null +++ b/migration/360lts-release/oracle/850_IDEMPIERE-320.sql @@ -0,0 +1,5 @@ +-- Jul 16, 2012 5:38:59 AM AST +-- IDEMPIERE-320 - Make Swing CTextArea consistent with ZK +INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Value,Description,AD_SysConfig_UU,Created,Updated,AD_Client_ID,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name) VALUES (200012,'D','C','N','Override Text Area behaviour, ENTER to change value, TAB to focus next, Shift-ENTER for new line','b8634904-e4d1-48da-8b86-cc46d12cb52d',TO_DATE('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),0,0,100,'Y',100,'SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR') +; + diff --git a/migration/360lts-release/postgresql/850_IDEMPIERE-320.sql b/migration/360lts-release/postgresql/850_IDEMPIERE-320.sql new file mode 100644 index 0000000000..c512a7b558 --- /dev/null +++ b/migration/360lts-release/postgresql/850_IDEMPIERE-320.sql @@ -0,0 +1,6 @@ +-- Jul 16, 2012 5:38:59 AM AST +-- IDEMPIERE-320 - Make Swing CTextArea consistent with ZK +INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Value,Description,AD_SysConfig_UU,Created,Updated,AD_Client_ID,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name) VALUES (200012,'D','C','N','Override Text Area behaviour, ENTER to change value, TAB to focus next, Shift-ENTER for new line','b8634904-e4d1-48da-8b86-cc46d12cb52d',TO_TIMESTAMP('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),0,0,100,'Y',100,'SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR') +; + + diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java index 9861dfb9d8..c8adc0028d 100644 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java +++ b/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java @@ -17,19 +17,31 @@ package org.compiere.swing; import java.awt.Color; +import java.awt.Component; import java.awt.Insets; +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; import java.awt.event.FocusListener; +import java.awt.event.InputEvent; import java.awt.event.InputMethodListener; +import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseListener; import java.awt.im.InputMethodRequests; +import javax.swing.AbstractAction; +import javax.swing.ActionMap; +import javax.swing.FocusManager; +import javax.swing.InputMap; import javax.swing.InputVerifier; import javax.swing.JScrollPane; import javax.swing.JTextArea; +import javax.swing.KeyStroke; import javax.swing.text.Document; import org.adempiere.plaf.AdempierePLAF; +import org.compiere.model.MSysConfig; +import org.compiere.util.Env; /** * Adempiere TextArea - A ScrollPane with a JTextArea. @@ -45,6 +57,12 @@ public class CTextArea extends JScrollPane * */ private static final long serialVersionUID = 6208738910767859872L; + + // IDEMPIERE-320 + private static final String FIRE_CHANGE = "fire-change"; + private static final String INSERT_BREAK = "insert-break"; + private static final String TAB_PRESS = "tab-press"; + private static final String SHIFT_TAB_PRESS = "shift-tab-press"; /** * Constructs a new TextArea. A default model is set, the initial string @@ -140,6 +158,60 @@ public class CTextArea extends JScrollPane m_textArea.setWrapStyleWord(true); // Overwrite default Tab m_textArea.firePropertyChange("editable", !isEditable(), isEditable()); + + // IDEMPIERE-320 + String taBehaviour = MSysConfig.getValue("SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR", Env.getAD_Client_ID(Env.getCtx())); + if (taBehaviour != null && taBehaviour.equals("Y")) + { + InputMap im = m_textArea.getInputMap(); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK), INSERT_BREAK); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), FIRE_CHANGE); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), TAB_PRESS); + im.put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK), SHIFT_TAB_PRESS); + + ActionMap am = m_textArea.getActionMap(); + am.put(FIRE_CHANGE, new AbstractAction() { + + /** + * + */ + private static final long serialVersionUID = -4599908611347627047L; + + @Override + public void actionPerformed(ActionEvent arg0) { + m_textArea.dispatchEvent(new FocusEvent(m_textArea, FocusEvent.FOCUS_LOST)); + m_textArea.requestFocus(); + } + }); + + am.put(TAB_PRESS, new AbstractAction() { + + /** + * + */ + private static final long serialVersionUID = -410878209760495750L; + + @Override + public void actionPerformed(ActionEvent arg0) { + FocusManager.getCurrentKeyboardFocusManager() + .focusNextComponent(); + } + }); + + am.put(SHIFT_TAB_PRESS, new AbstractAction() { + + /** + * + */ + private static final long serialVersionUID = 8279987397360805855L; + + @Override + public void actionPerformed(ActionEvent arg0) { + FocusManager.getCurrentKeyboardFocusManager() + .focusPreviousComponent(); + } + }); + } } // CTextArea /** Text Area */ From d1e3eb4a894cb023137c25e9369adbb3433dc4a6 Mon Sep 17 00:00:00 2001 From: "Hesham S. Ahmed" Date: Wed, 18 Jul 2012 14:41:19 +0300 Subject: [PATCH 13/13] IDEMPIERE-320 - Make Swing CTextArea consistent with ZK (transplanted from 1c201bf217991c1d82d05f8eaa4bc2711d69c355) --- .../oracle/{850_IDEMPIERE-320.sql => 851_IDEMPIERE-320.sql} | 5 +++++ .../{850_IDEMPIERE-320.sql => 851_IDEMPIERE-320.sql} | 5 +++++ org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) rename migration/360lts-release/oracle/{850_IDEMPIERE-320.sql => 851_IDEMPIERE-320.sql} (77%) rename migration/360lts-release/postgresql/{850_IDEMPIERE-320.sql => 851_IDEMPIERE-320.sql} (77%) diff --git a/migration/360lts-release/oracle/850_IDEMPIERE-320.sql b/migration/360lts-release/oracle/851_IDEMPIERE-320.sql similarity index 77% rename from migration/360lts-release/oracle/850_IDEMPIERE-320.sql rename to migration/360lts-release/oracle/851_IDEMPIERE-320.sql index 7228984d46..cb11af2088 100644 --- a/migration/360lts-release/oracle/850_IDEMPIERE-320.sql +++ b/migration/360lts-release/oracle/851_IDEMPIERE-320.sql @@ -3,3 +3,8 @@ INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Value,Description,AD_SysConfig_UU,Created,Updated,AD_Client_ID,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name) VALUES (200012,'D','C','N','Override Text Area behaviour, ENTER to change value, TAB to focus next, Shift-ENTER for new line','b8634904-e4d1-48da-8b86-cc46d12cb52d',TO_DATE('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),0,0,100,'Y',100,'SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR') ; +UPDATE AD_System + SET LastMigrationScriptApplied='851_IDEMPIERE-320.sql' +WHERE LastMigrationScriptApplied<'851_IDEMPIERE-320.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/migration/360lts-release/postgresql/850_IDEMPIERE-320.sql b/migration/360lts-release/postgresql/851_IDEMPIERE-320.sql similarity index 77% rename from migration/360lts-release/postgresql/850_IDEMPIERE-320.sql rename to migration/360lts-release/postgresql/851_IDEMPIERE-320.sql index c512a7b558..e26697a680 100644 --- a/migration/360lts-release/postgresql/850_IDEMPIERE-320.sql +++ b/migration/360lts-release/postgresql/851_IDEMPIERE-320.sql @@ -3,4 +3,9 @@ INSERT INTO AD_SysConfig (AD_SysConfig_ID,EntityType,ConfigurationLevel,Value,Description,AD_SysConfig_UU,Created,Updated,AD_Client_ID,AD_Org_ID,CreatedBy,IsActive,UpdatedBy,Name) VALUES (200012,'D','C','N','Override Text Area behaviour, ENTER to change value, TAB to focus next, Shift-ENTER for new line','b8634904-e4d1-48da-8b86-cc46d12cb52d',TO_TIMESTAMP('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-07-16 05:38:58','YYYY-MM-DD HH24:MI:SS'),0,0,100,'Y',100,'SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR') ; +UPDATE AD_System + SET LastMigrationScriptApplied='851_IDEMPIERE-320.sql' +WHERE LastMigrationScriptApplied<'851_IDEMPIERE-320.sql' + OR LastMigrationScriptApplied IS NULL +; diff --git a/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java b/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java index c8adc0028d..84ba42a978 100644 --- a/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java +++ b/org.adempiere.ui.swing/src/org/compiere/swing/CTextArea.java @@ -160,8 +160,8 @@ public class CTextArea extends JScrollPane m_textArea.firePropertyChange("editable", !isEditable(), isEditable()); // IDEMPIERE-320 - String taBehaviour = MSysConfig.getValue("SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR", Env.getAD_Client_ID(Env.getCtx())); - if (taBehaviour != null && taBehaviour.equals("Y")) + boolean taBehaviour = MSysConfig.getBooleanValue("SWING_OVERRIDE_TEXT_AREA_BEHAVIOUR", false, Env.getAD_Client_ID(Env.getCtx())); + if (taBehaviour) { InputMap im = m_textArea.getInputMap(); im.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK), INSERT_BREAK);