Mercurial > projects > dwt2
comparison org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/swt/TextEditableObservableValue.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) 2007, 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 *******************************************************************************/ | |
11 | |
12 module org.eclipse.jface.internal.databinding.swt.TextEditableObservableValue; | |
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.Text; | |
20 | |
21 /** | |
22 * Observable value for the editable property of a Text. | |
23 * | |
24 * @since 1.1 | |
25 */ | |
26 public class TextEditableObservableValue : AbstractSWTObservableValue { | |
27 private Text text; | |
28 | |
29 /** | |
30 * @param text | |
31 */ | |
32 public this(Text text) { | |
33 super(text); | |
34 this.text = text; | |
35 } | |
36 | |
37 /** | |
38 * @param realm | |
39 * @param text | |
40 */ | |
41 public this(Realm realm, Text text) { | |
42 super(realm, text); | |
43 this.text = text; | |
44 } | |
45 | |
46 /* (non-Javadoc) | |
47 * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doGetValue() | |
48 */ | |
49 protected Object doGetValue() { | |
50 return (text.getEditable()) ? Boolean.TRUE : Boolean.FALSE; | |
51 } | |
52 | |
53 /* (non-Javadoc) | |
54 * @see org.eclipse.core.databinding.observable.value.IObservableValue#getValueType() | |
55 */ | |
56 public Object getValueType() { | |
57 return Boolean.TYPE; | |
58 } | |
59 | |
60 /* (non-Javadoc) | |
61 * @see org.eclipse.core.databinding.observable.value.AbstractObservableValue#doSetValue(java.lang.Object) | |
62 */ | |
63 protected void doSetValue(Object value) { | |
64 if (value is null) { | |
65 throw new IllegalArgumentException("Parameter value was null."); //$NON-NLS-1$ | |
66 } | |
67 | |
68 Boolean oldValue = new Boolean(text.getEditable()); | |
69 Boolean newValue = cast(Boolean) value; | |
70 | |
71 text.setEditable(newValue.booleanValue()); | |
72 | |
73 if (!oldValue.equals(newValue)) { | |
74 fireValueChange(Diffs.createValueDiff(oldValue, newValue)); | |
75 } | |
76 } | |
77 } |