List of usage examples for com.google.gwt.cell.client DateCell DateCell
public DateCell(DateTimeFormat format)
From source file:com.Administration.client.Administration.java
License:Apache License
/** * ? ? // w w w . j a v a2s . c om */ private void initTable() { // ? Column<LinkData, String> codeColumn = new Column<LinkData, String>(new TextCell()) { // C ? - ? ? @Override public String getValue(LinkData object) { // ? ? ? ? return object.getCode(); } }; codeColumn.setSortable(true); // ? sortHandler.setComparator(codeColumn, new Comparator<LinkData>() { // ? // , ? @Override public int compare(LinkData o1, LinkData o2) { // ? ?? if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getCode().compareTo(o2.getCode()) : 1; } return -1; } }); cellTable.addColumn(codeColumn, "Short Link"); // ? // ? ?? Column<LinkData, String> originalLinkColumn = new Column<LinkData, String>(new EditTextCell()) { @Override public String getValue(LinkData object) { return object.getLink(); } }; originalLinkColumn.setSortable(true); sortHandler.setComparator(originalLinkColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getLink().compareTo(o2.getLink()) : 1; } return -1; } }); cellTable.addColumn(originalLinkColumn, "Original Link"); originalLinkColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { // ? ? @Override public void update(int index, final LinkData object, final String value) { // ?? ? // ? ? AdministrationServiceInterface.App.getInstance().setOriginalLink(object.getId(), value, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { // ? ? ??? label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); // ? } @Override public void onSuccess(Boolean result) { // ? ? if (!result) { // ? ? ? ? label.setHTML("<h4>Server error!<h4>"); // } else { // ? ? object.setLink(value); dataProvider.refresh(); } } }); } }); DateTimeFormat dateFormat = DateTimeFormat.getFormat("dd MMM yyyy"); // // ? ?? Column<LinkData, Date> createDateColumn = new Column<LinkData, Date>(new DateCell(dateFormat)) { @Override public Date getValue(LinkData object) { return object.getCreateDate(); } }; createDateColumn.setSortable(true); sortHandler.setComparator(createDateColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getCreateDate().compareTo(o2.getCreateDate()) : 1; } return -1; } }); cellTable.addColumn(createDateColumn, "Create date"); DatePickerCell cell = new DatePickerCell(dateFormat); // ?? ? // ? Column<LinkData, Date> expiredDateColumn = new Column<LinkData, Date>(cell) { @Override public Date getValue(LinkData object) { return object.getExpiredDate(); } }; expiredDateColumn.setSortable(true); sortHandler.setComparator(expiredDateColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getExpiredDate().compareTo(o2.getExpiredDate()) : 1; } return -1; } }); cellTable.addColumn(expiredDateColumn, "Expired Date"); expiredDateColumn.setFieldUpdater(new FieldUpdater<LinkData, Date>() { @Override public void update(int index, final LinkData object, final Date value) { AdministrationServiceInterface.App.getInstance().setExpiredDate(object.getId(), value, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("<h4>Server error!<h4>"); } else { object.setExpiredDate(value); dataProvider.refresh(); } } }); } }); // - Column<LinkData, Number> currentCountColumn = new Column<LinkData, Number>(new NumberCell()) { @Override public Number getValue(LinkData object) { return object.getCurrentCount(); } }; currentCountColumn.setSortable(true); sortHandler.setComparator(currentCountColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getCurrentCount().compareTo(o2.getCurrentCount()) : 1; } return -1; } }); currentCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); cellTable.addColumn(currentCountColumn, "Current visits"); // ?, GWT EditNumberCell. . // ? ? ?. ? ?? ?. // ? - Column<LinkData, String> maxCountColumn = new Column<LinkData, String>(new EditTextCell()) { @Override public String getValue(LinkData object) { Integer t = object.getMaxCount(); if (t == 0) { return "Infinity"; } else { return t.toString(); // GWT!!! } } }; maxCountColumn.setSortable(true); sortHandler.setComparator(maxCountColumn, new Comparator<LinkData>() { @Override public int compare(LinkData o1, LinkData o2) { if (o1 == o2) { return 0; } if (o1 != null) { return (o2 != null) ? o1.getMaxCount().compareTo(o2.getMaxCount()) : 1; } return -1; } }); maxCountColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); cellTable.addColumn(maxCountColumn, "Max Visits"); maxCountColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { @Override public void update(int index, final LinkData object, final String value) { final Integer t; if (value.equals("Infinity")) { t = 0; } else { t = Integer.parseInt(value); } if (t < 0) { label.setHTML("Wrong maximum count!"); } AdministrationServiceInterface.App.getInstance().setMaxCount(object.getId(), t, new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("Server error!"); } else { object.setMaxCount(t); dataProvider.refresh(); } } }); } }); // Column<LinkData, String> passwordColumn = new Column<LinkData, String>(new EditTextCell()) { @Override public String getValue(LinkData object) { if (object.getPassword().equals("")) { return ""; } else { // ? , ? return "*********"; } } }; cellTable.addColumn(passwordColumn, "Password"); passwordColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { @Override public void update(int index, final LinkData object, final String value) { final String pass; if (value.isEmpty() || value.contains(" ")) { // ? ? ? ?? ? ? pass = null; } else { pass = value; } AdministrationServiceInterface.App.getInstance().setPassword(object.getId(), getMD5(pass), new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't update data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("<h4>Server error!<h4>"); } else { object.setPassword(getMD5(pass)); dataProvider.refresh(); } } }); } }); // ?? Column<LinkData, String> deleteColumn = new Column<LinkData, String>(new ButtonCell()) { @Override public String getValue(LinkData object) { return "Delete link"; // + object.getCode(); // + "' link"; } }; cellTable.addColumn(deleteColumn, ""); deleteColumn.setFieldUpdater(new FieldUpdater<LinkData, String>() { @Override public void update(int index, final LinkData object, String value) { if (Window.confirm("Shortlink " + object.getCode() + " will be delete!")) { AdministrationServiceInterface.App.getInstance().deleteLink(object.getId(), new AsyncCallback<Boolean>() { @Override public void onFailure(Throwable caught) { label.setHTML("<h4>Connection error!<br>Can't delete data!<h4>"); } @Override public void onSuccess(Boolean result) { if (!result) { label.setHTML("<h4>Server error!<h4>"); } else { // ? ?? dataProvider.getList().remove(object); dataProvider.refresh(); } } }); } } }); }
From source file:com.chinarewards.gwt.license.client.license.presenter.LicenseListPresenterImpl.java
License:Open Source License
private void initTableColumns() { Sorting<LicenseClient> ref = new Sorting<LicenseClient>() { @Override/*w w w .j ava2 s . c o m*/ public void sortingCurrentPage(Comparator<LicenseClient> comparator) { // listViewAdapter.sortCurrentPage(comparator); } @Override public void sortingAll(String sorting, String direction) { listViewAdapter.sortFromDateBase(sorting, direction); } }; cellTable.addColumn("??", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getCorporationName(); } }, ref, "licenseName"); cellTable.addColumn("?", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getLicenseTypeText(); } }, ref, ""); cellTable.addColumn("", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getStaffNumber() + ""; } }, ref, ""); cellTable.addColumn("?", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getMacaddress(); } }, ref, ""); cellTable.addColumn("", new DateCell(dateFormatAll), new GetValue<LicenseClient, Date>() { @Override public Date getValue(LicenseClient object) { return object.getNotafter(); } }, ref, "notafter"); cellTable.addColumn("", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getDescription(); } }, ref, ""); cellTable.addColumn("?", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getAwarduser(); } }, ref, "awarduser"); cellTable.addColumn("?", new DateCell(dateFormatAll), new GetValue<LicenseClient, Date>() { @Override public Date getValue(LicenseClient object) { return object.getIssued(); } }, ref, "issued"); cellTable.addColumn("?", new TextCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return license.getStatus().getDisplayName(); } }, ref, "status"); cellTable.addColumn("?", new HyperLinkCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient arg0) { return ""; } }, new FieldUpdater<LicenseClient, String>() { @Override public void update(int index, LicenseClient licenseClient, String value) { licenseClient.setThisAction(LicenseConstants.ACTION_LICENSE_VIEW); Platform.getInstance().getEditorRegistry().openEditor(LicenseConstants.EDITOR_LICENSE_VIEW, LicenseConstants.EDITOR_LICENSE_VIEW + licenseClient.getId(), licenseClient); } }); cellTable.addColumn("?", new HyperLinkCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient arg0) { return ""; } }, new FieldUpdater<LicenseClient, String>() { @Override public void update(int index, final LicenseClient licenseClient, String value) { licenseClient.setThisAction(LicenseConstants.ACTION_LICENSE_EDIT); Platform.getInstance().getEditorRegistry().openEditor(LicenseConstants.EDITOR_LICENSE_EDIT, LicenseConstants.EDITOR_LICENSE_EDIT + licenseClient.getId(), licenseClient); } }); cellTable.addColumn("?", new HyperLinkCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return ""; } }, new FieldUpdater<LicenseClient, String>() { @Override public void update(int index, LicenseClient o, String value) { if (Window.confirm("?")) { delteLicense(o.getId()); } } }); cellTable.addColumn("?", new HyperLinkCell(), new GetValue<LicenseClient, String>() { @Override public String getValue(LicenseClient license) { return ""; } }, new FieldUpdater<LicenseClient, String>() { @Override public void update(int index, LicenseClient license, String value) { if (RootPanel.get("downloadiframe") != null) { Widget widgetFrame = (Widget) RootPanel.get("downloadiframe"); widgetFrame.removeFromParent(); } NamedFrame frame = new NamedFrame("downloadiframe"); String url = ""; // url+=GWT.getModuleBaseURL(); url += "filedownload?licenseFileName=" + license.getLicenseFileName(); frame.setUrl(url); frame.setVisible(false); RootPanel.get().add(frame); } }); }
From source file:com.ephesoft.gxt.core.client.ui.service.columnConfig.impl.FolderManagerColumnConfigService.java
License:Open Source License
public FolderManagerColumnConfigService() { columnConfigList = new ArrayList<ColumnConfig<FolderManagerDTO, ?>>(); editorsMap = new HashMap<ColumnConfig, IsField>(); ColumnConfig<FolderManagerDTO, Boolean> modelSelector = new ColumnConfig<FolderManagerDTO, Boolean>( FolderManagerProperties.property.selected()); CheckBoxCell modelSelectionCell = new CheckBoxCell(); modelSelector.setCell(modelSelectionCell); modelSelector.setHeader(LocaleDictionary.getConstantValue(CoreCommonConstants.FM_SELECT_COLUMN_HEADER)); modelSelector.setWidth(30);// w w w .ja va 2s .c o m modelSelector.setFixed(true); modelSelector.setSortable(false); modelSelector.setHideable(false); ColumnConfig<FolderManagerDTO, String> fileName = new ColumnConfig<FolderManagerDTO, String>( FolderManagerProperties.property.fileName()); fileName.setHeader(LocaleDictionary.getConstantValue(CoreCommonConstants.FM_NAME_COLUMN_HEADER)); fileName.setHideable(false); ColumnConfig<FolderManagerDTO, Float> fileSize = new ColumnConfig<FolderManagerDTO, Float>( FolderManagerProperties.property.size()); fileSize.setHeader(LocaleDictionary.getConstantValue(CoreCommonConstants.FM_SIZE_COLUMN_HEADER)); ColumnConfig<FolderManagerDTO, FileType> fileType = new ColumnConfig<FolderManagerDTO, FileType>( FolderManagerProperties.property.kind()); fileType.setHeader(LocaleDictionary.getConstantValue(CoreCommonConstants.FM_FILE_TYPE_COLUMN_HEADER)); ColumnConfig<FolderManagerDTO, Date> modifiedAt = new ColumnConfig<FolderManagerDTO, Date>( FolderManagerProperties.property.modifiedAt()); modifiedAt.setHeader(LocaleDictionary.getConstantValue(CoreCommonConstants.FM_MODIFIED_COLUMN_HEADER)); modifiedAt.setCell(new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM))); @SuppressWarnings("unchecked") ColumnConfig<FolderManagerDTO, ImageResource> fileIcon = new ColumnConfig<FolderManagerDTO, ImageResource>( new ValueProvider() { @Override public ImageResource getValue(Object object) { ImageResource image = null; FolderManagerDTO dto = (FolderManagerDTO) object; if (dto.getKind() == FileType.DIR) { image = imageResources.icon_folder(); } else if (dto.getKind() == FileType.DOC) { image = imageResources.icon_doc(); } else if (dto.getKind() == FileType.MM) { image = imageResources.icon_mm(); } else if (dto.getKind() == FileType.IMG) { image = imageResources.icon_img(); } else if (dto.getKind() == FileType.OTHER) { image = imageResources.icon_other(); } return image; } @Override public void setValue(Object object, Object value) { } @Override public String getPath() { return null; } }); fileIcon.setSortable(false); fileIcon.setHeader(LocaleDictionary.getConstantValue(CoreCommonConstants.FM_ICON_COLUMN_HEADER)); ImageResourceCell imageCell = new ImageResourceCell() { @Override public void render(com.google.gwt.cell.client.Cell.Context context, ImageResource value, SafeHtmlBuilder sb) { super.render(context, value, sb); } }; fileIcon.setCell(imageCell); columnConfigList.add(modelSelector); columnConfigList.add(fileIcon); columnConfigList.add(fileName); columnConfigList.add(modifiedAt); columnConfigList.add(fileType); columnConfigList.add(fileSize); editorsMap.put(fileName, new TextField()); }
From source file:com.google.gwt.sample.expenses.client.ExpenseDetails.java
License:Apache License
private CellTable<ExpenseProxy> initTable() { CellTable.Resources resources = GWT.create(TableResources.class); table = new CellTable<ExpenseProxy>(100, resources, Expenses.EXPENSE_RECORD_KEY_PROVIDER); Styles.Common common = Styles.common(); table.addColumnStyleName(0, common.spacerColumn()); table.addColumnStyleName(1, common.expenseDetailsDateColumn()); table.addColumnStyleName(3, common.expenseDetailsCategoryColumn()); table.addColumnStyleName(4, common.expenseDetailsAmountColumn()); table.addColumnStyleName(5, common.expenseDetailsApprovalColumn()); table.addColumnStyleName(6, common.spacerColumn()); // Spacer column. table.addColumn(new SpacerColumn<ExpenseProxy>()); // Created column. GetValue<ExpenseProxy, Date> createdGetter = new GetValue<ExpenseProxy, Date>() { public Date getValue(ExpenseProxy object) { return object.getCreated(); }/*from ww w .j av a 2 s. c o m*/ }; defaultComparator = createColumnComparator(createdGetter, false); Comparator<ExpenseProxy> createdDesc = createColumnComparator(createdGetter, true); addColumn(table, "Created", new DateCell(DateTimeFormat.getFormat("MMM dd yyyy")), createdGetter, defaultComparator, createdDesc); lastComparator = defaultComparator; // Description column. addColumn(table, "Description", new TextCell(), new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getDescription(); } }); // Category column. addColumn(table, "Category", new TextCell(), new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getCategory(); } }); // Amount column. final GetValue<ExpenseProxy, Double> amountGetter = new GetValue<ExpenseProxy, Double>() { public Double getValue(ExpenseProxy object) { return object.getAmount(); } }; Comparator<ExpenseProxy> amountAsc = createColumnComparator(amountGetter, false); Comparator<ExpenseProxy> amountDesc = createColumnComparator(amountGetter, true); addColumn(table, "Amount", new NumberCell(NumberFormat.getCurrencyFormat()), new GetValue<ExpenseProxy, Number>() { public Number getValue(ExpenseProxy object) { return amountGetter.getValue(object); } }, amountAsc, amountDesc); // Dialog box to obtain a reason for a denial denialPopup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { String reasonDenied = denialPopup.getReasonDenied(); ExpenseProxy record = denialPopup.getExpenseRecord(); if (reasonDenied == null || reasonDenied.length() == 0) { // Clear the view data. final Object key = items.getKey(record); approvalCell.clearViewData(key); // We need to redraw the table to reset the select box. syncCommit(record, null); } else { updateExpenseRecord(record, "Denied", reasonDenied); } // Return focus to the table. table.setFocus(true); } }); // Approval column. approvalCell = new ApprovalCell(); Column<ExpenseProxy, String> approvalColumn = addColumn(table, "Approval Status", approvalCell, new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getApproval(); } }); approvalColumn.setFieldUpdater(new FieldUpdater<ExpenseProxy, String>() { public void update(int index, final ExpenseProxy object, String value) { if ("Denied".equals(value)) { denialPopup.setExpenseRecord(object); denialPopup.setReasonDenied(object.getReasonDenied()); denialPopup.popup(); } else { updateExpenseRecord(object, value, ""); } } }); // Spacer column. table.addColumn(new SpacerColumn<ExpenseProxy>()); return table; }
From source file:com.google.gwt.sample.expenses.client.ExpenseList.java
License:Apache License
/** * Create the {@link CellTable}.//from ww w .j av a 2 s . c o m */ private void createTable() { CellTable.Resources resources = GWT.create(TableResources.class); table = new CellTable<ReportProxy>(20, resources); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); Styles.Common common = Styles.common(); table.addColumnStyleName(0, common.spacerColumn()); table.addColumnStyleName(1, common.expenseListPurposeColumn()); table.addColumnStyleName(3, common.expenseListDepartmentColumn()); table.addColumnStyleName(4, common.expenseListCreatedColumn()); table.addColumnStyleName(5, common.spacerColumn()); // Add a selection model. final NoSelectionModel<ReportProxy> selectionModel = new NoSelectionModel<ReportProxy>(); table.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Object selected = selectionModel.getLastSelectedObject(); if (selected != null && listener != null) { listener.onReportSelected((ReportProxy) selected); } } }); // Spacer column. table.addColumn(new SpacerColumn<ReportProxy>()); // Purpose column. addColumn("Purpose", new HighlightCell(), new GetValue<ReportProxy, String>() { public String getValue(ReportProxy object) { return object.getPurpose(); } }, "purpose"); // Notes column. addColumn("Notes", new HighlightCell(), new GetValue<ReportProxy, String>() { public String getValue(ReportProxy object) { return object.getNotes(); } }, "notes"); // Department column. addColumn("Department", new TextCell(), new GetValue<ReportProxy, String>() { public String getValue(ReportProxy object) { return object.getDepartment(); } }, "department"); // Created column. addColumn("Created", new DateCell(DateTimeFormat.getFormat("MMM dd yyyy")), new GetValue<ReportProxy, Date>() { public Date getValue(ReportProxy object) { return object.getCreated(); } }, "created"); // Spacer column. table.addColumn(new SpacerColumn<ReportProxy>()); }
From source file:com.google.gwt.sample.expenses.client.ExpenseReportDetails.java
License:Apache License
private CellTable<ExpenseProxy> initTable() { CellTable.Resources resources = GWT.create(TableResources.class); table = new CellTable<ExpenseProxy>(100, resources, new EntityProxyKeyProvider<ExpenseProxy>()); Styles.Common common = Styles.common(); table.addColumnStyleName(0, common.spacerColumn()); table.addColumnStyleName(1, common.expenseDetailsDateColumn()); table.addColumnStyleName(3, common.expenseDetailsCategoryColumn()); table.addColumnStyleName(4, common.expenseDetailsAmountColumn()); table.addColumnStyleName(5, common.expenseDetailsApprovalColumn()); table.addColumnStyleName(6, common.spacerColumn()); // Spacer column. table.addColumn(new SpacerColumn<ExpenseProxy>()); // Created column. GetValue<ExpenseProxy, Date> createdGetter = new GetValue<ExpenseProxy, Date>() { public Date getValue(ExpenseProxy object) { return object.getCreated(); }/*from w ww . j a v a2 s .c o m*/ }; defaultComparator = createColumnComparator(createdGetter, false); Comparator<ExpenseProxy> createdDesc = createColumnComparator(createdGetter, true); addColumn(table, "Created", new DateCell(DateTimeFormat.getFormat("MMM dd yyyy")), createdGetter, defaultComparator, createdDesc); lastComparator = defaultComparator; // Description column. addColumn(table, "Description", new TextCell(), new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getDescription(); } }); // Category column. addColumn(table, "Category", new TextCell(), new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getCategory(); } }); // Amount column. final GetValue<ExpenseProxy, Double> amountGetter = new GetValue<ExpenseProxy, Double>() { public Double getValue(ExpenseProxy object) { return object.getAmount(); } }; Comparator<ExpenseProxy> amountAsc = createColumnComparator(amountGetter, false); Comparator<ExpenseProxy> amountDesc = createColumnComparator(amountGetter, true); addColumn(table, "Amount", new NumberCell(NumberFormat.getCurrencyFormat()), new GetValue<ExpenseProxy, Number>() { public Number getValue(ExpenseProxy object) { return amountGetter.getValue(object); } }, amountAsc, amountDesc); // Dialog box to obtain a reason for a denial denialPopup.addCloseHandler(new CloseHandler<PopupPanel>() { public void onClose(CloseEvent<PopupPanel> event) { String reasonDenied = denialPopup.getReasonDenied(); ExpenseProxy record = denialPopup.getExpenseRecord(); if (reasonDenied == null || reasonDenied.length() == 0) { // Clear the view data. final Object key = items.getKey(record); approvalCell.clearViewData(key); // We need to redraw the table to reset the select box. syncCommit(record, null); } else { updateExpenseRecord(record, "Denied", reasonDenied); } // Return focus to the table. table.setFocus(true); } }); // Approval column. approvalCell = new ApprovalCell(); Column<ExpenseProxy, String> approvalColumn = addColumn(table, "Approval Status", approvalCell, new GetValue<ExpenseProxy, String>() { public String getValue(ExpenseProxy object) { return object.getApproval(); } }); approvalColumn.setFieldUpdater(new FieldUpdater<ExpenseProxy, String>() { public void update(int index, final ExpenseProxy object, String value) { if ("Denied".equals(value)) { denialPopup.setExpenseRecord(object); denialPopup.setReasonDenied(object.getReasonDenied()); denialPopup.popup(); } else { updateExpenseRecord(object, value, ""); } } }); // Spacer column. table.addColumn(new SpacerColumn<ExpenseProxy>()); return table; }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellSampler.java
License:Apache License
/** * Initialize this example.// w w w . ja v a2 s . co m */ @ShowcaseSource @Override public Widget onInitialize() { Images images = GWT.create(Images.class); // Create the table. editableCells = new ArrayList<AbstractEditableCell<?, ?>>(); contactList = new DataGrid<ContactInfo>(25, ContactInfo.KEY_PROVIDER); contactList.setMinimumTableWidth(140, Unit.EM); ContactDatabase.get().addDataDisplay(contactList); // CheckboxCell. final Category[] categories = ContactDatabase.get().queryCategories(); addColumn(new CheckboxCell(), "Checkbox", new GetValue<Boolean>() { @Override public Boolean getValue(ContactInfo contact) { // Checkbox indicates that the contact is a relative. // Index 0 = Family. return contact.getCategory() == categories[0]; } }, new FieldUpdater<ContactInfo, Boolean>() { @Override public void update(int index, ContactInfo object, Boolean value) { if (value) { // If a relative, use the Family Category. pendingChanges.add(new CategoryChange(object, categories[0])); } else { // If not a relative, use the Contacts Category. pendingChanges.add(new CategoryChange(object, categories[categories.length - 1])); } } }); // TextCell. addColumn(new TextCell(), "Text", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getFullName(); } }, null); // EditTextCell. Column<ContactInfo, String> editTextColumn = addColumn(new EditTextCell(), "EditText", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { pendingChanges.add(new FirstNameChange(object, value)); } }); contactList.setColumnWidth(editTextColumn, 16.0, Unit.EM); // TextInputCell. Column<ContactInfo, String> textInputColumn = addColumn(new TextInputCell(), "TextInput", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getLastName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { pendingChanges.add(new LastNameChange(object, value)); } }); contactList.setColumnWidth(textInputColumn, 16.0, Unit.EM); // ClickableTextCell. addColumn(new ClickableTextCell(), "ClickableText", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "Click " + contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { Window.alert("You clicked " + object.getFullName()); } }); // ActionCell. addColumn(new ActionCell<ContactInfo>("Click Me", new ActionCell.Delegate<ContactInfo>() { @Override public void execute(ContactInfo contact) { Window.alert("You clicked " + contact.getFullName()); } }), "Action", new GetValue<ContactInfo>() { @Override public ContactInfo getValue(ContactInfo contact) { return contact; } }, null); // ButtonCell. addColumn(new ButtonCell(), "Button", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "Click " + contact.getFirstName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { Window.alert("You clicked " + object.getFullName()); } }); // DateCell. DateTimeFormat dateFormat = DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM); addColumn(new DateCell(dateFormat), "Date", new GetValue<Date>() { @Override public Date getValue(ContactInfo contact) { return contact.getBirthday(); } }, null); // DatePickerCell. addColumn(new DatePickerCell(dateFormat), "DatePicker", new GetValue<Date>() { @Override public Date getValue(ContactInfo contact) { return contact.getBirthday(); } }, new FieldUpdater<ContactInfo, Date>() { @Override public void update(int index, ContactInfo object, Date value) { pendingChanges.add(new BirthdayChange(object, value)); } }); // NumberCell. Column<ContactInfo, Number> numberColumn = addColumn(new NumberCell(), "Number", new GetValue<Number>() { @Override public Number getValue(ContactInfo contact) { return contact.getAge(); } }, null); numberColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LOCALE_END); // IconCellDecorator. addColumn(new IconCellDecorator<String>(images.contactsGroup(), new TextCell()), "Icon", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getCategory().getDisplayName(); } }, null); // ImageCell. addColumn(new ImageCell(), "Image", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return "contact.jpg"; } }, null); // SelectionCell. List<String> options = new ArrayList<String>(); for (Category category : categories) { options.add(category.getDisplayName()); } addColumn(new SelectionCell(options), "Selection", new GetValue<String>() { @Override public String getValue(ContactInfo contact) { return contact.getCategory().getDisplayName(); } }, new FieldUpdater<ContactInfo, String>() { @Override public void update(int index, ContactInfo object, String value) { for (Category category : categories) { if (category.getDisplayName().equals(value)) { pendingChanges.add(new CategoryChange(object, category)); break; } } } }); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); Widget widget = uiBinder.createAndBindUi(this); // Add handlers to redraw or refresh the table. redrawButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { contactList.redraw(); } }); commitButton.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Commit the changes. for (PendingChange<?> pendingChange : pendingChanges) { pendingChange.commit(); } pendingChanges.clear(); // Push the changes to the views. ContactDatabase.get().refreshDisplays(); } }); return widget; }
From source file:com.gwtmodel.table.view.table.PresentationCellFactory.java
License:Apache License
@SuppressWarnings("rawtypes") Column constructDateEditCol(IVField v) { return new DateColumn(v, new DateCell(fo)); }
From source file:com.gwtmodel.table.view.table.PresentationCellFactory.java
License:Apache License
@SuppressWarnings("rawtypes") Cell constructCell(IVField v) {// w w w . java 2 s.com Cell ce; switch (v.getType().getType()) { case DATE: ce = new DateCell(fo); break; case LONG: case INT: ce = iCell; break; case BIGDECIMAL: switch (v.getType().getAfterdot()) { case 0: ce = iCell; break; case 1: ce = nCell1; break; case 2: ce = nCell2; break; case 3: ce = nCell3; break; default: ce = nCell4; break; } break; case BOOLEAN: return checkCell; default: ce = new TextCell(); break; } return ce; }
From source file:com.kk_electronic.kkportal.core.util.DateColumn.java
License:Open Source License
public DateColumn() { super(new DateCell(DateTimeFormat.getFormat(PredefinedFormat.DATE_MEDIUM))); }