[ 2236639 ] Creation of Location allowed without BP Location associated

This commit is contained in:
Heng Sin Low 2008-12-26 09:13:47 +00:00
parent 9e0dcaaaa3
commit 30086c2278
3 changed files with 35 additions and 14 deletions

View File

@ -24,6 +24,7 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Locationbox;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WLocationDialog;
import org.compiere.model.GridField;
import org.compiere.model.MLocation;
import org.compiere.model.MLocationLookup;
import org.compiere.util.CLogger;
@ -45,7 +46,6 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC
private static CLogger log = CLogger.getCLogger(WLocationEditor.class);
private static final long serialVersionUID = 1L;
private String m_columnName;
private MLocationLookup m_Location;
private MLocation m_value;
@ -62,12 +62,22 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC
{
super(new Locationbox(), "Address","",mandatory,isReadOnly,isUpdateable);
m_columnName = columnName;
setColumnName(columnName);
m_Location = mLocation;
getComponent().setButtonImage("/images/Location10.png");
}
@Override
/**
*
* @param gridField
*/
public WLocationEditor(GridField gridField) {
super(new Locationbox(), gridField);
m_Location = (MLocationLookup)gridField.getLookup();
getComponent().setButtonImage("/images/Location10.png");
}
@Override
public String getDisplay()
{
return getComponent().getText();
@ -155,11 +165,11 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC
C_Location_ID = m_value.getC_Location_ID();
Integer ii = new Integer(C_Location_ID);
// force Change - user does not realize that embedded object is already saved.
ValueChangeEvent valuechange = new ValueChangeEvent(this,m_columnName,null,null);
ValueChangeEvent valuechange = new ValueChangeEvent(this,getColumnName(),null,null);
fireValueChange(valuechange); // resets m_mLocation
if (C_Location_ID != 0)
{
ValueChangeEvent vc = new ValueChangeEvent(this,m_columnName,null,ii);
ValueChangeEvent vc = new ValueChangeEvent(this,getColumnName(),null,ii);
fireValueChange(vc);
}
setValue(ii);

View File

@ -28,6 +28,7 @@ import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.EditorBox;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WLocatorDialog;
import org.compiere.model.GridField;
import org.compiere.model.MLocator;
import org.compiere.model.MLocatorLookup;
import org.compiere.model.MRole;
@ -51,7 +52,6 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
{
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
private String m_columnName;
private MLocatorLookup m_mLocator;
private Object m_value;
private int m_WindowNo;
@ -82,7 +82,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
{
super(new EditorBox(), "Locator", "", mandatory, isReadOnly, isUpdateable);
m_columnName = columnName;
setColumnName(columnName);
m_mLocator = mLocator;
getComponent().setButtonImage("/images/Locator10.png");
@ -91,6 +91,20 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
m_WindowNo = windowNo;
}
/**
* @param gridField
*/
public WLocatorEditor(GridField gridField) {
super(new EditorBox(), gridField);
m_mLocator = (MLocatorLookup)gridField.getLookup();
getComponent().setButtonImage("/images/Locator10.png");
setDefault_Locator_ID(); // set default locator, teo_sarca [ 1661546 ]
m_WindowNo = gridField.getWindowNo();
}
public void setValue(Object value)
{
setValue (value, false);
@ -118,7 +132,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
// Data Binding
if (fire) {
ValueChangeEvent val = new ValueChangeEvent(this, m_columnName, null, value);
ValueChangeEvent val = new ValueChangeEvent(this, getColumnName(), null, value);
fireValueChange(val);
}
@ -201,7 +215,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
m_mLocator.setOnly_Warehouse_ID(only_Warehouse_ID);
m_mLocator.setOnly_Product_ID(getOnly_Product_ID());
WLocatorDialog ld = new WLocatorDialog(Msg.translate(Env.getCtx(), m_columnName),
WLocatorDialog ld = new WLocatorDialog(Msg.translate(Env.getCtx(), getColumnName()),
m_mLocator, M_Locator_ID, isMandatory(), only_Warehouse_ID, this.m_WindowNo);
// display

View File

@ -142,14 +142,11 @@ public class WebEditorFactory
else if (displayType == DisplayType.Location)
{
editor = new WLocationEditor(gridField.getColumnName(),gridField.isMandatory(false),gridField.isReadOnly(),gridField.isUpdateable(),
(MLocationLookup)gridField.getLookup());
editor = new WLocationEditor(gridField);
}
else if (displayType == DisplayType.Locator)
{
editor = new WLocatorEditor(gridField.getColumnName(), gridField.isMandatory(false),
gridField.isReadOnly(), gridField.isUpdateable(),
(MLocatorLookup)gridField.getLookup(), gridField.getWindowNo());
editor = new WLocatorEditor(gridField);
}
else if (displayType == DisplayType.Account)
{