01: /*******************************************************************************
02: * Copyright (c) 2007 MyGWT.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Darrell Meyer <darrell@mygwt.net> - initial API and implementation
10: *******************************************************************************/package net.mygwt.ui.client.viewer;
11:
12: import net.mygwt.ui.client.data.Model;
13:
14: /**
15: * A <code>CellLabelProvider</code> for <code>Model</code> instances.
16: */
17: public class ModelCellLabelProvider extends CellLabelProvider {
18:
19: protected ViewerCell viewerCell;
20:
21: public void update(ViewerCell cell) {
22: this .viewerCell = cell;
23: Model m = (Model) cell.getElement();
24: cell.setText(getModelProperty(m, cell.getColumnId()));
25: }
26:
27: /**
28: * Returns the cell's text by calling {@link Model#getAsString(String)} using
29: * the column's id. Method can be subclassed to provide specialized behavior.
30: *
31: * @param model the model
32: * @param columnId the column id
33: * @return the cell's property value
34: */
35: public String getModelProperty(Model model, String columnId) {
36: return model.getAsString(columnId);
37: }
38:
39: }
|