|
Lines 7-39
Link Here
|
| 7 |
* |
7 |
* |
| 8 |
* Contributors: |
8 |
* Contributors: |
| 9 |
* Brad Reynolds - initial API and implementation |
9 |
* Brad Reynolds - initial API and implementation |
|
|
10 |
* Chris Aniszczyk <zx@code9.com> - bug 131435 |
| 10 |
******************************************************************************/ |
11 |
******************************************************************************/ |
| 11 |
|
12 |
|
| 12 |
package org.eclipse.jface.tests.databinding.swt; |
13 |
package org.eclipse.jface.tests.databinding.swt; |
| 13 |
|
14 |
|
|
|
15 |
import org.eclipse.core.databinding.observable.IDecoratingObservable; |
| 14 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
16 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
|
|
17 |
import org.eclipse.core.databinding.property.IPropertyObservable; |
| 18 |
import org.eclipse.jface.databinding.conformance.util.ChangeEventTracker; |
| 15 |
import org.eclipse.jface.databinding.conformance.util.RealmTester; |
19 |
import org.eclipse.jface.databinding.conformance.util.RealmTester; |
|
|
20 |
import org.eclipse.jface.databinding.swt.ISWTObservable; |
| 16 |
import org.eclipse.jface.databinding.swt.ISWTObservableValue; |
21 |
import org.eclipse.jface.databinding.swt.ISWTObservableValue; |
| 17 |
import org.eclipse.jface.databinding.swt.SWTObservables; |
22 |
import org.eclipse.jface.databinding.swt.SWTObservables; |
| 18 |
import org.eclipse.jface.internal.databinding.swt.ButtonObservableValue; |
23 |
import org.eclipse.jface.internal.databinding.swt.CComboSelectionProperty; |
| 19 |
import org.eclipse.jface.internal.databinding.swt.CComboObservableList; |
24 |
import org.eclipse.jface.internal.databinding.swt.CComboTextProperty; |
| 20 |
import org.eclipse.jface.internal.databinding.swt.CComboObservableValue; |
25 |
import org.eclipse.jface.internal.databinding.swt.CLabelTextProperty; |
| 21 |
import org.eclipse.jface.internal.databinding.swt.CLabelObservableValue; |
26 |
import org.eclipse.jface.internal.databinding.swt.ComboSelectionProperty; |
| 22 |
import org.eclipse.jface.internal.databinding.swt.ComboObservableList; |
27 |
import org.eclipse.jface.internal.databinding.swt.ComboTextProperty; |
| 23 |
import org.eclipse.jface.internal.databinding.swt.ComboObservableValue; |
28 |
import org.eclipse.jface.internal.databinding.swt.LabelTextProperty; |
| 24 |
import org.eclipse.jface.internal.databinding.swt.LabelObservableValue; |
29 |
import org.eclipse.jface.internal.databinding.swt.ScaleMaximumProperty; |
| 25 |
import org.eclipse.jface.internal.databinding.swt.ListObservableList; |
30 |
import org.eclipse.jface.internal.databinding.swt.ScaleMinimumProperty; |
| 26 |
import org.eclipse.jface.internal.databinding.swt.ListObservableValue; |
31 |
import org.eclipse.jface.internal.databinding.swt.ScaleSelectionProperty; |
| 27 |
import org.eclipse.jface.internal.databinding.swt.SWTProperties; |
32 |
import org.eclipse.jface.internal.databinding.swt.SpinnerMaximumProperty; |
| 28 |
import org.eclipse.jface.internal.databinding.swt.ScaleObservableValue; |
33 |
import org.eclipse.jface.internal.databinding.swt.SpinnerMinimumProperty; |
| 29 |
import org.eclipse.jface.internal.databinding.swt.SpinnerObservableValue; |
34 |
import org.eclipse.jface.internal.databinding.swt.SpinnerSelectionProperty; |
| 30 |
import org.eclipse.jface.internal.databinding.swt.TableSingleSelectionObservableValue; |
35 |
import org.eclipse.jface.internal.databinding.swt.StyledTextTextProperty; |
| 31 |
import org.eclipse.jface.internal.databinding.swt.TextEditableObservableValue; |
36 |
import org.eclipse.jface.internal.databinding.swt.TableSingleSelectionIndexProperty; |
| 32 |
import org.eclipse.jface.internal.databinding.swt.TextObservableValue; |
37 |
import org.eclipse.jface.internal.databinding.swt.TextEditableProperty; |
|
|
38 |
import org.eclipse.jface.internal.databinding.swt.TextTextProperty; |
| 33 |
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase; |
39 |
import org.eclipse.jface.tests.databinding.AbstractSWTTestCase; |
| 34 |
import org.eclipse.swt.SWT; |
40 |
import org.eclipse.swt.SWT; |
| 35 |
import org.eclipse.swt.custom.CCombo; |
41 |
import org.eclipse.swt.custom.CCombo; |
| 36 |
import org.eclipse.swt.custom.CLabel; |
42 |
import org.eclipse.swt.custom.CLabel; |
|
|
43 |
import org.eclipse.swt.custom.StyledText; |
| 37 |
import org.eclipse.swt.graphics.Color; |
44 |
import org.eclipse.swt.graphics.Color; |
| 38 |
import org.eclipse.swt.graphics.Font; |
45 |
import org.eclipse.swt.graphics.Font; |
| 39 |
import org.eclipse.swt.widgets.Button; |
46 |
import org.eclipse.swt.widgets.Button; |
|
Lines 55-68
Link Here
|
| 55 |
|
62 |
|
| 56 |
protected void setUp() throws Exception { |
63 |
protected void setUp() throws Exception { |
| 57 |
super.setUp(); |
64 |
super.setUp(); |
| 58 |
|
65 |
|
| 59 |
shell = getShell(); |
66 |
shell = getShell(); |
| 60 |
RealmTester.setDefault(SWTObservables.getRealm(shell.getDisplay())); |
67 |
RealmTester.setDefault(SWTObservables.getRealm(shell.getDisplay())); |
| 61 |
} |
68 |
} |
| 62 |
|
69 |
|
| 63 |
protected void tearDown() throws Exception { |
70 |
protected void tearDown() throws Exception { |
| 64 |
super.tearDown(); |
71 |
super.tearDown(); |
| 65 |
|
72 |
|
| 66 |
RealmTester.setDefault(null); |
73 |
RealmTester.setDefault(null); |
| 67 |
} |
74 |
} |
| 68 |
|
75 |
|
|
Lines 88-141
Link Here
|
| 88 |
Spinner spinner = new Spinner(shell, SWT.NONE); |
95 |
Spinner spinner = new Spinner(shell, SWT.NONE); |
| 89 |
ISWTObservableValue value = SWTObservables.observeSelection(spinner); |
96 |
ISWTObservableValue value = SWTObservables.observeSelection(spinner); |
| 90 |
assertNotNull(value); |
97 |
assertNotNull(value); |
| 91 |
assertTrue(value instanceof SpinnerObservableValue); |
98 |
assertTrue(value.getWidget() == spinner); |
| 92 |
|
99 |
|
| 93 |
SpinnerObservableValue spinnerObservable = (SpinnerObservableValue) value; |
100 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 94 |
assertEquals(SWTProperties.SELECTION, spinnerObservable.getAttribute()); |
101 |
assertTrue(propertyObservable.getProperty() instanceof SpinnerSelectionProperty); |
| 95 |
} |
102 |
} |
| 96 |
|
103 |
|
| 97 |
public void testObserveSelectionOfButton() throws Exception { |
104 |
public void testObserveSelectionOfButton() throws Exception { |
| 98 |
Button button = new Button(shell, SWT.PUSH); |
105 |
Button button = new Button(shell, SWT.PUSH); |
| 99 |
ISWTObservableValue value = SWTObservables.observeSelection(button); |
106 |
ISWTObservableValue value = SWTObservables.observeSelection(button); |
| 100 |
assertNotNull(value); |
107 |
assertNotNull(value); |
| 101 |
assertTrue(value instanceof ButtonObservableValue); |
108 |
assertTrue(value.getWidget() == button); |
| 102 |
} |
109 |
} |
| 103 |
|
110 |
|
| 104 |
public void testObserveSelectionOfCombo() throws Exception { |
111 |
public void testObserveSelectionOfCombo() throws Exception { |
| 105 |
Combo combo = new Combo(shell, SWT.NONE); |
112 |
Combo combo = new Combo(shell, SWT.NONE); |
| 106 |
ISWTObservableValue value = SWTObservables.observeSelection(combo); |
113 |
ISWTObservableValue value = SWTObservables.observeSelection(combo); |
| 107 |
assertNotNull(value); |
114 |
assertNotNull(value); |
| 108 |
assertTrue(value instanceof ComboObservableValue); |
115 |
assertTrue(value.getWidget() == combo); |
| 109 |
|
116 |
|
| 110 |
ComboObservableValue comboObservable = (ComboObservableValue) value; |
117 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 111 |
assertEquals(SWTProperties.SELECTION, comboObservable.getAttribute()); |
118 |
assertTrue(propertyObservable.getProperty() instanceof ComboSelectionProperty); |
| 112 |
} |
119 |
} |
| 113 |
|
120 |
|
| 114 |
public void testObserveSelectionOfCCombo() throws Exception { |
121 |
public void testObserveSelectionOfCCombo() throws Exception { |
| 115 |
CCombo combo = new CCombo(shell, SWT.NONE); |
122 |
CCombo combo = new CCombo(shell, SWT.NONE); |
| 116 |
ISWTObservableValue value = SWTObservables.observeSelection(combo); |
123 |
ISWTObservableValue value = SWTObservables.observeSelection(combo); |
| 117 |
assertNotNull(value); |
124 |
assertNotNull(value); |
| 118 |
assertTrue(value instanceof CComboObservableValue); |
125 |
assertTrue(value.getWidget() == combo); |
| 119 |
|
126 |
|
| 120 |
CComboObservableValue ccomboObservable = (CComboObservableValue) value; |
127 |
IPropertyObservable property = getPropertyObservable(value); |
| 121 |
assertEquals(SWTProperties.SELECTION, ccomboObservable.getAttribute()); |
128 |
assertTrue(property.getProperty() instanceof CComboSelectionProperty); |
| 122 |
} |
129 |
} |
| 123 |
|
130 |
|
| 124 |
public void testObserveSelectionOfList() throws Exception { |
131 |
public void testObserveSelectionOfList() throws Exception { |
| 125 |
List list = new List(shell, SWT.NONE); |
132 |
List list = new List(shell, SWT.NONE); |
| 126 |
ISWTObservableValue value = SWTObservables.observeSelection(list); |
133 |
ISWTObservableValue value = SWTObservables.observeSelection(list); |
| 127 |
assertNotNull(value); |
134 |
assertNotNull(value); |
| 128 |
assertTrue(value instanceof ListObservableValue); |
135 |
assertTrue(value.getWidget() == list); |
| 129 |
} |
136 |
} |
| 130 |
|
137 |
|
| 131 |
public void testObserveSelectionOfScale() throws Exception { |
138 |
public void testObserveSelectionOfScale() throws Exception { |
| 132 |
Scale scale = new Scale(shell, SWT.NONE); |
139 |
Scale scale = new Scale(shell, SWT.NONE); |
| 133 |
ISWTObservableValue value = SWTObservables.observeSelection(scale); |
140 |
ISWTObservableValue value = SWTObservables.observeSelection(scale); |
| 134 |
assertNotNull(value); |
141 |
assertNotNull(value); |
| 135 |
assertTrue(value instanceof ScaleObservableValue); |
142 |
assertTrue(value.getWidget() == scale); |
| 136 |
|
143 |
|
| 137 |
ScaleObservableValue scaleObservable = (ScaleObservableValue) value; |
144 |
IPropertyObservable property = getPropertyObservable(value); |
| 138 |
assertEquals(SWTProperties.SELECTION, scaleObservable.getAttribute()); |
145 |
assertTrue(property.getProperty() instanceof ScaleSelectionProperty); |
| 139 |
} |
146 |
} |
| 140 |
|
147 |
|
| 141 |
public void testObserveSelectionOfUnsupportedControl() throws Exception { |
148 |
public void testObserveSelectionOfUnsupportedControl() throws Exception { |
|
Lines 154-160
Link Here
|
| 154 |
ISWTObservableValue value = SWTObservables.observeText(text, |
161 |
ISWTObservableValue value = SWTObservables.observeText(text, |
| 155 |
SWT.FocusOut); |
162 |
SWT.FocusOut); |
| 156 |
assertNotNull(value); |
163 |
assertNotNull(value); |
| 157 |
assertTrue(value instanceof TextObservableValue); |
164 |
assertTrue(value.getWidget() == text); |
|
|
165 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 166 |
assertTrue(propertyObservable.getProperty() instanceof TextTextProperty); |
| 167 |
|
| 168 |
assertFalse(text.isListening(SWT.FocusOut)); |
| 169 |
ChangeEventTracker.observe(value); |
| 170 |
assertTrue(text.isListening(SWT.FocusOut)); |
| 171 |
} |
| 172 |
|
| 173 |
public void testObserveTextOfStyledText() throws Exception { |
| 174 |
StyledText text = new StyledText(shell, SWT.NONE); |
| 175 |
assertFalse(text.isListening(SWT.FocusOut)); |
| 176 |
|
| 177 |
ISWTObservableValue value = SWTObservables.observeText(text, |
| 178 |
SWT.FocusOut); |
| 179 |
assertNotNull(value); |
| 180 |
assertTrue(value.getWidget() == text); |
| 181 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 182 |
assertTrue(propertyObservable.getProperty() instanceof StyledTextTextProperty); |
| 183 |
|
| 184 |
assertFalse(text.isListening(SWT.FocusOut)); |
| 185 |
ChangeEventTracker.observe(value); |
| 158 |
assertTrue(text.isListening(SWT.FocusOut)); |
186 |
assertTrue(text.isListening(SWT.FocusOut)); |
| 159 |
} |
187 |
} |
| 160 |
|
188 |
|
|
Lines 171-204
Link Here
|
| 171 |
Label label = new Label(shell, SWT.NONE); |
199 |
Label label = new Label(shell, SWT.NONE); |
| 172 |
ISWTObservableValue value = SWTObservables.observeText(label); |
200 |
ISWTObservableValue value = SWTObservables.observeText(label); |
| 173 |
assertNotNull(label); |
201 |
assertNotNull(label); |
| 174 |
assertTrue(value instanceof LabelObservableValue); |
202 |
assertTrue(value.getWidget() == label); |
|
|
203 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 204 |
assertTrue(propertyObservable.getProperty() instanceof LabelTextProperty); |
| 175 |
} |
205 |
} |
| 176 |
|
206 |
|
| 177 |
public void testObserveTextOfCLabel() throws Exception { |
207 |
public void testObserveTextOfCLabel() throws Exception { |
| 178 |
CLabel label = new CLabel(shell, SWT.NONE); |
208 |
CLabel label = new CLabel(shell, SWT.NONE); |
| 179 |
ISWTObservableValue value = SWTObservables.observeText(label); |
209 |
ISWTObservableValue value = SWTObservables.observeText(label); |
| 180 |
assertNotNull(label); |
210 |
assertNotNull(label); |
| 181 |
assertTrue(value instanceof CLabelObservableValue); |
211 |
assertTrue(value.getWidget() == label); |
|
|
212 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 213 |
assertTrue(propertyObservable.getProperty() instanceof CLabelTextProperty); |
| 182 |
} |
214 |
} |
| 183 |
|
215 |
|
| 184 |
public void testObserveTextOfCombo() throws Exception { |
216 |
public void testObserveTextOfCombo() throws Exception { |
| 185 |
Combo combo = new Combo(shell, SWT.NONE); |
217 |
Combo combo = new Combo(shell, SWT.NONE); |
| 186 |
ISWTObservableValue value = SWTObservables.observeText(combo); |
218 |
ISWTObservableValue value = SWTObservables.observeText(combo); |
| 187 |
assertNotNull(value); |
219 |
assertNotNull(value); |
| 188 |
assertTrue(value instanceof ComboObservableValue); |
220 |
assertTrue(value.getWidget() == combo); |
|
|
221 |
|
| 222 |
assertTrue(getPropertyObservable(value).getProperty() instanceof ComboTextProperty); |
| 223 |
} |
| 189 |
|
224 |
|
| 190 |
ComboObservableValue comboObservable = (ComboObservableValue) value; |
225 |
/** |
| 191 |
assertEquals(SWTProperties.TEXT, comboObservable.getAttribute()); |
226 |
* @param observable |
|
|
227 |
* @return |
| 228 |
*/ |
| 229 |
private IPropertyObservable getPropertyObservable( |
| 230 |
ISWTObservableValue observable) { |
| 231 |
IDecoratingObservable decoratingObservable = (IDecoratingObservable) observable; |
| 232 |
IPropertyObservable propertyObservable = (IPropertyObservable) decoratingObservable |
| 233 |
.getDecorated(); |
| 234 |
return propertyObservable; |
| 192 |
} |
235 |
} |
| 193 |
|
236 |
|
| 194 |
public void testObserveTextOfCCombo() throws Exception { |
237 |
public void testObserveTextOfCCombo() throws Exception { |
| 195 |
CCombo combo = new CCombo(shell, SWT.NONE); |
238 |
CCombo combo = new CCombo(shell, SWT.NONE); |
| 196 |
ISWTObservableValue value = SWTObservables.observeText(combo); |
239 |
ISWTObservableValue value = SWTObservables.observeText(combo); |
| 197 |
assertNotNull(value); |
240 |
assertNotNull(value); |
| 198 |
assertTrue(value instanceof CComboObservableValue); |
241 |
assertTrue(value.getWidget() == combo); |
| 199 |
|
242 |
|
| 200 |
CComboObservableValue ccomboObservable = (CComboObservableValue) value; |
243 |
IDecoratingObservable decorating = (IDecoratingObservable) value; |
| 201 |
assertEquals(SWTProperties.TEXT, ccomboObservable.getAttribute()); |
244 |
IPropertyObservable property = (IPropertyObservable) decorating |
|
|
245 |
.getDecorated(); |
| 246 |
assertTrue(property.getProperty() instanceof CComboTextProperty); |
| 202 |
} |
247 |
} |
| 203 |
|
248 |
|
| 204 |
public void testObserveTextOfUnsupportedControl() throws Exception { |
249 |
public void testObserveTextOfUnsupportedControl() throws Exception { |
|
Lines 214-234
Link Here
|
| 214 |
Combo combo = new Combo(shell, SWT.NONE); |
259 |
Combo combo = new Combo(shell, SWT.NONE); |
| 215 |
IObservableList list = SWTObservables.observeItems(combo); |
260 |
IObservableList list = SWTObservables.observeItems(combo); |
| 216 |
assertNotNull(list); |
261 |
assertNotNull(list); |
| 217 |
assertTrue(list instanceof ComboObservableList); |
262 |
assertTrue(list instanceof ISWTObservable); |
|
|
263 |
assertTrue(((ISWTObservable) list).getWidget() == combo); |
| 218 |
} |
264 |
} |
| 219 |
|
265 |
|
| 220 |
public void testObserveItemsOfCCombo() throws Exception { |
266 |
public void testObserveItemsOfCCombo() throws Exception { |
| 221 |
CCombo ccombo = new CCombo(shell, SWT.NONE); |
267 |
CCombo ccombo = new CCombo(shell, SWT.NONE); |
| 222 |
IObservableList list = SWTObservables.observeItems(ccombo); |
268 |
IObservableList list = SWTObservables.observeItems(ccombo); |
| 223 |
assertNotNull(list); |
269 |
assertNotNull(list); |
| 224 |
assertTrue(list instanceof CComboObservableList); |
270 |
ISWTObservable swtObservable = (ISWTObservable) list; |
|
|
271 |
assertTrue(swtObservable.getWidget() == ccombo); |
| 225 |
} |
272 |
} |
| 226 |
|
273 |
|
| 227 |
public void testObserveItemsOfList() throws Exception { |
274 |
public void testObserveItemsOfList() throws Exception { |
| 228 |
List list = new List(shell, SWT.NONE); |
275 |
List list = new List(shell, SWT.NONE); |
| 229 |
IObservableList observableList = SWTObservables.observeItems(list); |
276 |
IObservableList observableList = SWTObservables.observeItems(list); |
| 230 |
assertNotNull(observableList); |
277 |
assertNotNull(observableList); |
| 231 |
assertTrue(observableList instanceof ListObservableList); |
278 |
ISWTObservable swtObservable = (ISWTObservable) observableList; |
|
|
279 |
assertTrue(swtObservable.getWidget() == list); |
| 232 |
} |
280 |
} |
| 233 |
|
281 |
|
| 234 |
public void testObserveItemsOfUnsupportedControl() throws Exception { |
282 |
public void testObserveItemsOfUnsupportedControl() throws Exception { |
|
Lines 245-251
Link Here
|
| 245 |
ISWTObservableValue value = SWTObservables |
293 |
ISWTObservableValue value = SWTObservables |
| 246 |
.observeSingleSelectionIndex(table); |
294 |
.observeSingleSelectionIndex(table); |
| 247 |
assertNotNull(value); |
295 |
assertNotNull(value); |
| 248 |
assertTrue(value instanceof TableSingleSelectionObservableValue); |
296 |
assertTrue(value.getWidget() == table); |
|
|
297 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 298 |
assertTrue(propertyObservable.getProperty() instanceof TableSingleSelectionIndexProperty); |
| 249 |
} |
299 |
} |
| 250 |
|
300 |
|
| 251 |
public void testObserveSingleSelectionIndexOfUnsupportedControl() |
301 |
public void testObserveSingleSelectionIndexOfUnsupportedControl() |
|
Lines 258-282
Link Here
|
| 258 |
|
308 |
|
| 259 |
} |
309 |
} |
| 260 |
} |
310 |
} |
| 261 |
|
311 |
|
| 262 |
public void testObserveMinOfSpinner() throws Exception { |
312 |
public void testObserveMinOfSpinner() throws Exception { |
| 263 |
Spinner spinner = new Spinner(shell, SWT.NONE); |
313 |
Spinner spinner = new Spinner(shell, SWT.NONE); |
| 264 |
ISWTObservableValue value = SWTObservables.observeMin(spinner); |
314 |
ISWTObservableValue value = SWTObservables.observeMin(spinner); |
| 265 |
assertNotNull(value); |
315 |
assertNotNull(value); |
| 266 |
assertTrue(value instanceof SpinnerObservableValue); |
316 |
assertTrue(value.getWidget() == spinner); |
| 267 |
|
317 |
|
| 268 |
SpinnerObservableValue spinnerObservable = (SpinnerObservableValue) value; |
318 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 269 |
assertEquals(SWTProperties.MIN, spinnerObservable.getAttribute()); |
319 |
assertTrue(propertyObservable.getProperty() instanceof SpinnerMinimumProperty); |
| 270 |
} |
320 |
} |
| 271 |
|
321 |
|
| 272 |
public void testObserveMinOfScale() throws Exception { |
322 |
public void testObserveMinOfScale() throws Exception { |
| 273 |
Scale scale = new Scale(shell, SWT.NONE); |
323 |
Scale scale = new Scale(shell, SWT.NONE); |
| 274 |
ISWTObservableValue value = SWTObservables.observeMin(scale); |
324 |
ISWTObservableValue value = SWTObservables.observeMin(scale); |
| 275 |
assertNotNull(value); |
325 |
assertNotNull(value); |
| 276 |
assertTrue(value instanceof ScaleObservableValue); |
326 |
assertTrue(value.getWidget() == scale); |
| 277 |
|
327 |
|
| 278 |
ScaleObservableValue scaleObservable = (ScaleObservableValue) value; |
328 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 279 |
assertEquals(SWTProperties.MIN, scaleObservable.getAttribute()); |
329 |
assertTrue(propertyObservable.getProperty() instanceof ScaleMinimumProperty); |
| 280 |
} |
330 |
} |
| 281 |
|
331 |
|
| 282 |
public void testObserveMinOfUnsupportedControl() throws Exception { |
332 |
public void testObserveMinOfUnsupportedControl() throws Exception { |
|
Lines 284-313
Link Here
|
| 284 |
try { |
334 |
try { |
| 285 |
SWTObservables.observeMin(text); |
335 |
SWTObservables.observeMin(text); |
| 286 |
fail("Exception should have been thrown"); |
336 |
fail("Exception should have been thrown"); |
| 287 |
} catch (IllegalArgumentException e) { |
337 |
} catch (IllegalArgumentException e) { |
| 288 |
} |
338 |
} |
| 289 |
} |
339 |
} |
| 290 |
|
340 |
|
| 291 |
public void testObserveMaxOfSpinner() throws Exception { |
341 |
public void testObserveMaxOfSpinner() throws Exception { |
| 292 |
Spinner spinner = new Spinner(shell, SWT.NONE); |
342 |
Spinner spinner = new Spinner(shell, SWT.NONE); |
| 293 |
ISWTObservableValue value = SWTObservables.observeMax(spinner); |
343 |
ISWTObservableValue value = SWTObservables.observeMax(spinner); |
| 294 |
assertNotNull(value); |
344 |
assertNotNull(value); |
| 295 |
assertTrue(value instanceof SpinnerObservableValue); |
345 |
assertTrue(value.getWidget() == spinner); |
| 296 |
|
346 |
|
| 297 |
SpinnerObservableValue spinnerObservable = (SpinnerObservableValue) value; |
347 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 298 |
assertEquals(SWTProperties.MAX, spinnerObservable.getAttribute()); |
348 |
assertTrue(propertyObservable.getProperty() instanceof SpinnerMaximumProperty); |
| 299 |
} |
349 |
} |
| 300 |
|
350 |
|
| 301 |
public void testObserveMaxOfScale() throws Exception { |
351 |
public void testObserveMaxOfScale() throws Exception { |
| 302 |
Scale scale = new Scale(shell, SWT.NONE); |
352 |
Scale scale = new Scale(shell, SWT.NONE); |
| 303 |
ISWTObservableValue value = SWTObservables.observeMax(scale); |
353 |
ISWTObservableValue value = SWTObservables.observeMax(scale); |
| 304 |
assertNotNull(value); |
354 |
assertNotNull(value); |
| 305 |
assertTrue(value instanceof ScaleObservableValue); |
355 |
assertTrue(value.getWidget() == scale); |
| 306 |
|
356 |
|
| 307 |
ScaleObservableValue scaleObservable = (ScaleObservableValue) value; |
357 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 308 |
assertEquals(SWTProperties.MAX, scaleObservable.getAttribute()); |
358 |
assertTrue(propertyObservable.getProperty() instanceof ScaleMaximumProperty); |
| 309 |
} |
359 |
} |
| 310 |
|
360 |
|
| 311 |
public void testObserveMaxOfUnsupportedControl() throws Exception { |
361 |
public void testObserveMaxOfUnsupportedControl() throws Exception { |
| 312 |
Text text = new Text(shell, SWT.NONE); |
362 |
Text text = new Text(shell, SWT.NONE); |
| 313 |
try { |
363 |
try { |
|
Lines 316-329
Link Here
|
| 316 |
} catch (IllegalArgumentException e) { |
366 |
} catch (IllegalArgumentException e) { |
| 317 |
} |
367 |
} |
| 318 |
} |
368 |
} |
| 319 |
|
369 |
|
| 320 |
public void testObserveEditableOfText() throws Exception { |
370 |
public void testObserveEditableOfText() throws Exception { |
| 321 |
Text text = new Text(shell, SWT.NONE); |
371 |
Text text = new Text(shell, SWT.NONE); |
| 322 |
ISWTObservableValue value = SWTObservables.observeEditable(text); |
372 |
ISWTObservableValue value = SWTObservables.observeEditable(text); |
| 323 |
assertNotNull(value); |
373 |
assertNotNull(value); |
| 324 |
assertTrue(value instanceof TextEditableObservableValue); |
374 |
assertTrue(value.getWidget() == text); |
|
|
375 |
IPropertyObservable propertyObservable = getPropertyObservable(value); |
| 376 |
assertTrue(propertyObservable.getProperty() instanceof TextEditableProperty); |
| 325 |
} |
377 |
} |
| 326 |
|
378 |
|
| 327 |
public void testObserveEditableOfUnsupportedControl() throws Exception { |
379 |
public void testObserveEditableOfUnsupportedControl() throws Exception { |
| 328 |
Label label = new Label(shell, SWT.NONE); |
380 |
Label label = new Label(shell, SWT.NONE); |
| 329 |
try { |
381 |
try { |