001: /*
002: * MyGWT Widget Library
003: * Copyright(c) 2007, MyGWT.
004: * licensing@mygwt.net
005: *
006: * http://mygwt.net/license
007: */
008: package net.mygwt.samples.mail.client;
009:
010: import net.mygwt.ui.client.Events;
011: import net.mygwt.ui.client.Style;
012: import net.mygwt.ui.client.Registry;
013: import net.mygwt.ui.client.event.BaseEvent;
014: import net.mygwt.ui.client.event.Listener;
015: import net.mygwt.ui.client.mvc.AppEvent;
016: import net.mygwt.ui.client.mvc.Controller;
017: import net.mygwt.ui.client.mvc.Dispatcher;
018: import net.mygwt.ui.client.mvc.View;
019: import net.mygwt.ui.client.widget.ContentPanel;
020: import net.mygwt.ui.client.widget.ExpandBar;
021: import net.mygwt.ui.client.widget.ExpandItem;
022: import net.mygwt.ui.client.widget.ThemeSelector;
023: import net.mygwt.ui.client.widget.Viewport;
024: import net.mygwt.ui.client.widget.WidgetContainer;
025: import net.mygwt.ui.client.widget.layout.BorderLayout;
026: import net.mygwt.ui.client.widget.layout.BorderLayoutData;
027: import net.mygwt.ui.client.widget.layout.FillLayout;
028:
029: public class AppView extends View {
030:
031: private Viewport viewport;
032: private ContentPanel west;
033: private WidgetContainer main;
034: private ContentPanel center;
035:
036: private ExpandBar expandBar;
037:
038: public AppView(Controller controller) {
039: super (controller);
040: }
041:
042: protected void initialize() {
043: viewport = new Viewport();
044: viewport.setStyleName("my-border-layout");
045: viewport.setLayout(new BorderLayout());
046:
047: BorderLayoutData westData = new BorderLayoutData(Style.WEST,
048: 200, 150, 350);
049:
050: west = new ContentPanel(Style.HEADER);
051: west.setText("MyGWT Mail Demo");
052: west.getHeader().setStyleAttribute("borderBottom", "none");
053: createExpandBar();
054: west.setLayout(new FillLayout());
055: west.add(expandBar);
056:
057: viewport.add(west, westData);
058:
059: main = new WidgetContainer();
060: BorderLayout layout = new BorderLayout();
061: layout.setMargin(0);
062: main.setLayout(layout);
063:
064: center = new ContentPanel(Style.HEADER);
065: center.getHeader().addWidget(new ThemeSelector());
066: center.setLayout(new FillLayout());
067:
068: WidgetContainer south = new WidgetContainer();
069: south.setLayout(new FillLayout());
070: south.setBorders(true);
071: south.setStyleAttribute("backgroundColor", "white");
072:
073: main.add(center, new BorderLayoutData(Style.CENTER));
074: main.add(south,
075: new BorderLayoutData(Style.SOUTH, .5f, 50, 2000));
076:
077: viewport.add(main, new BorderLayoutData(Style.CENTER));
078:
079: viewport.layout();
080: viewport.hideLoadingPanel("loading");
081:
082: Registry.register("viewport", viewport);
083: Registry.register("west", west);
084: Registry.register("center", center);
085: Registry.register("south", south);
086: }
087:
088: protected void handleEvent(AppEvent event) {
089: if (event.type == AppEvents.Init) {
090: ExpandItem item = expandBar.getItem(0);
091: expandBar.setExpanded(item, true);
092: }
093: }
094:
095: private void createExpandBar() {
096: expandBar = new ExpandBar(Style.SINGLE | Style.HEADER);
097: expandBar.setBorders(false);
098: expandBar.setHeaderHeight(28);
099:
100: ExpandItem mailItem = new ExpandItem();
101: mailItem.setText("Mail");
102: mailItem.addListener(Events.Expand, new Listener() {
103: public void handleEvent(BaseEvent be) {
104: Dispatcher.forwardEvent(AppEvents.NavMail);
105: }
106: });
107: expandBar.add(mailItem);
108:
109: ExpandItem taskItem = new ExpandItem();
110: taskItem.setText("Tasks");
111: taskItem.addListener(Events.Expand, new Listener() {
112: public void handleEvent(BaseEvent be) {
113: Dispatcher.forwardEvent(AppEvents.NavTasks);
114: }
115: });
116: expandBar.add(taskItem);
117:
118: ExpandItem contactsItem = new ExpandItem();
119: contactsItem.setText("Contacts");
120: contactsItem.addListener(Events.Expand, new Listener() {
121: public void handleEvent(BaseEvent be) {
122: Dispatcher.forwardEvent(AppEvents.NavContacts);
123: }
124: });
125: expandBar.add(contactsItem);
126:
127: Registry.register("mailItem", mailItem);
128:
129: }
130:
131: }
|