List of usage examples for com.google.gwt.user.cellview.client Column Column
public Column(Cell<C> cell)
From source file:com.gsr.myschool.back.client.web.application.preinscription.PreInscriptionView.java
License:Apache License
private void initDataGrid() { TextColumn<DossierProxy> nomColumn = new TextColumn<DossierProxy>() { @Override//from w w w . j av a2 s . c om public String getValue(DossierProxy object) { if (object.getCandidat() == null) return ""; return object.getCandidat().getLastname() + " " + object.getCandidat().getFirstname(); } }; nomColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); preInscriptionsTable.addColumn(nomColumn, "Nom prnom"); preInscriptionsTable.setColumnWidth(nomColumn, 15, Style.Unit.PCT); TextColumn<DossierProxy> dateColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getCandidat().getBirthDate() == null) return ""; return dateFormat.format(object.getCandidat().getBirthDate()); } }; dateColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); preInscriptionsTable.addColumn(dateColumn, "Date de naissance"); preInscriptionsTable.setColumnWidth(dateColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> refColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { return object.getGeneratedNumDossier(); } }; refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); preInscriptionsTable.addColumn(refColumn, "N Dossier"); preInscriptionsTable.setColumnWidth(refColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> statusColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getStatus() == null) return ""; return object.getStatus().toString(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); preInscriptionsTable.addColumn(statusColumn, "Statut"); preInscriptionsTable.setColumnWidth(statusColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> anneeScolaireColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getAnneeScolaire() == null) return ""; return object.getAnneeScolaire().getLabel(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); preInscriptionsTable.addColumn(anneeScolaireColumn, "Anne scolaire"); preInscriptionsTable.setColumnWidth(anneeScolaireColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> createdColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getCreateDate() == null) return ""; return dateFormat.format(object.getCreateDate()); } }; createdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); preInscriptionsTable.addColumn(createdColumn, "Date de cration"); preInscriptionsTable.setColumnWidth(createdColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> cFiliereColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getFiliere() == null) { return ""; } else { return object.getFiliere().getNom(); } } }; cFiliereColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); preInscriptionsTable.addColumn(cFiliereColumn, "Formation"); preInscriptionsTable.setColumnWidth(cFiliereColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> cLevelColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getNiveauEtude() == null) { return ""; } else { return object.getNiveauEtude().getNom(); } } }; cLevelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); preInscriptionsTable.addColumn(cLevelColumn, "Niveau demand"); preInscriptionsTable.setColumnWidth(cLevelColumn, 15, Style.Unit.PCT); Delegate<DossierProxy> viewDetailsAction = new Delegate<DossierProxy>() { @Override public void execute(DossierProxy dossier) { getUiHandlers().viewDetails(dossier); } }; printAction = new Delegate<DossierProxy>() { @Override public void execute(DossierProxy inscription) { getUiHandlers().printInscription(inscription); } }; Delegate<DossierProxy> deleteAction = new Delegate<DossierProxy>() { @Override public void execute(DossierProxy inscription) { getUiHandlers().delete(inscription); } }; Delegate<DossierProxy> printConvocationAction = new Delegate<DossierProxy>() { @Override public void execute(DossierProxy inscription) { getUiHandlers().printConvocationAction(inscription); } }; Delegate<DossierProxy> sendConvocationAction = new Delegate<DossierProxy>() { @Override public void execute(DossierProxy inscription) { getUiHandlers().sendConvocationAction(inscription); } }; PreInscriptionActionCell actionsCell = actionCellFactory.create(viewDetailsAction, printAction, deleteAction, printConvocationAction, sendConvocationAction); Column<DossierProxy, DossierProxy> actionsColumn = new Column<DossierProxy, DossierProxy>(actionsCell) { @Override public DossierProxy getValue(DossierProxy object) { return object; } }; actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); preInscriptionsTable.addColumn(actionsColumn, "Dtails"); preInscriptionsTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT); }
From source file:com.gsr.myschool.back.client.web.application.settings.widget.MatiereExamenView.java
License:Apache License
private void initDataGrid() { TextColumn<MatiereExamenProxy> nomPrenomColumn = new TextColumn<MatiereExamenProxy>() { @Override/*w w w . ja v a 2s . c om*/ public String getValue(MatiereExamenProxy object) { return object.getNom(); } }; nomPrenomColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); matiereExamenTable.addColumn(nomPrenomColumn, "Nom"); matiereExamenTable.setColumnWidth(nomPrenomColumn, 70, Style.Unit.PCT); ActionCell<MatiereExamenProxy> actionCell = new ActionCell<MatiereExamenProxy>("Supprimer", new ActionCell.Delegate<MatiereExamenProxy>() { @Override public void execute(MatiereExamenProxy object) { getUiHandlers().deleteMatiereExamen(object); } }); Column<MatiereExamenProxy, MatiereExamenProxy> actionColumn = new Column<MatiereExamenProxy, MatiereExamenProxy>( actionCell) { @Override public MatiereExamenProxy getValue(MatiereExamenProxy object) { return object; } }; actionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); matiereExamenTable.addColumn(actionColumn, "Action"); matiereExamenTable.setColumnWidth(actionColumn, 30, Style.Unit.PCT); }
From source file:com.gsr.myschool.back.client.web.application.settings.widget.PiecesJustifView.java
License:Apache License
private void initDataGrid() { TextColumn<PieceJustifProxy> nomPrenomColumn = new TextColumn<PieceJustifProxy>() { @Override//from w ww. java 2s . c o m public String getValue(PieceJustifProxy object) { return object.getNom(); } }; nomPrenomColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); piecesJustifTable.addColumn(nomPrenomColumn, "Nom"); piecesJustifTable.setColumnWidth(nomPrenomColumn, 70, Style.Unit.PCT); ActionCell<PieceJustifProxy> actionCell = new ActionCell<PieceJustifProxy>("Supprimer", new ActionCell.Delegate<PieceJustifProxy>() { @Override public void execute(PieceJustifProxy object) { getUiHandlers().deletePieceJustif(object); } }); Column<PieceJustifProxy, PieceJustifProxy> actionColumn = new Column<PieceJustifProxy, PieceJustifProxy>( actionCell) { @Override public PieceJustifProxy getValue(PieceJustifProxy object) { return object; } }; actionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); piecesJustifTable.addColumn(actionColumn, "Action"); piecesJustifTable.setColumnWidth(actionColumn, 30, Style.Unit.PCT); }
From source file:com.gsr.myschool.back.client.web.application.user.UserAccountView.java
License:Apache License
private void initDataGrid() { TextColumn<UserProxy> refColumn = new TextColumn<UserProxy>() { @Override//w ww . j av a2 s .c o m public String getValue(UserProxy object) { return object.getFirstName() + " " + object.getLastName(); } }; refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userPortalTable.addColumn(refColumn, "Nom"); userPortalTable.setColumnWidth(refColumn, 20, Style.Unit.PCT); TextColumn<UserProxy> emailColumn = new TextColumn<UserProxy>() { @Override public String getValue(UserProxy object) { return object.getEmail(); } }; emailColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); userPortalTable.addColumn(emailColumn, "Email"); userPortalTable.setColumnWidth(emailColumn, 30, Style.Unit.PCT); TextColumn<UserProxy> submittedColumn = new TextColumn<UserProxy>() { @Override public String getValue(UserProxy object) { if (object.getCreated() == null) return ""; return dateFormat.format(object.getCreated()); } }; submittedColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); userPortalTable.addColumn(submittedColumn, "Date de cration"); userPortalTable.setColumnWidth(submittedColumn, 20, Style.Unit.PCT); TextColumn<UserProxy> statusColumn = new TextColumn<UserProxy>() { @Override public String getValue(UserProxy object) { if (object.getStatus() == null) return ""; return object.getStatus().toString(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userPortalTable.addColumn(statusColumn, "Statut"); userPortalTable.setColumnWidth(statusColumn, 15, Style.Unit.PCT); TextColumn<UserProxy> roleColumn = new TextColumn<UserProxy>() { @Override public String getValue(UserProxy object) { if (object.getAuthority() == null) return ""; return object.getAuthority().toString(); } }; roleColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userPortalTable.addColumn(roleColumn, "Type"); userPortalTable.setColumnWidth(roleColumn, 15, Style.Unit.PCT); UserAccountActionCell actionsCell = actionCellFactory.create(editAccount, logingAccount); Column<UserProxy, UserProxy> actionsColumn = new Column<UserProxy, UserProxy>(actionsCell) { @Override public UserProxy getValue(UserProxy object) { return object; } }; actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userPortalTable.addColumn(actionsColumn, "Actions"); userPortalTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT); }
From source file:com.gsr.myschool.back.client.web.application.usergsr.AdminUserAccountView.java
License:Apache License
private void initDataGrid() { TextColumn<AdminUserProxy> loginColumn = new TextColumn<AdminUserProxy>() { @Override/*from ww w . j av a2 s . c om*/ public String getValue(AdminUserProxy object) { return object.getEmail(); } }; loginColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userGsrTable.addColumn(loginColumn, "Email"); userGsrTable.setColumnWidth(loginColumn, 20, Style.Unit.PCT); TextColumn<AdminUserProxy> fNameColumn = new TextColumn<AdminUserProxy>() { @Override public String getValue(AdminUserProxy object) { return object.getFirstName(); } }; fNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userGsrTable.addColumn(fNameColumn, "Prnom"); userGsrTable.setColumnWidth(fNameColumn, 20, Style.Unit.PCT); TextColumn<AdminUserProxy> lNameColumn = new TextColumn<AdminUserProxy>() { @Override public String getValue(AdminUserProxy object) { return object.getLastName(); } }; lNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userGsrTable.addColumn(lNameColumn, "Nom"); userGsrTable.setColumnWidth(lNameColumn, 20, Style.Unit.PCT); TextColumn<AdminUserProxy> roleColumn = new TextColumn<AdminUserProxy>() { @Override public String getValue(AdminUserProxy object) { if (object.getAuthority() == null) return ""; return object.getAuthority().toString(); } }; roleColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); userGsrTable.addColumn(roleColumn, "Rle"); userGsrTable.setColumnWidth(roleColumn, 20, Style.Unit.PCT); TextColumn<AdminUserProxy> statusColumn = new TextColumn<AdminUserProxy>() { @Override public String getValue(AdminUserProxy object) { if (object.getStatus() == null) return ""; return object.getStatus().toString(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); userGsrTable.addColumn(statusColumn, "Statut"); userGsrTable.setColumnWidth(statusColumn, 20, Style.Unit.PCT); TextColumn<AdminUserProxy> submittedColumn = new TextColumn<AdminUserProxy>() { @Override public String getValue(AdminUserProxy object) { if (object.getCreated() == null) return ""; return dateFormat.format(object.getCreated()); } }; submittedColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); userGsrTable.addColumn(submittedColumn, "Date de Cration"); userGsrTable.setColumnWidth(submittedColumn, 30, Style.Unit.PCT); AdminUserActionCell actionsCellAdmin = actionCellFactoryAdmin.create(editAccount, delete); Column<AdminUserProxy, AdminUserProxy> actionsColumn = new Column<AdminUserProxy, AdminUserProxy>( actionsCellAdmin) { @Override public AdminUserProxy getValue(AdminUserProxy object) { return object; } }; actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); userGsrTable.addColumn(actionsColumn, "Actions"); userGsrTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT); }
From source file:com.gsr.myschool.back.client.web.application.validation.ValidationView.java
License:Apache License
private void initDataGrid() { TextColumn<DossierProxy> refColumn = new TextColumn<DossierProxy>() { @Override/*from www. java 2s . c o m*/ public String getValue(DossierProxy object) { return object.getGeneratedNumDossier(); } }; refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); inscriptionsTable.addColumn(refColumn, "N Dossier"); inscriptionsTable.setColumnWidth(refColumn, 10, Style.Unit.PCT); TextColumn<DossierProxy> cNameColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { return object.getCandidat().getFirstname() + " " + object.getCandidat().getLastname(); } }; refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); inscriptionsTable.addColumn(cNameColumn, "Nom Candidat"); inscriptionsTable.setColumnWidth(cNameColumn, 15, Style.Unit.PCT); TextColumn<DossierProxy> cFiliereColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getFiliere() == null) { return ""; } else { return object.getFiliere().getNom(); } } }; cFiliereColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(cFiliereColumn, "Formation"); inscriptionsTable.setColumnWidth(cFiliereColumn, 15, Style.Unit.PCT); TextColumn<DossierProxy> cLevelColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getNiveauEtude() == null) { return ""; } else { return object.getNiveauEtude().getNom(); } } }; cLevelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(cLevelColumn, "Niveau demand"); inscriptionsTable.setColumnWidth(cLevelColumn, 15, Style.Unit.PCT); TextColumn<DossierProxy> createdColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getCreateDate() == null) return ""; return dateFormat.format(object.getCreateDate()); } }; createdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(createdColumn, "Date du dossier"); inscriptionsTable.setColumnWidth(createdColumn, 20, Style.Unit.PCT); TextColumn<DossierProxy> statusColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getStatus() == null) return ""; return object.getStatus().toString(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(statusColumn, "Statut"); inscriptionsTable.setColumnWidth(statusColumn, 10, Style.Unit.PCT); ActionCell.Delegate<DossierProxy> verifyAction = new ActionCell.Delegate<DossierProxy>() { @Override public void execute(DossierProxy dossier) { getUiHandlers().verify(dossier); } }; ActionCell.Delegate<DossierProxy> previewAction = new ActionCell.Delegate<DossierProxy>() { @Override public void execute(DossierProxy dossier) { getUiHandlers().viewDetails(dossier); } }; ValidationActionCell actionsCell = actionCellFactory.create(verifyAction, previewAction); Column<DossierProxy, DossierProxy> actionsColumn = new Column<DossierProxy, DossierProxy>(actionsCell) { @Override public DossierProxy getValue(DossierProxy object) { return object; } }; actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); inscriptionsTable.addColumn(actionsColumn, "Action"); inscriptionsTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT); }
From source file:com.gsr.myschool.back.client.web.application.valueList.ValueListView.java
License:Apache License
private void initDataGrid() { TextColumn<ValueListProxy> labelColumn = new TextColumn<ValueListProxy>() { @Override//from w w w. ja v a 2s .c o m public String getValue(ValueListProxy valueList) { return valueList.getLabel(); } }; labelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); valueListTable.addColumn(labelColumn, "Label"); valueListTable.setColumnWidth(labelColumn, 35, Style.Unit.PCT); TextColumn<ValueListProxy> valueColumn = new TextColumn<ValueListProxy>() { @Override public String getValue(ValueListProxy valueList) { return valueList.getValue(); } }; valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); valueListTable.addColumn(valueColumn, "Valeur"); valueListTable.setColumnWidth(valueColumn, 35, Style.Unit.PCT); ValueListActionCell actionsCell = actionCellFactory.create(deleteAction, modifyAction); Column<ValueListProxy, ValueListProxy> actionsColumn = new Column<ValueListProxy, ValueListProxy>( actionsCell) { @Override public ValueListProxy getValue(ValueListProxy object) { return object; } }; actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); valueListTable.addColumn(actionsColumn, "Actions"); valueListTable.setColumnWidth(actionsColumn, 35, Style.Unit.PCT); }
From source file:com.gsr.myschool.front.client.web.application.inscription.InscriptionView.java
License:Apache License
private void initDataGrid() { TextColumn<DossierProxy> idColumn = new TextColumn<DossierProxy>() { @Override/* w ww. j a v a 2 s.c o m*/ public String getValue(DossierProxy object) { return object.getGeneratedNumDossier(); } }; idColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); inscriptionsTable.addColumn(idColumn, "N Dossier"); inscriptionsTable.setColumnWidth(idColumn, 15, Style.Unit.PCT); TextColumn<DossierProxy> statusColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { return object.getStatus().toString(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(statusColumn, "Statut"); inscriptionsTable.setColumnWidth(statusColumn, 20, Style.Unit.PCT); TextColumn<DossierProxy> anneeScolaireColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getAnneeScolaire() == null) return ""; return object.getAnneeScolaire().getLabel(); } }; statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(anneeScolaireColumn, "Anne scolaire"); inscriptionsTable.setColumnWidth(anneeScolaireColumn, 20, Style.Unit.PCT); TextColumn<DossierProxy> candidatColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy dossierProxy) { String firstName = dossierProxy.getCandidat().getFirstname(); String lastName = dossierProxy.getCandidat().getLastname(); if (Strings.isNullOrEmpty(firstName) && Strings.isNullOrEmpty(lastName)) { return ""; } else { return firstName + " " + lastName; } } }; candidatColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(candidatColumn, "Candidat"); inscriptionsTable.setColumnWidth(candidatColumn, 30, Style.Unit.PCT); TextColumn<DossierProxy> createdColumn = new TextColumn<DossierProxy>() { @Override public String getValue(DossierProxy object) { if (object.getCreateDate() == null) { return ""; } else { return dateFormat.format(object.getCreateDate()); } } }; createdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); inscriptionsTable.addColumn(createdColumn, "Date de pr-inscription"); inscriptionsTable.setColumnWidth(createdColumn, 20, Style.Unit.PCT); actionsCell = actionCellFactory.create(previewAction, editAction, deleteAction, submitAction, printAction); Column<DossierProxy, DossierProxy> actionsColumn = new Column<DossierProxy, DossierProxy>(actionsCell) { @Override public DossierProxy getValue(DossierProxy object) { return object; } }; actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); inscriptionsTable.addColumn(actionsColumn, "Actions"); inscriptionsTable.setColumnWidth(actionsColumn, 15, Style.Unit.PCT); }
From source file:com.gwt2go.dev.client.ui.CellTableSorting.java
License:Apache License
/** * Add a sortable column to the table.//from w ww . ja v a 2s . c om * * @param <C> * the data type for the column * @param text * the header text * @param cell * the cell used to render the column * @param getter * the getter to retrieve the value for the column * @param property * the property to sort by * @param ascComparator * ascendent comparator * @param descComparator * descendant comparator * @return the column */ private <C> Column<T, C> addColumn(final String text, final Cell<C> cell, final GetValue<T, C> getter, final Comparator<T> ascComparator, final Comparator<T> descComparator) { // gets the cell value final Column<T, C> column = new Column<T, C>(cell) { @Override public C getValue(T object) { return getter.getValue(object); } }; final SortableHeader header = new SortableHeader(text); allHeaders.add(header); // call this every time headers is clicked header.setUpdater(new ValueUpdater<String>() { public void update(String value) { header.setSorted(true); header.toggleReverseSort(); for (SortableHeader otherHeader : allHeaders) { if (otherHeader != header) { otherHeader.setSorted(false); otherHeader.setReverseSort(true); } } // sort the clicked column sortExpenses(dataProvider.getList(), header.getReverseSort() ? descComparator : ascComparator); // cellTable.redrawHeaders(); redrawHeaders(); // Go to the first page of the newly-sorted results, if wished // pager.firstPage(); } }); addColumn(column, header); return column; }
From source file:com.gwt2go.dev.client.ui.CellTableSortingViewImpl.java
License:Apache License
private void initTableColumns(final SelectionModel<ContactInfo> selectionModel, CellTableSorting<ContactInfo> cellTable) { // This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to // enable mouse selection. Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo, Boolean>(new CheckboxCell(true, true)) { @Override//from w w w . j av a2 s. com public Boolean getValue(ContactInfo object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; checkColumn.setFieldUpdater(new FieldUpdater<ContactInfo, Boolean>() { public void update(int index, ContactInfo object, Boolean value) { // Called when the user clicks on a checkbox. selectionModel.setSelected(object, value); } }); cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br>")); cellTable.addColumn("First name", new TextCell(), new GetValue<ContactInfo, String>() { public String getValue(ContactInfo object) { return object.getFirstName(); } }, new SortHeader("First name")); // Last name. Column<ContactInfo, String> lastNameColumn = new Column<ContactInfo, String>(new EditTextCell()) { @Override public String getValue(ContactInfo object) { return object.getLastName(); } }; cellTable.addColumn(lastNameColumn, "Last name"); lastNameColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { // Called when the user changes the value. object.setLastName(value); ContactDatabase.get().refreshDisplays(); } }); // Category. final Category[] categories = ContactDatabase.get().queryCategories(); List<String> categoryNames = new ArrayList<String>(); for (Category category : categories) { categoryNames.add(category.getDisplayName()); } SelectionCell categoryCell = new SelectionCell(categoryNames); Column<ContactInfo, String> categoryColumn = new Column<ContactInfo, String>(categoryCell) { @Override public String getValue(ContactInfo object) { return object.getCategory().getDisplayName(); } }; cellTable.addColumn(categoryColumn, "Category"); categoryColumn.setFieldUpdater(new FieldUpdater<ContactInfo, String>() { public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { object.setCategory(category); } } ContactDatabase.get().refreshDisplays(); } }); // Address. cellTable.addColumn("Address", new TextCell(), new GetValue<ContactInfo, String>() { public String getValue(ContactInfo object) { return object.getAddress(); } }, new SortHeader("Address")); cellTable.addColumn("Birthday", new DateCell(), new GetValue<ContactInfo, Date>() { public Date getValue(ContactInfo object) { return object.getBirthday(); } }, new SortHeader("Birthday")); }