if ( lDayX <= mouseEvent.getScreenX() && mouseEvent.getScreenX() < lDayX + lDayPane.getWidth()
&& lDayY <= mouseEvent.getScreenY() && mouseEvent.getScreenY() < lDayY + lDayPane.getHeight()
)
{
// get the appointment that needs handling
Appointment lAppointment = AbstractAppointmentPane.this.appointment;
Calendar lDroppedOnCalendar = lDayPane.calendarObjectProperty.get();
// is wholeday now, will become partial
if (lAppointment.isWholeDay())
{
// calculate new start
Calendar lStartCalendar = copyYMD( lDroppedOnCalendar, (Calendar)lAppointment.getStartTime().clone() );
// and end times
Calendar lEndCalendar = lAppointment.getEndTime() == null ? setTimeTo2359( (Calendar)lDroppedOnCalendar.clone() ) : copyYMD( lDroppedOnCalendar, (Calendar)lAppointment.getEndTime().clone() );
// set the new enddate
lAppointment.setStartTime(lStartCalendar);
lAppointment.setEndTime(lEndCalendar);
// no longer whole day
lAppointment.setWholeDay(false);
}
{
// calculate new start
Calendar lStartCalendar = copyYMD(lDroppedOnCalendar, (Calendar)lAppointment.getStartTime().clone());
// also add the delta Y minutes
int lDeltaDurationInMS = (int)((mouseEvent.getScreenY() - startY) * durationInMSPerPixelProperty.get());
lStartCalendar.add(Calendar.MILLISECOND, lDeltaDurationInMS);
setTimeToNearestMinutes(lStartCalendar, 5);
while (isSameDay(lStartCalendar, lDroppedOnCalendar) == false && lStartCalendar.before(lDroppedOnCalendar)) { lStartCalendar.add(Calendar.MINUTE, 1); }// the delta may have pushed it out of today
while (isSameDay(lStartCalendar, lDroppedOnCalendar) == false && lStartCalendar.after(lDroppedOnCalendar)) { lStartCalendar.add(Calendar.MINUTE, -1); }// the delta may have pushed it out of today
// duration -> enddate (take tasks -which have no enddate- into account)
Calendar lEndCalendar = null;
if (lAppointment.getEndTime() != null)
{
long lDurationInMS = lAppointment.getEndTime().getTimeInMillis() - lAppointment.getStartTime().getTimeInMillis();
lEndCalendar = (Calendar)lStartCalendar.clone();
lEndCalendar.add(Calendar.MILLISECOND, (int)lDurationInMS);
}
// set dates
lAppointment.setStartTime(lStartCalendar);
lAppointment.setEndTime(lEndCalendar);
}
}
}
// find out where it was dropped
for (DayHeaderPane lDayHeaderPane : weekHeaderPane.dayHeaderPanes)
{
double lDayX = NodeUtil.screenX(lDayHeaderPane);
double lDayY = NodeUtil.screenY(lDayHeaderPane);
if ( lDayX <= mouseEvent.getScreenX() && mouseEvent.getScreenX() < lDayX + lDayHeaderPane.getWidth()
&& lDayY <= mouseEvent.getScreenY() && mouseEvent.getScreenY() < lDayY + lDayHeaderPane.getHeight()
)
{
// get the appointment that needs handling
Appointment lAppointment = AbstractAppointmentPane.this.appointment;
// calculate new start
Calendar lStartCalendar = copyYMD(lDayHeaderPane.dayPane.calendarObjectProperty.get(), (Calendar)lAppointment.getStartTime().clone() );
// set the new start date
lAppointment.setStartTime(lStartCalendar);
// enddate can be ignored
// now a whole day (just in case it wasn't)
lAppointment.setWholeDay(true);
}
}
// redo whole week
setupAppointments();