01: /*******************************************************************************
02: * Copyright (c) 2007 MyGWT and others.
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>LabelProvider</code> implementation for <code>Model</code>
16: * instances. The text is retrieved from the property specified by the
17: * 'textProperty'.
18: */
19: public class ModelLabelProvider extends LabelProvider {
20:
21: /**
22: * textProperty specifies the property name to be used to retrieve a model's
23: * label. Default value is "name".
24: */
25: public String textProperty = "name";
26:
27: /**
28: * Creates a new label provider.
29: */
30: public ModelLabelProvider() {
31:
32: }
33:
34: /**
35: * Creates a new label provider.
36: *
37: * @param textPropery the property name
38: */
39: public ModelLabelProvider(String textPropery) {
40: this .textProperty = textPropery;
41: }
42:
43: public String getText(Object element) {
44: Model m = (Model) element;
45: return m.getAsString(textProperty);
46: }
47:
48: }
|