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 java.util.ArrayList;
24 import com.google.gwt.user.cellview.client.CellTable;
25 import com.google.gwt.user.cellview.client.SimplePager;
26 import com.google.gwt.user.cellview.client.TextColumn;
27 import com.google.gwt.user.client.rpc.AsyncCallback;
28 import com.google.gwt.user.client.ui.Composite;
29 import com.google.gwt.user.client.ui.VerticalPanel;
30 import com.google.gwt.view.client.AsyncDataProvider;
31 import com.google.gwt.view.client.HasData;
32 import com.google.gwt.view.client.Range;
34 class LayoutListDataProvider extends AsyncDataProvider<String[]> {
36 protected void onRangeChanged(HasData<String[]> display) {
37 final Range range = display.getVisibleRange();
39 final int start = range.getStart();
40 final int length = range.getLength();
42 AsyncCallback<ArrayList<String[]>> callback = new AsyncCallback<ArrayList<String[]>>() {
43 public void onFailure(Throwable caught) {
44 // FIXME: need to deal with failure
45 System.out.println("AsyncCallback Failed: LibGlomService.getTableData()");
48 public void onSuccess(ArrayList<String[]> result) {
49 updateRowData(start, result);
53 OnlineGlomServiceAsync.Util.getInstance().getTableData(start, length, OnlineGlom.getCurrentTableName(), callback);
57 public class LayoutListView extends Composite {
59 private CellTable<String[]> table = null;
61 public LayoutListView(String[] headers) {
62 table = new CellTable<String[]>();
63 LayoutListDataProvider dataProvider = new LayoutListDataProvider();
64 dataProvider.addDataDisplay(table);
66 // TODO wire up the pager
67 SimplePager pager = new SimplePager(SimplePager.TextLocation.CENTER);
68 pager.setDisplay(table);
70 // a panel to hold our widgets
71 VerticalPanel panel = new VerticalPanel();
75 for (int i = 0; i < headers.length; i++) {
76 // create a new column
77 final int j = new Integer(i);
78 TextColumn<String[]> column = new TextColumn<String[]>() {
80 public String getValue(String[] object) {
85 // add the column to the list
86 table.addColumn(column, headers[i]);
92 // take care of the necessary stuff required for composite widgets
94 setStyleName("glom-ListLayoutTable");