01: package org.columba.calendar.facade;
02:
03: import java.net.URI;
04:
05: import javax.swing.JOptionPane;
06:
07: import org.columba.calendar.model.api.IEventInfo;
08: import org.columba.calendar.store.CalendarStoreFactory;
09: import org.columba.calendar.store.api.ICalendarStore;
10: import org.columba.calendar.store.api.StoreException;
11: import org.columba.calendar.ui.dialog.EditEventDialog;
12: import org.columba.core.gui.frame.FrameManager;
13:
14: public class DialogFacade {
15:
16: public void openEventEditorDialog(URI location) {
17: String s = location.toString();
18: // TODO: @author fdietz replace with regular expression
19: int activityIndex = s.lastIndexOf('/');
20: String activityId = s.substring(activityIndex + 1, s.length());
21: int folderIndex = s.lastIndexOf('/', activityIndex - 1);
22: String folderId = s.substring(folderIndex + 1, activityIndex);
23: int componentIndex = s.lastIndexOf('/', folderIndex - 1);
24: String componentId = s.substring(componentIndex + 1,
25: folderIndex);
26:
27: ICalendarStore store = CalendarStoreFactory.getInstance()
28: .getLocaleStore();
29:
30: // retrieve event from store
31: try {
32: IEventInfo model = (IEventInfo) store.get(activityId);
33:
34: EditEventDialog dialog = new EditEventDialog(null, model);
35: if (dialog.success()) {
36: IEventInfo updatedModel = dialog.getModel();
37:
38: // update store
39: store.modify(activityId, updatedModel);
40: }
41:
42: } catch (StoreException e1) {
43: JOptionPane.showMessageDialog(FrameManager.getInstance()
44: .getActiveFrame(), e1.getMessage());
45: e1.printStackTrace();
46: }
47: }
48: }
|