hg merge release-2.1 (merge release2.1 into development)

This commit is contained in:
Carlos Ruiz 2015-04-08 16:21:21 -05:00
commit 8e0f178c35
20 changed files with 251 additions and 147 deletions

View File

@ -257,35 +257,39 @@ public class InitialClientSetup extends SvrProcess
// Process // Process
MSetup ms = new MSetup(Env.getCtx(), WINDOW_THIS_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");
}
if (! ms.createClient(p_ClientName, p_OrgValue, p_OrgName, p_AdminUserName, p_NormalUserName addLog(ms.getInfo());
, 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(); 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@"; return "@OK@";
} }

View File

@ -353,8 +353,9 @@ public class ReplicationLocal extends SvrProcess
// no keys - search for parents // no keys - search for parents
if (list.size() == 0) if (list.size() == 0)
{ {
DB.close(rs); DB.close(rs, pstmt);
rs = null; rs = null;
pstmt = null;
sql = "SELECT ColumnName FROM AD_Column " sql = "SELECT ColumnName FROM AD_Column "
+ "WHERE AD_Table_ID=?" + "WHERE AD_Table_ID=?"
+ " AND IsParent='Y'"; + " AND IsParent='Y'";

View File

@ -17,6 +17,7 @@
package org.compiere.impexp; package org.compiere.impexp;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import org.compiere.model.MBankStatementLoader; import org.compiere.model.MBankStatementLoader;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -71,6 +72,13 @@ public final class OFXFileBankStatementLoader extends OFXBankStatementHandler im
{ {
m_errorMessage = new StringBuffer("ErrorReadingData"); m_errorMessage = new StringBuffer("ErrorReadingData");
m_errorDescription = new StringBuffer(); m_errorDescription = new StringBuffer();
}finally{
if (m_stream != null)
try {
m_stream.close();
} catch (IOException e) {
e.printStackTrace();
}
} }
return result; return result;

View File

@ -439,7 +439,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
public boolean isAddressLinesReverse() public boolean isAddressLinesReverse()
{ {
// Local // 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().isAddressLinesLocalReverse();
return getCountry().isAddressLinesReverse(); return getCountry().isAddressLinesReverse();
} // isAddressLinesReverse } // isAddressLinesReverse
@ -465,7 +465,7 @@ public class MLocation extends X_C_Location implements Comparator<Object>
if (c == null) if (c == null)
return "CountryNotFound"; 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(); String inStr = local ? c.getDisplaySequenceLocal() : c.getDisplaySequence();
StringBuilder outStr = new StringBuilder(); StringBuilder outStr = new StringBuilder();

View File

@ -338,7 +338,7 @@ public class ModelValidationEngine
*/ */
public String fireModelChange (PO po, int changeType) public String fireModelChange (PO po, int changeType)
{ {
if (po == null || m_modelChangeListeners.size() == 0) if (po == null )
return null; return null;
String propertyName = po.get_TableName() + "*"; String propertyName = po.get_TableName() + "*";
@ -502,7 +502,7 @@ public class ModelValidationEngine
*/ */
public String fireDocValidate (PO po, int docTiming) public String fireDocValidate (PO po, int docTiming)
{ {
if (po == null || m_docValidateListeners.size() == 0) if (po == null)
return null; return null;
String propertyName = po.get_TableName() + "*"; String propertyName = po.get_TableName() + "*";
@ -688,7 +688,7 @@ public class ModelValidationEngine
*/ */
public String fireFactsValidate (MAcctSchema schema, List<Fact> facts, PO po) public String fireFactsValidate (MAcctSchema schema, List<Fact> facts, PO po)
{ {
if (schema == null || facts == null || po == null || m_factsValidateListeners.size() == 0) if (schema == null || facts == null || po == null)
return null; return null;
String propertyName = po.get_TableName() + "*"; String propertyName = po.get_TableName() + "*";
@ -715,6 +715,7 @@ public class ModelValidationEngine
FactsEventData eventData = new FactsEventData(schema, facts, po); FactsEventData eventData = new FactsEventData(schema, facts, po);
Event event = EventManager.newEvent(IEventTopics.ACCT_FACTS_VALIDATE, Event event = EventManager.newEvent(IEventTopics.ACCT_FACTS_VALIDATE,
new EventProperty(EventManager.EVENT_DATA, eventData), new EventProperty("tableName", po.get_TableName())); new EventProperty(EventManager.EVENT_DATA, eventData), new EventProperty("tableName", po.get_TableName()));
EventManager.getInstance().sendEvent(event);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES); List<String> errors = (List<String>) event.getProperty(IEventManager.EVENT_ERROR_MESSAGES);
if (errors != null && !errors.isEmpty()) if (errors != null && !errors.isEmpty())
@ -769,8 +770,6 @@ public class ModelValidationEngine
*/ */
public void fireImportValidate (ImportProcess process, PO importModel, PO targetModel, int timing) public void fireImportValidate (ImportProcess process, PO importModel, PO targetModel, int timing)
{ {
if (m_impValidateListeners.size() == 0)
return;
String propertyName = process.getImportTableName() + "*"; String propertyName = process.getImportTableName() + "*";
ArrayList<ImportValidator> list = m_impValidateListeners.get(propertyName); ArrayList<ImportValidator> list = m_impValidateListeners.get(propertyName);

View File

@ -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"; public static final String LOCAL_TRX_PREFIX = "POSave";
@ -1882,16 +1882,22 @@ public abstract class PO
/** Cache */ /** Cache */
private static CCache<String,String> trl_cache = new CCache<String,String>("po_trl", 5); private static CCache<String,String> trl_cache = new CCache<String,String>("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). * Get Translation of column (if needed).
* It checks if the base language is used or the column is not translated. * 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. * If there is no translation then it fallback to original value.
* @param columnName * @param columnName
* @param AD_Language * @param AD_Language
* @boolean reload
* @return translated string * @return translated string
* @throws IllegalArgumentException if columnName or AD_Language is null or model has multiple PK * @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 // 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 key = get_TableName() + "." + columnName + "|" + get_ID() + "|" + AD_Language;
String retValue = null; String retValue = null;
if (trl_cache.containsKey(key)) { if (! reload && trl_cache.containsKey(key)) {
retValue = trl_cache.get(key); retValue = trl_cache.get(key);
return retValue; return retValue;

View File

@ -1625,6 +1625,8 @@ queued-job-count = 0 (class javax.print.attribute.standard.QueuedJobCount)
.append("FROM C_DocType dt, C_Order o ") .append("FROM C_DocType dt, C_Order o ")
.append("WHERE o.C_DocTypeTarget_ID=dt.C_DocType_ID") .append("WHERE o.C_DocTypeTarget_ID=dt.C_DocType_ID")
.append(" AND o.C_Order_ID=?"); .append(" AND o.C_Order_ID=?");
DB.close(rs, pstmt);
rs = null; pstmt = null;
pstmt = DB.prepareStatement(sql.toString(), null); pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, C_Order_ID); pstmt.setInt(1, C_Order_ID);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();

View File

@ -265,7 +265,7 @@ public class LayoutEngine implements Pageable, Printable, Doc
m_printFont = MPrintFont.get (format.getAD_PrintFont_ID()); m_printFont = MPrintFont.get (format.getAD_PrintFont_ID());
// Print Context // 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, Page.CONTEXT_HEADER, Env.getHeader(m_printCtx, 0));
Env.setContext(m_printCtx, Env.LANGUAGE, m_format.getLanguage().getAD_Language()); 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); if (log.isLoggable(Level.INFO)) log.info("Row=" + row);
m_data.setRowIndex(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 boolean somethingPrinted = true; // prevent NL of nothing printed and supress null
// for every item // for every item
for (int i = 0; i < m_format.getItemCount(); i++) for (int i = 0; i < m_format.getItemCount(); i++)

View File

@ -2,7 +2,6 @@ package org.compiere.process;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.logging.Level; import java.util.logging.Level;
@ -51,9 +50,7 @@ public class FactReconciliation extends SvrProcess
*/ */
protected String doIt() protected String doIt()
{ {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "INSERT into T_Reconciliation " + String sql = "INSERT into T_Reconciliation " +
"(AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, " + "(AD_Client_ID, AD_Org_ID, Created, CreatedBy, Updated, UpdatedBy, " +
@ -69,8 +66,6 @@ public class FactReconciliation extends SvrProcess
try try
{ {
pstmt = DB.prepareStatement(sql, get_TrxName()); pstmt = DB.prepareStatement(sql, get_TrxName());
pstmt.setInt(1, getAD_PInstance_ID()); pstmt.setInt(1, getAD_PInstance_ID());
pstmt.setInt(2, p_Account_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 r.AD_PInstance_ID = t.AD_PInstance_ID) = 0 " +
"AND t.AD_PInstance_ID = ?"; "AND t.AD_PInstance_ID = ?";
pstmt = DB.prepareStatement(sql, get_TrxName()); DB.close(pstmt);
pstmt.setInt(1, getAD_PInstance_ID()); pstmt = null;
count = pstmt.executeUpdate(); pstmt = DB.prepareStatement(sql, get_TrxName());
result = Msg.getMsg(getCtx(), "@Deleted@") + ": " + count; 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)
catch (SQLException e) {
{ log.log(Level.SEVERE, sql, e);
log.log(Level.SEVERE, sql, e); return e.getLocalizedMessage();
return e.getLocalizedMessage(); }
} finally
finally {
{ DB.close(pstmt);
DB.close(rs, pstmt); pstmt = null;
rs = null; pstmt = null; }
}
if (log.isLoggable(Level.FINE)) log.fine((System.currentTimeMillis() - m_start) + " ms"); if (log.isLoggable(Level.FINE)) log.fine((System.currentTimeMillis() - m_start) + " ms");
return ""; return "";

View File

@ -18,7 +18,6 @@ package org.compiere.tools;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
@ -165,32 +164,15 @@ public class Strip
private boolean copy (File infile, File outfile) private boolean copy (File infile, File outfile)
{ {
FileInputStream fis = null; FileInputStream fis = null;
try
{
fis = new FileInputStream(infile);
}
catch (FileNotFoundException fnfe)
{
System.err.println(fnfe);
return false;
}
//
FileOutputStream fos = null; FileOutputStream fos = null;
try try{
{ fis = new FileInputStream(infile);
fos = new FileOutputStream(outfile, false); // no append fos = new FileOutputStream(outfile, false); // no append
}
catch (FileNotFoundException fnfe)
{
System.err.println(fnfe);
return false;
}
int noIn = 0; int noIn = 0;
int noOut = 0; int noOut = 0;
int noLines = 1; int noLines = 1;
try
{
int c; int c;
while ((c = fis.read()) != -1) while ((c = fis.read()) != -1)
{ {
@ -203,15 +185,24 @@ public class Strip
if (c == 13) // cr if (c == 13) // cr
noLines++; noLines++;
} }
fis.close(); System.out.println(" read: " + noIn + ", written: " + noOut + " - lines: " + noLines);
fos.close(); }catch (IOException ioe)
}
catch (IOException ioe)
{ {
System.err.println(ioe); System.err.println(ioe);
return false; 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; return true;
} // stripIt } // stripIt

View File

@ -188,6 +188,8 @@ public class CLogErrorBuffer extends Handler
loggerName = ""; loggerName = "";
//String className = record.getSourceClassName(); // physical class //String className = record.getSourceClassName(); // physical class
String methodName = record.getSourceMethodName(); // String methodName = record.getSourceMethodName(); //
if (methodName == null)
methodName = "";
if (DB.isConnected(false) if (DB.isConnected(false)
&& !methodName.equals("saveError") && !methodName.equals("saveError")
&& !methodName.equals("get_Value") && !methodName.equals("get_Value")

View File

@ -233,20 +233,25 @@ public class PackIn {
ZipFile zf = new ZipFile(m_packageDirectory+File.separator+"blobs"+File.separator+fileName); ZipFile zf = new ZipFile(m_packageDirectory+File.separator+"blobs"+File.separator+fileName);
Enumeration<?> e = zf.entries(); Enumeration<?> e = zf.entries();
ArrayList<File> files = new ArrayList<File>(); ArrayList<File> files = new ArrayList<File>();
while (e.hasMoreElements()) { File[] retValue = null;
ZipEntry ze = (ZipEntry) e.nextElement(); try{
File file = new File(m_packageDirectory + File.separator + ze.getName()); while (e.hasMoreElements()) {
FileOutputStream fout = new FileOutputStream(file); ZipEntry ze = (ZipEntry) e.nextElement();
InputStream in = zf.getInputStream(ze); File file = new File(m_packageDirectory + File.separator + ze.getName());
for (int c = in.read(); c != -1; c = in.read()) { FileOutputStream fout = new FileOutputStream(file);
fout.write(c); 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(); retValue = new File[files.size()];
fout.close(); files.toArray(retValue);
files.add(file); }catch (Exception ex){
zf.close();
} }
File[] retValue = new File[files.size()];
files.toArray(retValue);
return retValue; return retValue;
} }

View File

@ -204,11 +204,13 @@ public class PoFiller{
{ {
Element orgElement = element.properties.get("AD_Org_ID"); Element orgElement = element.properties.get("AD_Org_ID");
String sAD_Org_ID = orgElement != null ? orgElement.contents.toString() : null; 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) if (sAD_Org_ID != null && sAD_Org_ID.equals("0")) {
po.setAD_Org_ID(0); if (po.getAD_Org_ID() != 0) {
else if (sAD_Org_ID != null && sAD_Org_ID.equals("@AD_Org_ID@")) 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)); po.setAD_Org_ID(Env.getAD_Org_ID(ctx.ctx));
else { } else {
if (setTableReference("AD_Client_ID") >= 0) if (setTableReference("AD_Client_ID") >= 0)
setTableReference("AD_Org_ID"); setTableReference("AD_Org_ID");
} }

View File

@ -133,7 +133,7 @@ public class WArchive implements EventListener<Event>
if (allReports > 0) if (allReports > 0)
{ {
m_reportsAll = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedReportsAll") m_reportsAll = new Menuitem(Msg.getMsg(Env.getCtx(), "ArchivedReportsAll")
+ " (" + reportCount + ")"); + " (" + allReports + ")");
m_reportsAll.addEventListener(Events.ON_CLICK, this); m_reportsAll.addEventListener(Events.ON_CLICK, this);
m_popup.appendChild(m_reportsAll); m_popup.appendChild(m_reportsAll);
} }

View File

@ -64,6 +64,7 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.zkoss.util.media.AMedia; 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.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -133,15 +134,25 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
{ {
log.info(""); log.info("");
form = new CustomForm(); form = new CustomForm() {
try { private static final long serialVersionUID = 7226661630651936293L;
dynInit();
jbInit(); @Override
} public void onPageAttached(Page newpage, Page oldpage) {
catch(Exception e) super.onPageAttached(newpage, oldpage);
{ if (newpage != null)
log.log(Level.SEVERE, "init", e); try {
} dynInit();
jbInit();
}
catch(Exception e)
{
log.log(Level.SEVERE, "init", e);
}
}
};
m_WindowNo = form.getWindowNo(); m_WindowNo = form.getWindowNo();
} }
@ -511,6 +522,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
*/ */
private void updateQDisplay() private void updateQDisplay()
{ {
if (!showQuery)
return;
boolean reports = reportField.isChecked(); boolean reports = reportField.isChecked();
if (log.isLoggable(Level.CONFIG)) log.config("Reports=" + reports); if (log.isLoggable(Level.CONFIG)) log.config("Reports=" + reports);

View File

@ -17,9 +17,11 @@ import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import org.adempiere.model.GenericPO;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel; 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.Tabpanels;
import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WStringEditor;
import org.adempiere.webui.panel.ADForm; import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.panel.CustomForm; import org.adempiere.webui.panel.CustomForm;
import org.adempiere.webui.panel.IFormController; 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.FDialog;
import org.adempiere.webui.window.ZkReportViewer; import org.adempiere.webui.window.ZkReportViewer;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.Query;
import org.compiere.print.MPrintFormat; import org.compiere.print.MPrintFormat;
import org.compiere.print.MPrintFormatItem; import org.compiere.print.MPrintFormatItem;
import org.compiere.print.ReportEngine; import org.compiere.print.ReportEngine;
@ -54,6 +58,7 @@ import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.zkoss.util.media.AMedia; 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.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -86,7 +91,8 @@ public class WReportCustomization implements IFormController,EventListener<Even
public ArrayList<MPrintFormatItem> pfi ; public ArrayList<MPrintFormatItem> pfi ;
private Auxheader headerPanel=new Auxheader(); private Auxheader headerPanel=new Auxheader();
private Listbox comboReport = new Listbox(); private WStringEditor name = new WStringEditor();
private String tempName = "";
private Button newPrintFormat; private Button newPrintFormat;
private Label selectAll; private Label selectAll;
private Label deselectAll; private Label deselectAll;
@ -168,13 +174,21 @@ public class WReportCustomization implements IFormController,EventListener<Even
headerPanel.appendChild(new Separator("vertical")); headerPanel.appendChild(new Separator("vertical"));
comboReport.setMold("select");
fm =m_reportEngine.getPrintFormat(); fm =m_reportEngine.getPrintFormat();
comboReport.setTooltiptext(Msg.translate(Env.getCtx(), "AD_PrintFormat_ID")); name.setValue(fm.getName());
comboReport.appendItem(fm.getName(), fm.get_ID());
headerPanel.appendChild(comboReport); if (Env.isMultiLingualDocument(m_ctx))
name.setValue(fm.get_Translation("Name"));
else
name.setValue(fm.getName());
headerPanel.appendChild(name.getComponent());
headerPanel.appendChild(new Separator("vertical")); headerPanel.appendChild(new Separator("vertical"));
name.getComponent().addEventListener(Events.ON_FOCUS, this);
name.getComponent().addEventListener(Events.ON_BLUR, this);
name.getComponent().addEventListener(Events.ON_OK, this);
newPrintFormat=new Button(); newPrintFormat=new Button();
newPrintFormat.setName("NewPrintFormat"); newPrintFormat.setName("NewPrintFormat");
newPrintFormat.setLabel(Msg.getMsg(Env.getCtx(), "CreatePrintFormat")); newPrintFormat.setLabel(Msg.getMsg(Env.getCtx(), "CreatePrintFormat"));
@ -350,6 +364,16 @@ public class WReportCustomization implements IFormController,EventListener<Even
onSave(); onSave();
close(); close();
} }
if (event.getTarget() == name.getComponent()) {
if (event.getName().equals(Events.ON_FOCUS))
tempName = (String) name.getValue();
else if (event.getName().equals(Events.ON_BLUR) || event.getName().equals(Events.ON_OK)) {
if (!tempName.equals(name.getValue()))
setIsChanged(true);
}
}
selectAll.setVisible(oldtabidx == 0); selectAll.setVisible(oldtabidx == 0);
deselectAll.setVisible(oldtabidx == 0); deselectAll.setVisible(oldtabidx == 0);
pipeSeparator.setVisible(oldtabidx == 0); pipeSeparator.setVisible(oldtabidx == 0);
@ -357,11 +381,49 @@ public class WReportCustomization implements IFormController,EventListener<Even
private void onSave() { private void onSave() {
for (MPrintFormatItem item : pfi) if (name.getValue() == null || Util.isEmpty((String) name.getValue()))
if (item.is_Changed()) throw new WrongValueException(name.getComponent(), Msg.getMsg(m_ctx, "FillMandatory"));
item.saveEx();
setIsChanged(false); if (Env.isMultiLingualDocument(m_ctx)) {
if (Env.isBaseLanguage(m_ctx, "AD_PrintFormat")) {
if (!fm.getName().equals(name.getValue())) {
fm.setName((String) name.getValue());
fm.saveEx();
tempName = (String) name.getValue();
}
} else {
if (!fm.get_Translation("Name").equals(name.getValue())) {
updateTrl();
tempName = (String) name.getValue();
}
}
} else {
if (!fm.getName().equals(name.getValue())) {
fm.setName((String) name.getValue());
fm.saveEx();
updateTrl();
tempName = (String) name.getValue();
}
}
for (MPrintFormatItem item : pfi)
if (item.is_Changed())
item.saveEx();
setIsChanged(false);
}
private void updateTrl()
{
List<GenericPO> 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 @Override
@ -551,9 +613,11 @@ public class WReportCustomization implements IFormController,EventListener<Even
tpsf5.refresh(); tpsf5.refresh();
setIsChanged(false); setIsChanged(false);
comboReport.removeAllItems(); name.setValue(newpf.getName());
comboReport.appendItem(newpf.getName(), newpf.get_ID());
m_reportEngine.setPrintFormat(newpf); m_reportEngine.setPrintFormat(newpf);
newpf.saveEx();
fm = newpf;
} }
public void setIsChanged(boolean change){ public void setIsChanged(boolean change){

View File

@ -175,7 +175,7 @@ public class WRC3SortCriteriaPanel extends WRCTabPanel implements EventListener
noItems =new ArrayList<MPrintFormatItem>(); noItems =new ArrayList<MPrintFormatItem>();
for(int i=0 ; i< m_pfi.size();i++){ for(int i=0 ; i< m_pfi.size();i++){
MPrintFormatItem item = m_pfi.get(i); MPrintFormatItem item = m_pfi.get(i);
if(item!=null && item.isPrinted()){ if(item!=null){
if(item.isOrderBy()){ if(item.isOrderBy()){
yesItems.add(item); yesItems.add(item);
}else{ }else{

View File

@ -49,7 +49,7 @@ public class WRC4GroupingCriteriaPanel extends WRCTabPanel implements EventListe
public void refresh() { public void refresh() {
orderfield = new ArrayList<MPrintFormatItem>(); orderfield = new ArrayList<MPrintFormatItem>();
for(int i=0 ; i < m_pfi.size(); i++){ 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)); orderfield.add(m_pfi.get(i));
} }
} }

View File

@ -378,12 +378,23 @@ public class CSVImportAction implements EventListener<Event>
} catch (IOException e) { } catch (IOException e) {
throw new AdempiereException(e); throw new AdempiereException(e);
} finally { } finally {
try { if (in != null)
reader.close(); try {
in.close(); in.close();
if (bw != null) } catch (IOException e) {
}
if (bw != null)
try {
bw.close(); bw.close();
} catch (IOException e) {} } catch (IOException e) {
}
if (reader != null)
try {
reader.close();
} catch (IOException e) {
}
} }
return is; return is;
} }

View File

@ -213,7 +213,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
} }
m_isCanExport = MRole.getDefault().isCanExport(m_AD_Table_ID); 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); addEventListener(ON_RENDER_REPORT_EVENT, this);
} }
@ -624,7 +625,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
{ {
MPrintFormat printFormat = new MPrintFormat (Env.getCtx(), rs, null); 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()); Listitem li = comboReport.appendItem(pp.getName(), pp.getKey());
if (rs.getInt(1) == AD_PrintFormat_ID) if (rs.getInt(1) == AD_PrintFormat_ID)
{ {
@ -1174,9 +1175,6 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
/*IDEMPIERE -379*/ /*IDEMPIERE -379*/
private void cmd_Wizard() 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); ADForm form = ADForm.openForm(SystemIDs.FORM_REPORT_WIZARD);
WReportCustomization av = (WReportCustomization) form.getICustomForm(); WReportCustomization av = (WReportCustomization) form.getICustomForm();
av.setReportEngine(m_reportEngine); av.setReportEngine(m_reportEngine);
@ -1187,10 +1185,8 @@ public class ZkReportViewer extends Window implements EventListener<Event>, ITab
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
if (DialogEvents.ON_WINDOW_CLOSE.equals(event.getName())) { 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());
fillComboReport (m_reportEngine.getPrintFormat().get_ID()); cmd_report();
}
cmd_report();
} }
} }
}); });