2 * Copyright (C) 2010, 2011 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.client;
22 import com.google.gwt.core.client.EntryPoint;
23 import com.google.gwt.event.dom.client.ChangeEvent;
24 import com.google.gwt.event.dom.client.ChangeHandler;
25 import com.google.gwt.user.client.Window;
26 import com.google.gwt.user.client.rpc.AsyncCallback;
27 import com.google.gwt.user.client.ui.HorizontalPanel;
28 import com.google.gwt.user.client.ui.Label;
29 import com.google.gwt.user.client.ui.ListBox;
30 import com.google.gwt.user.client.ui.RootPanel;
31 import com.google.gwt.user.client.ui.VerticalPanel;
34 * Entry point classes define <code>onModuleLoad()</code>.
36 public class OnlineGlom implements EntryPoint {
38 private VerticalPanel mainVPanel = new VerticalPanel();
39 private HorizontalPanel hPanel = new HorizontalPanel();
40 private static ListBox dropBox = new ListBox();
41 private LayoutList table = null;
42 private String documentName = "";
44 public void onModuleLoad() {
45 dropBox.addChangeHandler(new ChangeHandler() {
46 public void onChange(ChangeEvent event) {
51 hPanel.add(new Label("Table:"));
54 mainVPanel.add(hPanel);
56 // associate the main panel with the HTML host page
57 RootPanel.get().add(mainVPanel);
59 // set up the callback object.
60 AsyncCallback<GlomDocument> callback = new AsyncCallback<GlomDocument>() {
61 public void onFailure(Throwable caught) {
62 // FIXME: need to deal with failure
63 System.out.println("AsyncCallback Failed: LibGlomService");
66 public void onSuccess(GlomDocument result) {
67 GlomTable[] tables = result.getTables();
68 for (int i = 0; i < tables.length; i++) {
69 dropBox.addItem(tables[i].getTitle(), tables[i].getName());
71 dropBox.setSelectedIndex(result.getDefaultTableIndex());
72 documentName = result.getTitle();
77 // make the call to get the filled in GlomDocument
78 LibGlomServiceAsync.Util.getInstance().getGlomDocument(callback);
81 private void updateTable() {
83 // set up the callback object.
84 AsyncCallback<String[]> callback = new AsyncCallback<String[]>() {
85 public void onFailure(Throwable caught) {
86 // FIXME: need to deal with failure
87 System.out.println("AsyncCallback Failed: LibGlomService.updateTable()");
90 public void onSuccess(String[] result) {
92 mainVPanel.remove(table);
93 table = new LayoutList(result);
94 mainVPanel.add(table);
95 Window.setTitle("OnlineGlom - " + documentName + ": " + dropBox.getItemText(dropBox.getSelectedIndex()));
99 String selectedTable = dropBox.getValue(dropBox.getSelectedIndex());
100 LibGlomServiceAsync.Util.getInstance().getLayoutListHeaders(selectedTable, callback);
104 // FIXME find a better way to do this
105 public static String getCurrentTableName() {
106 return dropBox.getValue(dropBox.getSelectedIndex());