List of usage examples for com.google.gwt.cell.client DateCell DateCell
public DateCell()
From source file:com.appspot.socialinquirer.client.view.HomeViewImpl.java
License:Apache License
/** * Inits the table columns.//from w ww .j a v a2s.c o m * * @param table the table * @param selectionModel the selection model */ private void initTableColumns(CellTable<Question> table, final SelectionModel<Question> selectionModel) { // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable // mouse selection. Column<Question, Boolean> checkColumn = new Column<Question, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(Question object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); // Title. Column<Question, SafeHtml> titleColumn = new Column<Question, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Question object) { return SafeHtmlUtils.fromSafeConstant(object.getTitle()); } }; table.addColumn(titleColumn, constants.templatesTableColumnName()); // Description. Column<Question, SafeHtml> textColumn = new Column<Question, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Question object) { return SafeHtmlUtils.fromSafeConstant(object.getContent()); } }; table.addColumn(textColumn, constants.templatesTableColumnSummary()); // Due Date. Column<Question, Date> dueDateColumn = new Column<Question, Date>(new DateCell()) { @Override public Date getValue(Question object) { return object.getPublishedDate(); } }; table.addColumn(dueDateColumn, constants.templatesTableColumnTags()); }
From source file:com.appspot.socialinquirer.client.view.QuestionsViewImpl.java
License:Apache License
/** * Inits the table columns./*from w w w . j a v a 2 s. c o m*/ * * @param table the table * @param selectionModel the selection model */ private void initTableColumns(CellTable<Question> table, final SelectionModel<Question> selectionModel) { // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable // mouse selection. Column<Question, Boolean> checkColumn = new Column<Question, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(Question object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); // Title. Column<Question, SafeHtml> titleColumn = new Column<Question, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Question object) { return SafeHtmlUtils.fromSafeConstant(object.getTitle()); } }; table.addColumn(titleColumn, constants.templatesTableColumnName()); // Description. Column<Question, SafeHtml> textColumn = new Column<Question, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Question object) { return SafeHtmlUtils.fromSafeConstant(object.getContent()); } }; table.addColumn(textColumn, constants.templatesTableColumnSummary()); // Status. Column<Question, SafeHtml> statusColumn = new Column<Question, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Question object) { return SafeHtmlUtils.fromSafeConstant(object.getTags().toString()); } }; table.addColumn(statusColumn, constants.templatesTableColumnTags()); Column<Question, SafeHtml> authorColumn = new Column<Question, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Question object) { return SafeHtmlUtils.fromSafeConstant(object.getAuthor()); } }; table.addColumn(authorColumn, constants.templatesTableColumnAuthor()); // Due Date. Column<Question, Date> dueDateColumn = new Column<Question, Date>(new DateCell()) { @Override public Date getValue(Question object) { return object.getPublishedDate(); } }; table.addColumn(dueDateColumn, constants.templatesTableColumnPostedDate()); }
From source file:com.appspot.socialinquirer.client.view.QuestionViewImpl.java
License:Apache License
/** * Inits the table columns.// ww w. ja va 2s .c o m * * @param table the table * @param selectionModel the selection model */ private void initTableColumns(CellTable<Answer> table, final SelectionModel<Answer> selectionModel) { // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable // mouse selection. // Column<Answer, Boolean> checkColumn = new Column<Answer, Boolean>( // new CheckboxCell(true, false)) { // @Override // public Boolean getValue(Answer object) { // // Get the value from the selection model. // return selectionModel.isSelected(object); // } // }; // table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); // Description. Column<Answer, SafeHtml> textColumn = new Column<Answer, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Answer object) { return SafeHtmlUtils.fromSafeConstant(object.getContent()); } }; table.addColumn(textColumn, constants.templatesTableColumnSummary()); // Status. Column<Answer, SafeHtml> authorColumn = new Column<Answer, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Answer object) { return SafeHtmlUtils.fromSafeConstant(object.getAuthor()); } }; table.addColumn(authorColumn, constants.templatesTableColumnAuthor()); // Due Date. Column<Answer, Date> dueDateColumn = new Column<Answer, Date>(new DateCell()) { @Override public Date getValue(Answer object) { return object.getPublishedDate(); } }; table.addColumn(dueDateColumn, constants.templatesTableColumnPostedDate()); }
From source file:com.appspot.socialinquirer.client.view.QuizViewImpl.java
License:Apache License
/** * Inits the table columns./*from www . j a v a 2 s . c o m*/ * * @param table the table * @param selectionModel the selection model */ private void initTableColumns(CellTable<Answer> table, final SelectionModel<Answer> selectionModel) { // Checkbox column. This table will uses a checkbox column for selection. // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable // mouse selection. Column<Answer, Boolean> checkColumn = new Column<Answer, Boolean>(new CheckboxCell(true, false)) { @Override public Boolean getValue(Answer object) { // Get the value from the selection model. return selectionModel.isSelected(object); } }; table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>")); // Description. Column<Answer, SafeHtml> textColumn = new Column<Answer, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Answer object) { return SafeHtmlUtils.fromSafeConstant(object.getContent()); } }; table.addColumn(textColumn, constants.templatesTableColumnSummary()); // Status. Column<Answer, SafeHtml> authorColumn = new Column<Answer, SafeHtml>(new SafeHtmlCell()) { @Override public SafeHtml getValue(Answer object) { return SafeHtmlUtils.fromSafeConstant(object.getAuthor()); } }; table.addColumn(authorColumn, constants.templatesTableColumnAuthor()); // Due Date. Column<Answer, Date> dueDateColumn = new Column<Answer, Date>(new DateCell()) { @Override public Date getValue(Answer object) { return object.getPublishedDate(); } }; table.addColumn(dueDateColumn, constants.templatesTableColumnPostedDate()); }
From source file:com.google.gwt.examples.cellview.CellTableExample.java
License:Apache License
public void onModuleLoad() { // Create a CellTable. CellTable<Contact> table = new CellTable<Contact>(); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); // Add a text column to show the name. TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override/*from ww w . j av a 2 s . c o m*/ public String getValue(Contact object) { return object.name; } }; table.addColumn(nameColumn, "Name"); // Add a date column to show the birthday. DateCell dateCell = new DateCell(); Column<Contact, Date> dateColumn = new Column<Contact, Date>(dateCell) { @Override public Date getValue(Contact object) { return object.birthday; } }; table.addColumn(dateColumn, "Birthday"); // Add a text column to show the address. TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact object) { return object.address; } }; table.addColumn(addressColumn, "Address"); // Add a selection model to handle user selection. final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>(); table.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Contact selected = selectionModel.getSelectedObject(); if (selected != null) { Window.alert("You selected: " + selected.name); } } }); // 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); // Add it to the root panel. RootPanel.get().add(table); }
From source file:com.google.gwt.sample.mobilewebapp.client.desktop.DesktopTaskListView.java
License:Apache License
/** * Construct a new {@link DesktopTaskListView}. *///from ww w . ja va 2 s . c o m public DesktopTaskListView() { // Create the CellTable. taskList = new DataGrid<TaskProxy>(); taskList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); taskList.setWidth("100%"); // Add the task name column. Column<TaskProxy, String> nameColumn = new TextColumn<TaskProxy>() { @Override public String getValue(TaskProxy object) { return (object == null) ? null : object.getName(); } }; taskList.addColumn(nameColumn, "Task"); // Add the task notes column. Column<TaskProxy, String> notesColumn = new TextColumn<TaskProxy>() { @Override public String getValue(TaskProxy object) { return (object == null) ? "" : object.getNotes(); } }; taskList.addColumn(notesColumn, "Description"); // Add the task due date column. Column<TaskProxy, Date> dateColumn = new Column<TaskProxy, Date>(new DateCell()) { @Override public Date getValue(TaskProxy object) { return (object == null) ? null : object.getDueDate(); } }; taskList.addColumn(dateColumn, "Due Date"); /* * Inform the presenter when the user selects a task from the task list. */ final NoSelectionModel<TaskProxy> selectionModel = new NoSelectionModel<TaskProxy>(); taskList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { // Edit the task. if (presenter != null) { presenter.selectTask(selectionModel.getLastSelectedObject()); } } }); // Initialize the widget. initWidget(taskList); }
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 ww w. j a v a 2 s . c o m*/ 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")); }
From source file:com.gwt2go.dev.client.ui.table.DataGridImpl1.java
License:Apache License
public DataGridImpl1() { // Create a CellTable. DataGrid<Contact> table = new DataGrid<Contact>(); table.setWidth("100%"); table.setHeight("100px"); // table.setRowStyles(new RowStyles<DataGridImpl1.Contact>() { // @Override // public String getStyleNames(Contact row, int rowIndex) { // return "headcol"; // }//from ww w .java 2 s .c om // }); table.setEmptyTableWidget(new Label("No Information to show")); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); // Add a text column to show the name. TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override public String getValue(Contact object) { return object.name; } }; table.addColumn(nameColumn, "Name"); // Add a date column to show the birthday. DateCell dateCell = new DateCell(); Column<Contact, Date> dateColumn = new Column<Contact, Date>(dateCell) { @Override public Date getValue(Contact object) { return object.birthday; } }; table.addColumn(dateColumn, "Birthday"); // Add a text column to show the address. TextColumn<Contact> addressColumn = new TextColumn<Contact>() { @Override public String getValue(Contact object) { return object.address; } }; table.addColumn(addressColumn, "Address"); // Add a selection model to handle user selection. final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>(); table.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Contact selected = selectionModel.getSelectedObject(); if (selected != null) { Window.alert("You selected: " + selected.name); } } }); // 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); // -- END TABLE // viewPanel.getElement().appendChild(nameSpan); viewPanel.add(table); viewPanel.setSize("30em", "10em"); initWidget(viewPanel); }
From source file:com.pronoiahealth.olhie.client.pages.admin.widgets.AuthorRequestWidget.java
License:Open Source License
/** * Build grid/* w ww. j a v a 2 s .c o m*/ */ @PostConstruct protected void postConstruct() { // Data Provider dataProvider = new ListDataProvider<RegistrationForm>(); // Grid configuration authorReqGrid = new CellTable<RegistrationForm>(10, KEY_PROVIDER); authorReqGrid.setWidth("100%"); authorReqGrid.setAutoHeaderRefreshDisabled(true); authorReqGrid.setAutoFooterRefreshDisabled(true); authorReqGrid.setEmptyTableWidget(new Label("Nothing to show")); authorReqGrid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); authorReqGrid.setWidth("100%", true); // Selection Model final SelectionModel<RegistrationForm> selectionModel = new SingleSelectionModel<RegistrationForm>( KEY_PROVIDER); authorReqGrid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<RegistrationForm>createCheckboxManager()); // Init columns // Id TextColumn<RegistrationForm> idColumn = new TextColumn<RegistrationForm>() { @Override public String getValue(RegistrationForm object) { return object.getId(); } }; idColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(idColumn, "ID"); authorReqGrid.setColumnWidth(idColumn, 5, Unit.PCT); // First Name TextColumn<RegistrationForm> firstColumn = new TextColumn<RegistrationForm>() { @Override public String getValue(RegistrationForm object) { return object.getFirstName(); } }; firstColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(firstColumn, "First"); authorReqGrid.setColumnWidth(firstColumn, 7, Unit.PCT); // Last Name TextColumn<RegistrationForm> lastColumn = new TextColumn<RegistrationForm>() { @Override public String getValue(RegistrationForm object) { return object.getLastName(); } }; lastColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(lastColumn, "Last"); authorReqGrid.setColumnWidth(lastColumn, 12, Unit.PCT); // userId TextColumn<RegistrationForm> userIdColumn = new TextColumn<RegistrationForm>() { @Override public String getValue(RegistrationForm object) { return object.getUserId(); } }; userIdColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(userIdColumn, "UserId"); authorReqGrid.setColumnWidth(userIdColumn, 10, Unit.PCT); // eMail TextColumn<RegistrationForm> eMailColumn = new TextColumn<RegistrationForm>() { @Override public String getValue(RegistrationForm object) { return object.getEmail(); } }; eMailColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(eMailColumn, "eMail"); authorReqGrid.setColumnWidth(eMailColumn, 15, Unit.PCT); // Registration Date DateCell dateCell = new DateCell(); Column<RegistrationForm, Date> dateColumn = new Column<RegistrationForm, Date>(dateCell) { @Override public Date getValue(RegistrationForm object) { return object.getRegDate(); } }; dateColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(dateColumn, "Reg Date"); authorReqGrid.setColumnWidth(dateColumn, 17, Unit.PCT); // Organization TextColumn<RegistrationForm> orgColumn = new TextColumn<RegistrationForm>() { @Override public String getValue(RegistrationForm object) { return object.getOrganization(); } }; orgColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(orgColumn, "Organization"); authorReqGrid.setColumnWidth(orgColumn, 15, Unit.PCT); // Status List<String> statusNames = Arrays.asList(authStatus); SelectionCell statusCell = new SelectionCell(statusNames); Column<RegistrationForm, String> statusColumn = new Column<RegistrationForm, String>(statusCell) { @Override public String getValue(RegistrationForm object) { return object.getAuthorStatus(); } }; statusColumn.setCellStyleNames("ph-Admin-tbl-cell-text-align-left"); authorReqGrid.addColumn(statusColumn, "Status"); // Status column updated statusColumn.setFieldUpdater(new FieldUpdater<RegistrationForm, String>() { @Override public void update(int index, RegistrationForm object, String value) { object.setAuthorStatus(value); dataProvider.refresh(); // Tell the AdminService about the change authorRequestStatusChangeEvent.fire(new AuthorRequestStatusChangeEvent(object.getId(), value)); } }); authorReqGrid.setColumnWidth(statusColumn, 19, Unit.PCT); // Set the dataprovider dataProvider.addDataDisplay(authorReqGrid); // Pager SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class); pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true); pager.setDisplay(authorReqGrid); pager.setPageSize(10); pager.getElement().setAttribute("style", "margin: auto;"); // Redraw the grid authorReqGrid.redraw(); authorReqGrid.setVisible(true); // Add to container authorRequestTbl.add(authorReqGrid); pagerContainer.add(pager); }
From source file:de.uni_koeln.spinfo.maalr.webapp.ui.admin.client.user.list.UserList.java
License:Apache License
/** * Initializes the table, by adding and configuring columns, * and by assigning the data provider./*w w w. j a v a2 s .c o m*/ */ private void initCellTable() { table = new PagingDataGrid<LightUserInfo>(); // Login Column UserColumn user = new UserColumn(); user.setDataStoreName(LightUserInfo.SORT_LOGIN); table.addColumn(user, "Login"); // First name column Column<LightUserInfo, String> firstName = new Column<LightUserInfo, String>(new TextCell()) { @Override public String getValue(LightUserInfo object) { return getDisplayString(object.getFirstName()); } }; // Unique identifier required for sorting firstName.setDataStoreName(LightUserInfo.SORT_FIRST_NAME); table.addColumn(firstName, "First Name"); // Last name column Column<LightUserInfo, String> lastName = new Column<LightUserInfo, String>(new TextCell()) { @Override public String getValue(LightUserInfo object) { return getDisplayString(object.getLastName()); } }; // Unique identifier required for sorting lastName.setDataStoreName(LightUserInfo.SORT_LAST_NAME); table.addColumn(lastName, "Last Name"); // Email column Column<LightUserInfo, String> email = new Column<LightUserInfo, String>(new TextCell()) { @Override public String getValue(LightUserInfo object) { return getDisplayString(object.getEmail()); } }; // Unique identifier required for sorting email.setDataStoreName(LightUserInfo.SORT_EMAIL); table.addColumn(email, "Email"); // Role column Column<LightUserInfo, String> role = new Column<LightUserInfo, String>(new TextCell()) { @Override public String getValue(LightUserInfo object) { return object.getRole().getRoleName(); } }; // Unique identifier required for sorting role.setDataStoreName(LightUserInfo.SORT_ROLE); table.addColumn(role, "Role"); // Creation date Column<LightUserInfo, Date> creation = new Column<LightUserInfo, Date>(new DateCell()) { @Override public Date getValue(LightUserInfo object) { return new Date(object.getCreationDate()); } }; // Unique identifier required for sorting creation.setDataStoreName(LightUserInfo.SORT_CREATED); table.addColumn(creation, "Created"); // Last modified date Column<LightUserInfo, Date> modified = new Column<LightUserInfo, Date>(new DateCell()) { @Override public Date getValue(LightUserInfo object) { return new Date(object.getLastModificationDate()); } }; // Unique identifier required for sorting modified.setDataStoreName(LightUserInfo.SORT_MODIFIED); table.addColumn(modified, "Last Change"); // Enable navigation through arrow keys table.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); // Assing data provider dataProvider = new UserListDataProvider(table); // Make columns sortable int columnCount = table.getColumnCount(); for (int i = 0; i < columnCount; i++) { table.getColumn(i).setSortable(true); } table.setRowCount(20); }