1 | public class CopyEventCommand extends Command {↵ | | 1 | public class MoveEventCommand extends Command {↵
|
|
2 | public CopyEventCommand(CalendarCommandReference ref) {↵ | | 2 | public MoveEventCommand(CalendarCommandReference ref) {↵
|
3 | super(ref);↵ | | 3 | super(ref);↵
|
|
4 | }↵ | | 4 | }↵
|
|
5 | @Override↵ | | 5 | @Override↵
|
6 | public void execute(IWorkerStatusController worker) throws Exception {↵ | | 6 | public void execute(IWorkerStatusController worker) throws Exception {↵
|
7 | ICalendarStore store = ((CalendarCommandReference) getReference())↵ | | 7 | ICalendarStore store = ((CalendarCommandReference) getReference())↵
|
8 | .getStore();↵ | | 8 | .getStore();↵
|
|
9 | ICalendarItem calendar = ((CalendarCommandReference) getReference())↵ | | 9 | ICalendarItem calendar = ((CalendarCommandReference) getReference())↵
|
10 | .getSrcCalendar();↵ | | 10 | .getSrcCalendar();↵
|
|
11 | IActivity eventItem = ((CalendarCommandReference) getReference())↵ | | 11 | IActivity eventItem = ((CalendarCommandReference) getReference())↵
|
12 | .getActivity();↵ | | 12 | .getActivity();↵
|
|
13 | try {↵ | | 13 | try {↵
|
14 | // retrieve event from store↵ | | 14 | // retrieve event from store↵
|
15 | IEventInfo event = (IEventInfo) store.get(eventItem.getId());↵ | | 15 | IEventInfo event = (IEventInfo) store.get(eventItem.getId());↵
|
|
16 | IEventInfo copy = (IEventInfo) event.createCopy();↵ | | |
|
|
17 | // set new calendar id↵ | | 16 | // set new calendar id↵
|
18 | copy.setCalendar(calendar.getId());↵ | | 17 | event.setCalendar(calendar.getId());↵
|
|
19 | // persist modified calendar↵ | | 18 | // persist modified calendar↵
|
20 | store.add(copy);↵ | | 19 | store.modify(eventItem.getId(), event);↵
|
|
21 | } catch (StoreException e1) {↵ | | 20 | } catch (StoreException e) {↵
|
22 | JOptionPane.showMessageDialog(FrameManager.getInstance()↵ | | 21 | JOptionPane.showMessageDialog(FrameManager.getInstance()↵
|
23 | .getActiveFrame(), e1.getMessage());↵ | | 22 | .getActiveFrame(), e.getMessage());↵
|
24 | e1.printStackTrace() | | 23 | e.printStackTrace()
|