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