diff --git a/org.adempiere.base.process/src/org/adempiere/process/InitialClientSetup.java b/org.adempiere.base.process/src/org/adempiere/process/InitialClientSetup.java index 9b9f791358..66741cf624 100644 --- a/org.adempiere.base.process/src/org/adempiere/process/InitialClientSetup.java +++ b/org.adempiere.base.process/src/org/adempiere/process/InitialClientSetup.java @@ -257,34 +257,38 @@ public class InitialClientSetup extends SvrProcess // Process MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_PROCESS); + try { + if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName + , p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID, p_AdminUserEmail, p_NormalUserEmail)) { + ms.rollback(); + throw new AdempiereException("Create client failed"); + } + + addLog(ms.getInfo()); - if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName - , p_Phone, p_Phone2, p_Fax, p_EMail, p_TaxID, p_AdminUserEmail, p_NormalUserEmail)) { + // Generate Accounting + MCurrency currency = MCurrency.get(getCtx(), p_C_Currency_ID); + KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription()); + if (!ms.createAccounting(currency_kp, + p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension, p_IsUseActivityDimension, + coaFile, p_UseDefaultCoA, p_InactivateDefaults)) { + ms.rollback(); + throw new AdempiereException("@AccountSetupError@"); + } + + // Generate Entities + if (!ms.createEntities(p_C_Country_ID, p_CityName, p_C_Region_ID, p_C_Currency_ID, p_Postal, p_Address1)) { + ms.rollback(); + throw new AdempiereException("@AccountSetupError@"); + } + addLog(ms.getInfo()); + + // Create Print Documents + PrintUtil.setupPrintForm(ms.getAD_Client_ID()); + } catch (Exception e) { ms.rollback(); - throw new AdempiereException("Create client failed"); + throw e; } - - addLog(ms.getInfo()); - - // Generate Accounting - MCurrency currency = MCurrency.get(getCtx(), p_C_Currency_ID); - KeyNamePair currency_kp = new KeyNamePair(p_C_Currency_ID, currency.getDescription()); - if (!ms.createAccounting(currency_kp, - p_IsUseProductDimension, p_IsUseBPDimension, p_IsUseProjectDimension, p_IsUseCampaignDimension, p_IsUseSalesRegionDimension, p_IsUseActivityDimension, - coaFile, p_UseDefaultCoA, p_InactivateDefaults)) { - ms.rollback(); - throw new AdempiereException("@AccountSetupError@"); - } - - // Generate Entities - if (!ms.createEntities(p_C_Country_ID, p_CityName, p_C_Region_ID, p_C_Currency_ID, p_Postal, p_Address1)) { - ms.rollback(); - throw new AdempiereException("@AccountSetupError@"); - } - addLog(ms.getInfo()); - - // Create Print Documents - PrintUtil.setupPrintForm(ms.getAD_Client_ID()); return "@OK@"; } diff --git a/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java b/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java index eadb2aff64..7e76fa705e 100644 --- a/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java +++ b/org.adempiere.base.process/src/org/compiere/process/ReplicationLocal.java @@ -353,8 +353,9 @@ public class ReplicationLocal extends SvrProcess // no keys - search for parents if (list.size() == 0) { - DB.close(rs); + DB.close(rs, pstmt); rs = null; + pstmt = null; sql = "SELECT ColumnName FROM AD_Column " + "WHERE AD_Table_ID=?" + " AND IsParent='Y'"; diff --git a/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java b/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java index bc444d6d98..7f2b1aedf4 100644 --- a/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java +++ b/org.adempiere.base/src/org/compiere/impexp/OFXFileBankStatementLoader.java @@ -17,6 +17,7 @@ package org.compiere.impexp; import java.io.FileInputStream; +import java.io.IOException; import org.compiere.model.MBankStatementLoader; import org.xml.sax.SAXException; @@ -71,6 +72,13 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im { m_errorMessage = new StringBuffer("ErrorReadingData"); m_errorDescription = new StringBuffer(); + }finally{ + if (m_stream != null) + try { + m_stream.close(); + } catch (IOException e) { + e.printStackTrace(); + } } return result; diff --git a/org.adempiere.base/src/org/compiere/model/MLocation.java b/org.adempiere.base/src/org/compiere/model/MLocation.java index 4590abdf22..f24c2c1bae 100644 --- a/org.adempiere.base/src/org/compiere/model/MLocation.java +++ b/org.adempiere.base/src/org/compiere/model/MLocation.java @@ -439,7 +439,7 @@ public class MLocation extends X_C_Location implements Comparator public boolean isAddressLinesReverse() { // Local - if (getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID()) + if (MCountry.getDefault(getCtx()) != null && getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID()) return getCountry().isAddressLinesLocalReverse(); return getCountry().isAddressLinesReverse(); } // isAddressLinesReverse @@ -465,7 +465,7 @@ public class MLocation extends X_C_Location implements Comparator if (c == null) return "CountryNotFound"; - boolean local = getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID(); + boolean local = MCountry.getDefault(getCtx()) != null && getC_Country_ID() == MCountry.getDefault(getCtx()).getC_Country_ID(); String inStr = local ? c.getDisplaySequenceLocal() : c.getDisplaySequence(); StringBuilder outStr = new StringBuilder(); diff --git a/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java b/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java index e5986554e7..a092a71cd6 100644 --- a/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java +++ b/org.adempiere.base/src/org/compiere/model/ModelValidationEngine.java @@ -338,7 +338,7 @@ public class ModelValidationEngine */ public String fireModelChange (PO po, int changeType) { - if (po == null || m_modelChangeListeners.size() == 0) + if (po == null ) return null; String propertyName = po.get_TableName() + "*"; @@ -502,7 +502,7 @@ public class ModelValidationEngine */ public String fireDocValidate (PO po, int docTiming) { - if (po == null || m_docValidateListeners.size() == 0) + if (po == null) return null; String propertyName = po.get_TableName() + "*"; @@ -688,7 +688,7 @@ public class ModelValidationEngine */ public String fireFactsValidate (MAcctSchema schema, List facts, PO po) { - if (schema == null || facts == null || po == null || m_factsValidateListeners.size() == 0) + if (schema == null || facts == null || po == null) return null; String propertyName = po.get_TableName() + "*"; @@ -715,6 +715,7 @@ public class ModelValidationEngine FactsEventData eventData = new FactsEventData(schema, facts, po); Event event = EventManager.newEvent(IEventTopics.ACCT_FACTS_VALIDATE, new EventProperty(EventManager.EVENT_DATA, eventData), new EventProperty("tableName", po.get_TableName())); + EventManager.getInstance().sendEvent(event); @SuppressWarnings("unchecked") List errors = (List) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES); if (errors != null && !errors.isEmpty()) @@ -769,8 +770,6 @@ public class ModelValidationEngine */ public void fireImportValidate (ImportProcess process, PO importModel, PO targetModel, int timing) { - if (m_impValidateListeners.size() == 0) - return; String propertyName = process.getImportTableName() + "*"; ArrayList list = m_impValidateListeners.get(propertyName); diff --git a/org.adempiere.base/src/org/compiere/model/PO.java b/org.adempiere.base/src/org/compiere/model/PO.java index 0a0487b330..83bb9c1e3d 100644 --- a/org.adempiere.base/src/org/compiere/model/PO.java +++ b/org.adempiere.base/src/org/compiere/model/PO.java @@ -107,7 +107,7 @@ public abstract class PO /** * */ - private static final long serialVersionUID = -2731993630208549493L; + private static final long serialVersionUID = 8237905660667141657L; public static final String LOCAL_TRX_PREFIX = "POSave"; @@ -1882,16 +1882,22 @@ public abstract class PO /** Cache */ private static CCache trl_cache = new CCache("po_trl", 5); + public String get_Translation (String columnName, String AD_Language) + { + return get_Translation(columnName, AD_Language, false); + } + /** * Get Translation of column (if needed). * It checks if the base language is used or the column is not translated. * If there is no translation then it fallback to original value. * @param columnName * @param AD_Language + * @boolean reload * @return translated string * @throws IllegalArgumentException if columnName or AD_Language is null or model has multiple PK */ - public String get_Translation (String columnName, String AD_Language) + public String get_Translation (String columnName, String AD_Language, boolean reload) { // // Check if columnName, AD_Language is valid or table support translation (has 1 PK) => error @@ -1907,7 +1913,7 @@ public abstract class PO String key = get_TableName() + "." + columnName + "|" + get_ID() + "|" + AD_Language; String retValue = null; - if (trl_cache.containsKey(key)) { + if (! reload && trl_cache.containsKey(key)) { retValue = trl_cache.get(key); return retValue; diff --git a/org.adempiere.base/src/org/compiere/print/ReportEngine.java b/org.adempiere.base/src/org/compiere/print/ReportEngine.java index 4599ebeaf7..6dd25c27be 100644 --- a/org.adempiere.base/src/org/compiere/print/ReportEngine.java +++ b/org.adempiere.base/src/org/compiere/print/ReportEngine.java @@ -1625,6 +1625,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount) .append("FROM C_DocType dt, C_Order o ") .append("WHERE o.C_DocTypeTarget_ID=dt.C_DocType_ID") .append(" AND o.C_Order_ID=?"); + DB.close(rs, pstmt); + rs = null; pstmt = null; pstmt = DB.prepareStatement(sql.toString(), null); pstmt.setInt(1, C_Order_ID); rs = pstmt.executeQuery(); diff --git a/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java b/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java index 300bfb287e..af6d9fcbdf 100644 --- a/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java +++ b/org.adempiere.base/src/org/compiere/print/layout/LayoutEngine.java @@ -265,7 +265,7 @@ public class LayoutEngine implements Pageable, Printable, Doc m_printFont = MPrintFont.get (format.getAD_PrintFont_ID()); // Print Context - Env.setContext(m_printCtx, Page.CONTEXT_REPORTNAME, m_format.getName()); + Env.setContext(m_printCtx, Page.CONTEXT_REPORTNAME, m_format.get_Translation(MPrintFormat.COLUMNNAME_Name)); Env.setContext(m_printCtx, Page.CONTEXT_HEADER, Env.getHeader(m_printCtx, 0)); Env.setContext(m_printCtx, Env.LANGUAGE, m_format.getLanguage().getAD_Language()); @@ -1009,6 +1009,9 @@ public class LayoutEngine implements Pageable, Printable, Doc { if (log.isLoggable(Level.INFO)) log.info("Row=" + row); m_data.setRowIndex(row); + if (row > 0) + newPage(true, false); // break page per record when the report is a form + boolean somethingPrinted = true; // prevent NL of nothing printed and supress null // for every item for (int i = 0; i < m_format.getItemCount(); i++) diff --git a/org.adempiere.base/src/org/compiere/process/FactReconciliation.java b/org.adempiere.base/src/org/compiere/process/FactReconciliation.java index f465ec7013..9e28d559c6 100644 --- a/org.adempiere.base/src/org/compiere/process/FactReconciliation.java +++ b/org.adempiere.base/src/org/compiere/process/FactReconciliation.java @@ -2,7 +2,6 @@ package org.compiere.process; import java.math.BigDecimal; import java.sql.PreparedStatement; -import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Timestamp; import java.util.logging.Level; @@ -51,9 +50,7 @@ public class FactReconciliation extends SvrProcess */ protected String doIt() { - PreparedStatement pstmt = null; - ResultSet rs = null; String sql = "INSERT into T_Reconciliation " + "(AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, " + @@ -69,8 +66,6 @@ public class FactReconciliation extends SvrProcess try { - - pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt.setInt(1, getAD_PInstance_ID()); pstmt.setInt(2, p_Account_ID); @@ -88,25 +83,26 @@ public class FactReconciliation extends SvrProcess " AND r.AD_PInstance_ID = t.AD_PInstance_ID) = 0 " + "AND t.AD_PInstance_ID = ?"; - pstmt = DB.prepareStatement(sql, get_TrxName()); - pstmt.setInt(1, getAD_PInstance_ID()); - count = pstmt.executeUpdate(); - result = Msg.getMsg(getCtx(), "@Deleted@") + ": " + count; + DB.close(pstmt); + pstmt = null; + pstmt = DB.prepareStatement(sql, get_TrxName()); + pstmt.setInt(1, getAD_PInstance_ID()); + count = pstmt.executeUpdate(); + result = Msg.getMsg(getCtx(), "@Deleted@") + ": " + count; + + if (log.isLoggable(Level.FINE))log.log(Level.FINE, result); - if (log.isLoggable(Level.FINE))log.log(Level.FINE, result); - - - } - catch (SQLException e) - { - log.log(Level.SEVERE, sql, e); - return e.getLocalizedMessage(); - } - finally - { - DB.close(rs, pstmt); - rs = null; pstmt = null; - } + } + catch (SQLException e) + { + log.log(Level.SEVERE, sql, e); + return e.getLocalizedMessage(); + } + finally + { + DB.close(pstmt); + pstmt = null; + } if (log.isLoggable(Level.FINE)) log.fine((System.currentTimeMillis() - m_start) + " ms"); return ""; diff --git a/org.adempiere.base/src/org/compiere/tools/Strip.java b/org.adempiere.base/src/org/compiere/tools/Strip.java index e15dcdb932..8449b2abca 100644 --- a/org.adempiere.base/src/org/compiere/tools/Strip.java +++ b/org.adempiere.base/src/org/compiere/tools/Strip.java @@ -18,7 +18,6 @@ package org.compiere.tools; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -165,32 +164,15 @@ public class Strip private boolean copy (File infile, File outfile) { FileInputStream fis = null; - try - { - fis = new FileInputStream(infile); - } - catch (FileNotFoundException fnfe) - { - System.err.println(fnfe); - return false; - } - // FileOutputStream fos = null; - try - { - fos = new FileOutputStream(outfile, false); // no append - } - catch (FileNotFoundException fnfe) - { - System.err.println(fnfe); - return false; - } - - int noIn = 0; - int noOut = 0; - int noLines = 1; - try - { + try{ + fis = new FileInputStream(infile); + fos = new FileOutputStream(outfile, false); // no append + + int noIn = 0; + int noOut = 0; + int noLines = 1; + int c; while ((c = fis.read()) != -1) { @@ -203,15 +185,24 @@ public class Strip if (c == 13) // cr noLines++; } - fis.close(); - fos.close(); - } - catch (IOException ioe) + System.out.println(" read: " + noIn + ", written: " + noOut + " - lines: " + noLines); + }catch (IOException ioe) { System.err.println(ioe); return false; + }finally{ + if (fos != null) + try { + fos.close(); + } catch (IOException e) { + } + if (fis != null) + try { + fis.close(); + } catch (IOException e) { + } + } - System.out.println(" read: " + noIn + ", written: " + noOut + " - lines: " + noLines); return true; } // stripIt diff --git a/org.adempiere.base/src/org/compiere/util/CLogErrorBuffer.java b/org.adempiere.base/src/org/compiere/util/CLogErrorBuffer.java index 8b66040750..8d5a140a05 100644 --- a/org.adempiere.base/src/org/compiere/util/CLogErrorBuffer.java +++ b/org.adempiere.base/src/org/compiere/util/CLogErrorBuffer.java @@ -188,6 +188,8 @@ public class CLogErrorBuffer extends Handler loggerName = ""; //String className = record.getSourceClassName(); // physical class String methodName = record.getSourceMethodName(); // + if (methodName == null) + methodName = ""; if (DB.isConnected(false) && !methodName.equals("saveError") && !methodName.equals("get_Value") diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PackIn.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PackIn.java index 0a1b1f7bc2..d19c0a5542 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PackIn.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PackIn.java @@ -233,20 +233,25 @@ public class PackIn { ZipFile zf = new ZipFile(m_packageDirectory+File.separator+"blobs"+File.separator+fileName); Enumeration e = zf.entries(); ArrayList files = new ArrayList(); - while (e.hasMoreElements()) { - ZipEntry ze = (ZipEntry) e.nextElement(); - File file = new File(m_packageDirectory + File.separator + ze.getName()); - FileOutputStream fout = new FileOutputStream(file); - InputStream in = zf.getInputStream(ze); - for (int c = in.read(); c != -1; c = in.read()) { - fout.write(c); + File[] retValue = null; + try{ + while (e.hasMoreElements()) { + ZipEntry ze = (ZipEntry) e.nextElement(); + File file = new File(m_packageDirectory + File.separator + ze.getName()); + FileOutputStream fout = new FileOutputStream(file); + InputStream in = zf.getInputStream(ze); + for (int c = in.read(); c != -1; c = in.read()) { + fout.write(c); + } + in.close(); + fout.close(); + files.add(file); } - in.close(); - fout.close(); - files.add(file); + retValue = new File[files.size()]; + files.toArray(retValue); + }catch (Exception ex){ + zf.close(); } - File[] retValue = new File[files.size()]; - files.toArray(retValue); return retValue; } diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java index 1f7136d27a..60fcb6ff04 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java @@ -204,11 +204,13 @@ public class PoFiller{ { Element orgElement = element.properties.get("AD_Org_ID"); String sAD_Org_ID = orgElement != null ? orgElement.contents.toString() : null; - if (sAD_Org_ID != null && sAD_Org_ID.equals("0") && po.getAD_Org_ID() != 0) - po.setAD_Org_ID(0); - else if (sAD_Org_ID != null && sAD_Org_ID.equals("@AD_Org_ID@")) + if (sAD_Org_ID != null && sAD_Org_ID.equals("0")) { + if (po.getAD_Org_ID() != 0) { + po.setAD_Org_ID(0); + } + } else if (sAD_Org_ID != null && sAD_Org_ID.equals("@AD_Org_ID@")) { po.setAD_Org_ID(Env.getAD_Org_ID(ctx.ctx)); - else { + } else { if (setTableReference("AD_Client_ID") >= 0) setTableReference("AD_Org_ID"); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WArchive.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WArchive.java index 6fe382662f..b2a9d0d1bb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WArchive.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/WArchive.java @@ -133,7 +133,7 @@ public class WArchive implements EventListener if (allReports > 0) { m_reportsAll = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedReportsAll") - + " (" + reportCount + ")"); + + " (" + allReports + ")"); m_reportsAll.addEventListener(Events.ON_CLICK, this); m_popup.appendChild(m_reportsAll); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java index 59558899a8..b66df115a6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WArchiveViewer.java @@ -64,6 +64,7 @@ import org.compiere.util.KeyNamePair; import org.compiere.util.Msg; import org.compiere.util.Util; import org.zkoss.util.media.AMedia; +import org.zkoss.zk.ui.Page; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; @@ -133,15 +134,25 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis { log.info(""); - form = new CustomForm(); - try { - dynInit(); - jbInit(); - } - catch(Exception e) - { - log.log(Level.SEVERE, "init", e); - } + form = new CustomForm() { + private static final long serialVersionUID = 7226661630651936293L; + + @Override + public void onPageAttached(Page newpage, Page oldpage) { + super.onPageAttached(newpage, oldpage); + if (newpage != null) + try { + dynInit(); + jbInit(); + } + catch(Exception e) + { + log.log(Level.SEVERE, "init", e); + } + + } + + }; m_WindowNo = form.getWindowNo(); } @@ -511,6 +522,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis */ private void updateQDisplay() { + if (!showQuery) + return; + boolean reports = reportField.isChecked(); if (log.isLoggable(Level.CONFIG)) log.config("Reports=" + reports); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java index cf28bd4715..34ceaea40d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WReportCustomization.java @@ -17,9 +17,11 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.StringWriter; import java.util.ArrayList; +import java.util.List; import java.util.Properties; import java.util.logging.Level; +import org.adempiere.model.GenericPO; import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.component.Button; import org.adempiere.webui.component.ConfirmPanel; @@ -32,6 +34,7 @@ import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Window; +import org.adempiere.webui.editor.WStringEditor; import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.panel.CustomForm; import org.adempiere.webui.panel.IFormController; @@ -46,6 +49,7 @@ import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.window.FDialog; import org.adempiere.webui.window.ZkReportViewer; import org.compiere.model.MRole; +import org.compiere.model.Query; import org.compiere.print.MPrintFormat; import org.compiere.print.MPrintFormatItem; import org.compiere.print.ReportEngine; @@ -54,6 +58,7 @@ import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.Util; import org.zkoss.util.media.AMedia; +import org.zkoss.zk.ui.WrongValueException; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; @@ -86,7 +91,8 @@ public class WReportCustomization implements IFormController,EventListener pfi ; private Auxheader headerPanel=new Auxheader(); - private Listbox comboReport = new Listbox(); + private WStringEditor name = new WStringEditor(); + private String tempName = ""; private Button newPrintFormat; private Label selectAll; private Label deselectAll; @@ -168,12 +174,20 @@ public class WReportCustomization implements IFormController,EventListener list = new Query(m_ctx, "AD_PrintFormat_Trl", "AD_PrintFormat_ID = ?", null) + .setParameters(fm.getAD_PrintFormat_ID()) + .list(); + for (GenericPO trl : list) { + trl.set_ValueOfColumn("Name", (String) name.getValue()); + trl.saveEx(); + + fm.get_Translation("Name", trl.get_ValueAsString("AD_Language"), true); // reload + } + } + @Override public ADForm getForm() { return form; @@ -551,9 +613,11 @@ public class WReportCustomization implements IFormController,EventListener(); for(int i=0 ; i< m_pfi.size();i++){ MPrintFormatItem item = m_pfi.get(i); - if(item!=null && item.isPrinted()){ + if(item!=null){ if(item.isOrderBy()){ yesItems.add(item); }else{ diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java index d9632c197b..50dd7de396 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WRC4GroupingCriteriaPanel.java @@ -49,7 +49,7 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe public void refresh() { orderfield = new ArrayList(); for(int i=0 ; i < m_pfi.size(); i++){ - if(m_pfi.get(i) != null && m_pfi.get(i).isOrderBy() && m_pfi.get(i).isPrinted()){ + if(m_pfi.get(i) != null && m_pfi.get(i).isOrderBy()){ orderfield.add(m_pfi.get(i)); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java index 952e7b812f..42ec95ff9b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java @@ -378,12 +378,23 @@ public class CSVImportAction implements EventListener } catch (IOException e) { throw new AdempiereException(e); } finally { - try { - reader.close(); - in.close(); - if (bw != null) + if (in != null) + try { + in.close(); + } catch (IOException e) { + } + + if (bw != null) + try { bw.close(); - } catch (IOException e) {} + } catch (IOException e) { + } + + if (reader != null) + try { + reader.close(); + } catch (IOException e) { + } } return is; } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 2633ea6a40..854a8684e9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -213,7 +213,8 @@ public class ZkReportViewer extends Window implements EventListener, ITab } m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID); - setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Report") + ": " + m_reportEngine.getName())); + setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Report") + ": " + + m_reportEngine.getPrintFormat().get_Translation(MPrintFormat.COLUMNNAME_Name))); addEventListener(ON_RENDER_REPORT_EVENT, this); } @@ -624,7 +625,7 @@ public class ZkReportViewer extends Window implements EventListener, ITab { MPrintFormat printFormat = new MPrintFormat (Env.getCtx(), rs, null); - KeyNamePair pp = new KeyNamePair(printFormat.get_ID(), printFormat.get_Translation(MPrintFormat.COLUMNNAME_Name)); + KeyNamePair pp = new KeyNamePair(printFormat.get_ID(), printFormat.get_Translation(MPrintFormat.COLUMNNAME_Name, Env.getAD_Language(Env.getCtx()), true)); Listitem li = comboReport.appendItem(pp.getName(), pp.getKey()); if (rs.getInt(1) == AD_PrintFormat_ID) { @@ -1174,9 +1175,6 @@ public class ZkReportViewer extends Window implements EventListener, ITab /*IDEMPIERE -379*/ private void cmd_Wizard() { - int AD_PrintFormat_ID = m_reportEngine.getPrintFormat().get_ID(); - - Env.setContext(m_ctx, "AD_PrintFormat_ID", AD_PrintFormat_ID); ADForm form = ADForm.openForm(SystemIDs.FORM_REPORT_WIZARD); WReportCustomization av = (WReportCustomization) form.getICustomForm(); av.setReportEngine(m_reportEngine); @@ -1187,10 +1185,8 @@ public class ZkReportViewer extends Window implements EventListener, ITab @Override public void onEvent(Event event) throws Exception { if (DialogEvents.ON_WINDOW_CLOSE.equals(event.getName())) { - if(m_reportEngine.getPrintFormat().get_ID()!=Env.getContextAsInt(m_ctx, "AD_PrintFormat_ID")){ - fillComboReport (m_reportEngine.getPrintFormat().get_ID()); - } - cmd_report(); + fillComboReport (m_reportEngine.getPrintFormat().get_ID()); + cmd_report(); } } });