Fix for swing - report fields - drop down field not cleared

https://sourceforge.net/projects/adempiere/forums/forum/610547/topic/4450695
This commit is contained in:
Carlos Ruiz 2011-04-10 01:29:55 -05:00
parent b83d30409e
commit fbf30aed43
21 changed files with 192 additions and 29 deletions

View File

@ -38,8 +38,10 @@ import org.compiere.grid.ed.VEditorFactory;
import org.compiere.model.GridField;
import org.compiere.model.GridFieldVO;
import org.compiere.model.MClient;
import org.compiere.model.MLookup;
import org.compiere.model.MPInstancePara;
import org.compiere.process.ProcessInfo;
import org.compiere.swing.CLabel;
import org.compiere.swing.CPanel;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@ -362,9 +364,54 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException
{
// log.fine( "ProcessParameterPanel.vetoableChange");
if (evt.getSource() instanceof VEditor) {
GridField changedField = ((VEditor) evt.getSource()).getField();
if (changedField != null) {
processDependencies (changedField);
// future processCallout (changedField);
}
}
processNewValue(evt.getNewValue(), evt.getPropertyName());
} // vetoableChange
/**
* Evaluate Dependencies
* @param changedField changed field
*/
private void processDependencies (GridField changedField)
{
String columnName = changedField.getColumnName();
for (GridField field : m_mFields) {
if (field == null || field == changedField)
continue;
verifyChangedField(field, columnName);
}
for (GridField field : m_mFields2) {
if (field == null || field == changedField)
continue;
verifyChangedField(field, columnName);
}
} // processDependencies
private void verifyChangedField(GridField field, String columnName) {
ArrayList<String> list = field.getDependentOn();
if (list.contains(columnName)) {
if (field.getLookup() instanceof MLookup)
{
MLookup mLookup = (MLookup)field.getLookup();
// if the lookup is dynamic (i.e. contains this columnName as variable)
if (mLookup.getValidation().indexOf("@"+columnName+"@") != -1)
{
log.fine(columnName + " changed - "
+ field.getColumnName() + " set to null");
// invalidate current selection
field.setValue(null, true);
}
}
}
}
private void processNewValue(Object value, String name) {
if (value == null)
value = new String("");
@ -393,6 +440,8 @@ public class ProcessParameterPanel extends CPanel implements VetoableChangeListe
Component[] comps = centerPanel.getComponents();
for (int i = 0; i < comps.length; i++) {
Component comp = comps[i];
if (comp instanceof CLabel)
continue;
String columnName = comp.getName();
if (columnName != null && columnName.length() > 0) {

View File

@ -66,7 +66,7 @@ public final class VAccount extends JComponent
/**
*
*/
private static final long serialVersionUID = -3397625857773619178L;
private static final long serialVersionUID = -4177614835777620089L;
/******************************************************************************
* Mouse Listener
@ -451,6 +451,11 @@ public final class VAccount extends JComponent
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* String Representation
* @return info
@ -485,5 +490,5 @@ public final class VAccount extends JComponent
cmd_text();
}
}
} // VAccount

View File

@ -65,7 +65,7 @@ public class VAssignment extends JComponent
/**
*
*/
private static final long serialVersionUID = 796127013756416974L;
private static final long serialVersionUID = 1362298262975012883L;
/**
* Mouse Listener
@ -362,6 +362,11 @@ public class VAssignment extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* Action Listener Interface
* @param listener listener

View File

@ -30,6 +30,7 @@ import java.util.logging.Level;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import org.compiere.model.GridField;
import org.compiere.util.CLogger;
/**
@ -45,7 +46,7 @@ public class VBinary extends JButton
/**
*
*/
private static final long serialVersionUID = -2651582926471195345L;
private static final long serialVersionUID = 298576564679201761L;
/**
* Binary Editor
@ -256,12 +257,20 @@ public class VBinary extends JButton
catch (PropertyVetoException pve) {}
} // actionPerformed
// Field for Value Preference
private GridField m_mField = null;
/**
* Set Field/WindowNo for ValuePreference (NOP)
* @param mField
*/
public void setField (org.compiere.model.GridField mField)
public void setField (GridField mField)
{
m_mField = mField;
} // setField
@Override
public GridField getField() {
return m_mField;
}
} // VBinary

View File

@ -57,7 +57,7 @@ public final class VButton extends CButton
/**
*
*/
private static final long serialVersionUID = -5979521568246908136L;
private static final long serialVersionUID = 567682963060073664L;
/**
* Constructor
@ -337,6 +337,8 @@ public final class VButton extends CButton
return m_values;
} // getValues
// Field for Value Preference
private GridField m_mField = null;
/**
* Set Field/WindowNo for ValuePreference
* @param mField field model
@ -354,8 +356,14 @@ public final class VButton extends CButton
m_lookup = MLookupFactory.get(Env.getCtx(), mField.getWindowNo(), 0,
mField.getAD_Column_ID(), DisplayType.List);
}
m_mField = mField;
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* @return Returns the savedMnemonic.
*/

View File

@ -46,7 +46,7 @@ public class VCheckBox extends CCheckBox
/**
*
*/
private static final long serialVersionUID = -3822806631369725112L;
private static final long serialVersionUID = -9199643773556184995L;
/******************************************************************************
* Mouse Listener
@ -242,6 +242,11 @@ public class VCheckBox extends CCheckBox
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* @return Returns the savedMnemonic.
*/

View File

@ -51,7 +51,7 @@ public class VColor extends CButton
/**
*
*/
private static final long serialVersionUID = -1668126756160533715L;
private static final long serialVersionUID = 3881508174949938138L;
/**
* Constructor
@ -165,6 +165,8 @@ public class VColor extends CButton
}
} // propertyChange
// Field for Value Preference
private GridField m_mField = null;
/**
* Set Field/WindowNo for ValuePreference
* @param mField field
@ -172,8 +174,14 @@ public class VColor extends CButton
public void setField (GridField mField)
{
mField.setValueNoFire(false); // fire every time
m_mField = mField;
} // setField
@Override
public GridField getField() {
return m_mField;
}
/*************************************************************************/
/**

View File

@ -68,7 +68,7 @@ public class VDate extends JComponent
/**
*
*/
private static final long serialVersionUID = -9090302458969544529L;
private static final long serialVersionUID = 5265412413586160999L;
/*****************************************************************************
* Mouse Listener for Popup Menu
@ -569,6 +569,11 @@ public class VDate extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* Set Enabled
* @param enabled enabled

View File

@ -92,6 +92,12 @@ public interface VEditor extends CEditor, PropertyChangeListener
*/
public void setField (GridField mField);
/**
* Get Field/WindowNo for ValuePreference
* @return mField
*/
public GridField getField ();
/**
* Dispose
*/

View File

@ -27,6 +27,7 @@ import javax.swing.ImageIcon;
import javax.swing.JButton;
import org.compiere.apps.AEnv;
import org.compiere.model.GridField;
import org.compiere.model.MImage;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
@ -43,7 +44,7 @@ public class VImage extends JButton
/**
*
*/
private static final long serialVersionUID = -176278573866019572L;
private static final long serialVersionUID = 368261613546756534L;
/**
* Image Editor
@ -234,12 +235,20 @@ public class VImage extends JButton
catch (PropertyVetoException pve) {}
} // actionPerformed
// Field for Value Preference
private GridField m_mField = null;
/**
* Set Field/WindowNo for ValuePreference (NOP)
* @param mField
*/
public void setField (org.compiere.model.GridField mField)
public void setField (GridField mField)
{
m_mField = mField;
} // setField
@Override
public GridField getField() {
return m_mField;
}
} // VImage

View File

@ -59,7 +59,7 @@ public class VLocation extends JComponent
/**
*
*/
private static final long serialVersionUID = -3155246553879767899L;
private static final long serialVersionUID = -288409058154703379L;
/**
* Mouse Listener for Popup Menu
@ -396,6 +396,8 @@ public class VLocation extends JComponent
m_text.addActionListener(listener);
} // addActionListener
// Field for Value Preference
private GridField m_mField = null;
/**
* Set Field/WindowNo for ValuePreference (NOP)
* @param mField Model Field
@ -407,6 +409,11 @@ public class VLocation extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
} // VLocation
/*****************************************************************************/

View File

@ -69,7 +69,7 @@ public class VLocator extends JComponent
/**
*
*/
private static final long serialVersionUID = 6173109396306219205L;
private static final long serialVersionUID = 1953277256988665242L;
/**
* Mouse Listener for Popup Menu
@ -550,6 +550,10 @@ public class VLocator extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* Get Warehouse restriction if any.

View File

@ -98,9 +98,9 @@ public class VLookup extends JComponent
implements VEditor, ActionListener, FocusListener
{
/**
*
*
*/
private static final long serialVersionUID = -104909868954609498L;
private static final long serialVersionUID = 1307112072890929329L;
/*****************************************************************************
* Mouse Listener for Popup Menu
@ -678,6 +678,10 @@ public class VLookup extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**************************************************************************
* Action Listener - data binding

View File

@ -38,6 +38,7 @@ import javax.swing.SwingUtilities;
import org.adempiere.plaf.AdempierePLAF;
import org.compiere.apps.AEnv;
import org.compiere.apps.ScriptEditor;
import org.compiere.model.GridField;
import org.compiere.swing.CMenuItem;
import org.compiere.swing.CTextArea;
import org.compiere.util.CLogger;
@ -56,9 +57,7 @@ public class VMemo extends CTextArea
/**
*
*/
private static final long serialVersionUID = 9218826231484540367L;
/*****************************************************************************/
private static final long serialVersionUID = -1589654941310687511L;
/**
* Mouse Listener
@ -279,14 +278,21 @@ public class VMemo extends CTextArea
/*************************************************************************/
// Field for Value Preference
private GridField m_mField = null;
/**
* Set Field/WindowNo for ValuePreference (NOP)
* @param mField
*/
public void setField (org.compiere.model.GridField mField)
{
m_mField = mField;
} // setField
@Override
public GridField getField() {
return m_mField;
}
private class CInputVerifier extends InputVerifier {

View File

@ -75,7 +75,8 @@ public final class VNumber extends JComponent
/**
*
*/
private static final long serialVersionUID = -516704171367798447L;
private static final long serialVersionUID = -1473227631807352033L;
/** Number of Columns (12) */
public final static int SIZE = 12;
/** Automatically pop up calculator */
@ -764,6 +765,10 @@ public final class VNumber extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/*
* BF [ 1834393 ] VNumber.setFocusable not working
*/

View File

@ -66,7 +66,7 @@ public class VPAttribute extends JComponent
/**
*
*/
private static final long serialVersionUID = 108156477716619163L;
private static final long serialVersionUID = -1823370077523962901L;
/**
* Mouse Listener
@ -351,6 +351,11 @@ public class VPAttribute extends JComponent
if (m_mField != null)
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* Action Listener Interface

View File

@ -45,7 +45,7 @@ public final class VPassword extends CPassword
/**
*
*/
private static final long serialVersionUID = -1251556129161613098L;
private static final long serialVersionUID = 1659042515884579907L;
/**
* IDE Bean Constructor for 30 character updateable field
@ -194,6 +194,11 @@ public final class VPassword extends CPassword
m_mField = mField;
} // setField
@Override
public GridField getField() {
return m_mField;
}
@Override
public void focusGained(FocusEvent e) {
}

View File

@ -60,7 +60,8 @@ public final class VString extends CTextField
/**
*
*/
private static final long serialVersionUID = 3142768153171970900L;
private static final long serialVersionUID = 8487860095322876086L;
/** Max Display Length - 60 */
public static final int MAXDISPLAY_LENGTH = org.compiere.model.GridField.MAXDISPLAY_LENGTH;
@ -303,6 +304,11 @@ public final class VString extends CTextField
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* Feature Request [1707462]
* Set VFormat

View File

@ -55,9 +55,7 @@ public class VText extends CTextArea
/**
*
*/
private static final long serialVersionUID = -2873467246871800195L;
/*****************************************************************************/
private static final long serialVersionUID = 437954563775941704L;
/**
* Mouse Listener
@ -250,6 +248,11 @@ public class VText extends CTextArea
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
@Override
public void focusGained(FocusEvent e) {
}

View File

@ -54,12 +54,12 @@ import org.compiere.util.Msg;
public class VTextLong extends CTextPane
implements VEditor, KeyListener, ActionListener, FocusListener
{
/*****************************************************************************/
/**
*
*/
private static final long serialVersionUID = 2293022820407789036L;
/*****************************************************************************/
private static final long serialVersionUID = 6484690202241390248L;
/**
* Mouse Listener
@ -256,6 +256,11 @@ public class VTextLong extends CTextPane
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
@Override
public void focusGained(FocusEvent e) {
}

View File

@ -63,7 +63,7 @@ public class VURL extends JComponent
/**
*
*/
private static final long serialVersionUID = -350536181025487190L;
private static final long serialVersionUID = -3023749380845372419L;
/******************************************************************************
* Mouse Listener
@ -442,6 +442,10 @@ public class VURL extends JComponent
FieldRecordInfo.addMenu(this, popupMenu);
} // setField
@Override
public GridField getField() {
return m_mField;
}
/**
* Set Text