List of usage examples for com.google.gwt.user.cellview.client DataGrid DataGrid
public DataGrid(ProvidesKey<T> keyProvider)
From source file:com.dingziran.effective.client.content.widgets.person.PersonSummaryWidget.java
License:Apache License
public PersonSummaryWidget(EventBus eventBus, Factory requestFactory, int numRows) { this.eventBus = eventBus; this.requestFactory = requestFactory; this.numRows = numRows; table = new DataGrid<GoalProxy>(numRows); initWidget(GWT.<Binder>create(Binder.class).createAndBindUi(this)); Column<GoalProxy, String> nameColumn = new NameColumn(); table.addColumn(nameColumn, "Name"); table.setColumnWidth(nameColumn, "25ex"); Column<GoalProxy, String> descriptionColumn = new DescriptionColumn(); table.addColumn(descriptionColumn, "Description"); table.setColumnWidth(descriptionColumn, "40ex"); table.setRowCount(numRows, false);/* w w w . j a va 2 s . c o m*/ table.setSelectionModel(selectionModel); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); EntityProxyChange.registerForProxyType(eventBus, GoalProxy.class, new EntityProxyChange.Handler<GoalProxy>() { @Override public void onProxyChange(EntityProxyChange<GoalProxy> event) { PersonSummaryWidget.this.onPersonChanged(event); } }); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { PersonSummaryWidget.this.refreshSelection(); } }); fetch(0); }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCustomDataGrid.java
License:Apache License
/** * Initialize this example.//from w w w . j av a 2 s.c o m */ @ShowcaseSource @Override public Widget onInitialize() { resources = GWT.create(Resources.class); resources.styles().ensureInjected(); // Create a DataGrid. // Set a key provider that provides a unique key for each contact. If key is // used to identify contacts when fields (such as the name and address) // change. dataGrid = new DataGrid<ContactInfo>(ContactDatabase.ContactInfo.KEY_PROVIDER); dataGrid.setWidth("100%"); // Set the message to display when the table is empty. dataGrid.setEmptyTableWidget(new Label(constants.cwCustomDataGridEmpty())); // Attach a column sort handler to the ListDataProvider to sort the list. ListHandler<ContactInfo> sortHandler = new ListHandler<ContactInfo>( ContactDatabase.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Create a Pager to control the table. SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); // Add a selection model so we can select cells. final SelectionModel<ContactInfo> selectionModel = new MultiSelectionModel<ContactInfo>( ContactDatabase.ContactInfo.KEY_PROVIDER); dataGrid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ContactInfo>createCheckboxManager()); // Specify a custom table. dataGrid.setTableBuilder(new CustomTableBuilder(sortHandler)); // Add the CellList to the adapter in the database. ContactDatabase.get().addDataDisplay(dataGrid); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); return uiBinder.createAndBindUi(this); }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwDataGrid.java
License:Apache License
/** * Initialize this example./*from www . j a va 2 s.co m*/ */ @ShowcaseSource @Override public Widget onInitialize() { // Create a DataGrid. // Set a key provider that provides a unique key for each contact. If key is // used to identify contacts when fields (such as the name and address) // change. dataGrid = new DataGrid<ContactInfo>(ContactDatabase.ContactInfo.KEY_PROVIDER); dataGrid.setWidth("100%"); // Set the message to display when the table is empty. dataGrid.setEmptyTableWidget(new Label(constants.cwDataGridEmpty())); // Attach a column sort handler to the ListDataProvider to sort the list. ListHandler<ContactInfo> sortHandler = new ListHandler<ContactInfo>( ContactDatabase.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Create a Pager to control the table. SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); // Add a selection model so we can select cells. final SelectionModel<ContactInfo> selectionModel = new MultiSelectionModel<ContactInfo>( ContactDatabase.ContactInfo.KEY_PROVIDER); dataGrid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<ContactInfo>createCheckboxManager()); // Initialize the columns. initTableColumns(selectionModel, sortHandler); // Add the CellList to the adapter in the database. ContactDatabase.get().addDataDisplay(dataGrid); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); return uiBinder.createAndBindUi(this); }
From source file:com.vo.search.admin.client.content.widgets.CwQueryIndex.java
License:Apache License
/** * Initialize this widget./*from w w w .j a v a2 s .co m*/ */ @Override public Widget onInitialize() { // initialize search box searchBox = new TextBox(); searchBox.ensureDebugId("cwBasicText-textbox"); // Set the text box to automatically adjust its direction according // to the input text. Use the Any-RTL heuristic, which sets an RTL // direction // iff the text contains at least one RTL character. searchBox.setDirectionEstimator(AnyRtlDirectionEstimator.get()); // innitialize label label = new Label(constants.cwQueryIndexEnterQuery()); label.ensureDebugId("cwQueryIndex-label"); // initialize submit button submitButton = new Button(constants.cwQueryIndexButtonSubmit()); submitButton.ensureDebugId("cwBasicButton-normal"); // Create the popup dialog box final DialogBox dialogBox = new DialogBox(); dialogBox.setText("Remote Procedure Call"); dialogBox.setAnimationEnabled(true); // Set a key provider that provides a unique key for each content. dataGrid = new DataGrid<ContentInfo>(ContentInfo.KEY_PROVIDER); // Set the message to display when the table is empty. dataGrid.setWidth("100%"); dataGrid.setEmptyTableWidget(new Label(constants.cwDataGridEmpty())); // Initialize data provider if (dataProvider == null) { dataProvider = new ListDataProvider<ContentInfo>(); } dataProvider.addDataDisplay(dataGrid); // Create a Pager to control the table. SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); // Create a handler for the sendButton and nameField class MyHandler implements ClickHandler { /** * Fired when the user clicks on the sendButton. */ public void onClick(ClickEvent event) { sendQueryToServer(); } /** * Send the name from the nameField to the server and wait for a * response. */ private void sendQueryToServer() { String queryToServer = searchBox.getText(); // Then, we send the input to the server. greetingService.queryServer(queryToServer, new AsyncCallback<QueryResult>() { public void onFailure(Throwable caught) { // Show the RPC error message to the user dialogBox.setText("Remote Procedure Call - Failure"); dialogBox.center(); submitButton.setEnabled(false); } public void onSuccess(QueryResult result) { // Initialize the columns. dataProvider.getList().clear(); dataProvider.setList(result.getResults()); initTableData(result); } }); } } // Add a handler to send the name to the server MyHandler handler = new MyHandler(); submitButton.addClickHandler(handler); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); return uiBinder.createAndBindUi(this); }
From source file:io.fns.calculator.client.view.impl.LoanMainViewImpl.java
License:Apache License
protected void initializeGrid() { /*/*www . ja va2 s .c o m*/ * Set a key provider that provides a unique key for each payment. */ loanResults = new DataGrid<Payment>(KEY_PROVIDER); /* * Do not refresh the headers every time the data is updated. The footer * depends on the current data, so we do not disable auto refresh on the * footer. */ loanResults.setAutoHeaderRefreshDisabled(true); // Set the message to display when the table is empty. loanResults.setEmptyTableWidget(new Label(Messages.INSTANCE.no_results())); dataProvider.addDataDisplay(loanResults); }
From source file:net.exclaimindustries.paste.braket.client.ui.Leaderboard.java
License:Open Source License
public Leaderboard() { // Make the DataGrid before binding! dataGrid = new DataGrid<SelectionInfo>(SelectionInfo.KEY_PROVIDER); // dataGrid.setWidth("600px"); dataGrid.setMinimumTableWidth(500, Unit.PX); dataGrid.setHeight("100%"); dataGrid.setAutoHeaderRefreshDisabled(true); dataGrid.setEmptyTableWidget(new Label("no data to show right now...")); // Add a ColumnSortEvent.ListHandler to connect sorting to the // java.util.List. ListHandler<SelectionInfo> columnSortHandler = new ListHandler<SelectionInfo>(dataProvider.getList()); // Number (not sortable) TextColumn<SelectionInfo> numColumn = new TextColumn<SelectionInfo>() { @Override/*from w ww .j a va2 s. co m*/ public String getValue(SelectionInfo object) { return Integer.toString(dataProvider.getList().indexOf(object) + 1); } }; // Name TextColumn<SelectionInfo> nameColumn = new TextColumn<SelectionInfo>() { @Override public String getValue(SelectionInfo object) { return object.getUser().getName().toString(); } }; columnSortHandler.setComparator(nameColumn, new Comparator<SelectionInfo>() { public int compare(SelectionInfo o1, SelectionInfo o2) { UserName n1 = o1.getUser().getName(); UserName n2 = o2.getUser().getName(); return n1.toString().compareTo(n2.toString()); } }); pointsColumn = new TextColumn<SelectionInfo>() { @Override public String getValue(SelectionInfo object) { return Double.toString(object.getPoints()); } }; columnSortHandler.setComparator(pointsColumn, new Comparator<SelectionInfo>() { public int compare(SelectionInfo o1, SelectionInfo o2) { return Double.compare(o1.getPoints(), o2.getPoints()); } }); TextColumn<SelectionInfo> possiblePointsColumn = new TextColumn<SelectionInfo>() { @Override public String getValue(SelectionInfo object) { return Double.toString(object.getPointsPossible()); } }; columnSortHandler.setComparator(possiblePointsColumn, new Comparator<SelectionInfo>() { public int compare(SelectionInfo o1, SelectionInfo o2) { return Double.compare(o1.getPointsPossible(), o2.getPointsPossible()); } }); TextColumn<SelectionInfo> expectedPayoutColumn = new TextColumn<SelectionInfo>() { @Override public String getValue(SelectionInfo object) { return numberFormat.format(object.getExpectedPayout()); } }; columnSortHandler.setComparator(expectedPayoutColumn, new Comparator<SelectionInfo>() { public int compare(SelectionInfo o1, SelectionInfo o2) { return Double.compare(o1.getExpectedPayout(), o2.getExpectedPayout()); } }); // Add columns to the grid dataGrid.addColumn(numColumn); dataGrid.setColumnWidth(numColumn, 3, Unit.EM); nameColumn.setSortable(true); dataGrid.addColumn(nameColumn, "name"); pointsColumn.setSortable(true); dataGrid.addColumn(pointsColumn, "points"); dataGrid.setColumnWidth(pointsColumn, 6, Unit.EM); possiblePointsColumn.setSortable(true); dataGrid.addColumn(possiblePointsColumn, "points possible"); dataGrid.setColumnWidth(possiblePointsColumn, 15, Unit.EM); expectedPayoutColumn.setSortable(true); dataGrid.addColumn(expectedPayoutColumn, "Expect-O-Matic"); dataGrid.setColumnWidth(expectedPayoutColumn, 15, Unit.EM); // ActionCell. Column<SelectionInfo, SelectionInfo> viewColumn = addColumn( new ActionCell<SelectionInfo>("view braket", new ActionCell.Delegate<SelectionInfo>() { @Override public void execute(SelectionInfo object) { // BraketEntryPoint.doBraketDisplay(object // .getSelection()); } }), "", new GetValue<SelectionInfo>() { @Override public SelectionInfo getValue(SelectionInfo si) { return si; } }, null); dataGrid.setColumnWidth(viewColumn, 10, Unit.EM); // Attach the column sorter dataGrid.addColumnSortHandler(columnSortHandler); // Attach the data provider to the dataGrid dataProvider.addDataDisplay(dataGrid); setWidget(uiBinder.createAndBindUi(this)); }
From source file:org.cimav.client.ui.departamentos.DepartamentosUI.java
private void buildGrid() { // super.onLoad(); //To change body of generated methods, choose Tools | Templates. /*/*from ww w .ja va2s . c o m*/ * Set a key provider that provides a unique key for each contact. If key is * used to identify contacts when fields (such as the name and address) * change. */ dataGrid = new DataGrid<>(Departamento.KEY_PROVIDER); dataGrid.setWidth("100%"); dataGrid.setHeight("100%"); /* * Do not refresh the headers every time the data is updated. The footer * depends on the current data, so we do not disable auto refresh on the * footer. */ dataGrid.setAutoHeaderRefreshDisabled(true); // Set the message to display when the table is empty. dataGrid.setEmptyTableWidget(new Label("No hay departamentos")); // Attach a column sort handler to the ListDataProvider to sort the list. ListHandler<Departamento> sortHandler = new ListHandler<>(DeptoDatabase.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Create a Pager to control the table. SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(dataGrid); dataGrid.setPageSize(30); // Add a selection model so we can select cells. final SelectionModel<Departamento> selectionModel = new SingleSelectionModel<>(Departamento.KEY_PROVIDER); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { //System.out.println("123> " + event.getSource() + " - " + event.getAssociatedType()); if (event.getSource() instanceof SingleSelectionModel) { SingleSelectionModel selecter = (SingleSelectionModel) event.getSource(); Departamento sel = (Departamento) selecter.getSelectedObject(); // Seleccion actual DeptoDatabase.currentDepto = sel; System.out.println("Depto.Id --> " + DeptoDatabase.currentDepto); departamentoEditorUI.setDepartamento(DeptoDatabase.currentDepto); // Actualizar botones updateWidgets(); } } }); dataGrid.setSelectionModel(selectionModel); dataGrid.addDomHandler(new DoubleClickHandler() { @SuppressWarnings("unchecked") @Override public void onDoubleClick(DoubleClickEvent event) { // DataGrid<Departamento> grid = (DataGrid<Departamento>) event.getSource(); // int row = grid.getKeyboardSelectedRow(); // Departamento item = grid.getVisibleItem(row); // simple selecciona el tab del Editor tabLayout.selectTab(1); } }, DoubleClickEvent.getType()); initTableColumns(sortHandler); // Add the CellList to the adapter in the database. DeptoDatabase.get().addDataDisplay(dataGrid); }
From source file:org.cimav.rh.client.departamentos.DepartamentosUI.java
private void buildGrid() { // super.onLoad(); //To change body of generated methods, choose Tools | Templates. /*/*from w w w .j av a 2s . c o m*/ * Set a key provider that provides a unique key for each contact. If key is * used to identify contacts when fields (such as the name and address) * change. */ dataGrid = new DataGrid<>(Departamento.KEY_PROVIDER); dataGrid.setWidth("100%"); dataGrid.setHeight("100%"); /* * Do not refresh the headers every time the data is updated. The footer * depends on the current data, so we do not disable auto refresh on the * footer. */ dataGrid.setAutoHeaderRefreshDisabled(true); // Set the message to display when the table is empty. dataGrid.setEmptyTableWidget(new Label("No hay departamentos")); // Attach a column sort handler to the ListDataProvider to sort the list. ListHandler<Departamento> sortHandler = new ListHandler<>(DeptoDatabase.get().getDataProvider().getList()); dataGrid.addColumnSortHandler(sortHandler); // Add a selection model so we can select cells. final SelectionModel<Departamento> selectionModel = new SingleSelectionModel<>(Departamento.KEY_PROVIDER); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { //System.out.println("123> " + event.getSource() + " - " + event.getAssociatedType()); if (event.getSource() instanceof SingleSelectionModel) { SingleSelectionModel selecter = (SingleSelectionModel) event.getSource(); Departamento sel = (Departamento) selecter.getSelectedObject(); // Seleccion actual DeptoDatabase.currentDepto = sel; System.out.println("Depto.Id --> " + DeptoDatabase.currentDepto); departamentoEditorUI.setDepartamento(DeptoDatabase.currentDepto); // Actualizar botones updateWidgets(); } } }); dataGrid.setSelectionModel(selectionModel); initTableColumns(sortHandler); // Add the CellList to the adapter in the database. DeptoDatabase.get().addDataDisplay(dataGrid); }
From source file:org.jboss.ci.tracker.client.widgets.BuildList.java
License:Open Source License
public BuildList() { dataGrid = new DataGrid<BuildDto>(500); initDatagrid(); initPager(); initWidget(uiBinder.createAndBindUi(this)); }
From source file:org.jboss.ci.tracker.client.widgets.CategorizationList.java
License:Open Source License
public CategorizationList() { categorizationDataGrid = new DataGrid<CategorizationDto>(500); categoryDataGrid = new DataGrid<CategoryDto>(500); initCategorizationDatagrid();/*from w ww . j a va 2 s. co m*/ initCategoryDataGrid(); initWidget(uiBinder.createAndBindUi(this)); }