Implement [1685158] - Modify Callout Behaviour - changed calling callout per keystroke in swing to focuslost - consistent with zkwebui behavior

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=1685158
This commit is contained in:
Carlos Ruiz 2010-03-26 14:51:32 +00:00
parent f101ae3063
commit 805b30e6d9
9 changed files with 138 additions and 89 deletions

View File

@ -476,17 +476,6 @@ public class VDate extends JComponent
// ESC // ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
m_text.setText(m_initialText); 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 } // keyReleased
/** /**
@ -503,6 +492,18 @@ public class VDate extends JComponent
*/ */
public void focusLost (FocusEvent e) 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 // did not get Focus first
if (e.isTemporary()) if (e.isTemporary())
return; return;

View File

@ -22,6 +22,8 @@ import java.awt.Dimension;
import java.awt.Insets; import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
@ -51,12 +53,12 @@ import org.compiere.util.Msg;
* @author Teo Sarca * @author Teo Sarca
*/ */
public class VFile extends JComponent 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 * Mouse Listener for Popup Menu
@ -129,6 +131,7 @@ public class VFile extends JComponent
m_text.setForeground(AdempierePLAF.getTextColor_Normal()); m_text.setForeground(AdempierePLAF.getTextColor_Normal());
m_text.addMouseListener(new VFile_mouseAdapter(this)); m_text.addMouseListener(new VFile_mouseAdapter(this));
m_text.addKeyListener(this); m_text.addKeyListener(this);
m_text.addFocusListener(this);
this.add(m_text, BorderLayout.CENTER); this.add(m_text, BorderLayout.CENTER);
// Editable // Editable
@ -394,6 +397,22 @@ public class VFile extends JComponent
// Ignore keys that do not alter the text // Ignore keys that do not alter the text
else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED) else if (e.getKeyChar() == KeyEvent.CHAR_UNDEFINED)
return; 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; m_setting = true;
try try
{ {
@ -406,6 +425,6 @@ public class VFile extends JComponent
{ {
} }
m_setting = false; m_setting = false;
} } // focusLost
} // VFile } // VFile

View File

@ -245,18 +245,6 @@ public class VMemo extends CTextArea
setText(m_oldText); setText(m_oldText);
return; 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 } // keyReleased
/** /**
@ -278,10 +266,14 @@ public class VMemo extends CTextArea
*/ */
public void focusLost (FocusEvent e) public void focusLost (FocusEvent e)
{ {
//log.config( "VMemo.focusLost " + e.getSource(), e.paramString()); // Indicate Change
// something changed? log.fine( "focusLost");
return; try
{
String text = getText();
fireVetoableChange(m_columnName, text, null); // No data committed - done when focus lost !!!
}
catch (PropertyVetoException pve) {}
} // focusLost } // focusLost
/*************************************************************************/ /*************************************************************************/

View File

@ -604,11 +604,11 @@ public final class VNumber extends JComponent
fireVetoableChange (m_columnName, m_oldText, getValue()); fireVetoableChange (m_columnName, m_oldText, getValue());
fireActionPerformed(); fireActionPerformed();
} }
else // else
{ // {
// indicate change // indicate change
fireVetoableChange (m_columnName, m_oldText, null); // fireVetoableChange (m_columnName, m_oldText, null);
} // }
} }
catch (PropertyVetoException pve) {} catch (PropertyVetoException pve) {}
m_setting = false; m_setting = false;

View File

@ -18,6 +18,8 @@ package org.compiere.grid.ed;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.beans.PropertyChangeEvent; 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 $ * @version $Id: VPassword.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/ */
public final class VPassword extends CPassword 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 * IDE Bean Constructor for 30 character updateable field
@ -88,6 +90,7 @@ public final class VPassword extends CPassword
} }
this.addKeyListener(this); this.addKeyListener(this);
this.addFocusListener(this);
this.addActionListener(this); this.addActionListener(this);
setForeground(AdempierePLAF.getTextColor_Normal()); setForeground(AdempierePLAF.getTextColor_Normal());
@ -165,14 +168,6 @@ public final class VPassword extends CPassword
*/ */
public void keyReleased(KeyEvent e) 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 } // keyReleased
/** /**
@ -199,5 +194,21 @@ public final class VPassword extends CPassword
m_mField = mField; m_mField = mField;
} // setField } // 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 } // VPassword

View File

@ -133,7 +133,6 @@ public final class VString extends CTextField
m_obscure = new Obscure ("", ObscureType); m_obscure = new Obscure ("", ObscureType);
m_stdFont = getFont(); m_stdFont = getFont();
m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize()); m_obscureFont = new Font("SansSerif", Font.ITALIC, m_stdFont.getSize());
addFocusListener(this);
} }
// Editable // Editable
@ -145,6 +144,7 @@ public final class VString extends CTextField
this.addKeyListener(this); this.addKeyListener(this);
this.addActionListener(this); this.addActionListener(this);
this.addFocusListener(this);
addMouseListener(new VString_mouseAdapter(this)); addMouseListener(new VString_mouseAdapter(this));
// Popup for Editor // Popup for Editor
if (fieldLength > displayLength) if (fieldLength > displayLength)
@ -252,18 +252,6 @@ public final class VString extends CTextField
// ESC // ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
setText(m_initialText); 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 } // keyReleased
/** /**
@ -408,6 +396,19 @@ public final class VString extends CTextField
*/ */
public void focusLost (FocusEvent e) 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; m_infocus = false;
setText(getText()); // obscure setText(getText()); // obscure
} // focus Lost } // focus Lost

View File

@ -20,6 +20,8 @@ import java.awt.Component;
import java.awt.Container; import java.awt.Container;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter; 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 $ * @version $Id: VText.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/ */
public class VText extends CTextArea 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) if (isReadOnly || !isUpdateable)
setReadWrite(false); setReadWrite(false);
addKeyListener(this); addKeyListener(this);
addFocusListener(this);
// Popup // Popup
addMouseListener(new VText_mouseAdapter(this)); addMouseListener(new VText_mouseAdapter(this));
@ -233,13 +236,6 @@ public class VText extends CTextArea
// ESC // ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
setText(m_initialText); setText(m_initialText);
m_setting = true;
try
{
fireVetoableChange(m_columnName, m_oldText, getText());
}
catch (PropertyVetoException pve) {}
m_setting = false;
} // keyReleased } // keyReleased
/** /**
@ -253,4 +249,19 @@ public class VText extends CTextArea
FieldRecordInfo.addMenu(this, popupMenu); FieldRecordInfo.addMenu(this, popupMenu);
} // setField } // 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 } // VText

View File

@ -21,6 +21,8 @@ import java.awt.Container;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter; 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 $ * @version $Id: VTextLong.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/ */
public class VTextLong extends CTextPane 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) if (isReadOnly || !isUpdateable)
setReadWrite(false); setReadWrite(false);
addKeyListener(this); addKeyListener(this);
addFocusListener(this);
// Popup // Popup
addMouseListener(new VTextLong_mouseAdapter(this)); addMouseListener(new VTextLong_mouseAdapter(this));
@ -239,13 +242,6 @@ public class VTextLong extends CTextPane
// ESC // ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
setText(m_initialText); setText(m_initialText);
m_setting = true;
try
{
fireVetoableChange(m_columnName, m_oldText, getText());
}
catch (PropertyVetoException pve) {}
m_setting = false;
} // keyReleased } // keyReleased
/** /**
@ -259,5 +255,20 @@ public class VTextLong extends CTextPane
FieldRecordInfo.addMenu(this, popupMenu); FieldRecordInfo.addMenu(this, popupMenu);
} // setField } // 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 } // VTextLong

View File

@ -24,6 +24,7 @@ import java.awt.Insets;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusEvent; import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter; 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 $ * @version $Id: VURL.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
*/ */
public class VURL extends JComponent 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 * Mouse Listener
@ -151,6 +152,7 @@ public class VURL extends JComponent
setReadWrite(true); setReadWrite(true);
m_text.addKeyListener(this); m_text.addKeyListener(this);
m_text.addFocusListener(this);
m_text.addActionListener(this); m_text.addActionListener(this);
m_text.addMouseListener(new VURL_mouseAdapter(this)); m_text.addMouseListener(new VURL_mouseAdapter(this));
// Popup for Editor // Popup for Editor
@ -336,18 +338,6 @@ public class VURL extends JComponent
// ESC // ESC
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
setText(m_initialText); 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 } // keyReleased
/** /**
@ -491,6 +481,19 @@ public class VURL extends JComponent
*/ */
public void focusLost (FocusEvent e) 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; m_infocus = false;
setText(getText()); // obscure setText(getText()); // obscure
} // focus Lost } // focus Lost