Mailpublic class Mail extends Object implements com.google.gwt.core.client.EntryPoint, com.google.gwt.user.client.WindowResizeListenerThis application demonstrates how to construct a relatively complex user
interface, similar to many common email readers. It has no back-end,
populating its components with hard-coded data. |
Fields Summary |
---|
private static Mail | singleton | private static final Images | imagesInstantiate an application-level image bundle. This object will provide
programmatic access to all the images needed by widgets. | private TopPanel | topPanel | private com.google.gwt.user.client.ui.VerticalPanel | rightPanel | private MailList | mailList | private MailDetail | mailDetail | private Shortcuts | shortcuts |
Methods Summary |
---|
public void | displayItem(MailItem item)Displays the specified item.
mailDetail.setItem(item);
| public static com.google.gwt.sample.mail.client.Mail | get()Gets the singleton Mail instance.
return singleton;
| public void | onModuleLoad()This method constructs the application user interface by instantiating
controls and hooking up event listeners.
singleton = this;
topPanel.setWidth("100%");
// MailList uses Mail.get() in its constructor, so initialize it after
// 'singleton'.
mailList = new MailList();
mailList.setWidth("100%");
// Create the right panel, containing the email list & details.
rightPanel.add(mailList);
rightPanel.add(mailDetail);
mailList.setWidth("100%");
mailDetail.setWidth("100%");
// Create a dock panel that will contain the menu bar at the top,
// the shortcuts to the left, and the mail list & details taking the rest.
DockPanel outer = new DockPanel();
outer.add(topPanel, DockPanel.NORTH);
outer.add(shortcuts, DockPanel.WEST);
outer.add(rightPanel, DockPanel.CENTER);
outer.setWidth("100%");
outer.setSpacing(4);
outer.setCellWidth(rightPanel, "100%");
// Hook the window resize event, so that we can adjust the UI.
Window.addWindowResizeListener(this);
// Get rid of scrollbars, and clear out the window's built-in margin,
// because we want to take advantage of the entire client area.
Window.enableScrolling(false);
Window.setMargin("0px");
// Finally, add the outer panel to the RootPanel, so that it will be
// displayed.
RootPanel.get().add(outer);
// Call the window resized handler to get the initial sizes setup. Doing
// this in a deferred command causes it to occur after all widgets' sizes
// have been computed by the browser.
DeferredCommand.addCommand(new Command() {
public void execute() {
onWindowResized(Window.getClientWidth(), Window.getClientHeight());
}
});
onWindowResized(Window.getClientWidth(), Window.getClientHeight());
| public void | onWindowResized(int width, int height)
// Adjust the shortcut panel and detail area to take up the available room
// in the window.
int shortcutHeight = height - shortcuts.getAbsoluteTop() - 8;
if (shortcutHeight < 1) {
shortcutHeight = 1;
}
shortcuts.setHeight("" + shortcutHeight);
// Give the mail detail widget a chance to resize itself as well.
mailDetail.adjustSize(width, height);
|
|