01: /*
02: * MyGWT Widget Library
03: * Copyright(c) 2007, MyGWT.
04: * licensing@mygwt.net
05: *
06: * http://mygwt.net/license
07: */
08: package net.mygwt.samples.mail.client;
09:
10: import java.util.List;
11:
12: import net.mygwt.samples.resources.client.Folder;
13: import net.mygwt.samples.resources.client.MailItem;
14: import net.mygwt.samples.resources.client.TestData;
15: import net.mygwt.ui.client.Registry;
16: import net.mygwt.ui.client.mvc.AppEvent;
17: import net.mygwt.ui.client.mvc.Dispatcher;
18: import net.mygwt.ui.client.mvc.DispatcherListener;
19:
20: import com.google.gwt.core.client.EntryPoint;
21:
22: public class Mail implements EntryPoint {
23:
24: private Dispatcher dispatcher;
25:
26: public void onModuleLoad() {
27: Registry.register("mail", createModel());
28:
29: dispatcher = Dispatcher.get();
30: dispatcher.addController(new AppController());
31: dispatcher.addController(new MailController());
32: dispatcher.addController(new TaskController());
33: dispatcher.addController(new ContactController());
34:
35: // you can listen for dispatch events
36: dispatcher.addDispatcherListener(new DispatcherListener() {
37: public void beforeDispatch(AppEvent ae) {
38: }
39:
40: public void afterDispatch(AppEvent ae) {
41: }
42: });
43:
44: // start the app
45: dispatcher.dispatch(AppEvents.Init);
46: }
47:
48: private Folder createModel() {
49: Folder mail = new Folder("root");
50:
51: Folder inbox = new Folder("Inbox");
52: Folder sent = new Folder("Sent Items");
53: Folder trash = new Folder("Trash");
54:
55: mail.add(inbox);
56: mail.add(sent);
57: mail.add(trash);
58:
59: List items = TestData.getMailItems();
60: int count = items.size();
61: for (int i = 0; i < count; i++) {
62: MailItem item = (MailItem) items.get(i);
63: if (i < (count / 2)) {
64: inbox.add(item);
65: } else {
66: sent.add(item);
67: }
68: }
69: return mail;
70: }
71:
72: }
|