KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > internal > databinding > internal > swt > LabelObservableValue


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  * Brad Reynolds - bug 164653
11  *******************************************************************************/

12 package org.eclipse.jface.internal.databinding.internal.swt;
13
14 import org.eclipse.core.databinding.observable.Diffs;
15 import org.eclipse.jface.internal.databinding.provisional.swt.AbstractSWTObservableValue;
16 import org.eclipse.swt.widgets.Label;
17
18 /**
19  * @since 3.3
20  *
21  */

22 public class LabelObservableValue extends AbstractSWTObservableValue {
23
24     private final Label label;
25
26     /**
27      * @param label
28      */

29     public LabelObservableValue(Label label) {
30         super(label);
31         this.label = label;
32     }
33
34     public void doSetValue(final Object JavaDoc value) {
35         String JavaDoc oldValue = label.getText();
36         label.setText(value == null ? "" : value.toString()); //$NON-NLS-1$
37
fireValueChange(Diffs.createValueDiff(oldValue, label.getText()));
38     }
39
40     public Object JavaDoc doGetValue() {
41         return label.getText();
42     }
43
44     public Object JavaDoc getValueType() {
45         return String JavaDoc.class;
46     }
47
48 }
49
Popular Tags