1 package org.glom.web.client;
3 import com.google.gwt.core.client.EntryPoint;
4 import com.google.gwt.event.dom.client.ChangeEvent;
5 import com.google.gwt.event.dom.client.ChangeHandler;
6 import com.google.gwt.user.client.Window;
7 import com.google.gwt.user.client.rpc.AsyncCallback;
8 import com.google.gwt.user.client.ui.HorizontalPanel;
9 import com.google.gwt.user.client.ui.Label;
10 import com.google.gwt.user.client.ui.ListBox;
11 import com.google.gwt.user.client.ui.RootPanel;
12 import com.google.gwt.user.client.ui.VerticalPanel;
15 * Entry point classes define <code>onModuleLoad()</code>.
17 public class OnlineGlom implements EntryPoint {
19 private VerticalPanel mainVPanel = new VerticalPanel();
20 private HorizontalPanel hPanel = new HorizontalPanel();
21 private static ListBox dropBox = new ListBox();
22 private LayoutList table = null;
23 private String documentName = "";
25 public void onModuleLoad() {
26 dropBox.addChangeHandler(new ChangeHandler() {
27 public void onChange(ChangeEvent event) {
32 hPanel.add(new Label("Table:"));
35 mainVPanel.add(hPanel);
37 // associate the main panel with the HTML host page
38 RootPanel.get().add(mainVPanel);
40 // set up the callback object.
41 AsyncCallback<GlomDocument> callback = new AsyncCallback<GlomDocument>() {
42 public void onFailure(Throwable caught) {
43 // FIXME: need to deal with failure
44 System.out.println("AsyncCallback Failed: LibGlomService");
47 public void onSuccess(GlomDocument result) {
48 GlomTable[] tables = result.getTables();
49 for (int i = 0; i < tables.length; i++) {
50 dropBox.addItem(tables[i].getTitle(), tables[i].getName());
52 dropBox.setSelectedIndex(result.getDefaultTableIndex());
53 documentName = result.getTitle();
58 // make the call to get the filled in GlomDocument
59 LibGlomServiceAsync.Util.getInstance().getGlomDocument(callback);
62 private void updateTable() {
64 // set up the callback object.
65 AsyncCallback<String[]> callback = new AsyncCallback<String[]>() {
66 public void onFailure(Throwable caught) {
67 // FIXME: need to deal with failure
68 System.out.println("AsyncCallback Failed: LibGlomService.updateTable()");
71 public void onSuccess(String[] result) {
73 mainVPanel.remove(table);
74 table = new LayoutList(result);
75 mainVPanel.add(table);
76 Window.setTitle("OnlineGlom - " + documentName + ": " + dropBox.getItemText(dropBox.getSelectedIndex()));
80 String selectedTable = dropBox.getValue(dropBox.getSelectedIndex());
81 LibGlomServiceAsync.Util.getInstance().getLayoutListHeaders(selectedTable, callback);
85 // FIXME find a better way to do this
86 public static String getCurrentTableName() {
87 return dropBox.getValue(dropBox.getSelectedIndex());