|
Lines 9-17
Link Here
|
| 9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
| 10 |
* Matt Carter - bug 170668 |
10 |
* Matt Carter - bug 170668 |
| 11 |
* Brad Reynolds - bug 170848 |
11 |
* Brad Reynolds - bug 170848 |
| 12 |
* Matthew Hall - bugs 180746, 207844, 245647, 248621, 232917 |
12 |
* Matthew Hall - bugs 180746, 207844, 245647, 248621, 232917, 194734 |
| 13 |
* Michael Krauter - bug 180223 |
13 |
* Michael Krauter - bug 180223 |
| 14 |
* Boris Bokowski - bug 245647 |
14 |
* Boris Bokowski - bug 245647 |
|
|
15 |
* Tom Schindl - bug 246462 |
| 15 |
*******************************************************************************/ |
16 |
*******************************************************************************/ |
| 16 |
package org.eclipse.jface.databinding.swt; |
17 |
package org.eclipse.jface.databinding.swt; |
| 17 |
|
18 |
|
|
Lines 24-57
Link Here
|
| 24 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
25 |
import org.eclipse.core.databinding.observable.value.IObservableValue; |
| 25 |
import org.eclipse.core.databinding.observable.value.IVetoableValue; |
26 |
import org.eclipse.core.databinding.observable.value.IVetoableValue; |
| 26 |
import org.eclipse.core.databinding.observable.value.ValueChangingEvent; |
27 |
import org.eclipse.core.databinding.observable.value.ValueChangingEvent; |
| 27 |
import org.eclipse.jface.internal.databinding.internal.swt.LinkObservableValue; |
28 |
import org.eclipse.core.databinding.property.PropertyObservables; |
| 28 |
import org.eclipse.jface.internal.databinding.swt.ButtonObservableValue; |
29 |
import org.eclipse.core.databinding.property.list.IListProperty; |
| 29 |
import org.eclipse.jface.internal.databinding.swt.CComboObservableList; |
30 |
import org.eclipse.core.databinding.property.value.IValueProperty; |
| 30 |
import org.eclipse.jface.internal.databinding.swt.CComboObservableValue; |
|
|
| 31 |
import org.eclipse.jface.internal.databinding.swt.CComboSingleSelectionObservableValue; |
| 32 |
import org.eclipse.jface.internal.databinding.swt.CLabelObservableValue; |
| 33 |
import org.eclipse.jface.internal.databinding.swt.ComboObservableList; |
| 34 |
import org.eclipse.jface.internal.databinding.swt.ComboObservableValue; |
| 35 |
import org.eclipse.jface.internal.databinding.swt.ComboSingleSelectionObservableValue; |
| 36 |
import org.eclipse.jface.internal.databinding.swt.ControlObservableValue; |
| 37 |
import org.eclipse.jface.internal.databinding.swt.ItemObservableValue; |
| 38 |
import org.eclipse.jface.internal.databinding.swt.ItemTooltipObservableValue; |
| 39 |
import org.eclipse.jface.internal.databinding.swt.LabelObservableValue; |
| 40 |
import org.eclipse.jface.internal.databinding.swt.ListObservableList; |
| 41 |
import org.eclipse.jface.internal.databinding.swt.ListObservableValue; |
| 42 |
import org.eclipse.jface.internal.databinding.swt.ListSingleSelectionObservableValue; |
| 43 |
import org.eclipse.jface.internal.databinding.swt.SWTDelayedObservableValueDecorator; |
31 |
import org.eclipse.jface.internal.databinding.swt.SWTDelayedObservableValueDecorator; |
| 44 |
import org.eclipse.jface.internal.databinding.swt.SWTProperties; |
32 |
import org.eclipse.jface.internal.databinding.swt.SWTObservableListDecorator; |
| 45 |
import org.eclipse.jface.internal.databinding.swt.ScaleObservableValue; |
33 |
import org.eclipse.jface.internal.databinding.swt.SWTObservableValueDecorator; |
| 46 |
import org.eclipse.jface.internal.databinding.swt.ShellObservableValue; |
34 |
import org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator; |
| 47 |
import org.eclipse.jface.internal.databinding.swt.SpinnerObservableValue; |
|
|
| 48 |
import org.eclipse.jface.internal.databinding.swt.TableSingleSelectionObservableValue; |
| 49 |
import org.eclipse.jface.internal.databinding.swt.TextEditableObservableValue; |
| 50 |
import org.eclipse.jface.internal.databinding.swt.TextObservableValue; |
| 51 |
import org.eclipse.swt.SWT; |
35 |
import org.eclipse.swt.SWT; |
| 52 |
import org.eclipse.swt.custom.CCombo; |
36 |
import org.eclipse.swt.custom.CCombo; |
| 53 |
import org.eclipse.swt.custom.CLabel; |
37 |
import org.eclipse.swt.custom.CLabel; |
| 54 |
import org.eclipse.swt.custom.CTabItem; |
38 |
import org.eclipse.swt.custom.CTabItem; |
|
|
39 |
import org.eclipse.swt.custom.StyledText; |
| 55 |
import org.eclipse.swt.widgets.Button; |
40 |
import org.eclipse.swt.widgets.Button; |
| 56 |
import org.eclipse.swt.widgets.Combo; |
41 |
import org.eclipse.swt.widgets.Combo; |
| 57 |
import org.eclipse.swt.widgets.Control; |
42 |
import org.eclipse.swt.widgets.Control; |
|
Lines 139-160
Link Here
|
| 139 |
.observeDelayedValue(delay, observable), observable.getWidget()); |
124 |
.observeDelayedValue(delay, observable), observable.getWidget()); |
| 140 |
} |
125 |
} |
| 141 |
|
126 |
|
|
|
127 |
private static ISWTObservableValue observeWidgetProperty(Widget widget, |
| 128 |
IValueProperty property) { |
| 129 |
return new SWTObservableValueDecorator(PropertyObservables |
| 130 |
.observeValue(getRealm(widget.getDisplay()), widget, property), |
| 131 |
widget); |
| 132 |
} |
| 133 |
|
| 142 |
/** |
134 |
/** |
|
|
135 |
* Returns an observable value tracking the enabled state of the given |
| 136 |
* control |
| 137 |
* |
| 143 |
* @param control |
138 |
* @param control |
|
|
139 |
* the control to observe |
| 144 |
* @return an observable value tracking the enabled state of the given |
140 |
* @return an observable value tracking the enabled state of the given |
| 145 |
* control |
141 |
* control |
| 146 |
*/ |
142 |
*/ |
| 147 |
public static ISWTObservableValue observeEnabled(Control control) { |
143 |
public static ISWTObservableValue observeEnabled(Control control) { |
| 148 |
return new ControlObservableValue(control, SWTProperties.ENABLED); |
144 |
return observeWidgetProperty(control, ControlProperties.enabled()); |
| 149 |
} |
145 |
} |
| 150 |
|
146 |
|
| 151 |
/** |
147 |
/** |
|
|
148 |
* Returns an observable value tracking the visible state of the given |
| 149 |
* control |
| 150 |
* |
| 152 |
* @param control |
151 |
* @param control |
|
|
152 |
* the control to observe |
| 153 |
* @return an observable value tracking the visible state of the given |
153 |
* @return an observable value tracking the visible state of the given |
| 154 |
* control |
154 |
* control |
| 155 |
*/ |
155 |
*/ |
| 156 |
public static ISWTObservableValue observeVisible(Control control) { |
156 |
public static ISWTObservableValue observeVisible(Control control) { |
| 157 |
return new ControlObservableValue(control, SWTProperties.VISIBLE); |
157 |
return observeWidgetProperty(control, ControlProperties.visible()); |
| 158 |
} |
158 |
} |
| 159 |
|
159 |
|
| 160 |
/** |
160 |
/** |
|
Lines 176-202
Link Here
|
| 176 |
*/ |
176 |
*/ |
| 177 |
public static ISWTObservableValue observeTooltipText(Widget widget) { |
177 |
public static ISWTObservableValue observeTooltipText(Widget widget) { |
| 178 |
if (widget instanceof Control) { |
178 |
if (widget instanceof Control) { |
| 179 |
return new ControlObservableValue((Control)widget, SWTProperties.TOOLTIP_TEXT); |
179 |
return observeTooltipText((Control) widget); |
| 180 |
} else if (widget instanceof CTabItem |
|
|
| 181 |
|| widget instanceof TabItem |
| 182 |
|| widget instanceof TableColumn |
| 183 |
|| widget instanceof ToolItem |
| 184 |
|| widget instanceof TrayItem |
| 185 |
|| widget instanceof TreeColumn) { |
| 186 |
return new ItemTooltipObservableValue((Item) widget); |
| 187 |
} |
180 |
} |
| 188 |
|
181 |
|
| 189 |
throw new IllegalArgumentException( |
182 |
IValueProperty property; |
| 190 |
"Item [" + widget.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
183 |
if (widget instanceof CTabItem) { |
|
|
184 |
property = CTabItemProperties.tooltipText(); |
| 185 |
} else if (widget instanceof TabItem) { |
| 186 |
property = TabItemProperties.tooltipText(); |
| 187 |
} else if (widget instanceof TableColumn) { |
| 188 |
property = TableColumnProperties.tooltipText(); |
| 189 |
} else if (widget instanceof ToolItem) { |
| 190 |
property = ToolItemProperties.tooltipText(); |
| 191 |
} else if (widget instanceof TrayItem) { |
| 192 |
property = TrayItemProperties.tooltipText(); |
| 193 |
} else if (widget instanceof TreeColumn) { |
| 194 |
property = TreeColumnProperties.tooltipText(); |
| 195 |
} else { |
| 196 |
throw new IllegalArgumentException( |
| 197 |
"Item [" + widget.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 198 |
} |
| 199 |
|
| 200 |
return observeWidgetProperty(widget, property); |
| 191 |
} |
201 |
} |
| 192 |
|
202 |
|
| 193 |
/** |
203 |
/** |
|
|
204 |
* Returns an observable value tracking the tooltip text of the given |
| 205 |
* control |
| 206 |
* |
| 194 |
* @param control |
207 |
* @param control |
|
|
208 |
* the control to observe |
| 195 |
* @return an observable value tracking the tooltip text of the given |
209 |
* @return an observable value tracking the tooltip text of the given |
| 196 |
* control |
210 |
* control |
| 197 |
*/ |
211 |
*/ |
| 198 |
public static ISWTObservableValue observeTooltipText(Control control) { |
212 |
public static ISWTObservableValue observeTooltipText(Control control) { |
| 199 |
return observeTooltipText((Widget) control); |
213 |
return observeWidgetProperty(control, ControlProperties.toolTipText()); |
| 200 |
} |
214 |
} |
| 201 |
|
215 |
|
| 202 |
/** |
216 |
/** |
|
Lines 217-242
Link Here
|
| 217 |
* if <code>control</code> type is unsupported |
231 |
* if <code>control</code> type is unsupported |
| 218 |
*/ |
232 |
*/ |
| 219 |
public static ISWTObservableValue observeSelection(Control control) { |
233 |
public static ISWTObservableValue observeSelection(Control control) { |
|
|
234 |
IValueProperty property; |
| 220 |
if (control instanceof Spinner) { |
235 |
if (control instanceof Spinner) { |
| 221 |
return new SpinnerObservableValue((Spinner) control, |
236 |
property = SpinnerProperties.selection(); |
| 222 |
SWTProperties.SELECTION); |
|
|
| 223 |
} else if (control instanceof Button) { |
237 |
} else if (control instanceof Button) { |
| 224 |
return new ButtonObservableValue((Button) control); |
238 |
property = ButtonProperties.selection(); |
| 225 |
} else if (control instanceof Combo) { |
239 |
} else if (control instanceof Combo) { |
| 226 |
return new ComboObservableValue((Combo) control, |
240 |
property = ComboProperties.selection(); |
| 227 |
SWTProperties.SELECTION); |
|
|
| 228 |
} else if (control instanceof CCombo) { |
241 |
} else if (control instanceof CCombo) { |
| 229 |
return new CComboObservableValue((CCombo) control, |
242 |
property = CComboProperties.selection(); |
| 230 |
SWTProperties.SELECTION); |
|
|
| 231 |
} else if (control instanceof List) { |
243 |
} else if (control instanceof List) { |
| 232 |
return new ListObservableValue((List) control); |
244 |
property = ListProperties.selection(); |
| 233 |
} else if (control instanceof Scale) { |
245 |
} else if (control instanceof Scale) { |
| 234 |
return new ScaleObservableValue((Scale) control, |
246 |
property = ScaleProperties.selection(); |
| 235 |
SWTProperties.SELECTION); |
247 |
} else { |
|
|
248 |
throw new IllegalArgumentException( |
| 249 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 236 |
} |
250 |
} |
| 237 |
|
251 |
|
| 238 |
throw new IllegalArgumentException( |
252 |
return observeWidgetProperty(control, property); |
| 239 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 240 |
} |
253 |
} |
| 241 |
|
254 |
|
| 242 |
/** |
255 |
/** |
|
Lines 253-267
Link Here
|
| 253 |
* if <code>control</code> type is unsupported |
266 |
* if <code>control</code> type is unsupported |
| 254 |
*/ |
267 |
*/ |
| 255 |
public static ISWTObservableValue observeMin(Control control) { |
268 |
public static ISWTObservableValue observeMin(Control control) { |
|
|
269 |
IValueProperty property; |
| 256 |
if (control instanceof Spinner) { |
270 |
if (control instanceof Spinner) { |
| 257 |
return new SpinnerObservableValue((Spinner) control, |
271 |
property = SpinnerProperties.minimum(); |
| 258 |
SWTProperties.MIN); |
|
|
| 259 |
} else if (control instanceof Scale) { |
272 |
} else if (control instanceof Scale) { |
| 260 |
return new ScaleObservableValue((Scale) control, SWTProperties.MIN); |
273 |
property = ScaleProperties.minimum(); |
|
|
274 |
} else { |
| 275 |
throw new IllegalArgumentException( |
| 276 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 261 |
} |
277 |
} |
| 262 |
|
278 |
|
| 263 |
throw new IllegalArgumentException( |
279 |
return observeWidgetProperty(control, property); |
| 264 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 265 |
} |
280 |
} |
| 266 |
|
281 |
|
| 267 |
/** |
282 |
/** |
|
Lines 278-292
Link Here
|
| 278 |
* if <code>control</code> type is unsupported |
293 |
* if <code>control</code> type is unsupported |
| 279 |
*/ |
294 |
*/ |
| 280 |
public static ISWTObservableValue observeMax(Control control) { |
295 |
public static ISWTObservableValue observeMax(Control control) { |
|
|
296 |
IValueProperty property; |
| 281 |
if (control instanceof Spinner) { |
297 |
if (control instanceof Spinner) { |
| 282 |
return new SpinnerObservableValue((Spinner) control, |
298 |
property = SpinnerProperties.maximum(); |
| 283 |
SWTProperties.MAX); |
|
|
| 284 |
} else if (control instanceof Scale) { |
299 |
} else if (control instanceof Scale) { |
| 285 |
return new ScaleObservableValue((Scale) control, SWTProperties.MAX); |
300 |
property = ScaleProperties.maximum(); |
|
|
301 |
} else { |
| 302 |
throw new IllegalArgumentException( |
| 303 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 286 |
} |
304 |
} |
| 287 |
|
305 |
|
| 288 |
throw new IllegalArgumentException( |
306 |
return observeWidgetProperty(control, property); |
| 289 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 290 |
} |
307 |
} |
| 291 |
|
308 |
|
| 292 |
/** |
309 |
/** |
|
Lines 294-299
Link Here
|
| 294 |
* <code>control</code>. The supported types are: |
311 |
* <code>control</code>. The supported types are: |
| 295 |
* <ul> |
312 |
* <ul> |
| 296 |
* <li>org.eclipse.swt.widgets.Text</li> |
313 |
* <li>org.eclipse.swt.widgets.Text</li> |
|
|
314 |
* <li>org.eclipse.swt.custom.StyledText (as of 1.3)</li> |
| 297 |
* </ul> |
315 |
* </ul> |
| 298 |
* |
316 |
* |
| 299 |
* @param control |
317 |
* @param control |
|
Lines 303-314
Link Here
|
| 303 |
* if <code>control</code> type is unsupported |
321 |
* if <code>control</code> type is unsupported |
| 304 |
*/ |
322 |
*/ |
| 305 |
public static ISWTObservableValue observeText(Control control, int event) { |
323 |
public static ISWTObservableValue observeText(Control control, int event) { |
|
|
324 |
IValueProperty property; |
| 306 |
if (control instanceof Text) { |
325 |
if (control instanceof Text) { |
| 307 |
return new TextObservableValue((Text) control, event); |
326 |
property = TextProperties.text(event); |
|
|
327 |
} else if (control instanceof StyledText) { |
| 328 |
property = StyledTextProperties.text(event); |
| 329 |
} else { |
| 330 |
throw new IllegalArgumentException( |
| 331 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 308 |
} |
332 |
} |
| 309 |
|
333 |
|
| 310 |
throw new IllegalArgumentException( |
334 |
return new SWTVetoableValueDecorator(PropertyObservables.observeValue( |
| 311 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
335 |
control, property), control); |
| 312 |
} |
336 |
} |
| 313 |
|
337 |
|
| 314 |
/** |
338 |
/** |
|
Lines 333-355
Link Here
|
| 333 |
* @since 1.3 |
357 |
* @since 1.3 |
| 334 |
*/ |
358 |
*/ |
| 335 |
public static ISWTObservableValue observeText(Widget widget) { |
359 |
public static ISWTObservableValue observeText(Widget widget) { |
| 336 |
if (widget instanceof Label) { |
360 |
if (widget instanceof Control) { |
| 337 |
return new LabelObservableValue((Label) widget); |
361 |
return observeText((Control) widget); |
| 338 |
} else if (widget instanceof Link) { |
|
|
| 339 |
return new LinkObservableValue((Link) widget); |
| 340 |
} else if (widget instanceof CLabel) { |
| 341 |
return new CLabelObservableValue((CLabel) widget); |
| 342 |
} else if (widget instanceof Combo) { |
| 343 |
return new ComboObservableValue((Combo) widget, SWTProperties.TEXT); |
| 344 |
} else if (widget instanceof CCombo) { |
| 345 |
return new CComboObservableValue((CCombo) widget, |
| 346 |
SWTProperties.TEXT); |
| 347 |
} else if (widget instanceof Shell) { |
| 348 |
return new ShellObservableValue((Shell) widget); |
| 349 |
} else if (widget instanceof Text) { |
| 350 |
return new TextObservableValue((Text) widget, SWT.None); |
| 351 |
} else if (widget instanceof Item) { |
362 |
} else if (widget instanceof Item) { |
| 352 |
return new ItemObservableValue((Item)widget); |
363 |
return observeWidgetProperty(widget, ItemProperties.text()); |
| 353 |
} |
364 |
} |
| 354 |
|
365 |
|
| 355 |
throw new IllegalArgumentException( |
366 |
throw new IllegalArgumentException( |
|
Lines 367-372
Link Here
|
| 367 |
* <li>org.eclipse.swt.custom.CCombo</li> |
378 |
* <li>org.eclipse.swt.custom.CCombo</li> |
| 368 |
* <li>org.eclipse.swt.widgets.Shell</li> |
379 |
* <li>org.eclipse.swt.widgets.Shell</li> |
| 369 |
* <li>org.eclipse.swt.widgets.Text (as of 1.3)</li> |
380 |
* <li>org.eclipse.swt.widgets.Text (as of 1.3)</li> |
|
|
381 |
* <li>org.eclipse.swt.custom.StyledText (as of 1.3)</li> |
| 370 |
* </ul> |
382 |
* </ul> |
| 371 |
* |
383 |
* |
| 372 |
* @param control |
384 |
* @param control |
|
Lines 375-381
Link Here
|
| 375 |
* if <code>control</code> type is unsupported |
387 |
* if <code>control</code> type is unsupported |
| 376 |
*/ |
388 |
*/ |
| 377 |
public static ISWTObservableValue observeText(Control control) { |
389 |
public static ISWTObservableValue observeText(Control control) { |
| 378 |
return observeText((Widget) control); |
390 |
if (control instanceof Text || control instanceof StyledText) { |
|
|
391 |
return observeText(control, SWT.None); |
| 392 |
} |
| 393 |
|
| 394 |
IValueProperty property; |
| 395 |
if (control instanceof Label) { |
| 396 |
property = LabelProperties.text(); |
| 397 |
} else if (control instanceof Link) { |
| 398 |
property = LinkProperties.text(); |
| 399 |
} else if (control instanceof CLabel) { |
| 400 |
property = CLabelProperties.text(); |
| 401 |
} else if (control instanceof Combo) { |
| 402 |
property = ComboProperties.text(); |
| 403 |
} else if (control instanceof CCombo) { |
| 404 |
property = CComboProperties.text(); |
| 405 |
} else if (control instanceof Shell) { |
| 406 |
property = ShellProperties.text(); |
| 407 |
} else { |
| 408 |
throw new IllegalArgumentException( |
| 409 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 410 |
} |
| 411 |
|
| 412 |
return observeWidgetProperty(control, property); |
| 379 |
} |
413 |
} |
| 380 |
|
414 |
|
| 381 |
/** |
415 |
/** |
|
Lines 393-408
Link Here
|
| 393 |
* if <code>control</code> type is unsupported |
427 |
* if <code>control</code> type is unsupported |
| 394 |
*/ |
428 |
*/ |
| 395 |
public static IObservableList observeItems(Control control) { |
429 |
public static IObservableList observeItems(Control control) { |
|
|
430 |
IListProperty property; |
| 396 |
if (control instanceof Combo) { |
431 |
if (control instanceof Combo) { |
| 397 |
return new ComboObservableList((Combo) control); |
432 |
property = ComboProperties.items(); |
| 398 |
} else if (control instanceof CCombo) { |
433 |
} else if (control instanceof CCombo) { |
| 399 |
return new CComboObservableList((CCombo) control); |
434 |
property = CComboProperties.items(); |
| 400 |
} else if (control instanceof List) { |
435 |
} else if (control instanceof List) { |
| 401 |
return new ListObservableList((List) control); |
436 |
property = ListProperties.items(); |
|
|
437 |
} else { |
| 438 |
throw new IllegalArgumentException( |
| 439 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 402 |
} |
440 |
} |
| 403 |
|
441 |
|
| 404 |
throw new IllegalArgumentException( |
442 |
return new SWTObservableListDecorator(PropertyObservables.observeList( |
| 405 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
443 |
control, property), control); |
| 406 |
} |
444 |
} |
| 407 |
|
445 |
|
| 408 |
/** |
446 |
/** |
|
Lines 422-501
Link Here
|
| 422 |
*/ |
460 |
*/ |
| 423 |
public static ISWTObservableValue observeSingleSelectionIndex( |
461 |
public static ISWTObservableValue observeSingleSelectionIndex( |
| 424 |
Control control) { |
462 |
Control control) { |
|
|
463 |
IValueProperty property; |
| 425 |
if (control instanceof Table) { |
464 |
if (control instanceof Table) { |
| 426 |
return new TableSingleSelectionObservableValue((Table) control); |
465 |
property = TableProperties.singleSelectionIndex(); |
| 427 |
} else if (control instanceof Combo) { |
466 |
} else if (control instanceof Combo) { |
| 428 |
return new ComboSingleSelectionObservableValue((Combo) control); |
467 |
property = ComboProperties.singleSelectionIndex(); |
| 429 |
} else if (control instanceof CCombo) { |
468 |
} else if (control instanceof CCombo) { |
| 430 |
return new CComboSingleSelectionObservableValue((CCombo) control); |
469 |
property = CComboProperties.singleSelectionIndex(); |
| 431 |
} else if (control instanceof List) { |
470 |
} else if (control instanceof List) { |
| 432 |
return new ListSingleSelectionObservableValue((List) control); |
471 |
property = ListProperties.singleSelectionIndex(); |
|
|
472 |
} else { |
| 473 |
throw new IllegalArgumentException( |
| 474 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 433 |
} |
475 |
} |
| 434 |
|
476 |
|
| 435 |
throw new IllegalArgumentException( |
477 |
return observeWidgetProperty(control, property); |
| 436 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 437 |
} |
478 |
} |
| 438 |
|
479 |
|
| 439 |
/** |
480 |
/** |
|
|
481 |
* Returns an observable value tracking the foreground color of the given |
| 482 |
* control |
| 483 |
* |
| 440 |
* @param control |
484 |
* @param control |
|
|
485 |
* the control to observe |
| 441 |
* @return an observable value tracking the foreground color of the given |
486 |
* @return an observable value tracking the foreground color of the given |
| 442 |
* control |
487 |
* control |
| 443 |
*/ |
488 |
*/ |
| 444 |
public static ISWTObservableValue observeForeground(Control control) { |
489 |
public static ISWTObservableValue observeForeground(Control control) { |
| 445 |
return new ControlObservableValue(control, SWTProperties.FOREGROUND); |
490 |
return observeWidgetProperty(control, ControlProperties.foreground()); |
| 446 |
} |
491 |
} |
| 447 |
|
492 |
|
| 448 |
/** |
493 |
/** |
|
|
494 |
* Returns an observable value tracking the background color of the given |
| 495 |
* control |
| 496 |
* |
| 449 |
* @param control |
497 |
* @param control |
|
|
498 |
* the control to observe |
| 450 |
* @return an observable value tracking the background color of the given |
499 |
* @return an observable value tracking the background color of the given |
| 451 |
* control |
500 |
* control |
| 452 |
*/ |
501 |
*/ |
| 453 |
public static ISWTObservableValue observeBackground(Control control) { |
502 |
public static ISWTObservableValue observeBackground(Control control) { |
| 454 |
return new ControlObservableValue(control, SWTProperties.BACKGROUND); |
503 |
return observeWidgetProperty(control, ControlProperties.background()); |
| 455 |
} |
504 |
} |
| 456 |
|
505 |
|
| 457 |
/** |
506 |
/** |
|
|
507 |
* Returns an observable value tracking the font of the given control. |
| 508 |
* |
| 458 |
* @param control |
509 |
* @param control |
|
|
510 |
* the control to observe |
| 459 |
* @return an observable value tracking the font of the given control |
511 |
* @return an observable value tracking the font of the given control |
| 460 |
*/ |
512 |
*/ |
| 461 |
public static ISWTObservableValue observeFont(Control control) { |
513 |
public static ISWTObservableValue observeFont(Control control) { |
| 462 |
return new ControlObservableValue(control, SWTProperties.FONT); |
514 |
return observeWidgetProperty(control, ControlProperties.font()); |
| 463 |
} |
515 |
} |
| 464 |
|
516 |
|
| 465 |
/** |
517 |
/** |
|
|
518 |
* Returns an observable value tracking the size of the given control. |
| 519 |
* |
| 466 |
* @param control |
520 |
* @param control |
|
|
521 |
* the control to observe |
| 467 |
* @return an observable value tracking the size of the given control |
522 |
* @return an observable value tracking the size of the given control |
| 468 |
* @since 1.3 |
523 |
* @since 1.3 |
| 469 |
*/ |
524 |
*/ |
| 470 |
public static ISWTObservableValue observeSize(Control control) { |
525 |
public static ISWTObservableValue observeSize(Control control) { |
| 471 |
return new ControlObservableValue(control,SWTProperties.SIZE); |
526 |
return observeWidgetProperty(control, ControlProperties.size()); |
| 472 |
} |
527 |
} |
| 473 |
|
528 |
|
| 474 |
/** |
529 |
/** |
|
|
530 |
* Returns an observable value tracking the location of the given control. |
| 531 |
* |
| 475 |
* @param control |
532 |
* @param control |
|
|
533 |
* the control to observe |
| 476 |
* @return an observable value tracking the location of the given control |
534 |
* @return an observable value tracking the location of the given control |
| 477 |
* @since 1.3 |
535 |
* @since 1.3 |
| 478 |
*/ |
536 |
*/ |
| 479 |
public static ISWTObservableValue observeLocation(Control control) { |
537 |
public static ISWTObservableValue observeLocation(Control control) { |
| 480 |
return new ControlObservableValue(control,SWTProperties.LOCATION); |
538 |
return observeWidgetProperty(control, ControlProperties.location()); |
| 481 |
} |
539 |
} |
| 482 |
|
540 |
|
| 483 |
/** |
541 |
/** |
|
|
542 |
* Returns an observable value tracking the focus of the given control. |
| 543 |
* |
| 484 |
* @param control |
544 |
* @param control |
|
|
545 |
* the control to observe |
| 485 |
* @return an observable value tracking the focus of the given control |
546 |
* @return an observable value tracking the focus of the given control |
| 486 |
* @since 1.3 |
547 |
* @since 1.3 |
| 487 |
*/ |
548 |
*/ |
| 488 |
public static ISWTObservableValue observeFocus(Control control) { |
549 |
public static ISWTObservableValue observeFocus(Control control) { |
| 489 |
return new ControlObservableValue(control,SWTProperties.FOCUS); |
550 |
return observeWidgetProperty(control, ControlProperties.focused()); |
| 490 |
} |
551 |
} |
| 491 |
|
552 |
|
| 492 |
/** |
553 |
/** |
|
|
554 |
* Returns an observable value tracking the bounds of the given control. |
| 555 |
* |
| 493 |
* @param control |
556 |
* @param control |
|
|
557 |
* the control to observe |
| 494 |
* @return an observable value tracking the bounds of the given control |
558 |
* @return an observable value tracking the bounds of the given control |
| 495 |
* @since 1.3 |
559 |
* @since 1.3 |
| 496 |
*/ |
560 |
*/ |
| 497 |
public static ISWTObservableValue observeBounds(Control control) { |
561 |
public static ISWTObservableValue observeBounds(Control control) { |
| 498 |
return new ControlObservableValue(control,SWTProperties.BOUNDS); |
562 |
return observeWidgetProperty(control, ControlProperties.bounds()); |
| 499 |
} |
563 |
} |
| 500 |
|
564 |
|
| 501 |
/** |
565 |
/** |
|
Lines 511-522
Link Here
|
| 511 |
* if <code>control</code> type is unsupported |
575 |
* if <code>control</code> type is unsupported |
| 512 |
*/ |
576 |
*/ |
| 513 |
public static ISWTObservableValue observeEditable(Control control) { |
577 |
public static ISWTObservableValue observeEditable(Control control) { |
|
|
578 |
IValueProperty property; |
| 514 |
if (control instanceof Text) { |
579 |
if (control instanceof Text) { |
| 515 |
return new TextEditableObservableValue((Text) control); |
580 |
property = TextProperties.editable(); |
|
|
581 |
} else { |
| 582 |
throw new IllegalArgumentException( |
| 583 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 516 |
} |
584 |
} |
| 517 |
|
585 |
|
| 518 |
throw new IllegalArgumentException( |
586 |
return observeWidgetProperty(control, property); |
| 519 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 520 |
} |
587 |
} |
| 521 |
|
588 |
|
| 522 |
private static class DisplayRealm extends Realm { |
589 |
private static class DisplayRealm extends Realm { |