BF [ 1830531 ] Process parameter with type Account not working
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=1830531&group_id=176962
This commit is contained in:
parent
adfb8ffb1c
commit
3d5f101627
|
@ -23,6 +23,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.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.beans.PropertyVetoException;
|
import java.beans.PropertyVetoException;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
|
@ -46,14 +48,17 @@ import org.compiere.util.Env;
|
||||||
*
|
*
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: VAccount.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
* @version $Id: VAccount.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
|
*
|
||||||
|
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
|
||||||
|
* <li>BF [ 1830531 ] Process parameter with type Account not working
|
||||||
*/
|
*/
|
||||||
public final class VAccount extends JComponent
|
public final class VAccount extends JComponent
|
||||||
implements VEditor, ActionListener
|
implements VEditor, ActionListener, FocusListener
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 906418220544555281L;
|
private static final long serialVersionUID = -3397625857773619178L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -82,6 +87,7 @@ public final class VAccount extends JComponent
|
||||||
// *** Button & Text ***
|
// *** Button & Text ***
|
||||||
m_text.setBorder(null);
|
m_text.setBorder(null);
|
||||||
m_text.addActionListener(this);
|
m_text.addActionListener(this);
|
||||||
|
m_text.addFocusListener(this);
|
||||||
m_text.setFont(AdempierePLAF.getFont_Field());
|
m_text.setFont(AdempierePLAF.getFont_Field());
|
||||||
m_text.setForeground(AdempierePLAF.getTextColor_Normal());
|
m_text.setForeground(AdempierePLAF.getTextColor_Normal());
|
||||||
this.add(m_text, BorderLayout.CENTER);
|
this.add(m_text, BorderLayout.CENTER);
|
||||||
|
@ -263,14 +269,19 @@ public final class VAccount extends JComponent
|
||||||
public void cmd_button()
|
public void cmd_button()
|
||||||
{
|
{
|
||||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||||
int C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID");
|
int C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID", false);
|
||||||
|
// Try to get C_AcctSchema_ID from global context - teo_sarca BF [ 1830531 ]
|
||||||
|
if (C_AcctSchema_ID <= 0)
|
||||||
|
{
|
||||||
|
C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), "$C_AcctSchema_ID");
|
||||||
|
}
|
||||||
VAccountDialog ad = new VAccountDialog (Env.getFrame(this), m_title,
|
VAccountDialog ad = new VAccountDialog (Env.getFrame(this), m_title,
|
||||||
m_mAccount, C_AcctSchema_ID);
|
m_mAccount, C_AcctSchema_ID);
|
||||||
setCursor(Cursor.getDefaultCursor());
|
setCursor(Cursor.getDefaultCursor());
|
||||||
//
|
//
|
||||||
Integer newValue = ad.getValue();
|
Integer newValue = ad.getValue();
|
||||||
if (newValue == null)
|
// if (newValue == null)
|
||||||
return;
|
// return;
|
||||||
|
|
||||||
// set & redisplay
|
// set & redisplay
|
||||||
setValue(newValue);
|
setValue(newValue);
|
||||||
|
@ -285,16 +296,22 @@ public final class VAccount extends JComponent
|
||||||
}
|
}
|
||||||
} // cmd_button
|
} // cmd_button
|
||||||
|
|
||||||
|
private boolean m_cmdTextRunning = false;
|
||||||
/**
|
/**
|
||||||
* Text - try to find Alias or start Dialog
|
* Text - try to find Alias or start Dialog
|
||||||
*/
|
*/
|
||||||
public void cmd_text()
|
public void cmd_text()
|
||||||
{
|
{
|
||||||
|
if (m_cmdTextRunning)
|
||||||
|
return;
|
||||||
|
m_cmdTextRunning = true;
|
||||||
|
|
||||||
String text = m_text.getText();
|
String text = m_text.getText();
|
||||||
log.info("Text=" + text);
|
log.info("Text=" + text);
|
||||||
if (text == null || text.length() == 0 || text.equals("%"))
|
if (text == null || text.length() == 0 || text.equals("%"))
|
||||||
{
|
{
|
||||||
cmd_button();
|
cmd_button();
|
||||||
|
m_cmdTextRunning = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!text.endsWith("%"))
|
if (!text.endsWith("%"))
|
||||||
|
@ -344,6 +361,10 @@ public final class VAccount extends JComponent
|
||||||
if (C_ValidCombination_ID > 0)
|
if (C_ValidCombination_ID > 0)
|
||||||
{
|
{
|
||||||
Integer newValue = new Integer(C_ValidCombination_ID);
|
Integer newValue = new Integer(C_ValidCombination_ID);
|
||||||
|
|
||||||
|
// set & redisplay
|
||||||
|
setValue(newValue);
|
||||||
|
|
||||||
// Data Binding
|
// Data Binding
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -355,6 +376,8 @@ public final class VAccount extends JComponent
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cmd_button();
|
cmd_button();
|
||||||
|
|
||||||
|
m_cmdTextRunning = false;
|
||||||
} // actionPerformed
|
} // actionPerformed
|
||||||
|
|
||||||
|
|
||||||
|
@ -387,5 +410,29 @@ public final class VAccount extends JComponent
|
||||||
sb.append (m_value).append ("]");
|
sb.append (m_value).append ("]");
|
||||||
return sb.toString ();
|
return sb.toString ();
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
|
public void focusGained(FocusEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void focusLost(FocusEvent e)
|
||||||
|
{
|
||||||
|
if (m_text == null) return; // arhipac: teo_sarca: already disposed
|
||||||
|
// Test Case: Open a window, click on account field that is mandatory but not filled, close the window and you will get an NPE
|
||||||
|
// TODO: integrate to trunk
|
||||||
|
// New text
|
||||||
|
String newText = m_text.getText();
|
||||||
|
if (newText == null)
|
||||||
|
newText = "";
|
||||||
|
// Actual text
|
||||||
|
String actualText = m_mAccount.getDisplay(m_value);
|
||||||
|
if (actualText == null)
|
||||||
|
actualText = "";
|
||||||
|
// If text was modified, try to resolve the valid combination
|
||||||
|
if (!newText.equals(actualText))
|
||||||
|
{
|
||||||
|
cmd_text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // VAccount
|
} // VAccount
|
Loading…
Reference in New Issue