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