Make a listBox with table titles instead of the flexTable demo.
[online-glom:gwt-glom.git] / src / org / glom / web / client / OnlineGlom.java
1 package org.glom.web.client;
2
3 import com.google.gwt.core.client.EntryPoint;
4 import com.google.gwt.core.client.GWT;
5 import com.google.gwt.user.client.rpc.AsyncCallback;
6 import com.google.gwt.user.client.ui.HorizontalPanel;
7 import com.google.gwt.user.client.ui.Label;
8 import com.google.gwt.user.client.ui.ListBox;
9 import com.google.gwt.user.client.ui.RootPanel;
10 import com.google.gwt.user.client.ui.VerticalPanel;
11
12 /**
13  * Entry point classes define <code>onModuleLoad()</code>.
14  */
15 public class OnlineGlom implements EntryPoint {
16
17         private VerticalPanel mainVPanel = new VerticalPanel();
18         private HorizontalPanel tableSelectorHPanel = new HorizontalPanel();
19         private ListBox tableListBox = new ListBox();
20         private LibGlomServiceAsync libGlomSvc = GWT.create(LibGlomService.class);
21
22         public void onModuleLoad() {
23
24                 tableSelectorHPanel.add(new Label("Table:"));
25                 tableSelectorHPanel.add(tableListBox);
26                 
27                 mainVPanel.add(tableSelectorHPanel);
28
29                 // associate the main panel with the HTML host page
30                 RootPanel.get("GlomWebApp").add(mainVPanel);
31                 
32                 // initialize the service proxy
33                 if (libGlomSvc == null) {
34                         libGlomSvc = GWT.create(LibGlomService.class);
35                 }
36
37                 // set up the callback object.
38                 AsyncCallback<GlomDocument> callback = new AsyncCallback<GlomDocument>() {
39                         public void onFailure(Throwable caught) {
40                                 // FIXME: need to deal with failure
41                                 System.out.println("AsyncCallback Failed: LibGlomService");
42                         }
43
44                         public void onSuccess(GlomDocument result) {
45                                 // TODO set page title
46                                 GlomTable[] tables = result.getTables();
47                                 for (int i = 0; i < tables.length; i++) {
48                                         tableListBox.addItem(tables[i].getTitle());
49                                 }
50                                 tableListBox.setSelectedIndex(result.getDefaultTable());
51                         }
52
53                 };
54
55                 // make the call to get the filled in GlomDocument
56                 libGlomSvc.getGlomDocument(callback);
57         }
58 }