diff --git a/client/src/org/compiere/grid/ed/VDate.java b/client/src/org/compiere/grid/ed/VDate.java index 05962797e4..352e4da25d 100644 --- a/client/src/org/compiere/grid/ed/VDate.java +++ b/client/src/org/compiere/grid/ed/VDate.java @@ -476,17 +476,6 @@ public class VDate extends JComponent // ESC if (e.getKeyCode() == KeyEvent.VK_ESCAPE) m_text.setText(m_initialText); - m_setting = true; - try - { - Timestamp ts = getTimestamp(); // getValue - if (ts == null) // format error - just indicate change - fireVetoableChange (m_columnName, m_oldText, null); - else - fireVetoableChange (m_columnName, m_oldText, ts); - } - catch (PropertyVetoException pve) {} - m_setting = false; } // keyReleased /** @@ -503,6 +492,18 @@ public class VDate extends JComponent */ public void focusLost (FocusEvent e) { + m_setting = true; + try + { + Timestamp ts = getTimestamp(); // getValue + if (ts == null) // format error - just indicate change + fireVetoableChange (m_columnName, m_oldText, null); + else + fireVetoableChange (m_columnName, m_oldText, ts); + } + catch (PropertyVetoException pve) {} + m_setting = false; + // did not get Focus first if (e.isTemporary()) return; diff --git a/client/src/org/compiere/grid/ed/VFile.java b/client/src/org/compiere/grid/ed/VFile.java index d94469afe8..e348291b48 100644 --- a/client/src/org/compiere/grid/ed/VFile.java +++ b/client/src/org/compiere/grid/ed/VFile.java @@ -22,6 +22,8 @@ import java.awt.Dimension; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseEvent; @@ -51,12 +53,12 @@ import org.compiere.util.Msg; * @author Teo Sarca */ public class VFile extends JComponent - implements VEditor, ActionListener, KeyListener + implements VEditor, ActionListener, KeyListener, FocusListener { /** * */ - private static final long serialVersionUID = 7246339063197204992L; + private static final long serialVersionUID = -4665930745414194731L; /****************************************************************************** * Mouse Listener for Popup Menu @@ -129,6 +131,7 @@ public class VFile extends JComponent m_text.setForeground(AdempierePLAF.getTextColor_Normal()); m_text.addMouseListener(new VFile_mouseAdapter(this)); m_text.addKeyListener(this); + m_text.addFocusListener(this); this.add(m_text, BorderLayout.CENTER); // Editable @@ -394,6 +397,22 @@ public class VFile extends JComponent // Ignore keys that do not alter the text else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) return; + } + + /** + * Focus Gained - Save for Escape + * @param e event + */ + public void focusGained (FocusEvent e) + { + } // focusGained + + /** + * Data Binding to to GridController. + * @param e event + */ + public void focusLost (FocusEvent e) + { m_setting = true; try { @@ -406,6 +425,6 @@ public class VFile extends JComponent { } m_setting = false; - } + } // focusLost } // VFile diff --git a/client/src/org/compiere/grid/ed/VMemo.java b/client/src/org/compiere/grid/ed/VMemo.java index 0a3bc5c954..612861acd5 100644 --- a/client/src/org/compiere/grid/ed/VMemo.java +++ b/client/src/org/compiere/grid/ed/VMemo.java @@ -245,18 +245,6 @@ public class VMemo extends CTextArea setText(m_oldText); return; } - // Indicate Change - if (m_firstChange && !m_oldText.equals(getText())) - { - log.fine( "VMemo.keyReleased - firstChange"); - m_firstChange = false; - try - { - String text = getText(); - fireVetoableChange(m_columnName, text, null); // No data committed - done when focus lost !!! - } - catch (PropertyVetoException pve) {} - } // firstChange } // keyReleased /** @@ -278,10 +266,14 @@ public class VMemo extends CTextArea */ public void focusLost (FocusEvent e) { - //log.config( "VMemo.focusLost " + e.getSource(), e.paramString()); - // something changed? - return; - + // Indicate Change + log.fine( "focusLost"); + try + { + String text = getText(); + fireVetoableChange(m_columnName, text, null); // No data committed - done when focus lost !!! + } + catch (PropertyVetoException pve) {} } // focusLost /*************************************************************************/ diff --git a/client/src/org/compiere/grid/ed/VNumber.java b/client/src/org/compiere/grid/ed/VNumber.java index c166e4d279..788e008f4c 100644 --- a/client/src/org/compiere/grid/ed/VNumber.java +++ b/client/src/org/compiere/grid/ed/VNumber.java @@ -604,11 +604,11 @@ public final class VNumber extends JComponent fireVetoableChange (m_columnName, m_oldText, getValue()); fireActionPerformed(); } - else - { + // else + // { // indicate change - fireVetoableChange (m_columnName, m_oldText, null); - } + // fireVetoableChange (m_columnName, m_oldText, null); + // } } catch (PropertyVetoException pve) {} m_setting = false; diff --git a/client/src/org/compiere/grid/ed/VPassword.java b/client/src/org/compiere/grid/ed/VPassword.java index d4a5d87407..2106bf9a73 100644 --- a/client/src/org/compiere/grid/ed/VPassword.java +++ b/client/src/org/compiere/grid/ed/VPassword.java @@ -18,6 +18,8 @@ package org.compiere.grid.ed; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.beans.PropertyChangeEvent; @@ -38,12 +40,12 @@ import org.compiere.swing.CPassword; * @version $Id: VPassword.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ */ public final class VPassword extends CPassword - implements VEditor, KeyListener, ActionListener + implements VEditor, KeyListener, ActionListener, FocusListener { /** * */ - private static final long serialVersionUID = -7727795751575110982L; + private static final long serialVersionUID = -1251556129161613098L; /** * IDE Bean Constructor for 30 character updateable field @@ -88,6 +90,7 @@ public final class VPassword extends CPassword } this.addKeyListener(this); + this.addFocusListener(this); this.addActionListener(this); setForeground(AdempierePLAF.getTextColor_Normal()); @@ -165,14 +168,6 @@ public final class VPassword extends CPassword */ public void keyReleased(KeyEvent e) { - String newText = String.valueOf(getPassword()); - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, newText); - } - catch (PropertyVetoException pve) {} - m_setting = false; } // keyReleased /** @@ -199,5 +194,21 @@ public final class VPassword extends CPassword m_mField = mField; } // setField + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + String newText = String.valueOf(getPassword()); + m_setting = true; + try + { + fireVetoableChange(m_columnName, m_oldText, newText); + } + catch (PropertyVetoException pve) {} + m_setting = false; + } + } // VPassword diff --git a/client/src/org/compiere/grid/ed/VString.java b/client/src/org/compiere/grid/ed/VString.java index 739ff605b0..25833e2943 100644 --- a/client/src/org/compiere/grid/ed/VString.java +++ b/client/src/org/compiere/grid/ed/VString.java @@ -133,7 +133,6 @@ public final class VString extends CTextField m_obscure = new Obscure ("", ObscureType); m_stdFont = getFont(); m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize()); - addFocusListener(this); } // Editable @@ -145,6 +144,7 @@ public final class VString extends CTextField this.addKeyListener(this); this.addActionListener(this); + this.addFocusListener(this); addMouseListener(new VString_mouseAdapter(this)); // Popup for Editor if (fieldLength > displayLength) @@ -252,18 +252,6 @@ public final class VString extends CTextField // ESC if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setText(m_initialText); - m_setting = true; - try - { - String clear = getText(); - if (clear.length() > m_fieldLength) - clear = clear.substring(0, m_fieldLength); - fireVetoableChange (m_columnName, m_oldText, clear); - } - catch (PropertyVetoException pve) - { - } - m_setting = false; } // keyReleased /** @@ -408,6 +396,19 @@ public final class VString extends CTextField */ public void focusLost (FocusEvent e) { + m_setting = true; + try + { + String clear = getText(); + if (clear.length() > m_fieldLength) + clear = clear.substring(0, m_fieldLength); + fireVetoableChange (m_columnName, m_oldText, clear); + } + catch (PropertyVetoException pve) + { + } + m_setting = false; + m_infocus = false; setText(getText()); // obscure } // focus Lost diff --git a/client/src/org/compiere/grid/ed/VText.java b/client/src/org/compiere/grid/ed/VText.java index 4d2517a766..bdd16088fe 100644 --- a/client/src/org/compiere/grid/ed/VText.java +++ b/client/src/org/compiere/grid/ed/VText.java @@ -20,6 +20,8 @@ import java.awt.Component; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; @@ -47,12 +49,12 @@ import org.compiere.util.Msg; * @version $Id: VText.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ */ public class VText extends CTextArea - implements VEditor, KeyListener, ActionListener + implements VEditor, KeyListener, ActionListener, FocusListener { /** * */ - private static final long serialVersionUID = -2479847373606754733L; + private static final long serialVersionUID = -2873467246871800195L; /*****************************************************************************/ @@ -115,6 +117,7 @@ public class VText extends CTextArea if (isReadOnly || !isUpdateable) setReadWrite(false); addKeyListener(this); + addFocusListener(this); // Popup addMouseListener(new VText_mouseAdapter(this)); @@ -233,13 +236,6 @@ public class VText extends CTextArea // ESC if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setText(m_initialText); - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) {} - m_setting = false; } // keyReleased /** @@ -253,4 +249,19 @@ public class VText extends CTextArea FieldRecordInfo.addMenu(this, popupMenu); } // setField + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + m_setting = true; + try + { + fireVetoableChange(m_columnName, m_oldText, getText()); + } + catch (PropertyVetoException pve) {} + m_setting = false; + } + } // VText diff --git a/client/src/org/compiere/grid/ed/VTextLong.java b/client/src/org/compiere/grid/ed/VTextLong.java index fca17244a0..cd0a08c1bf 100644 --- a/client/src/org/compiere/grid/ed/VTextLong.java +++ b/client/src/org/compiere/grid/ed/VTextLong.java @@ -21,6 +21,8 @@ import java.awt.Container; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; @@ -49,12 +51,12 @@ import org.compiere.util.Msg; * @version $Id: VTextLong.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ */ public class VTextLong extends CTextPane - implements VEditor, KeyListener, ActionListener + implements VEditor, KeyListener, ActionListener, FocusListener { /** * */ - private static final long serialVersionUID = 4776186117962407679L; + private static final long serialVersionUID = 2293022820407789036L; /*****************************************************************************/ @@ -133,6 +135,7 @@ public class VTextLong extends CTextPane if (isReadOnly || !isUpdateable) setReadWrite(false); addKeyListener(this); + addFocusListener(this); // Popup addMouseListener(new VTextLong_mouseAdapter(this)); @@ -239,13 +242,6 @@ public class VTextLong extends CTextPane // ESC if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setText(m_initialText); - m_setting = true; - try - { - fireVetoableChange(m_columnName, m_oldText, getText()); - } - catch (PropertyVetoException pve) {} - m_setting = false; } // keyReleased /** @@ -259,5 +255,20 @@ public class VTextLong extends CTextPane FieldRecordInfo.addMenu(this, popupMenu); } // setField + @Override + public void focusGained(FocusEvent e) { + } + + @Override + public void focusLost(FocusEvent e) { + m_setting = true; + try + { + fireVetoableChange(m_columnName, m_oldText, getText()); + } + catch (PropertyVetoException pve) {} + m_setting = false; + } + } // VTextLong \ No newline at end of file diff --git a/client/src/org/compiere/grid/ed/VURL.java b/client/src/org/compiere/grid/ed/VURL.java index 2cd4deb885..0154ad8ec1 100644 --- a/client/src/org/compiere/grid/ed/VURL.java +++ b/client/src/org/compiere/grid/ed/VURL.java @@ -24,6 +24,7 @@ import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; @@ -57,12 +58,12 @@ import org.compiere.util.Msg; * @version $Id: VURL.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $ */ public class VURL extends JComponent - implements VEditor, ActionListener, KeyListener + implements VEditor, ActionListener, KeyListener, FocusListener { /** * */ - private static final long serialVersionUID = -5090157084793992376L; + private static final long serialVersionUID = -350536181025487190L; /****************************************************************************** * Mouse Listener @@ -151,6 +152,7 @@ public class VURL extends JComponent setReadWrite(true); m_text.addKeyListener(this); + m_text.addFocusListener(this); m_text.addActionListener(this); m_text.addMouseListener(new VURL_mouseAdapter(this)); // Popup for Editor @@ -336,18 +338,6 @@ public class VURL extends JComponent // ESC if (e.getKeyCode() == KeyEvent.VK_ESCAPE) setText(m_initialText); - m_setting = true; - try - { - String clear = getText(); - if (clear.length() > m_fieldLength) - clear = clear.substring(0, m_fieldLength); - fireVetoableChange (m_columnName, m_oldText, clear); - } - catch (PropertyVetoException pve) - { - } - m_setting = false; } // keyReleased /** @@ -491,6 +481,19 @@ public class VURL extends JComponent */ public void focusLost (FocusEvent e) { + m_setting = true; + try + { + String clear = getText(); + if (clear.length() > m_fieldLength) + clear = clear.substring(0, m_fieldLength); + fireVetoableChange (m_columnName, m_oldText, clear); + } + catch (PropertyVetoException pve) + { + } + m_setting = false; + m_infocus = false; setText(getText()); // obscure } // focus Lost