BF [2891211] - VDate: once a date is set, its not possible to NULL it
https://sourceforge.net/tracker/?func=detail&atid=879332&aid=2891211&group_id=176962
This commit is contained in:
parent
57208125e6
commit
c88e6c5875
|
@ -135,6 +135,8 @@ public class Calendar extends CDialog
|
|||
private boolean m_abort = true;
|
||||
/** Cancel = set null */
|
||||
private boolean m_cancel = false;
|
||||
/** Clear = set new Timestamp(-1) */
|
||||
private boolean m_clear = false;
|
||||
//
|
||||
private long m_lastClick = System.currentTimeMillis();
|
||||
private int m_lastDay = -1;
|
||||
|
@ -330,6 +332,10 @@ public class Calendar extends CDialog
|
|||
m_days[m_days.length-2].setBackground(Color.red);
|
||||
m_days[m_days.length-2].setText("x");
|
||||
m_days[m_days.length-2].setToolTipText(Msg.getMsg(Env.getCtx(), "Cancel"));
|
||||
// Clear
|
||||
m_days[m_days.length-3].setBackground(Color.yellow);
|
||||
m_days[m_days.length-3].setText("c");
|
||||
m_days[m_days.length-3].setToolTipText(Msg.getMsg(Env.getCtx(), "Clear"));
|
||||
|
||||
// Date/Time
|
||||
m_current24Hour = m_calendar.get(java.util.Calendar.HOUR_OF_DAY);
|
||||
|
@ -443,7 +449,7 @@ public class Calendar extends CDialog
|
|||
|
||||
// for all buttons but the last
|
||||
int curDay = 1;
|
||||
for (int i = 0; i < m_days.length-2; i++)
|
||||
for (int i = 0; i < m_days.length-3; i++)
|
||||
{
|
||||
if (i >= dayOne && i <= lastDate)
|
||||
{
|
||||
|
@ -537,8 +543,14 @@ public class Calendar extends CDialog
|
|||
m_calendar.set(java.util.Calendar.MILLISECOND, 0);
|
||||
|
||||
// Return value
|
||||
if (m_abort || m_cancel)
|
||||
return null;
|
||||
if (m_abort || m_cancel)
|
||||
{
|
||||
if (m_clear)
|
||||
// 1970-01-01 04:59:59.999
|
||||
return new Timestamp(-1);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
long time = m_calendar.getTimeInMillis();
|
||||
if (m_displayType == DisplayType.Date)
|
||||
time = new java.sql.Date(time).getTime();
|
||||
|
@ -556,6 +568,15 @@ public class Calendar extends CDialog
|
|||
return m_cancel;
|
||||
} // isCancel
|
||||
|
||||
/**
|
||||
* Clear button pressed
|
||||
* @return true if canceled
|
||||
*/
|
||||
public boolean isClear()
|
||||
{
|
||||
return m_clear;
|
||||
} // isCancel
|
||||
|
||||
/**************************************************************************
|
||||
* Action Listener for Month/Year combo & date buttons.
|
||||
* - Double clicking on a date closes it
|
||||
|
@ -614,6 +635,13 @@ public class Calendar extends CDialog
|
|||
dispose();
|
||||
return;
|
||||
}
|
||||
// Clear
|
||||
else if (text.equals("c"))
|
||||
{
|
||||
m_clear = true;
|
||||
dispose();
|
||||
return;
|
||||
}
|
||||
// we have a day
|
||||
else if (text.length() > 0)
|
||||
{
|
||||
|
|
|
@ -547,8 +547,10 @@ public class VDate extends JComponent
|
|||
AEnv.showCenterWindow(frame, cal);
|
||||
Timestamp result = cal.getTimestamp();
|
||||
log.config( "Result=" + result);
|
||||
if (result == null && !cal.isCancel()) // F3P: added check for 'isCancel',
|
||||
if (result == null)
|
||||
result = value; // original
|
||||
else if (result.compareTo(new Timestamp(-1))==0)
|
||||
result = null;
|
||||
cal = null;
|
||||
return result;
|
||||
} // startCalendar
|
||||
|
|
Loading…
Reference in New Issue