List of usage examples for com.google.gwt.cell.client HasCell HasCell
HasCell
From source file:accelerator.client.ui.TaskDialogBox.java
License:Open Source License
/** * //from w w w. j a v a2s.c o m */ public TaskDialogBox() { setWidget(uiBinder.createAndBindUi(this)); projectListBox.addItem("(??)", ""); List<HasCell<Tag, ?>> hasCells = CollectionUtil.createArrayList(); hasCells.add(new HasCell<Tag, Boolean>() { private final CheckboxCell cell = new CheckboxCell(); public Cell<Boolean> getCell() { return cell; } public FieldUpdater<Tag, Boolean> getFieldUpdater() { return null; } public Boolean getValue(Tag object) { return selectionModel.isSelected(object); } }); hasCells.add(new HasCell<Tag, Tag>() { private final TagCell cell = new TagCell(); public Cell<Tag> getCell() { return cell; } public FieldUpdater<Tag, Tag> getFieldUpdater() { return null; } public Tag getValue(Tag object) { return object; } }); CompositeCell<Tag> tagCell = new CompositeCell<Tag>(hasCells); tagCellList = new CellList<Tag>(tagCell); tagCellList.setSelectionModel(selectionModel, selectionManager); scrollPanel.add(tagCellList); nameErrorLabel.setVisible(false); setText("??"); setHandler(null); // DateBox ?? dueDateBox.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat("yyyy/MM/dd"))); }
From source file:accelerator.client.view.desktop.DesktopTaskListView.java
License:Open Source License
/** * CompositCell ? HasCell ?????//from ww w . j a va 2 s . com * * @param handler * ???????? * @return HasCell ? */ private List<HasCell<Task, ?>> createHasCellList() { List<HasCell<Task, ?>> hasCellList = CollectionUtil.createArrayList(); // ?? hasCellList.add(new HasCell<Task, Boolean>() { private final CheckboxCell cell = new CheckboxCell(); public Cell<Boolean> getCell() { return cell; } public FieldUpdater<Task, Boolean> getFieldUpdater() { return new FieldUpdater<Task, Boolean>() { public void update(int index, Task object, Boolean value) { object.setCompleted(value); DesktopTaskListView.this.presenter.updateTask(object); } }; } public Boolean getValue(Task object) { return object.getCompleted(); } }); // ? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); // ???????????? if (presenter instanceof InboxPresenter) { return sb.toSafeHtml(); } else if (presenter instanceof ProjectPresenter) { return sb.toSafeHtml(); } Key projectKey = object.getProject(); if ((projectKey != null) && projectList.containsKey(projectKey)) { Project p = projectList.get(projectKey); sb.appendHtmlConstant("<span class=\"project\">"); sb.appendEscaped(p.getName()); sb.appendEscaped(":"); sb.appendHtmlConstant("</span>"); } return sb.toSafeHtml(); } }); // ??? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (object.getCompleted()) { sb.appendHtmlConstant("<s>"); sb.appendEscaped(object.getName()); sb.appendHtmlConstant("</s>"); } else { sb.appendEscaped(object.getName()); } return sb.toSafeHtml(); } }); // ? hasCellList.add(new HasCell<Task, String>() { private final IconButtonCell cell = new IconButtonCell(); public Cell<String> getCell() { cell.setIcon(JQueryUI.UI_ICON_CLOSE); return cell; } public FieldUpdater<Task, String> getFieldUpdater() { return new FieldUpdater<Task, String>() { public void update(int index, Task object, String value) { List<Task> tasks = CollectionUtil.createArrayList(); tasks.add(object); DesktopTaskListView.this.presenter.deleteTask(tasks); } }; } public String getValue(Task object) { return "?"; } }); // ? hasCellList.add(new HasCell<Task, String>() { private final IconButtonCell cell = new IconButtonCell(); public Cell<String> getCell() { cell.setIcon(JQueryUI.UI_ICON_PENCIL); return cell; } public FieldUpdater<Task, String> getFieldUpdater() { return new FieldUpdater<Task, String>() { public void update(int index, Task object, String value) { DesktopTaskListView.this.editTask(object); } }; } public String getValue(Task object) { return "?"; } }); // ?? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); private final DateTimeFormat format = DateTimeFormat.getFormat("yyyyMMdd"); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); Date d = object.getDueDate(); if (d != null) { sb.appendHtmlConstant("<span class=\"duedate\">"); sb.appendEscaped(format.format(d)); sb.appendHtmlConstant("</span>"); } return sb.toSafeHtml(); } }); // ?? hasCellList.add(new HasCell<Task, SafeHtml>() { private final SafeHtmlCell cell = new SafeHtmlCell(); public Cell<SafeHtml> getCell() { return cell; } public FieldUpdater<Task, SafeHtml> getFieldUpdater() { return null; } public SafeHtml getValue(Task object) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); if (DesktopTaskListView.this.tagMap != null) { List<Key> tagKeys = object.getTags(); for (Key tagKey : tagKeys) { if (DesktopTaskListView.this.tagMap.containsKey(tagKey)) { Tag tag = DesktopTaskListView.this.tagMap.get(tagKey); sb.appendHtmlConstant("<span class=\"tag\">"); sb.appendEscaped(tag.getName()); sb.appendHtmlConstant("</span>"); } } } return sb.toSafeHtml(); } }); return hasCellList; }
From source file:com.akanoo.client.views.SharingPopupView.java
License:Apache License
private void setupCellList(CellList.Resources cellListResources) { selectionModel = new MultiSelectionModel<UserInfo>(UserInfo.keyprovider); // Construct a composite cell for contacts that includes a checkbox. List<HasCell<UserInfo, ?>> hasCells = new ArrayList<HasCell<UserInfo, ?>>(); hasCells.add(new HasCell<UserInfo, Boolean>() { private CheckboxCell cell = new CheckboxCell(true, false); public Cell<Boolean> getCell() { return cell; }/*w w w. j a va2s . c om*/ public FieldUpdater<UserInfo, Boolean> getFieldUpdater() { return null; } public Boolean getValue(UserInfo object) { return selectionModel.isSelected(object); } }); hasCells.add(new HasCell<UserInfo, UserInfo>() { private UserCell cell = new UserCell(); public Cell<UserInfo> getCell() { return cell; } public FieldUpdater<UserInfo, UserInfo> getFieldUpdater() { return null; } public UserInfo getValue(UserInfo object) { return object; } }); CompositeCell<UserInfo> friendCell = new CompositeCell<UserInfo>(hasCells) { @Override public void render(Context context, UserInfo value, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<table><tbody><tr>"); super.render(context, value, sb); sb.appendHtmlConstant("</tr></tbody></table>"); } @Override protected Element getContainerElement(Element parent) { // Return the first TR element in the table. return parent.getFirstChildElement().getFirstChildElement().getFirstChildElement(); } @Override protected <X> void render(Context context, UserInfo value, SafeHtmlBuilder sb, HasCell<UserInfo, X> hasCell) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<td>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant("</td>"); } }; shares = new CellList<UserInfo>(friendCell, cellListResources, UserInfo.keyprovider); shares.setSelectionModel(selectionModel, DefaultSelectionEventManager.<UserInfo>createCheckboxManager()); dataProvider = new ListDataProvider<UserInfo>(UserInfo.keyprovider); dataProvider.addDataDisplay(shares); selectionModel.addSelectionChangeHandler(this); }
From source file:com.ephesoft.gxt.core.client.ui.widget.TableExtractionAPICompositeCell.java
License:Open Source License
public CompositeCell<T> createCompositeCell() { final ListStore<String> andOrOpearators = new ListStore<String>(new ModelKeyProvider<String>() { @Override// ww w . jav a2s .c o m public String getKey(String item) { if (StringUtil.isNullOrEmpty(item)) { item = CoreCommonConstant.OR_OPERATOR; } return item; } }); andOrOpearators.add(CoreCommonConstant.OR_OPERATOR); andOrOpearators.add(CoreCommonConstant.AND_OPERATOR); final HasCell<T, String> coordHeaderCombo = new HasCell<T, String>() { public ComboBoxCell<String> getCell() { ComboBoxCell<String> coordHeaderComboCell = new ComboBoxCell<String>(andOrOpearators, new LabelProvider<String>() { @Override public String getLabel(String item) { if (StringUtil.isNullOrEmpty(item)) { item = CoreCommonConstant.OR_OPERATOR; } return item; } }); coordHeaderComboCell.setTriggerAction(TriggerAction.ALL); coordHeaderComboCell.setForceSelection(true); coordHeaderComboCell.setWidth(60); return coordHeaderComboCell; } public FieldUpdater<T, String> getFieldUpdater() { return new FieldUpdater<T, String>() { @Override public void update(int index, T object, String value) { // TODO Auto-generated method stub if (object != null && value != null) { object.setCoordinateHeaderComb(value); ; } } }; } public String getValue(T object) { if (object != null && !StringUtil.isNullOrEmpty(object.getCoordinateHeaderComb())) { return object.getCoordinateHeaderComb(); } return CoreCommonConstant.OR_OPERATOR; } }; final HasCell<T, Boolean> colCoordCell = new HasCell<T, Boolean>() { public CheckBoxCell getCell() { return new CheckBoxCell(); } public FieldUpdater<T, Boolean> getFieldUpdater() { return new FieldUpdater<T, Boolean>() { @Override public void update(int index, T object, Boolean value) { // TODO Auto-generated method stub if (object != null && value != null) { object.setColumnCoordinates(value); } } }; } public Boolean getValue(T object) { boolean chkValue = false; if (object != null) { chkValue = object.isColumnCoordinates(); } return chkValue; } }; HasCell<T, String> colCoordLabel = new HasCell<T, String>() { public Cell<String> getCell() { return new TextCell(); } public FieldUpdater<T, String> getFieldUpdater() { return null; } public String getValue(T object) { return LocaleDictionary.getConstantValue(CoreCommonConstants.LABEL_COLUMN_COORDINATES); } }; final HasCell<T, Boolean> colHeaderCell = new HasCell<T, Boolean>() { public CheckBoxCell getCell() { return new CheckBoxCell(); } public FieldUpdater<T, Boolean> getFieldUpdater() { return new FieldUpdater<T, Boolean>() { @Override public void update(int index, T object, Boolean value) { // TODO Auto-generated method stub if (object != null && value != null) { object.setColumnHeader(value); } } }; } public Boolean getValue(T object) { if (object != null) { return object.isColumnHeader(); } return false; } }; HasCell<T, String> colHeaderLabel = new HasCell<T, String>() { public Cell<String> getCell() { return new TextCell(); } public FieldUpdater<T, String> getFieldUpdater() { return null; } public String getValue(T object) { return LocaleDictionary.getConstantValue(CoreCommonConstants.LABEL_COLUMN_HEADER); } }; final HasCell<T, String> headerRegexCombo = new HasCell<T, String>() { public ComboBoxCell<String> getCell() { ComboBoxCell<String> headerRegexComboCell = new ComboBoxCell<String>(andOrOpearators, new LabelProvider<String>() { @Override public String getLabel(String item) { if (StringUtil.isNullOrEmpty(item)) { item = CoreCommonConstant.OR_OPERATOR; } return item; } }); headerRegexComboCell.setTriggerAction(TriggerAction.ALL); headerRegexComboCell.setForceSelection(true); headerRegexComboCell.setWidth(60); return headerRegexComboCell; } public FieldUpdater<T, String> getFieldUpdater() { return new FieldUpdater<T, String>() { @Override public void update(int index, T object, String value) { // TODO Auto-generated method stub if (object != null && value != null) { object.setHeaderRegexComb(value); } } }; } public String getValue(T object) { if (object != null && !StringUtil.isNullOrEmpty(object.getHeaderRegexComb())) { return object.getHeaderRegexComb(); } return CoreCommonConstant.OR_OPERATOR; } }; HasCell<T, Boolean> regexExtCell = new HasCell<T, Boolean>() { public CheckBoxCell getCell() { CheckBoxCell checkBox = new CheckBoxCell(); return checkBox; } public FieldUpdater<T, Boolean> getFieldUpdater() { return new FieldUpdater<T, Boolean>() { @Override public void update(int index, TableExtractionAPIModel object, Boolean value) { // TODO Auto-generated method stub if (object != null && value != null) { object.setRegexExtraction(value); } } }; } public Boolean getValue(T object) { if (object != null) { return object.isRegexExtraction(); } return false; } }; HasCell<T, String> regexExtLabel = new HasCell<T, String>() { public Cell<String> getCell() { return new TextCell(); } public FieldUpdater<T, String> getFieldUpdater() { return null; } public String getValue(T object) { return LocaleDictionary.getConstantValue(CoreCommonConstants.LABEL_REGEX_EXTRACTION); } }; List<HasCell<T, ?>> cells = new ArrayList<HasCell<T, ?>>(); cells.add(colCoordCell); cells.add(colCoordLabel); cells.add(coordHeaderCombo); cells.add(colHeaderCell); cells.add(colHeaderLabel); cells.add(headerRegexCombo); cells.add(regexExtCell); cells.add(regexExtLabel); CompositeCell<T> compositeCell = new CompositeCell<T>(cells); return compositeCell; }
From source file:com.goodow.wave.client.wavepanel.blip.TreeTestViewModel.java
License:Apache License
TreeTestViewModel() {
List<String> title = titles.getList();
title.add("a");
title.add("b");
title.add("c");
title.add("d");
List<HasCell<Integer, ?>> hasCell = new ArrayList<HasCell<Integer, ?>>();
hasCell.add(new HasCell<Integer, Integer>() {
private AbstractCell<Integer> cell = new AbstractCell<Integer>() {
@Override/*from w ww. ja va2 s .c o m*/
public void render(final com.google.gwt.cell.client.Cell.Context context, final Integer value,
final SafeHtmlBuilder sb) {
sb.append(SafeHtmlUtils.fromTrustedString("<div style='float:left;'>"));
sb.append(value.intValue());
sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
}
};
@Override
public Cell<Integer> getCell() {
return cell;
}
@Override
public FieldUpdater<Integer, Integer> getFieldUpdater() {
return null;
}
@Override
public Integer getValue(final Integer object) {
return object;
}
});
hasCell.add(new HasCell<Integer, Integer>() {
private TrangleButtonCell<Integer> tbc = new TrangleButtonCell<Integer>();
@Override
public Cell<Integer> getCell() {
return tbc;
}
@Override
public FieldUpdater<Integer, Integer> getFieldUpdater() {
return null;
}
@Override
public Integer getValue(final Integer object) {
return object;
}
});
composite = new CompositeCell<Integer>(hasCell) {
@Override
public void render(final Context context, final Integer value, final SafeHtmlBuilder sb) {
sb.append(SafeHtmlUtils.fromTrustedString("<div>"));
super.render(context, value, sb);
sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
}
@Override
protected Element getContainerElement(final Element parent) {
return parent.getFirstChildElement();
}
@Override
protected <X> void render(final Context context, final Integer value, final SafeHtmlBuilder sb,
final HasCell<Integer, X> hasCell) {
Cell<X> cell = hasCell.getCell();
// sb.append(SafeHtmlUtils.fromTrustedString("<div>"));
cell.render(context, hasCell.getValue(value), sb);
// sb.append(SafeHtmlUtils.fromTrustedString("</div>"));
}
};
}
From source file:com.google.gwt.sample.showcase.client.content.cell.CompositeContactCell.java
private static HasCell<ContactInfo, Boolean> createStar(final CwCellList.Images images) { return new HasCell<ContactInfo, Boolean>() { @Override/*from w ww .j av a 2s. c om*/ public Cell<Boolean> getCell() { return new AbstractCell<Boolean>(BrowserEvents.CLICK) { private ImageResourceRenderer renderer = new ImageResourceRenderer(); @Override public void render(Cell.Context context, Boolean value, SafeHtmlBuilder sb) { if (value != null) { sb.append(renderer.render(value ? images.star() : images.starOutline())); } } @Override public void onBrowserEvent(Cell.Context context, Element parent, Boolean value, NativeEvent event, ValueUpdater<Boolean> valueUpdater) { // Let AbstractCell handle the keydown event. super.onBrowserEvent(context, parent, value, event, valueUpdater); // Handle the click event. if (BrowserEvents.CLICK.equals(event.getType())) { // Ignore clicks that occur outside of the outermost element. EventTarget eventTarget = event.getEventTarget(); if (parent.getFirstChildElement().isOrHasChild(Element.as(eventTarget))) { boolean newValue = !value; valueUpdater.update(newValue); SafeHtmlBuilder sb = new SafeHtmlBuilder(); render(context, newValue, sb); parent.setInnerSafeHtml(sb.toSafeHtml()); } } } }; } @Override public FieldUpdater<ContactInfo, Boolean> getFieldUpdater() { return new FieldUpdater<ContactInfo, Boolean>() { @Override public void update(int index, ContactInfo contact, Boolean value) { contact.setStarred(value); } }; } @Override public Boolean getValue(ContactInfo contact) { return contact.isStarred(); } }; }
From source file:com.google.gwt.sample.showcase.client.content.cell.ContactTreeViewModel.java
License:Apache License
public ContactTreeViewModel(final SelectionModel<ContactInfo> selectionModel) { this.selectionModel = selectionModel; if (images == null) { images = GWT.create(Images.class); }/*from w w w .j av a 2 s. com*/ // Create a data provider that provides categories. categoryDataProvider = new ListDataProvider<Category>(); List<Category> categoryList = categoryDataProvider.getList(); for (Category category : ContactDatabase.get().queryCategories()) { categoryList.add(category); } // Construct a composite cell for contacts that includes a checkbox. List<HasCell<ContactInfo, ?>> hasCells = new ArrayList<HasCell<ContactInfo, ?>>(); hasCells.add(new HasCell<ContactInfo, Boolean>() { private CheckboxCell cell = new CheckboxCell(true, false); public Cell<Boolean> getCell() { return cell; } public FieldUpdater<ContactInfo, Boolean> getFieldUpdater() { return null; } public Boolean getValue(ContactInfo object) { return selectionModel.isSelected(object); } }); hasCells.add(new HasCell<ContactInfo, ContactInfo>() { private ContactCell cell = new ContactCell(images.contact()); public Cell<ContactInfo> getCell() { return cell; } public FieldUpdater<ContactInfo, ContactInfo> getFieldUpdater() { return null; } public ContactInfo getValue(ContactInfo object) { return object; } }); contactCell = new CompositeCell<ContactInfo>(hasCells) { @Override public void render(Context context, ContactInfo value, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<table><tbody><tr>"); super.render(context, value, sb); sb.appendHtmlConstant("</tr></tbody></table>"); } @Override protected Element getContainerElement(Element parent) { // Return the first TR element in the table. return parent.getFirstChildElement().getFirstChildElement().getFirstChildElement(); } @Override protected <X> void render(Context context, ContactInfo value, SafeHtmlBuilder sb, HasCell<ContactInfo, X> hasCell) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<td>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant("</td>"); } }; }
From source file:com.google.gwt.sample.showcase.client.content.cell.HasCells.java
public static <T> HasCell<T, T> forCell(final Cell<T> cell) { return new HasCell<T, T>() { @Override// www .j av a2s . c om public Cell<T> getCell() { return cell; } @Override public FieldUpdater<T, T> getFieldUpdater() { return null; } @Override public T getValue(T value) { return value; } }; }
From source file:com.google.gwt.sample.showcase.client.content.cell.HasCells.java
public static <F, T> HasCell<F, T> forCellWithConstantValue(final Cell<T> cell, final T value) { return new HasCell<F, T>() { @Override/* w ww. j av a2 s .co m*/ public Cell<T> getCell() { return cell; } @Override public FieldUpdater<F, T> getFieldUpdater() { return null; } @Override public T getValue(F ignored) { return value; } }; }
From source file:com.google.gwt.sample.showcase.client.content.cell.HasCells.java
public static <F, T> HasCell<F, T> forAdaptedCell(final Cell<T> cell, final Function<F, T> transform) { return new HasCell<F, T>() { @Override/*www . j ava 2 s .c o m*/ public Cell<T> getCell() { return cell; } @Override public FieldUpdater<F, T> getFieldUpdater() { return null; } @Override public T getValue(F input) { return transform.apply(input); } }; }