78
|
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.CLabelObservableValue;
|
|
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.custom.CLabel;
|
|
20
|
|
21 /**
|
|
22 * @since 1.0
|
|
23 *
|
|
24 */
|
|
25 public class CLabelObservableValue : AbstractSWTObservableValue {
|
|
26
|
|
27 private final CLabel label;
|
|
28
|
|
29 /**
|
|
30 * @param label
|
|
31 */
|
|
32 public this(CLabel label) {
|
|
33 super(label);
|
|
34 this.label = label;
|
|
35 }
|
|
36
|
|
37 /**
|
|
38 * @param realm
|
|
39 * @param label
|
|
40 */
|
|
41 public this(Realm realm, CLabel 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.equals(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 }
|