KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > calendar > facade > DialogFacade


1 package org.columba.calendar.facade;
2
3 import java.net.URI JavaDoc;
4
5 import javax.swing.JOptionPane JavaDoc;
6
7 import org.columba.calendar.model.api.IEventInfo;
8 import org.columba.calendar.store.CalendarStoreFactory;
9 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 JavaDoc location) {
17         String JavaDoc s = location.toString();
18         // TODO: @author fdietz replace with regular expression
19
int activityIndex = s.lastIndexOf('/');
20         String JavaDoc activityId = s.substring(activityIndex + 1, s.length());
21         int folderIndex = s.lastIndexOf('/', activityIndex - 1);
22         String JavaDoc folderId = s.substring(folderIndex + 1, activityIndex);
23         int componentIndex = s.lastIndexOf('/', folderIndex - 1);
24         String JavaDoc 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 }
49
Popular Tags