Merge 3ec3918730fd

This commit is contained in:
Heng Sin Low 2012-12-28 00:30:38 +08:00
commit 1a096ff10a
15 changed files with 260 additions and 32 deletions

View File

@ -0,0 +1,12 @@
-- Dec 27, 2012 6:53:37 PM SGT
-- Ticket 1001758: FedEx & UPS
UPDATE AD_Process SET Description='Create Package for Shipment',Updated=TO_DATE('2012-12-27 18:53:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=282
;
-- Dec 27, 2012 6:53:37 PM SGT
-- Ticket 1001758: FedEx & UPS
UPDATE AD_Process_Trl SET IsTranslated='N' WHERE AD_Process_ID=282
;
SELECT register_migration_script('201212271855_TICKET-1001758.sql') FROM dual
;

View File

@ -0,0 +1,12 @@
-- Dec 27, 2012 6:53:37 PM SGT
-- Ticket 1001758: FedEx & UPS
UPDATE AD_Process SET Description='Create Package for Shipment',Updated=TO_TIMESTAMP('2012-12-27 18:53:37','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Process_ID=282
;
-- Dec 27, 2012 6:53:37 PM SGT
-- Ticket 1001758: FedEx & UPS
UPDATE AD_Process_Trl SET IsTranslated='N' WHERE AD_Process_ID=282
;
SELECT register_migration_script('201212271855_TICKET-1001758.sql') FROM dual
;

View File

@ -66,8 +66,6 @@ public class GridFieldVO implements Serializable
return sql.toString();
} // getSQL
public String InfoFactoryClass = null;
/**
* Create Field Value Object
* @param ctx context
@ -185,9 +183,6 @@ public class GridFieldVO implements Serializable
// Collapse Default State
else if (columnName.equalsIgnoreCase("IsCollapsedByDefault"))
vo.IsCollapsedByDefault = "Y".equals(rs.getString(i));
//Info Factory class
else if (columnName.equalsIgnoreCase("InfoFactoryClass"))
vo.InfoFactoryClass = rs.getString(i);
// Feature Request FR [ 2003044 ]
else if (columnName.equalsIgnoreCase("IsAutocomplete"))
vo.IsAutocomplete = "Y".equals(rs.getString(i));
@ -639,8 +634,6 @@ public class GridFieldVO implements Serializable
IsParent, ValidationCode);
if (lookupInfo == null)
displayType = DisplayType.ID;
else
lookupInfo.InfoFactoryClass = this.InfoFactoryClass;
}
catch (Exception e) // Cannot create Lookup
{

View File

@ -19,6 +19,9 @@ package org.compiere.model;
import java.sql.ResultSet;
import java.util.Properties;
import org.compiere.model.AccessSqlParser.TableInfo;
import org.compiere.util.Env;
/**
* Info Window Column Model
*
@ -53,5 +56,39 @@ public class MInfoColumn extends X_AD_InfoColumn
{
super (ctx, rs, trxName);
} // MInfoColumn
/**
* check column read access
* @param tableInfos
* @return false if current role don't have read access to the column, false otherwise
*/
public boolean isColumnAccess(TableInfo[] tableInfos)
{
int index = getSelectClause().indexOf(".");
if (index == getSelectClause().lastIndexOf("."))
{
String synonym = getSelectClause().substring(0, index);
String column = getSelectClause().substring(index+1);
for(TableInfo tableInfo : tableInfos)
{
if (tableInfo.getSynonym() != null && tableInfo.getSynonym().equals(synonym))
{
String tableName = tableInfo.getTableName();
MTable mTable = MTable.get(Env.getCtx(), tableName);
if (mTable != null)
{
MColumn mColumn = mTable.getColumn(column);
if (mColumn != null)
{
if (!MRole.getDefault().isColumnAccess(mTable.getAD_Table_ID(), mColumn.getAD_Column_ID(), true))
{
return false;
}
}
}
}
}
}
return true;
}
} // MInfoColumn

View File

@ -17,8 +17,12 @@
package org.compiere.model;
import java.sql.ResultSet;
import java.util.List;
import java.util.Properties;
import org.compiere.model.AccessSqlParser.TableInfo;
import org.compiere.util.Env;
/**
* Info Window Model
*
@ -53,5 +57,49 @@ public class MInfoWindow extends X_AD_InfoWindow
{
super (ctx, rs, trxName);
} // MInfoWindow
public static MInfoWindow get(String tableName, String trxName) {
Query query = new Query(Env.getCtx(), MTable.get(Env.getCtx(), I_AD_InfoWindow.Table_ID), I_AD_InfoWindow.COLUMNNAME_AD_Table_ID+"=?", null);
MTable table = MTable.get(Env.getCtx(), tableName);
if (table != null) {
return query.setParameters(table.getAD_Table_ID())
.setOrderBy("AD_Client_ID Desc, AD_Org_ID Desc, AD_InfoWidnow_ID Desc")
.setOnlyActiveRecords(true)
.setApplyAccessFilter(true)
.first();
}
return null;
}
public MInfoColumn[] getInfoColumns(TableInfo[] tableInfos) {
Query query = new Query(getCtx(), MTable.get(getCtx(), I_AD_InfoColumn.Table_ID), I_AD_InfoColumn.COLUMNNAME_AD_InfoWindow_ID+"=?", get_TrxName());
List<MInfoColumn> list = query.setParameters(getAD_InfoWindow_ID())
.setOrderBy(I_AD_InfoColumn.COLUMNNAME_SeqNo)
.list();
for(int i = list.size() - 1; i >= 0; i--) {
MInfoColumn infoColumn = list.get(i);
if (!infoColumn.isColumnAccess(tableInfos))
list.remove(i);
}
return list.toArray(new MInfoColumn[0]);
}
@Override
protected boolean beforeSave(boolean newRecord) {
String tableName = getAD_Table().getTableName();
AccessSqlParser parser = new AccessSqlParser("SELECT * FROM " + getFromClause());
TableInfo[] tableInfos = parser.getTableInfo(0);
if (tableInfos == null || tableInfos.length == 0) {
log.saveError("ParseFromClauseError", "Failed to parse from clause");
return false;
}
if (!tableInfos[0].getTableName().equalsIgnoreCase(tableName)) {
log.saveError("TableNameDifferent", "Table name is different between from clause and info window definition.");
return false;
}
return true;
}
} // MInfoWindow

View File

@ -464,6 +464,7 @@ public class MLookupFactory
}
}
String lookupDisplayColumn = null;
// Translated
if (IsTranslated && !Env.isBaseLanguage(language, TableName))
{
@ -477,8 +478,10 @@ public class MLookupFactory
else {
if (showID) {
StringBuilder displayColumn = getDisplayColumn(language, TableName, list);
lookupDisplayColumn = displayColumn.toString();
realSQL.append(displayColumn);
} else {
lookupDisplayColumn = DisplayColumn;
realSQL.append("NVL(").append(TableName).append("_Trl.").append(DisplayColumn).append(",'-1')");
}
}
@ -503,8 +506,10 @@ public class MLookupFactory
else {
if (showID) {
StringBuilder displayColumn = getDisplayColumn(language, TableName, list);
lookupDisplayColumn = displayColumn.toString();
realSQL.append(displayColumn);
} else {
lookupDisplayColumn = DisplayColumn;
realSQL.append("NVL(").append(TableName).append(".").append(DisplayColumn).append(",'-1')");
}
}
@ -554,6 +559,7 @@ public class MLookupFactory
StringBuilder msginf = new StringBuilder().append(TableName).append(".").append(KeyColumn);
retValue = new MLookupInfo (realSQL.toString(), TableName,
msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery);
retValue.DisplayColumn = lookupDisplayColumn;
s_cacheRefTable.put(key.toString(), retValue.cloneIt());
return retValue;
} // getLookup_Table
@ -750,6 +756,7 @@ public class MLookupFactory
StringBuilder msginf = new StringBuilder().append(TableName).append(".").append(KeyColumn);
MLookupInfo lInfo = new MLookupInfo(realSQL.toString(), TableName,
msginf.toString(), ZoomWindow, ZoomWindowPO, zoomQuery);
lInfo.DisplayColumn = displayColumn.toString();
s_cacheRefTable.put(cacheKey.toString(), lInfo.cloneIt());
return lInfo;
} // getLookup_TableDir

View File

@ -192,6 +192,8 @@ public class MLookupInfo implements Serializable, Cloneable
public String InfoFactoryClass = null;
public String DisplayColumn;
/**
* String representation
* @return info

View File

@ -482,7 +482,7 @@ public class MPackage extends X_M_Package
st.setAction(action);
st.setAD_Client_ID(getAD_Client_ID());
st.setAD_Org_ID(getAD_Org_ID());
st.setAD_User_ID(ioOut.getAD_User_ID());
st.setAD_User_ID(ioOut.getAD_User_ID() > 0 ? ioOut.getAD_User_ID() : order.getAD_User_ID());
st.setBill_Location_ID(getC_BPartner_Location_ID());
st.setBoxCount(getBoxCount());
st.setC_BP_ShippingAcct_ID(getC_BP_ShippingAcct_ID());

View File

@ -482,7 +482,6 @@ public final class Find extends CDialog
ynvo.lookupInfo = MLookupFactory.getLookupInfo (ynvo.ctx, ynvo.WindowNo, ynvo.AD_Column_ID, ynvo.displayType,
Env.getLanguage(ynvo.ctx), ynvo.ColumnName, ynvo.AD_Reference_Value_ID,
ynvo.IsParent, ynvo.ValidationCode);
ynvo.lookupInfo.InfoFactoryClass = ynvo.InfoFactoryClass;
GridField ynfield = new GridField(ynvo);
@ -504,7 +503,6 @@ public final class Find extends CDialog
postedvo.lookupInfo = MLookupFactory.getLookupInfo (postedvo.ctx, postedvo.WindowNo, postedvo.AD_Column_ID, postedvo.displayType,
Env.getLanguage(postedvo.ctx), postedvo.ColumnName, postedvo.AD_Reference_Value_ID,
postedvo.IsParent, postedvo.ValidationCode);
postedvo.lookupInfo.InfoFactoryClass = postedvo.InfoFactoryClass;
GridField postedfield = new GridField(postedvo);

View File

@ -763,7 +763,33 @@ public class WListbox extends Listbox implements IMiniTable, TableValueChangeLis
return null;
} // getSelectedRowKey
public Integer getFirstRowKey()
{
if (m_layout == null)
{
throw new UnsupportedOperationException("Layout not defined");
}
if (getRowCount() <= 0)
{
return null;
}
Object data = getModel().getDataAt(0, m_keyColumnIndex);
if (data instanceof IDColumn)
{
data = ((IDColumn)data).getRecord_ID();
}
if (data instanceof Integer)
{
return (Integer)data;
}
return null;
}
/**
* Returns the index of the first selected row, -1 if no row is selected.
*

View File

@ -47,7 +47,6 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -322,10 +321,11 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
actionButton(text);
return;
}
text = text.toUpperCase();
// text = text.toUpperCase();
log.config(getColumnName() + " - " + text);
// Exact first
/*
PreparedStatement pstmt = null;
String finalSQL = Msg.parseTranslation(Env.getCtx(), getDirectAccessSQL(text));
int id = -3;
@ -383,17 +383,31 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
catch (Exception e)
{
}
*/
int id = -3;
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, getComponent().getText(), false, getWhereClause());
if (ip != null && ip.loadedOK() && ip.getRowCount() == 1)
{
Integer key = ip.getFirstRowKey();
if (key != null && key.intValue() > 0)
{
id = key.intValue();
}
}
// No (unique) result
if (id <= 0)
{
if (id == -3)
log.fine(getColumnName() + " - Not Found - " + finalSQL);
else
log.fine(getColumnName() + " - Not Unique - " + finalSQL);
//m_value = null; // force re-display
actionButton(getComponent().getText());
if (ip != null && ip.loadedOK())
{
showInfoPanel(ip);
}
else
{
actionButton(getComponent().getText());
}
return;
}
log.fine(getColumnName() + " - Unique ID=" + id);
@ -512,6 +526,11 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
getDirectAccessSQL("*");
final InfoPanel ip = InfoManager.create(lookup, gridField, m_tableName, m_keyColumnName, queryValue, false, whereClause);
showInfoPanel(ip);
}
protected void showInfoPanel(final InfoPanel ip) {
ip.setVisible(true);
ip.setStyle("border: 2px");
ip.setClosable(true);
@ -566,6 +585,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
m_tableName = m_columnName.substring(0, m_columnName.length()-3);
m_keyColumnName = m_columnName;
//TODO: check info window definition
if (m_columnName.equals("M_Product_ID"))
{
// Reset

View File

@ -13,6 +13,7 @@
*****************************************************************************/
package org.adempiere.webui.factory;
import org.adempiere.webui.info.InfoWindow;
import org.adempiere.webui.panel.InfoAssetPanel;
import org.adempiere.webui.panel.InfoAssignmentPanel;
import org.adempiere.webui.panel.InfoBPartnerPanel;
@ -40,6 +41,7 @@ public class DefaultInfoFactory implements IInfoFactory {
String value, boolean multiSelection, String whereClause, boolean lookup) {
InfoPanel info = null;
//TODO: info window for c_bpartner, m_product, c_invoice, a_asset, c_order, m_inout, c_payment and resource
if (tableName.equals("C_BPartner"))
info = new InfoBPartnerPanel (value,WindowNo, !Env.getContext(Env.getCtx(),"IsSOTrx").equals("N"),
multiSelection, whereClause, lookup);
@ -68,10 +70,14 @@ public class DefaultInfoFactory implements IInfoFactory {
else if (tableName.equals("S_ResourceAssigment"))
info = new InfoAssignmentPanel (WindowNo, value,
multiSelection, whereClause, lookup);
else
info = new InfoGeneralPanel (value, WindowNo,
tableName, keyColumn,
multiSelection, whereClause, lookup);
else {
// info = new InfoWindow(WindowNo, tableName, keyColumn, value, multiSelection, whereClause, lookup);
// if (!((InfoWindow)info).loadedOK()) {
info = new InfoGeneralPanel (value, WindowNo,
tableName, keyColumn,
multiSelection, whereClause, lookup);
// }
}
//
return info;
}
@ -87,6 +93,12 @@ public class DefaultInfoFactory implements IInfoFactory {
col = col.substring(col.indexOf('.')+1);
if (col.equals("M_Product_ID"))
{
//TODO: Product info window
/*
InfoWindow infoWindow = new InfoWindow(lookup.getWindowNo(), tableName, keyColumn, value, multiSelection, whereClause);
if (infoWindow.loadedOk())
return infoWindow;
*/
// Reset
Env.setContext(Env.getCtx(), lookup.getWindowNo(), Env.TAB_INFO, "M_Product_ID", "0");
Env.setContext(Env.getCtx(), lookup.getWindowNo(), Env.TAB_INFO, "M_AttributeSetInstance_ID", "0");
@ -103,6 +115,12 @@ public class DefaultInfoFactory implements IInfoFactory {
}
else if (col.equals("C_BPartner_ID"))
{
//TODO: BPartner info window
/*
InfoWindow infoWindow = new InfoWindow(lookup.getWindowNo(), tableName, keyColumn, multiSelection, whereClause);
if (infoWindow.isValid())
return infoWindow;
*/
boolean isSOTrx = true; // default
if (Env.getContext(Env.getCtx(), lookup.getWindowNo(), "IsSOTrx").equals("N"))

View File

@ -25,8 +25,10 @@ import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Level;
@ -38,6 +40,7 @@ import org.adempiere.webui.component.ListModelTable;
import org.adempiere.webui.component.WListItemRenderer;
import org.adempiere.webui.component.WListbox;
import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.event.WTableModelEvent;
@ -63,6 +66,7 @@ import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.au.out.AuEcho;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
@ -93,7 +97,9 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
*/
private static final long serialVersionUID = 325050327514511004L;
private final static int PAGE_SIZE = 100;
protected Map<String, WEditor> editorMap = new HashMap<String, WEditor>();
public static InfoPanel create (int WindowNo,
String tableName, String keyColumn, String value,
boolean multiSelection, String whereClause)
@ -464,12 +470,42 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
else if (c == Integer.class)
value = new Integer(rs.getInt(colIndex));
else if (c == KeyNamePair.class)
{
if (p_layout[col].isKeyPairCol())
{
String display = rs.getString(colIndex);
int key = rs.getInt(colIndex+1);
value = new KeyNamePair(key, display);
colOffset++;
}
else
{
int key = rs.getInt(colIndex);
WEditor editor = editorMap.get(p_layout[col].getColSQL());
if (editor != null)
{
editor.setValue(key);
value = new KeyNamePair(key, editor.getDisplayTextForGridView(key));
}
else
{
value = new KeyNamePair(key, Integer.toString(key));
}
}
}
else if (c == ValueNamePair.class)
{
String display = rs.getString(colIndex);
int key = rs.getInt(colIndex+1);
value = new KeyNamePair(key, display);
colOffset++;
String key = rs.getString(colIndex);
WEditor editor = editorMap.get(p_layout[col].getColSQL());
if (editor != null)
{
value = new ValueNamePair(key, editor.getDisplayTextForGridView(key));
}
else
{
value = new ValueNamePair(key, key);
}
}
else
{
@ -1312,4 +1348,12 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
public int getWindowNo() {
return p_WindowNo;
}
public int getRowCount() {
return contentPanel.getRowCount();
}
public Integer getFirstRowKey() {
return contentPanel.getFirstRowKey();
}
} // Info

View File

@ -611,7 +611,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
ynvo.lookupInfo = MLookupFactory.getLookupInfo (ynvo.ctx, ynvo.WindowNo, ynvo.AD_Column_ID, ynvo.displayType,
Env.getLanguage(ynvo.ctx), ynvo.ColumnName, ynvo.AD_Reference_Value_ID,
ynvo.IsParent, ynvo.ValidationCode);
ynvo.lookupInfo.InfoFactoryClass = ynvo.InfoFactoryClass;
GridField ynfield = new GridField(ynvo);
@ -633,7 +632,6 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
postedvo.lookupInfo = MLookupFactory.getLookupInfo (postedvo.ctx, postedvo.WindowNo, postedvo.AD_Column_ID, postedvo.displayType,
Env.getLanguage(postedvo.ctx), postedvo.ColumnName, postedvo.AD_Reference_Value_ID,
postedvo.IsParent, postedvo.ValidationCode);
postedvo.lookupInfo.InfoFactoryClass = postedvo.InfoFactoryClass;
GridField postedfield = new GridField(postedvo);

View File

@ -16,6 +16,8 @@
*****************************************************************************/
package org.compiere.minigrid;
import org.compiere.model.GridField;
/**
* Info Column Details
*
@ -77,6 +79,7 @@ public class ColumnInfo
private boolean m_readOnly;
private boolean m_colorColumn;
private String m_keyPairColSQL = "";
private GridField m_gridField;
/**
* Get Col Class
@ -191,4 +194,14 @@ public class ColumnInfo
{
return m_keyPairColSQL.length() > 0;
}
public void setGridField(GridField gridField)
{
m_gridField = gridField;
}
public GridField getGridField()
{
return m_gridField;
}
} // infoColumn