[ 1892461 ] Callout for VLocation field invoke twice

This commit is contained in:
Heng Sin Low 2008-02-13 07:04:06 +00:00
parent 294f4f87ed
commit ae19bfa77e
2 changed files with 34 additions and 4 deletions

View File

@ -186,7 +186,7 @@ public class VEditorFactory
// Location // Location
else if (displayType == DisplayType.Location) else if (displayType == DisplayType.Location)
{ {
VLocation loc = new VLocation (columnName, mandatory, readOnly, updateable, VLocation loc = new VLocation (mTab, columnName, mandatory, readOnly, updateable,
(MLocationLookup)mField.getLookup()); (MLocationLookup)mField.getLookup());
loc.setName(columnName); loc.setName(columnName);
loc.setField (mField); loc.setField (mField);

View File

@ -47,9 +47,26 @@ public class VLocation extends JComponent
*/ */
public VLocation(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable, public VLocation(String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
MLocationLookup mLocation) MLocationLookup mLocation)
{
this(null, columnName, mandatory, isReadOnly, isUpdateable, mLocation);
}
/**
* Constructor
*
* @param gridTab
* @param columnName column name
* @param mandatory mandatory
* @param isReadOnly read only
* @param isUpdateable updateable
* @param mLocation location model
*/
public VLocation(GridTab gridTab, String columnName, boolean mandatory, boolean isReadOnly, boolean isUpdateable,
MLocationLookup mLocation)
{ {
super(); super();
super.setName(columnName); super.setName(columnName);
m_GridTab = gridTab;
m_columnName = columnName; m_columnName = columnName;
m_mLocation = mLocation; m_mLocation = mLocation;
// //
@ -95,6 +112,8 @@ public class VLocation extends JComponent
m_text = null; m_text = null;
m_button = null; m_button = null;
m_mLocation = null; m_mLocation = null;
m_GridField = null;
m_GridTab = null;
} // dispose } // dispose
/** The Text Field */ /** The Text Field */
@ -113,6 +132,11 @@ public class VLocation extends JComponent
JPopupMenu popupMenu = new JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu();
private CMenuItem mDelete; private CMenuItem mDelete;
/** The Grid Tab * */
private GridTab m_GridTab; // added for processCallout
/** The Grid Field * */
private GridField m_GridField; // added for processCallout
/** /**
* Enable/disable * Enable/disable
* @param value true if ReadWrite * @param value true if ReadWrite
@ -271,6 +295,7 @@ public class VLocation extends JComponent
VLocationDialog ld = new VLocationDialog(Env.getFrame(this), VLocationDialog ld = new VLocationDialog(Env.getFrame(this),
Msg.getMsg(Env.getCtx(), "Location"), m_value); Msg.getMsg(Env.getCtx(), "Location"), m_value);
ld.setVisible(true); ld.setVisible(true);
Object oldValue = getValue();
m_value = ld.getValue(); m_value = ld.getValue();
// //
if (e.getSource() == mDelete) if (e.getSource() == mDelete)
@ -285,11 +310,15 @@ public class VLocation extends JComponent
if (m_value != null) if (m_value != null)
C_Location_ID = m_value.getC_Location_ID(); C_Location_ID = m_value.getC_Location_ID();
Integer ii = new Integer(C_Location_ID); Integer ii = new Integer(C_Location_ID);
// force Change - user does not realize that embedded object is already saved.
fireVetoableChange(m_columnName, null, null); // resets m_mLocation
if (C_Location_ID != 0) if (C_Location_ID != 0)
fireVetoableChange(m_columnName, null, ii); fireVetoableChange(m_columnName, oldValue, ii);
setValue(ii); setValue(ii);
if (ii.equals(oldValue) && m_GridTab != null && m_GridField != null)
{
// force Change - user does not realize that embedded object is already saved.
m_GridTab.processFieldChange(m_GridField);
}
} }
catch (PropertyVetoException pve) catch (PropertyVetoException pve)
{ {
@ -313,6 +342,7 @@ public class VLocation extends JComponent
*/ */
public void setField (org.compiere.model.GridField mField) public void setField (org.compiere.model.GridField mField)
{ {
m_GridField = mField;
} // setField } // setField
} // VLocation } // VLocation