Merge 8ec4eb9e7161

This commit is contained in:
Heng Sin Low 2012-12-11 01:38:57 +08:00
commit a5adac4806
20 changed files with 142 additions and 101 deletions

View File

@ -30,5 +30,5 @@ INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,V
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200122 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('101212102127_IDEMPIERE-293.sql') FROM dual
SELECT register_migration_script('201212102127_IDEMPIERE-293.sql') FROM dual
;

View File

@ -30,5 +30,5 @@ INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,V
INSERT INTO AD_Message_Trl (AD_Language,AD_Message_ID, MsgText,MsgTip, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Message_Trl_UU ) SELECT l.AD_Language,t.AD_Message_ID, t.MsgText,t.MsgTip, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Message t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Message_ID=200122 AND NOT EXISTS (SELECT * FROM AD_Message_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Message_ID=t.AD_Message_ID)
;
SELECT register_migration_script('101212102127_IDEMPIERE-293.sql') FROM dual
SELECT register_migration_script('201212102127_IDEMPIERE-293.sql') FROM dual
;

View File

@ -107,4 +107,10 @@ public class ArchiveDB implements IArchiveStore {
archive.setByteData(deflatedData);
}
@Override
public boolean deleteArchive(MArchive archive, MStorageProvider prov) {
return true;
}
}

View File

@ -163,7 +163,7 @@ public class ArchiveFileSystem implements IArchiveStore {
BufferedOutputStream out = null;
try {
// create destination folder
StringBuilder msgfile = new StringBuilder().append(archivePathRoot).append(File.separator)
StringBuilder msgfile = new StringBuilder().append(archivePathRoot)
.append(archive.getArchivePathSnippet());
final File destFolder = new File(msgfile.toString());
if (!destFolder.exists()) {
@ -226,4 +226,23 @@ public class ArchiveFileSystem implements IArchiveStore {
return archivePathRoot;
}
@Override
public boolean deleteArchive(MArchive archive, MStorageProvider prov) {
String archivePathRoot = getArchivePathRoot(prov);
if ("".equals(archivePathRoot)) {
throw new IllegalArgumentException("no attachmentPath defined");
}
StringBuilder msgfile = new StringBuilder().append(archivePathRoot)
.append(archive.getArchivePathSnippet()).append(archive.get_ID()).append(".pdf");
File file=new File(msgfile.toString());
if (file !=null && file.exists()) {
if (!file.delete()) {
log.warning("unable to delete " + file.getAbsolutePath());
return false;
}
}
return true;
}
}

View File

@ -97,7 +97,7 @@ public class GridTable extends AbstractTableModel
/**
*
*/
private static final long serialVersionUID = 2328810326636468776L;
private static final long serialVersionUID = -3181940154166340664L;
public static final String DATA_REFRESH_MESSAGE = "Refreshed";
@ -109,7 +109,7 @@ public class GridTable extends AbstractTableModel
* @param TableName table name
* @param WindowNo window no
* @param TabNo tab no
* @param withAccessControl if true adds AD_Client/Org restrictuins
* @param withAccessControl if true adds AD_Client/Org restrictions
*/
public GridTable(Properties ctx, int AD_Table_ID, String TableName, int WindowNo, int TabNo,
boolean withAccessControl)
@ -878,7 +878,6 @@ public class GridTable extends AbstractTableModel
* @param col col
* @param ascending ascending
*/
@SuppressWarnings("unchecked")
public void sort (int col, boolean ascending)
{
log.info("#" + col + " " + ascending);
@ -1144,7 +1143,7 @@ public class GridTable extends AbstractTableModel
Collections.reverse(toremove);
for(Integer row : toremove)
{
m_sort.remove(row);
m_sort.remove(row.intValue());
}
}
}

View File

@ -19,5 +19,6 @@ public interface IArchiveStore {
public void save(MArchive archive, MStorageProvider prov,byte[] inflatedData);
public boolean deleteArchive(MArchive archive, MStorageProvider prov);
}

View File

@ -276,4 +276,13 @@ public class MArchive extends X_AD_Archive {
return true;
} // beforeSave
protected boolean beforeDelete ()
{
IArchiveStore prov = provider.getArchiveStore();
if (prov != null)
return prov.deleteArchive(this,provider);
return true;
}
} // MArchive

View File

@ -28,7 +28,10 @@ import org.compiere.util.CLogger;
*/
public class MAssetChange extends X_A_Asset_Change
{
private static final long serialVersionUID = 1L;
/**
*
*/
private static final long serialVersionUID = 4083373951793617528L;
/** Static Logger */
private static CLogger s_log = CLogger.getCLogger(MAssetChange.class);
@ -67,11 +70,6 @@ public class MAssetChange extends X_A_Asset_Change
return true;
} // beforeSave
/** ARHIPAC: TEO: BEGIN ------------------------------------------------------------------ */
public void setSerno(String value) { setSerNo(value); }
public void setVersionno(String value) { setVersionNo(value); }
public void setAd_User_ID(int value) { setAD_User_ID(value); }
public static MAssetChange createAddition(MAssetAddition assetAdd, MDepreciationWorkfile assetwk) {
MAssetChange change = new MAssetChange (assetAdd.getCtx(), 0, assetAdd.get_TrxName());
change.setAD_Org_ID(assetAdd.getAD_Org_ID()); //@win added

View File

@ -3,10 +3,6 @@ package org.compiere.model;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.model.CalloutEngine;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.model.Query;
import org.compiere.util.ArhRuntimeException;
import org.compiere.util.CCache;
import org.compiere.util.Env;
@ -17,16 +13,13 @@ import org.compiere.util.Env;
*/
public class MAssetType extends X_A_Asset_Type
{
private static final long serialVersionUID = 1L;
/**
*
*/
private static final long serialVersionUID = -1371478760221357780L;
public static final String A_ASSET_TYPE_MFX = "MFX";
public static final String A_ASSET_TYPE_INV = "INV";
public static final int A_ASSET_TYPE_ID_MFX = 1;
public static final int A_ASSET_TYPE_ID_INV = 2;
public static final int A_ASSET_TYPE_ID_SUP = 3;
/** Obiecte tert */
public static final int A_ASSET_TYPE_ID_OIN = 4;
private static final String A_ASSET_TYPE_MFX = "MFX"; // HARDCODED - you must create a Asset Type with Value=MFX to indicate is Fixed Asset
private static final String A_ASSET_TYPE_INV = "INV"; // HARDCODED - you must create a Asset Type with Value=MFX to indicate is Inventory Object
public static interface Model
{
@ -98,17 +91,13 @@ public class MAssetType extends X_A_Asset_Type
public static boolean isFixedAsset(int A_Asset_ID)
{
final String whereClause = MAsset.COLUMNNAME_A_Asset_ID+"=?"
+" AND "+MAsset.COLUMNNAME_A_AssetType+"=?";
return new Query(Env.getCtx(), MAsset.Table_Name, whereClause, null)
.setParameters(new Object[]{A_Asset_ID, A_ASSET_TYPE_MFX})
.match();
MAsset asset = MAsset.get(Env.getCtx(), A_Asset_ID, null);
return isFixedAsset(asset);
}
public static boolean isFixedAsset(MAsset asset)
{
return asset != null && A_ASSET_TYPE_MFX.equals(asset.getA_Asset_Type());
return asset != null && A_ASSET_TYPE_MFX.equals(asset.getA_Asset_Type().getValue());
}
public static boolean isFixedAssetGroup(Properties ctx, int A_Asset_Group_ID)
@ -150,7 +139,7 @@ public class MAssetType extends X_A_Asset_Type
/**
* Validate a Model
* @param m model
* @thorows ContextUserException
* @throws ContextUserException
*/
public static void validate(Model m)
{

View File

@ -117,7 +117,7 @@ public class MClientShare extends X_AD_ClientShare
s_shares.put("0_0", Boolean.TRUE);
} // load
StringBuilder key = new StringBuilder().append(AD_Client_ID).append("_").append(AD_Table_ID);
return s_shares.get(key);
return s_shares.get(key.toString());
} // load
/** Shared Info */

View File

@ -51,7 +51,7 @@ public class MEntityType extends X_AD_EntityType
* @param ctx context
* @return entity type array
*/
static public MEntityType[] getEntityTypes(Properties ctx)
static synchronized public MEntityType[] getEntityTypes(Properties ctx)
{
if (s_entityTypes != null)
return s_entityTypes;

View File

@ -363,7 +363,7 @@ public class MLookupFactory
{
// Try cache - assume no language change
StringBuilder key = new StringBuilder().append(Env.getAD_Client_ID(ctx)).append("|").append(String.valueOf(AD_Reference_Value_ID));
MLookupInfo retValue = (MLookupInfo)s_cacheRefTable.get(key);
MLookupInfo retValue = (MLookupInfo)s_cacheRefTable.get(key.toString());
if (retValue != null)
{
s_log.finest("Cache: " + retValue);
@ -687,8 +687,8 @@ public class MLookupFactory
//try cache
StringBuilder cacheKey = new StringBuilder().append(Env.getAD_Client_ID(ctx)).append("|").append(TableName).append(".").append(KeyColumn);
if (s_cacheRefTable.containsKey(cacheKey))
return s_cacheRefTable.get(cacheKey).cloneIt();
if (s_cacheRefTable.containsKey(cacheKey.toString()))
return s_cacheRefTable.get(cacheKey.toString()).cloneIt();
ArrayList<LookupDisplayColumn> list = getListIdentifiers(TableName);

View File

@ -308,7 +308,7 @@ public class MMailText extends X_R_MailText
if (m_bpartner != null && m_bpartner.getAD_Language() != null)
{
StringBuilder key = new StringBuilder().append(m_bpartner.getAD_Language()).append(get_ID());
MMailTextTrl trl = s_cacheTrl.get(key);
MMailTextTrl trl = s_cacheTrl.get(key.toString());
if (trl == null)
{
trl = getTranslation(m_bpartner.getAD_Language());

View File

@ -472,9 +472,10 @@ public class MProject extends X_C_Project
public MInvoice[] getMInvoices(){
StringBuilder sb = new StringBuilder();
sb.append(MInvoice.COLUMNNAME_C_Project_ID).append("=?");
Query qry = new Query(getCtx(), MInvoice.Table_Name, sb.toString(), get_TrxName());
qry.setParameters(getC_Project_ID());
return (MInvoice[]) qry.list().toArray();
List<MInvoice> list = new Query(getCtx(), MInvoice.Table_Name, sb.toString(), get_TrxName())
.setParameters(getC_Project_ID())
.list();
return list.toArray(new MInvoice[list.size()]);
}
} // MProject

View File

@ -55,6 +55,8 @@ import org.compiere.process.SvrProcess;
import org.compiere.report.MReportTree;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Language;
import org.compiere.util.Msg;
/**
* GL Journal Generator
@ -410,6 +412,9 @@ public class GLJournalGenerate extends SvrProcess
j.setAD_Org_ID(journalGenerator.getAD_Org_ID());
else
j.setAD_Org_ID(Env.getAD_Org_ID(getCtx()));
if (j.getAD_Org_ID() == 0) {
throw new AdempiereException(Msg.getMsg(Language.getBaseAD_Language(), "Org0NotAllowed"));
}
j.setC_Currency_ID(as.getC_Currency_ID());
j.setC_DocType_ID(journalGenerator.getC_DocType_ID());
j.setControlAmt(Env.ZERO);
@ -512,11 +517,14 @@ public class GLJournalGenerate extends SvrProcess
if (j != null && p_DocAction != null) {
// DocAction
if (!j.processIt(p_DocAction))
throw new AdempiereException("Could not " + p_DocAction + " journal");
throw new AdempiereException("Couldn't set docAction: " + p_DocAction + ((org.compiere.process.DocAction) j).getProcessMsg()+ " journal");
j.saveEx();
}
return "@OK@" + (j != null ? " @Created@ @GL_Journal_ID@=" + j.getDocumentNo() : "");
StringBuilder msg = new StringBuilder(Msg.parseTranslation(getCtx(), "@Created@ @GL_Journal_ID@=")).append(j.getDocumentNo());
addLog(j.get_ID(), null, null, msg.toString(), MJournal.Table_ID, j.get_ID());
return "@OK@";
} // doIt
private BigDecimal applyMultiplierAndFactor(BigDecimal sourceAmt, BigDecimal amtMultiplier, int roundFactor) {

View File

@ -49,7 +49,7 @@ public class AdempiereServerMgr
* Get Adempiere Server Manager
* @return mgr
*/
public static AdempiereServerMgr get()
public synchronized static AdempiereServerMgr get()
{
if (m_serverMgr == null)
{
@ -62,7 +62,7 @@ public class AdempiereServerMgr
} // get
/** Singleton */
private static AdempiereServerMgr m_serverMgr = null;
private static AdempiereServerMgr m_serverMgr = null;
/** Logger */
protected CLogger log = CLogger.getCLogger(getClass());

View File

@ -798,7 +798,7 @@ public class MiniTable extends CTable implements IMiniTable
if(subtotal == null)
subtotal = new Double(0);
if(amt == null )
subtotal = new Double(0);
amt = new Double(0);
total[col] = subtotal + amt;
}
@ -873,7 +873,7 @@ public class MiniTable extends CTable implements IMiniTable
if(subtotal == null)
subtotal = new Double(0);
if(amt == null )
subtotal = new Double(0);
amt = new Double(0);
total[col] = subtotal + amt;
}

View File

@ -26,6 +26,7 @@ import java.sql.Timestamp;
import java.util.Date;
import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.Checkbox;
import org.adempiere.webui.component.ConfirmPanel;
@ -48,6 +49,7 @@ import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.panel.CustomForm;
import org.adempiere.webui.panel.IFormController;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.FDialog;
import org.compiere.apps.form.Archive;
import org.compiere.model.MArchive;
import org.compiere.model.MLookup;
@ -111,6 +113,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
private Textbox helpField = new Textbox();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private Button updateArchive = new Button();
private Button deleteArchive = new Button();
private Tabbox tabbox = new Tabbox();
private Tabs tabs = new Tabs();
@ -194,15 +197,19 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
updateArchive.setTooltiptext(Msg.getMsg(Env.getCtx(), "Update"));
updateArchive.addEventListener(Events.ON_CLICK, this);
deleteArchive.setImage("/images/Delete24.png");
deleteArchive.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete"));
deleteArchive.addEventListener(Events.ON_CLICK, this);
bRefresh.setImage("/images/Refresh24.png");
bRefresh.setTooltiptext(Msg.getMsg(Env.getCtx(), "Refresh"));
bRefresh.addEventListener(Events.ON_CLICK, this);
bBack.setImage("/images/Parent24.png");
bBack.setImage("/images/wfBack24.png");
bBack.setTooltiptext(Msg.getMsg(Env.getCtx(), "Previous"));
bBack.addEventListener(Events.ON_CLICK, this);
bNext.setImage("/images/Detail24.png");
bNext.setImage("/images/wfNext24.png");
bNext.setTooltiptext(Msg.getMsg(Env.getCtx(), "Next"));
bNext.addEventListener(Events.ON_CLICK, this);
@ -405,6 +412,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
row.setSpans("4");
div = new Div();
div.setAlign("right");
div.appendChild(deleteArchive);
div.appendChild(bRefresh);
div.appendChild(updateArchive);
row.appendChild(div);
@ -449,6 +457,8 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
if (e.getTarget() == updateArchive)
cmd_updateArchive();
else if(e.getTarget() == deleteArchive)
cmd_deleteArchive();
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
SessionManager.getAppDesktop().closeActiveWindow();
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
@ -479,16 +489,9 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
}
}
/* public void valueChange(ValueChangeEvent evt)
{
if (m_archives.length > 0)
updateArchive.setEnabled(true);
}
*/
/**
* Update Query Display
*/
private void updateQDisplay()
{
boolean reports = reportField.isChecked();
@ -503,6 +506,23 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
bPartnerField.setVisible(!reports);
} // updateQDisplay
public void cmd_deleteArchive(){
FDialog.ask(m_WindowNo, this.form, "DeleteRecord?", new Callback<Boolean>() {
@Override
public void onCallback(Boolean result)
{
if (result)
{
MArchive ar = m_archives[m_index];
ar.delete(true);
tabbox.setSelectedIndex(0);
dynInit();
}
}
});
}
/**
* Update View Display
* @param next show next Archive
@ -526,13 +546,14 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
bBack.setEnabled(m_index > 0);
bNext.setEnabled(m_index < m_archives.length-1);
deleteArchive.setEnabled(m_archives.length > 0);
updateArchive.setEnabled(false);
log.info("Index=" + m_index + ", Length=" + m_archives.length);
if (m_archives.length == 0)
{
positionInfo.setValue("No Record Found");
positionInfo.setValue(Msg.getMsg(Env.getCtx(), "NoRecordsFound"));
createdByField.setText("");
createdField.setValue(null);
nameField.setText("");

View File

@ -20,6 +20,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -64,8 +65,11 @@ import org.zkoss.zul.Vbox;
*/
public class CustomizeGridViewPanel extends Panel
{
/**
*
*/
private static final long serialVersionUID = -3190425241947591357L;
private static final long serialVersionUID = 4289328613547509587L;
private Map<Integer, String> m_columnsWidth;
ArrayList<Integer> tableSeqs;
GridView gridPanel = null;
@ -131,9 +135,6 @@ public class CustomizeGridViewPanel extends Panel
noLabel.setValue(Msg.getMsg(Env.getCtx(), "Available"));
yesLabel.setValue(Msg.getMsg(Env.getCtx(), "Selected"));
yesList.setHeight("100%");
noList.setHeight("100%");
yesList.setVflex(true);
noList.setVflex(true);
@ -157,8 +158,8 @@ public class CustomizeGridViewPanel extends Panel
migrateValueAcrossLists(event);
}
};
yesList.setSeltype("multiple");
noList.setSeltype("multiple");
yesModel.setMultiple(true);
noModel.setMultiple(true);
bAdd.setImage("images/Next24.png");
bAdd.addEventListener(Events.ON_CLICK, actionListener);
@ -396,14 +397,19 @@ public class CustomizeGridViewPanel extends Panel
}
Listbox listFrom = (source == bAdd || source == noList) ? noList : yesList;
Listbox listTo = (source == bAdd || source == noList) ? yesList : noList;
SimpleListModel lmFrom = (source == bAdd || source == noList) ?
noModel : yesModel;
SimpleListModel lmTo = (lmFrom == yesModel) ? noModel : yesModel;
migrateLists (listFrom,listTo);
}
void migrateLists (Listbox listFrom , Listbox listTo)
{
int index = 0;
SimpleListModel lmFrom = (SimpleListModel) listFrom.getModel();
SimpleListModel lmTo = (SimpleListModel) listTo.getModel();
Set<?> selectedItems = listFrom.getSelectedItems();
List<ListElement> selObjects = new ArrayList<ListElement>();
for (Object obj : selectedItems) {
ListItem listItem = (ListItem) obj;
int index = listFrom.getIndexOfItem(listItem);
index = listFrom.getIndexOfItem(listItem);
ListElement selObject = (ListElement)lmFrom.getElementAt(index);
selObjects.add(selObject);
}
@ -415,10 +421,10 @@ public class CustomizeGridViewPanel extends Panel
lmFrom.removeElement(selObject);
lmTo.addElement(selObject);
}
index = 0;
for (ListElement selObject : selObjects)
{
int index = lmTo.indexOf(selObject);
index = lmTo.indexOf(selObject);
listTo.setSelectedIndex(index);
}
if ( listTo.getSelectedItem() != null)
@ -426,8 +432,7 @@ public class CustomizeGridViewPanel extends Panel
AuFocus focus = new AuFocus(listTo.getSelectedItem());
Clients.response(focus);
}
} // migrateValueAcrossLists
}
/**
* Move within Yes List
@ -444,6 +449,7 @@ public class CustomizeGridViewPanel extends Panel
return;
//
int[] indices = yesList.getSelectedIndices();
Arrays.sort(indices);
//
boolean change = false;
//
@ -667,29 +673,14 @@ public class CustomizeGridViewPanel extends Panel
if (event instanceof DropEvent)
{
DropEvent me = (DropEvent) event;
ListItem endItem = (ListItem) me.getTarget();
if (!(endItem.getListbox() == yesList))
{
return; // move within noList
}
ListItem startItem = (ListItem) me.getDragged();
if (startItem.getListbox() == endItem.getListbox())
if (!(startItem.getListbox() == endItem.getListbox()))
{
return; //move within same list
Listbox listFrom = (Listbox)startItem.getListbox();
Listbox listTo = (Listbox)endItem.getListbox();
migrateLists (listFrom,listTo);
}
int startIndex = noList.getIndexOfItem(startItem);
Object element = noModel.getElementAt(startIndex);
noModel.removeElement(element);
int endIndex = yesList.getIndexOfItem(endItem);
yesModel.add(endIndex, element);
//
noList.clearSelection();
yesList.clearSelection();
yesList.setSelectedIndex(endIndex);
//
}
}
}

View File

@ -194,8 +194,7 @@ public class ReportProcessor
}
else if (para.getP_Number() != null)
{
if (para.getP_Number_To() != null
&& !para.getP_Number_To().equals(""))
if (para.getP_Number_To() != null)
{
try
{