Add some basic style to the table listing.
[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.FlexTable;
7 import com.google.gwt.user.client.ui.RootPanel;
8 import com.google.gwt.user.client.ui.VerticalPanel;
9
10 /**
11  * Entry point classes define <code>onModuleLoad()</code>.
12  */
13 public class OnlineGlom implements EntryPoint {
14
15         private VerticalPanel mainPanel = new VerticalPanel();
16         private FlexTable tablesFlexTable = new FlexTable();
17         private TableNameServiceAsync tableNameSvc = GWT
18                         .create(TableNameService.class);
19
20         public void onModuleLoad() {
21                 // create table to hold the table names
22                 tablesFlexTable.setText(0, 0, "Tables");
23
24                 // add some style
25                 tablesFlexTable.setCellPadding(6);
26                 tablesFlexTable.getRowFormatter().addStyleName(0, "tablesHeader");
27                 
28                 mainPanel.add(tablesFlexTable);
29
30                 // associate the main panel with the HTML host page
31                 RootPanel.get("tableList").add(mainPanel);
32                 
33                 // initialize the service proxy.
34                 if (tableNameSvc == null) {
35                         tableNameSvc = GWT.create(TableNameService.class);
36                 }
37
38                 // set up the callback object.
39                 AsyncCallback<GlomTable[]> callback = new AsyncCallback<GlomTable[]>() {
40                         public void onFailure(Throwable caught) {
41                                 // FIXME: need to deal with failure
42                                 System.out.println("AsyncCallback Failed: TableNameService");
43                         }
44
45                         public void onSuccess(GlomTable[] result) {
46                                 for (int i = 0; i < result.length; i++) {
47                                         tablesFlexTable.setText(i + 1, 0, result[i].getName());
48                                 }
49                         }
50
51                 };
52
53                 // make the call to get the names
54                 tableNameSvc.getNames(callback);
55         }
56 }