List of usage examples for com.google.gwt.cell.client Cell render
void render(Context context, C value, SafeHtmlBuilder sb);
From source file:accelerator.client.ui.cell.StyleCompositeCell.java
License:Open Source License
/** * {@inheritDoc}/*from ww w . j a v a 2 s .co m*/ */ @Override protected <X> void render(Context context, C value, SafeHtmlBuilder sb, HasCell<C, X> hasCell) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<span>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant("</span>"); }
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; }/*from w w w.ja v a 2s . c o m*/ 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.bearsoft.gwt.ui.widgets.grid.GridSection.java
public <C> void redrawAllRowsInColumn(int aIndex, ListDataProvider<T> aDataProvider) { if (aIndex >= 0 && aIndex < getColumnCount()) { int start = getVisibleRange().getStart(); Column<T, C> column = (Column<T, C>) getColumn(aIndex); Cell<C> cell = column.getCell(); List<T> data = aDataProvider.getList(); ProvidesKey<T> keys = getKeyProvider(); NodeList<TableRowElement> rows = getTableBodyElement().getRows(); for (int i = 0; i < rows.getLength(); i++) { TableRowElement row = rows.getItem(i); NodeList<TableCellElement> cells = row.getCells(); if (aIndex >= 0 && aIndex < cells.getLength()) { TableCellElement toRerender = cells.getItem(aIndex); if (toRerender != null) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); int dataIdx = start + i; if (dataIdx >= 0 && dataIdx < data.size()) { T object = data.get(dataIdx); Cell.Context cx = new Cell.Context(start + i, aIndex, keys.getKey(object)); cell.render(cx, column.getValue(object), sb); // Take into account, that cell builder supports // some // maps // to cells' divs // and generates them. So we have to work with first // <div> // in <td>. toRerender.getFirstChildElement().setInnerSafeHtml(sb.toSafeHtml()); }/*from w ww . j ava 2s .c o m*/ } } } } }
From source file:com.dawg6.gwt.client.widgets.ListRowCell.java
License:Open Source License
@Override public void render(com.google.gwt.cell.client.Cell.Context context, T value, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<table>"); sb.appendHtmlConstant("<tr>"); for (Cell<T> w : cells) { sb.appendHtmlConstant("<td>"); w.render(context, value, sb); sb.appendHtmlConstant("</td>"); }/*w ww . j ava2 s .c o m*/ sb.appendHtmlConstant("</tr>"); sb.appendHtmlConstant("</table>"); }
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 w w .ja v a 2s.com
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.ContactTreeViewModel.java
License:Apache License
public ContactTreeViewModel(final SelectionModel<ContactInfo> selectionModel) { this.selectionModel = selectionModel; if (images == null) { images = GWT.create(Images.class); }//from ww w.j av a 2s . co m // 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.retech.reader.web.client.labs.Labs.java
License:Apache License
@Inject Labs(final CellList.Resources resource, final PlaceController placeController, final Provider<BasePlace> base) { this.setWaveContent(binder.createAndBindUi(this)); setColor.setChangeElm(simplePanel.getElement()); minimize.setIconElement(//from w w w . j a va2 s . c o m AbstractImagePrototype.create(WaveTitleResources.image().waveTitleMinimize()).createElement()); // add Data List<LabsIconDecorator> list = listDataProvider.getList(); LabsIconDecorator touch = new LabsIconDecorator(bunder.laboratory(), "", WaveTest.class); list.add(touch); LabsIconDecorator flip = new LabsIconDecorator(bunder.laboratory(), "3D", BookFlip.class); list.add(flip); LabsIconDecorator contact = new LabsIconDecorator(bunder.laboratory(), "??", ContactPanel.class); list.add(contact); LabsIconDecorator treeTest = new LabsIconDecorator(bunder.laboratory(), "TreeTest", TreeTest.class); list.add(treeTest); LabsIconDecorator search = new LabsIconDecorator(bunder.laboratory(), "?", SearchPanel.class); list.add(search); LabsIconDecorator blipTest = new LabsIconDecorator(bunder.laboratory(), "BlipTest", BlipTest.class); list.add(blipTest); LabsIconDecorator blipTree = new LabsIconDecorator(bunder.laboratory(), "NestedBlipTest", NestedBlipTest.class); list.add(blipTree); LabsIconDecorator settingsView = new LabsIconDecorator(bunder.laboratory(), "", SettingsView.class); list.add(settingsView); LabsIconDecorator contactPanel = new LabsIconDecorator(bunder.laboratory(), "", ContactPanel.class); list.add(contactPanel); server.add( new Anchor("Android", "https://build.phonegap.com/apps/95095/download/android", "_blank")); server.add( new Anchor("iOS", "https://build.phonegap.com/apps/95095/download/ios", "_blank")); server.add(new Anchor("Google Play?", "https://play.google.com/store/apps/details?id=com.goodow.web.mobile", "_blank")); server.add(new Anchor("SCM - Subversion", SERVER_URL + "/svn/retech", "_blank")); server.add(new Anchor("Files", SERVER_URL + "/files", "_blank")); server.add(new Anchor("Document", SERVER_URL + "/svn/retech/document", "_blank")); server.add(new Anchor("CI - Hudson", SERVER_URL + ":8080", "_blank")); server.add(new Anchor("Repository - Nexus", SERVER_URL + ":8081/nexus", "_blank")); // add cell List<HasCell<LabsIconDecorator, ?>> hasCells = new ArrayList<HasCell<LabsIconDecorator, ?>>(); hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() { LabsIconDecoratorCell cell = new LabsIconDecoratorCell( new LabsIconDecoratorCell.Delegate<LabsIconDecorator>() { @Override public void execute(final LabsIconDecorator object) { placeController.goTo(base.get().setPath(object.getClassName().getName())); } }); @Override public Cell<LabsIconDecorator> getCell() { return cell; } @Override public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() { return null; } @Override public LabsIconDecorator getValue(final LabsIconDecorator object) { return object; } }); hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() { private TrangleButtonCell<LabsIconDecorator> tbc = new TrangleButtonCell<LabsIconDecorator>(); @Override public Cell<LabsIconDecorator> getCell() { return tbc; } @Override public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() { return null; } @Override public LabsIconDecorator getValue(final LabsIconDecorator object) { return object; } }); compositeCell = new CompositeCell<LabsIconDecorator>(hasCells) { @Override public void render(final com.google.gwt.cell.client.Cell.Context context, final LabsIconDecorator value, final SafeHtmlBuilder sb) { super.render(context, value, sb); } @Override protected Element getContainerElement(final Element parent) { return parent; } @Override protected <X> void render(final com.google.gwt.cell.client.Cell.Context context, final LabsIconDecorator value, final SafeHtmlBuilder sb, final HasCell<LabsIconDecorator, X> hasCell) { Cell<X> cell = hasCell.getCell(); cell.render(context, hasCell.getValue(value), sb); } }; // add cellList cellList = new CellList<LabsIconDecorator>(compositeCell, resource); // add cellPreviewHanler cellList.addCellPreviewHandler(new CellPreviewEvent.Handler<LabsIconDecorator>() { @Override public void onCellPreview(final CellPreviewEvent<LabsIconDecorator> event) { NativeEvent nativeEvent = event.getNativeEvent(); boolean isClick = nativeEvent.getType().equals(BrowserEvents.CLICK); if (isClick) { Element clickelm = cellList.getRowElement(event.getIndex()); Element eventTarget = Element.as(nativeEvent.getEventTarget()); if (clickelm.getFirstChildElement() == eventTarget) { if (Labs.this.lastElm == null) { Labs.this.lastElm = clickelm; } if (Labs.this.lastElm != clickelm) { Labs.this.lastElm.removeClassName(LabsResources.css().cellListSelectionItem()); clickelm.addClassName(LabsResources.css().cellListSelectionItem()); Labs.this.lastElm = clickelm; } else if (Labs.this.lastElm == clickelm) { clickelm.addClassName(LabsResources.css().cellListSelectionItem()); } } } } }); simplePanel.add(cellList); }
From source file:com.sencha.gxt.widget.core.client.grid.GridView.java
License:sencha.com license
/** * Renders the value of a cell into safe HTML. * * @param rowIndex the row index//from w w w . j a va 2s .c o m * @param colIndex the column index * @param m the data model * @param record the optional {@link Record} for this row (may be null) * @return the safe HTML representing the cell */ protected <N> SafeHtml getRenderedValue(int rowIndex, int colIndex, M m, ListStore<M>.Record record) { ValueProvider<? super M, N> valueProvider = cm.getValueProvider(colIndex); N val = null; if (record != null) { val = record.getValue(valueProvider); } else { val = valueProvider.getValue(m); } Cell<N> r = cm.getCell(colIndex); if (r != null) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); r.render(new Context(rowIndex, colIndex, ds.getKeyProvider().getKey(m)), val, sb); return sb.toSafeHtml(); } String text = null; if (val != null) { text = val.toString(); } return Util.isEmptyString(text) ? Util.NBSP_SAFE_HTML : SafeHtmlUtils.fromString(text); }
From source file:com.webgocommerce.client.view.tree.TreeMenuModel.java
private void initComponents() { List<HasCell<MenuBar, ?>> hasCells = new ArrayList<HasCell<MenuBar, ?>>(); hasCells.add(new HasCell<MenuBar, Boolean>() { private CheckboxCell cell = new CheckboxCell(true, true); @Override//from www . ja v a 2s . com public Cell<Boolean> getCell() { return cell; } @Override public FieldUpdater<MenuBar, Boolean> getFieldUpdater() { return new FieldUpdater<MenuBar, Boolean>() { public void update(int index, MenuBar object, Boolean value) { selectionModel.setSelected(object, value); object.setOperacion("A"); object.setEstado(value == true ? "A" : "D"); if (object.getPadre() != null && !object.getPadre().getVariable().equalsIgnoreCase("root")) { if (value) { //selectionModel.setSelected(object.getPadre(), value); //object.getPadre().setOperacion("A"); SelectedFather(object); } } isSelectedChild(object, value); } }; } @Override public Boolean getValue(MenuBar object) { if (object.getEstado().equalsIgnoreCase("A") && object.getOperacion().equalsIgnoreCase("N")) { selectionModel.setSelected(object, true); return true; } return selectionModel.isSelected(object); } public void SelectedFather(MenuBar menuBar) { if (!selectionModel.isSelected(menuBar.getPadre())) { selectionModel.setSelected(menuBar.getPadre(), true); menuBar.getPadre().setOperacion("A"); menuBar.getPadre().setEstado("A"); if (menuBar.getPadre() != null) { SelectedFather(menuBar.getPadre()); } } } public void isSelectedChild(MenuBar menuBar, Boolean val) { Iterator<MenuBar> iterador = menuBar.getHijos().iterator(); while (iterador.hasNext()) { MenuBar bean = iterador.next(); selectionModel.setSelected(bean, val); bean.setOperacion("A"); bean.setEstado(val == true ? "A" : "D"); isSelectedChild(bean, val); } } }); menuBarCell = new CompositeCell<MenuBar>(hasCells) { /*@Override public void onBrowserEvent(Cell.Context context, Element parent, MenuBar value, NativeEvent event, ValueUpdater<MenuBar> valueUpdater) { if ("keyup".equals(event.getType()) && event.getKeyCode() == KeyCodes.KEY_ENTER) { selectionModel.setSelected(value, !selectionModel.isSelected(value)); } }*/ @Override public void render(Cell.Context context, MenuBar 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 parent.getFirstChildElement().getFirstChildElement().getFirstChildElement(); } @Override protected <X> void render(Cell.Context context, MenuBar value, SafeHtmlBuilder sb, HasCell<MenuBar, X> hasCell) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<td>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant(" " + value.getOrden()); sb.appendHtmlConstant(" " + value.getDescripcion()); sb.appendHtmlConstant("</td>"); } }; /*hasCells.add(new HasCell<MenuBar, MenuBar>() { private MenuBarCell cell = new MenuBarCell(); public Cell<MenuBar> getCell() { return cell; } public FieldUpdater<MenuBar, MenuBar> getFieldUpdater() { return null; } public MenuBar getValue(MenuBar object) { return object; } });*/ }
From source file:org.dataconservancy.dcs.access.client.model.CollectionTreeViewModel.java
License:Apache License
public CollectionTreeViewModel(final SelectionModel<CollectionNode> selectionModel, final DatasetRelation relations, String root) { this.selectionModel = selectionModel; this.dusMap = relations.getDuAttrMap(); this.parentMap = relations.getParentMap(); this.root = root; // Construct a composite cell for contacts that includes a checkbox. //adding//w w w. j av a2 s .co m List<HasCell<CollectionNode, ?>> hasCells = new ArrayList<HasCell<CollectionNode, ?>>(); hasCells.add(new HasCell<CollectionNode, Boolean>() { private CheckboxCell cell = new CheckboxCell(true, false); public Cell<Boolean> getCell() { return cell; } public Boolean getValue(CollectionNode object) { return selectionModel.isSelected(object); } private void updateChildNodes(CollectionNode object, Boolean value) { List<String> subCollections = object.getSub().get(SubType.Collection); if (subCollections != null)//why is this running twice? { for (int i = 0; i < subCollections.size(); i++) { selectionModel.setSelected((CollectionNode) dusMap.get(subCollections.get(i)), value); MediciIngestPresenter.EVENT_BUS.fireEvent(new CollectionPassiveSelectEvent( (CollectionNode) dusMap.get(subCollections.get(i)), value)); updateChildNodes((CollectionNode) dusMap.get(subCollections.get(i)), value); } } } @Override public FieldUpdater<CollectionNode, Boolean> getFieldUpdater() { // TODO Auto-generated method stub //return null; return new FieldUpdater<CollectionNode, Boolean>() { public void update(int index, CollectionNode object, Boolean value) { //Update child Nodes /* List<String> subCollections = object.getSub().get(SubType.Collection); if(subCollections!=null)//why is this running twice? { for(int i=0;i<subCollections.size();i++) selectionModel.setSelected((CollectionNode)dusMap.get(subCollections.get(i)), value); }*/ //Update child collection nodes updateChildNodes(object, value); //update the Parent Node String parentCollection = parentMap.get(object.getId()); if (parentCollection != null) { List<String> siblingCollections = dusMap.get(parentCollection).getSub() .get(SubType.Collection); int allSelected = 1; if (value) { for (String sibling : siblingCollections) { if (!selectionModel.isSelected(dusMap.get(sibling))) { allSelected = 0; break; } } } if (allSelected == 1 && value) { //set parent true selectionModel.setSelected((CollectionNode) dusMap.get(parentCollection), true); } else { //set parent false selectionModel.setSelected((CollectionNode) dusMap.get(parentCollection), false); } } MediciIngestPresenter.EVENT_BUS.fireEvent(new CollectionSelectEvent(object, value)); } }; } }); hasCells.add(new HasCell<CollectionNode, CollectionNode>() { private CollectionCell cell = new CollectionCell(); public Cell<CollectionNode> getCell() { return cell; } public FieldUpdater<CollectionNode, CollectionNode> getFieldUpdater() { return null; } public CollectionNode getValue(CollectionNode object) { return object; } }); collectionCell = new CompositeCell<CollectionNode>(hasCells) { @Override public void render(Context context, CollectionNode value, SafeHtmlBuilder sb) { if (value == null) return; 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, CollectionNode value, SafeHtmlBuilder sb, HasCell<CollectionNode, X> hasCell) { if (value != null) { Cell<X> cell = hasCell.getCell(); sb.appendHtmlConstant("<td>"); cell.render(context, hasCell.getValue(value), sb); sb.appendHtmlConstant("</td>"); } } }; }