Hi,
We are using the calendar to show on the left a month view of a jplanner calendar and on the right and timeline view of a day on the calendar. This is exactly like the DualView sample.
We would like to be able to drag items from the right calendar and drop them on a day on the left calendar, catch that drop and then modify the item so that it's start date is the day that they dropped it on.
Is this possible and if so, do you have any hints or suggestions on how to do it?
I played around with adding a transfer handler on both of the calendars but it doesn't seem to hit the breakpoint I set in the canImport method.
Do I need to do something to the item to make it draggable to the other calendar?
I am going to paste in the code from the DualView Sample with some minor changes I made. Note that myTransferHandler just extends transfer handler and does nothing because I wanted to just check if the code was ran or not.
// Calendar initialization start
calendar.beginInit();
calendar.setCurrentView(CalendarView.MonthRange);
calendar.setTheme(ThemeType.Silver);
calendar.getMonthRangeSettings().setMonthsPerRow(1);
calendar.getMonthRangeSettings().setNumberOfMonths(2);
calendar.getMonthRangeSettings().setScrollInterval(1);
calendar.getSelection().setAllowMultiple(false);
calendar.getMonthSettings().getDaySettings().setHeaderSize(0);
// Select the current date
calendar.getSelection().set(DateTime.today());
calendar.setDate(DateTime.today());
calendar.endInit();
// Calendar initialization end
_schedule = new Calendar();
_schedule.setCurrentView(CalendarView.Timetable);
// Synchronize both views
_schedule.beginInit();
_schedule.setSchedule(calendar.getSchedule());
_schedule.setTheme(ThemeType.Silver);
_schedule.setDate(calendar.getDate());
_schedule.setEndDate(calendar.getEndDate());
_schedule.setAllowDrag(true);
_schedule.endInit();
Appointment app = new Appointment();
app.setStartTime(new DateTime(LocalDateTime.now().withHour(12).withMinute(0).withSecond(0).withNano(0)));
app.setEndTime(new DateTime(LocalDateTime.now().withHour(13).withMinute(0).withSecond(0).withNano(0)));
app.setHeaderText("Some Appointment");
MyTransferHandler handler = new MyTransferHandler();
_schedule.setTransferHandler(handler);
calendar.setTransferHandler(handler);
_schedule.getSchedule().getAllItems().add(app);
// Listen for selection changes
calendar.getSelection().addChangeListener(new ChangeListener(){
@Override
public void changed(EventObject e) {
onSelectionChanged();
}
});
// Listen for item creation/deletion/modification
_schedule.addCalendarListener(new CalendarAdapter(){
public void itemCreated(ItemEvent e) {
onItemCreated(e);
}
public void itemDeleted(ItemEvent e) {
onItemDeleted(e);
}
});
JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, calendar, _schedule);
pane.setDividerLocation(250);
content.add(pane);
Thanks in advance.