List of usage examples for com.google.gwt.user.cellview.client CellTable CellTable
public CellTable()
From source file:com.google.gwt.sample.stockwatcher.client.Cells.java
private Widget createCellTable() { class Contact { private final String name; private final String address; public Contact(String name, String address) { this.name = name; this.address = address; }/* w ww . j a v a2s . c o m*/ } List<Contact> CONTACTS = Arrays.asList(new Contact("John", "123 Fourth Road"), new Contact("Mary", "222 Lancer Lane")); CellTable<Contact> table = new CellTable<>(); TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override public String getValue(Contact contact) { return contact.name; } }; TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact contact) { return contact.address; } }; table.addColumn(nameColumn, "Name"); table.addColumn(addressColumn, "Address"); // Set the total row count. This isn't strictly necessary, but it affects // paging calculations, so its good habit to keep the row count up to date. table.setRowCount(CONTACTS.size(), true); // Push the data into the widget. table.setRowData(0, CONTACTS); return table; }
From source file:com.gwt2go.dev.client.ui.CellTableSortingView23Impl.java
License:Apache License
public CellTableSortingView23Impl() { // -- START TABLE // Create a CellTable. CellTable<Contact> table = new CellTable<Contact>(); // Create name column. TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override/*from w w w. j a va 2 s .com*/ public String getValue(Contact contact) { return contact.name; } }; // Make the name column sortable. nameColumn.setSortable(true); // Create address column. TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact contact) { return contact.address; } }; ImagesColumn<Contact> imagesColumn = new ImagesColumn<Contact>() { @Override public String getValue(Contact object) { return object.color; } }; // try to use the filed updater to call the value updater!!! imagesColumn.setFieldUpdater(new FieldUpdater<CellTableSortingView23Impl.Contact, String>() { @Override public void update(int index, Contact object, String value) { Window.alert("This is the field updater, with value: " + value + " Index: " + index + " Contact: " + object.name); } }); // Add the columns. table.addColumn(nameColumn, "Name"); table.addColumn(addressColumn, "Address"); table.addColumn(imagesColumn, "Export to"); // Create a data provider. ListDataProvider<Contact> dataProvider = new ListDataProvider<Contact>(); // Connect the table to the data provider. dataProvider.addDataDisplay(table); // Add the data to the data provider, which automatically pushes it to the // widget. List<Contact> list = dataProvider.getList(); for (Contact contact : CONTACTS) { list.add(contact); } // Add a ColumnSortEvent.ListHandler to connect sorting to the // java.util.List. ListHandler<Contact> columnSortHandler = new ListHandler<Contact>(list); columnSortHandler.setComparator(nameColumn, new Comparator<Contact>() { public int compare(Contact o1, Contact o2) { if (o1 == o2) { return 0; } // Compare the name columns. if (o1 != null) { return (o2 != null) ? o1.name.compareTo(o2.name) : 1; } return -1; } }); table.addColumnSortHandler(columnSortHandler); // We know that the data is sorted alphabetically by default. table.getColumnSortList().push(nameColumn); // -- END TABLE viewPanel.getElement().appendChild(nameSpan); viewPanel.add(table); initWidget(viewPanel); }
From source file:com.gwtplatform.carstore.client.application.cars.CarsView.java
License:Apache License
private void initCarGrid() { carGrid = new CellTable<CarDto>(); carGrid.setSelectionModel(new NoSelectionModel<CarDto>()); pager = new SimplePager(SimplePager.TextLocation.CENTER); pager.setDisplay(carGrid);//from ww w . j ava 2 s . c om pager.setPageSize(PAGE_SIZE); initDataColumns(); initActionColumns(); }
From source file:com.gwtplatform.carstore.client.application.manufacturer.ManufacturerView.java
License:Apache License
private void initManufacturerGrid() { manufacturerGrid = new CellTable<ManufacturerDto>(); manufacturerGrid.setSelectionModel(new NoSelectionModel<ManufacturerDto>()); initDataColumns();/* w ww .j ava 2s .c o m*/ initActionColumns(); }
From source file:com.gwtplatform.carstore.client.application.rating.RatingView.java
License:Apache License
private void initRatingGrid() { ratingGrid = new CellTable<RatingDto>(); ratingGrid.setSelectionModel(new NoSelectionModel<RatingDto>()); ratingColumnInitializer.initializeColumns(ratingGrid); initActionColumns();/*from ww w. j a v a2 s. c om*/ }
From source file:com.gwtplatform.carstore.client.application.report.ReportView.java
License:Apache License
private void initCarGrid() { reportGrid = new CellTable<ManufacturerRatingDto>(); reportGrid.setSelectionModel(new NoSelectionModel<ManufacturerRatingDto>()); ratingsProvider.addDataDisplay(reportGrid); initDataColumns();/* w w w . j av a2 s.c o m*/ }
From source file:com.mquick.client.application.home.HomePageView.java
License:Apache License
@Inject public HomePageView(Binder uiBinder, ListDataProvider<ClientEntity> dataProvider) { this.dataProvider = dataProvider; expressportals = new CellTable<ClientEntity>(); this.dataProvider.addDataDisplay(expressportals); initCellTable();/*from w w w.j av a 2 s . co m*/ initWidget(uiBinder.createAndBindUi(this)); }
From source file:com.mycompany.celltableexmaple.client.CellTableExample.java
License:Open Source License
public void onModuleLoad() { // Create a CellTable. final CellTable<GalleryApp> galleryTable = new CellTable<GalleryApp>(); // Display 3 rows in one page galleryTable.setPageSize(5);// www.ja v a 2 s .c om // Add a text column to show the title. TextColumn<GalleryApp> titleColumn = new TextColumn<GalleryApp>() { @Override public String getValue(GalleryApp object) { return object.title; } }; galleryTable.addColumn(titleColumn, "Title"); // Add a text column to show the title. TextColumn<GalleryApp> descColumn = new TextColumn<GalleryApp>() { @Override public String getValue(GalleryApp object) { return object.description; } }; galleryTable.addColumn(descColumn, "Description"); // Add a text column to show the address. TextColumn<GalleryApp> imageColumn = new TextColumn<GalleryApp>() { @Override public String getValue(GalleryApp object) { return object.image; } }; galleryTable.addColumn(imageColumn, "Image URL"); /* * Associate an async data provider to the table. */ AsyncDataProvider<GalleryApp> provider = new AsyncDataProvider<GalleryApp>() { // @Override // /* // * The default event listener which involves no remote data handling, // * replace the onRangeChanged below with this for a simpler demo. // */ // protected void onRangeChanged(HasData<GalleryApp> display) { // int start = display.getVisibleRange().getStart(); // int end = start + display.getVisibleRange().getLength(); // end = end >= GALLERYAPPS.size() ? GALLERYAPPS.size() : end; // List<GalleryApp> sub = GALLERYAPPS.subList(start, end); // updateRowData(start, sub); // } @Override /* * Event handler that will grab data from remote server in async fashion * @see com.google.gwt.view.client.AbstractDataProvider#onRangeChanged(com.google.gwt.view.client.HasData) */ protected void onRangeChanged(HasData<GalleryApp> display) { final int start = display.getVisibleRange().getStart(); int length = display.getVisibleRange().getLength(); AsyncCallback<List<GalleryApp>> callback = new AsyncCallback<List<GalleryApp>>() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); } @Override public void onSuccess(List<GalleryApp> result) { // The result here will be the returned value in the async callback updateRowData(start, result); } }; // The remote service that should be implemented greetingService.getApps(start, length, callback); } }; provider.addDataDisplay(galleryTable); provider.updateRowCount(GALLERYAPPS.size(), true); SimplePager pager = new SimplePager(); pager.setDisplay(galleryTable); VerticalPanel vp = new VerticalPanel(); vp.add(galleryTable); vp.add(pager); // Add it to the root panel. RootPanel.get().add(vp); }
From source file:com.nitrous.gwt.earth.client.demo.MouseListenerDemo.java
License:Apache License
/** * The Google earth API has loaded, start the application *//* w w w. j a v a2 s . c o m*/ private void onApiLoaded() { // the table that will be used to render mouse event information table = new CellTable<MouseEventInfo>(); TextColumn<MouseEventInfo> eventType = new TextColumn<MouseEventInfo>() { @Override public String getValue(MouseEventInfo object) { return object.getEventType(); } }; eventType.setSortable(false); TextColumn<MouseEventInfo> eventDetail = new TextColumn<MouseEventInfo>() { @Override public String getValue(MouseEventInfo object) { KmlMouseEvent event = object.getMouseEvent(); return "Button=" + event.getButton() + " Latitude=" + event.getLatitude() + " Longitude=" + event.getLongitude() + " X=" + event.getClientX() + " Y=" + event.getClientY(); } }; eventDetail.setSortable(false); TextColumn<MouseEventInfo> eventTime = new TextColumn<MouseEventInfo>() { @Override public String getValue(MouseEventInfo object) { return dateTimeFormat.format(object.getTimestamp()); } }; eventTime.setSortable(false); // add the columns table.addColumn(eventTime, "Time"); table.addColumn(eventType, "Type"); table.addColumn(eventDetail, "Detail"); table.setWidth("100%"); // set the data model into the table dataProvider = new ListDataProvider<MouseEventInfo>(); dataProvider.addDataDisplay(table); // construct the UI widget earth = new GoogleEarthWidget(); // register a listener to be notified when the earth plug-in has loaded earth.addPluginReadyListener(new GEPluginReadyListener() { public void pluginReady(GEPlugin ge) { // show map content once the plugin has loaded loadMapContent(); } public void pluginInitFailure() { // failure! Window.alert("Failed to initialize Google Earth Plug-in"); } }); scrollPanel = new ScrollPanel(); scrollPanel.setHeight("100%"); scrollPanel.add(table); HorizontalPanel header = new HorizontalPanel(); header.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); mouseLocation = new HTML(""); header.add(mouseLocation); SplitLayoutPanel split = new SplitLayoutPanel(); split.addWest(scrollPanel, 450); split.add(earth); DockLayoutPanel dockLayout = new DockLayoutPanel(Unit.PX); dockLayout.addNorth(header, 30D); dockLayout.add(split); RootLayoutPanel.get().add(dockLayout); // begin loading the Google Earth Plug-in earth.init(); }
From source file:com.ootb.client.application.deliveryInfo.DeliveryInfoPageView.java
License:Apache License
@Inject public DeliveryInfoPageView(final Binder uiBinder, final ListDataProvider<BoxEntityProxy> dataProvider) { this.dataProvider = dataProvider; this.myTable = new CellTable<BoxEntityProxy>(); initCellTable();/*from w w w . ja va 2 s. c o m*/ dataProvider.addDataDisplay(myTable); initWidget(uiBinder.createAndBindUi(this)); }