comparison org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/LabelObservableValue.d @ 78:0a55d2d5a946

Added file for databinding
author Frank Benoit <benoit@tionex.de>
date Tue, 14 Apr 2009 11:35:29 +0200
parents
children 6be48cf9f95c
comparison
equal deleted inserted replaced
76:f05e6e8b2f2d 78:0a55d2d5a946
1 /*******************************************************************************
2 * Copyright (c) 2005, 2008 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 module org.eclipse.jface.internal.databinding.swt.LabelObservableValue;
13
14 import java.lang.all;
15
16 import org.eclipse.core.databinding.observable.Diffs;
17 import org.eclipse.core.databinding.observable.Realm;
18 import org.eclipse.jface.internal.databinding.provisional.swt.AbstractSWTObservableValue;
19 import org.eclipse.swt.widgets.Label;
20
21 /**
22 * @since 3.3
23 *
24 */
25 public class LabelObservableValue : AbstractSWTObservableValue {
26
27 private final Label label;
28
29 /**
30 * @param label
31 */
32 public this(Label label) {
33 super(label);
34 this.label = label;
35 }
36
37 /**
38 * @param realm
39 * @param label
40 */
41 public this(Realm realm, Label label) {
42 super(realm, label);
43 this.label = label;
44 }
45
46 public void doSetValue(Object value) {
47 String oldValue = label.getText();
48 String newValue = value is null ? "" : value.toString(); //$NON-NLS-1$
49 label.setText(newValue);
50
51 if (!newValue.opEquals(oldValue)) {
52 fireValueChange(Diffs.createValueDiff(oldValue, newValue));
53 }
54 }
55
56 public Object doGetValue() {
57 return label.getText();
58 }
59
60 public Object getValueType() {
61 return String.classinfo;
62 }
63
64 }