|
Lines 10-16
Link Here
|
| 10 |
* Matt Carter - bug 170668 |
10 |
* Matt Carter - bug 170668 |
| 11 |
* Brad Reynolds - bug 170848 |
11 |
* Brad Reynolds - bug 170848 |
| 12 |
* Matthew Hall - bug 180746, bug 207844 |
12 |
* Matthew Hall - bug 180746, bug 207844 |
| 13 |
* Michael Krauter, bug 180223 |
13 |
* Michael Krauter - bug 180223 |
|
|
14 |
* Tom Schindl - bug 246462 |
| 14 |
*******************************************************************************/ |
15 |
*******************************************************************************/ |
| 15 |
package org.eclipse.jface.databinding.swt; |
16 |
package org.eclipse.jface.databinding.swt; |
| 16 |
|
17 |
|
|
Lines 19-48
Link Here
|
| 19 |
|
20 |
|
| 20 |
import org.eclipse.core.databinding.observable.Realm; |
21 |
import org.eclipse.core.databinding.observable.Realm; |
| 21 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
22 |
import org.eclipse.core.databinding.observable.list.IObservableList; |
| 22 |
import org.eclipse.jface.internal.databinding.swt.ButtonObservableValue; |
23 |
import org.eclipse.core.databinding.property.IListProperty; |
| 23 |
import org.eclipse.jface.internal.databinding.swt.CComboObservableList; |
24 |
import org.eclipse.core.databinding.property.IValueProperty; |
| 24 |
import org.eclipse.jface.internal.databinding.swt.CComboObservableValue; |
25 |
import org.eclipse.core.databinding.property.PropertyObservables; |
| 25 |
import org.eclipse.jface.internal.databinding.swt.CComboSingleSelectionObservableValue; |
|
|
| 26 |
import org.eclipse.jface.internal.databinding.swt.CLabelObservableValue; |
| 27 |
import org.eclipse.jface.internal.databinding.swt.ComboObservableList; |
| 28 |
import org.eclipse.jface.internal.databinding.swt.ComboObservableValue; |
| 29 |
import org.eclipse.jface.internal.databinding.internal.swt.LinkObservableValue; |
| 30 |
import org.eclipse.jface.internal.databinding.swt.ComboSingleSelectionObservableValue; |
| 31 |
import org.eclipse.jface.internal.databinding.swt.ControlObservableValue; |
| 32 |
import org.eclipse.jface.internal.databinding.swt.DelayedObservableValue; |
26 |
import org.eclipse.jface.internal.databinding.swt.DelayedObservableValue; |
| 33 |
import org.eclipse.jface.internal.databinding.swt.LabelObservableValue; |
27 |
import org.eclipse.jface.internal.databinding.swt.SWTObservableListDecorator; |
| 34 |
import org.eclipse.jface.internal.databinding.swt.ListObservableList; |
28 |
import org.eclipse.jface.internal.databinding.swt.SWTObservableValueDecorator; |
| 35 |
import org.eclipse.jface.internal.databinding.swt.ListObservableValue; |
29 |
import org.eclipse.jface.internal.databinding.swt.SWTVetoableValueDecorator; |
| 36 |
import org.eclipse.jface.internal.databinding.swt.ListSingleSelectionObservableValue; |
|
|
| 37 |
import org.eclipse.jface.internal.databinding.swt.SWTProperties; |
| 38 |
import org.eclipse.jface.internal.databinding.swt.ScaleObservableValue; |
| 39 |
import org.eclipse.jface.internal.databinding.swt.ShellObservableValue; |
| 40 |
import org.eclipse.jface.internal.databinding.swt.SpinnerObservableValue; |
| 41 |
import org.eclipse.jface.internal.databinding.swt.TableSingleSelectionObservableValue; |
| 42 |
import org.eclipse.jface.internal.databinding.swt.TextEditableObservableValue; |
| 43 |
import org.eclipse.jface.internal.databinding.swt.TextObservableValue; |
| 44 |
import org.eclipse.swt.custom.CCombo; |
30 |
import org.eclipse.swt.custom.CCombo; |
| 45 |
import org.eclipse.swt.custom.CLabel; |
31 |
import org.eclipse.swt.custom.CLabel; |
|
|
32 |
import org.eclipse.swt.custom.StyledText; |
| 46 |
import org.eclipse.swt.widgets.Button; |
33 |
import org.eclipse.swt.widgets.Button; |
| 47 |
import org.eclipse.swt.widgets.Combo; |
34 |
import org.eclipse.swt.widgets.Combo; |
| 48 |
import org.eclipse.swt.widgets.Control; |
35 |
import org.eclipse.swt.widgets.Control; |
|
Lines 88-100
Link Here
|
| 88 |
|
75 |
|
| 89 |
/** |
76 |
/** |
| 90 |
* Returns an observable which delays notification of value change events |
77 |
* Returns an observable which delays notification of value change events |
| 91 |
* from <code>observable</code> until <code>delay</code> milliseconds |
78 |
* from <code>observable</code> until <code>delay</code> milliseconds have |
| 92 |
* have passed since the last change event, or until a FocusOut event is |
79 |
* passed since the last change event, or until a FocusOut event is received |
| 93 |
* received from the underlying widget (whichever happens earlier). This |
80 |
* from the underlying widget (whichever happens earlier). This class helps |
| 94 |
* class helps to delay validation until the user stops typing. To notify |
81 |
* to delay validation until the user stops typing. To notify about pending |
| 95 |
* about pending changes, the returned observable value will fire a stale |
82 |
* changes, the returned observable value will fire a stale event when the |
| 96 |
* event when the wrapped observable value fires a change event, but this |
83 |
* wrapped observable value fires a change event, but this change is being |
| 97 |
* change is being delayed. |
84 |
* delayed. |
| 98 |
* |
85 |
* |
| 99 |
* @param delay |
86 |
* @param delay |
| 100 |
* @param observable |
87 |
* @param observable |
|
Lines 104-138
Link Here
|
| 104 |
* |
91 |
* |
| 105 |
* @since 1.2 |
92 |
* @since 1.2 |
| 106 |
*/ |
93 |
*/ |
| 107 |
public static ISWTObservableValue observeDelayedValue(int delay, ISWTObservableValue observable) { |
94 |
public static ISWTObservableValue observeDelayedValue(int delay, |
| 108 |
return new DelayedObservableValue(delay, observable); |
95 |
ISWTObservableValue observable) { |
|
|
96 |
return new DelayedObservableValue(delay, observable); |
| 97 |
} |
| 98 |
|
| 99 |
private static ISWTObservableValue observeControl(Control control, |
| 100 |
IValueProperty property) { |
| 101 |
return new SWTObservableValueDecorator( |
| 102 |
PropertyObservables.observeValue( |
| 103 |
getRealm(control.getDisplay()), control, property), |
| 104 |
control); |
| 109 |
} |
105 |
} |
| 110 |
|
106 |
|
| 111 |
/** |
107 |
/** |
|
|
108 |
* Returns an observable value tracking the enabled state of the given |
| 109 |
* control |
| 110 |
* |
| 112 |
* @param control |
111 |
* @param control |
|
|
112 |
* the control to observe |
| 113 |
* @return an observable value tracking the enabled state of the given |
113 |
* @return an observable value tracking the enabled state of the given |
| 114 |
* control |
114 |
* control |
| 115 |
*/ |
115 |
*/ |
| 116 |
public static ISWTObservableValue observeEnabled(Control control) { |
116 |
public static ISWTObservableValue observeEnabled(Control control) { |
| 117 |
return new ControlObservableValue(control, SWTProperties.ENABLED); |
117 |
return observeControl(control, ControlProperties.enabled()); |
| 118 |
} |
118 |
} |
| 119 |
|
119 |
|
| 120 |
/** |
120 |
/** |
|
|
121 |
* Returns an observable value tracking the visible state of the given |
| 122 |
* control |
| 123 |
* |
| 121 |
* @param control |
124 |
* @param control |
|
|
125 |
* the control to observe |
| 122 |
* @return an observable value tracking the visible state of the given |
126 |
* @return an observable value tracking the visible state of the given |
| 123 |
* control |
127 |
* control |
| 124 |
*/ |
128 |
*/ |
| 125 |
public static ISWTObservableValue observeVisible(Control control) { |
129 |
public static ISWTObservableValue observeVisible(Control control) { |
| 126 |
return new ControlObservableValue(control, SWTProperties.VISIBLE); |
130 |
return observeControl(control, ControlProperties.visible()); |
| 127 |
} |
131 |
} |
| 128 |
|
132 |
|
| 129 |
/** |
133 |
/** |
|
|
134 |
* Returns an observable value tracking the tooltip text of the given |
| 135 |
* control |
| 136 |
* |
| 130 |
* @param control |
137 |
* @param control |
|
|
138 |
* the control to observe |
| 131 |
* @return an observable value tracking the tooltip text of the given |
139 |
* @return an observable value tracking the tooltip text of the given |
| 132 |
* control |
140 |
* control |
| 133 |
*/ |
141 |
*/ |
| 134 |
public static ISWTObservableValue observeTooltipText(Control control) { |
142 |
public static ISWTObservableValue observeTooltipText(Control control) { |
| 135 |
return new ControlObservableValue(control, SWTProperties.TOOLTIP_TEXT); |
143 |
return observeControl(control, ControlProperties.toolTipText()); |
| 136 |
} |
144 |
} |
| 137 |
|
145 |
|
| 138 |
/** |
146 |
/** |
|
Lines 153-178
Link Here
|
| 153 |
* if <code>control</code> type is unsupported |
161 |
* if <code>control</code> type is unsupported |
| 154 |
*/ |
162 |
*/ |
| 155 |
public static ISWTObservableValue observeSelection(Control control) { |
163 |
public static ISWTObservableValue observeSelection(Control control) { |
|
|
164 |
IValueProperty property; |
| 156 |
if (control instanceof Spinner) { |
165 |
if (control instanceof Spinner) { |
| 157 |
return new SpinnerObservableValue((Spinner) control, |
166 |
property = SpinnerProperties.selection(); |
| 158 |
SWTProperties.SELECTION); |
|
|
| 159 |
} else if (control instanceof Button) { |
167 |
} else if (control instanceof Button) { |
| 160 |
return new ButtonObservableValue((Button) control); |
168 |
property = ButtonProperties.selection(); |
| 161 |
} else if (control instanceof Combo) { |
169 |
} else if (control instanceof Combo) { |
| 162 |
return new ComboObservableValue((Combo) control, |
170 |
property = ComboProperties.selection(); |
| 163 |
SWTProperties.SELECTION); |
|
|
| 164 |
} else if (control instanceof CCombo) { |
171 |
} else if (control instanceof CCombo) { |
| 165 |
return new CComboObservableValue((CCombo) control, |
172 |
property = CComboProperties.selection(); |
| 166 |
SWTProperties.SELECTION); |
|
|
| 167 |
} else if (control instanceof List) { |
173 |
} else if (control instanceof List) { |
| 168 |
return new ListObservableValue((List) control); |
174 |
property = ListProperties.selection(); |
| 169 |
} else if (control instanceof Scale) { |
175 |
} else if (control instanceof Scale) { |
| 170 |
return new ScaleObservableValue((Scale) control, |
176 |
property = ScaleProperties.selection(); |
| 171 |
SWTProperties.SELECTION); |
177 |
} else { |
|
|
178 |
throw new IllegalArgumentException( |
| 179 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 172 |
} |
180 |
} |
| 173 |
|
181 |
|
| 174 |
throw new IllegalArgumentException( |
182 |
return observeControl(control, property); |
| 175 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 176 |
} |
183 |
} |
| 177 |
|
184 |
|
| 178 |
/** |
185 |
/** |
|
Lines 189-203
Link Here
|
| 189 |
* if <code>control</code> type is unsupported |
196 |
* if <code>control</code> type is unsupported |
| 190 |
*/ |
197 |
*/ |
| 191 |
public static ISWTObservableValue observeMin(Control control) { |
198 |
public static ISWTObservableValue observeMin(Control control) { |
|
|
199 |
IValueProperty property; |
| 192 |
if (control instanceof Spinner) { |
200 |
if (control instanceof Spinner) { |
| 193 |
return new SpinnerObservableValue((Spinner) control, |
201 |
property = SpinnerProperties.minimum(); |
| 194 |
SWTProperties.MIN); |
|
|
| 195 |
} else if (control instanceof Scale) { |
202 |
} else if (control instanceof Scale) { |
| 196 |
return new ScaleObservableValue((Scale) control, SWTProperties.MIN); |
203 |
property = ScaleProperties.minimum(); |
|
|
204 |
} else { |
| 205 |
throw new IllegalArgumentException( |
| 206 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 197 |
} |
207 |
} |
| 198 |
|
208 |
|
| 199 |
throw new IllegalArgumentException( |
209 |
return observeControl(control, property); |
| 200 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 201 |
} |
210 |
} |
| 202 |
|
211 |
|
| 203 |
/** |
212 |
/** |
|
Lines 214-228
Link Here
|
| 214 |
* if <code>control</code> type is unsupported |
223 |
* if <code>control</code> type is unsupported |
| 215 |
*/ |
224 |
*/ |
| 216 |
public static ISWTObservableValue observeMax(Control control) { |
225 |
public static ISWTObservableValue observeMax(Control control) { |
|
|
226 |
IValueProperty property; |
| 217 |
if (control instanceof Spinner) { |
227 |
if (control instanceof Spinner) { |
| 218 |
return new SpinnerObservableValue((Spinner) control, |
228 |
property = SpinnerProperties.maximum(); |
| 219 |
SWTProperties.MAX); |
|
|
| 220 |
} else if (control instanceof Scale) { |
229 |
} else if (control instanceof Scale) { |
| 221 |
return new ScaleObservableValue((Scale) control, SWTProperties.MAX); |
230 |
property = ScaleProperties.maximum(); |
|
|
231 |
} else { |
| 232 |
throw new IllegalArgumentException( |
| 233 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 222 |
} |
234 |
} |
| 223 |
|
235 |
|
| 224 |
throw new IllegalArgumentException( |
236 |
return observeControl(control, property); |
| 225 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 226 |
} |
237 |
} |
| 227 |
|
238 |
|
| 228 |
/** |
239 |
/** |
|
Lines 230-251
Link Here
|
| 230 |
* <code>control</code>. The supported types are: |
241 |
* <code>control</code>. The supported types are: |
| 231 |
* <ul> |
242 |
* <ul> |
| 232 |
* <li>org.eclipse.swt.widgets.Text</li> |
243 |
* <li>org.eclipse.swt.widgets.Text</li> |
|
|
244 |
* <li>org.eclipse.swt.custom.StyledText (as of 1.3)</li> |
| 233 |
* </ul> |
245 |
* </ul> |
| 234 |
* |
246 |
* |
| 235 |
* <li>org.eclipse.swt.widgets.Label</li> |
|
|
| 236 |
* @param control |
247 |
* @param control |
| 237 |
* @param event event type to register for change events |
248 |
* @param event |
|
|
249 |
* event type to register for change events |
| 238 |
* @return observable value |
250 |
* @return observable value |
| 239 |
* @throws IllegalArgumentException |
251 |
* @throws IllegalArgumentException |
| 240 |
* if <code>control</code> type is unsupported |
252 |
* if <code>control</code> type is unsupported |
| 241 |
*/ |
253 |
*/ |
| 242 |
public static ISWTObservableValue observeText(Control control, int event) { |
254 |
public static ISWTObservableValue observeText(Control control, int event) { |
|
|
255 |
IValueProperty property; |
| 243 |
if (control instanceof Text) { |
256 |
if (control instanceof Text) { |
| 244 |
return new TextObservableValue((Text) control, event); |
257 |
property = TextProperties.text(event); |
|
|
258 |
} else if (control instanceof StyledText) { |
| 259 |
property = StyledTextProperties.text(event); |
| 260 |
} else { |
| 261 |
throw new IllegalArgumentException( |
| 262 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 245 |
} |
263 |
} |
| 246 |
|
264 |
|
| 247 |
throw new IllegalArgumentException( |
265 |
return new SWTVetoableValueDecorator(PropertyObservables.observeValue( |
| 248 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
266 |
control, property), control); |
| 249 |
} |
267 |
} |
| 250 |
|
268 |
|
| 251 |
/** |
269 |
/** |
|
Lines 266-288
Link Here
|
| 266 |
* if <code>control</code> type is unsupported |
284 |
* if <code>control</code> type is unsupported |
| 267 |
*/ |
285 |
*/ |
| 268 |
public static ISWTObservableValue observeText(Control control) { |
286 |
public static ISWTObservableValue observeText(Control control) { |
|
|
287 |
IValueProperty property; |
| 269 |
if (control instanceof Label) { |
288 |
if (control instanceof Label) { |
| 270 |
return new LabelObservableValue((Label) control); |
289 |
property = LabelProperties.text(); |
| 271 |
} else if (control instanceof Link) { |
290 |
} else if (control instanceof Link) { |
| 272 |
return new LinkObservableValue((Link) control); |
291 |
property = LinkProperties.text(); |
| 273 |
} else if (control instanceof CLabel) { |
292 |
} else if (control instanceof CLabel) { |
| 274 |
return new CLabelObservableValue((CLabel) control); |
293 |
property = CLabelProperties.text(); |
| 275 |
} else if (control instanceof Combo) { |
294 |
} else if (control instanceof Combo) { |
| 276 |
return new ComboObservableValue((Combo) control, SWTProperties.TEXT); |
295 |
property = ComboProperties.text(); |
| 277 |
} else if (control instanceof CCombo) { |
296 |
} else if (control instanceof CCombo) { |
| 278 |
return new CComboObservableValue((CCombo) control, |
297 |
property = CComboProperties.text(); |
| 279 |
SWTProperties.TEXT); |
|
|
| 280 |
} else if (control instanceof Shell) { |
298 |
} else if (control instanceof Shell) { |
| 281 |
return new ShellObservableValue((Shell) control); |
299 |
property = ShellProperties.text(); |
|
|
300 |
} else { |
| 301 |
throw new IllegalArgumentException( |
| 302 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 282 |
} |
303 |
} |
| 283 |
|
304 |
|
| 284 |
throw new IllegalArgumentException( |
305 |
return observeControl(control, property); |
| 285 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 286 |
} |
306 |
} |
| 287 |
|
307 |
|
| 288 |
/** |
308 |
/** |
|
Lines 300-315
Link Here
|
| 300 |
* if <code>control</code> type is unsupported |
320 |
* if <code>control</code> type is unsupported |
| 301 |
*/ |
321 |
*/ |
| 302 |
public static IObservableList observeItems(Control control) { |
322 |
public static IObservableList observeItems(Control control) { |
|
|
323 |
IListProperty property; |
| 303 |
if (control instanceof Combo) { |
324 |
if (control instanceof Combo) { |
| 304 |
return new ComboObservableList((Combo) control); |
325 |
property = ComboProperties.items(); |
| 305 |
} else if (control instanceof CCombo) { |
326 |
} else if (control instanceof CCombo) { |
| 306 |
return new CComboObservableList((CCombo) control); |
327 |
property = CComboProperties.items(); |
| 307 |
} else if (control instanceof List) { |
328 |
} else if (control instanceof List) { |
| 308 |
return new ListObservableList((List) control); |
329 |
property = ListProperties.items(); |
|
|
330 |
} else { |
| 331 |
throw new IllegalArgumentException( |
| 332 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 309 |
} |
333 |
} |
| 310 |
|
334 |
|
| 311 |
throw new IllegalArgumentException( |
335 |
return new SWTObservableListDecorator(PropertyObservables.observeList( |
| 312 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
336 |
control, property), control); |
| 313 |
} |
337 |
} |
| 314 |
|
338 |
|
| 315 |
/** |
339 |
/** |
|
Lines 329-346
Link Here
|
| 329 |
*/ |
353 |
*/ |
| 330 |
public static ISWTObservableValue observeSingleSelectionIndex( |
354 |
public static ISWTObservableValue observeSingleSelectionIndex( |
| 331 |
Control control) { |
355 |
Control control) { |
|
|
356 |
IValueProperty property; |
| 332 |
if (control instanceof Table) { |
357 |
if (control instanceof Table) { |
| 333 |
return new TableSingleSelectionObservableValue((Table) control); |
358 |
property = TableProperties.singleSelectionIndex(); |
| 334 |
} else if (control instanceof Combo) { |
359 |
} else if (control instanceof Combo) { |
| 335 |
return new ComboSingleSelectionObservableValue((Combo) control); |
360 |
property = ComboProperties.singleSelectionIndex(); |
| 336 |
} else if (control instanceof CCombo) { |
361 |
} else if (control instanceof CCombo) { |
| 337 |
return new CComboSingleSelectionObservableValue((CCombo) control); |
362 |
property = CComboProperties.singleSelectionIndex(); |
| 338 |
} else if (control instanceof List) { |
363 |
} else if (control instanceof List) { |
| 339 |
return new ListSingleSelectionObservableValue((List) control); |
364 |
property = ListProperties.singleSelectionIndex(); |
|
|
365 |
} else { |
| 366 |
throw new IllegalArgumentException( |
| 367 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 340 |
} |
368 |
} |
| 341 |
|
369 |
|
| 342 |
throw new IllegalArgumentException( |
370 |
return observeControl(control, property); |
| 343 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 344 |
} |
371 |
} |
| 345 |
|
372 |
|
| 346 |
/** |
373 |
/** |
|
Lines 349-377
Link Here
|
| 349 |
* control |
376 |
* control |
| 350 |
*/ |
377 |
*/ |
| 351 |
public static ISWTObservableValue observeForeground(Control control) { |
378 |
public static ISWTObservableValue observeForeground(Control control) { |
| 352 |
return new ControlObservableValue(control, SWTProperties.FOREGROUND); |
379 |
return observeControl(control, ControlProperties.foreground()); |
| 353 |
} |
380 |
} |
| 354 |
|
381 |
|
| 355 |
/** |
382 |
/** |
|
|
383 |
* Returns an observable value tracking the background color of the given |
| 384 |
* control |
| 385 |
* |
| 356 |
* @param control |
386 |
* @param control |
|
|
387 |
* the control to observe |
| 357 |
* @return an observable value tracking the background color of the given |
388 |
* @return an observable value tracking the background color of the given |
| 358 |
* control |
389 |
* control |
| 359 |
*/ |
390 |
*/ |
| 360 |
public static ISWTObservableValue observeBackground(Control control) { |
391 |
public static ISWTObservableValue observeBackground(Control control) { |
| 361 |
return new ControlObservableValue(control, SWTProperties.BACKGROUND); |
392 |
return observeControl(control, ControlProperties.background()); |
| 362 |
} |
393 |
} |
| 363 |
|
394 |
|
| 364 |
/** |
395 |
/** |
|
|
396 |
* Returns an observable value tracking the font of the given control. |
| 397 |
* |
| 365 |
* @param control |
398 |
* @param control |
|
|
399 |
* the control to observe |
| 366 |
* @return an observable value tracking the font of the given control |
400 |
* @return an observable value tracking the font of the given control |
| 367 |
*/ |
401 |
*/ |
| 368 |
public static ISWTObservableValue observeFont(Control control) { |
402 |
public static ISWTObservableValue observeFont(Control control) { |
| 369 |
return new ControlObservableValue(control, SWTProperties.FONT); |
403 |
return observeControl(control, ControlProperties.font()); |
| 370 |
} |
404 |
} |
| 371 |
|
405 |
|
| 372 |
/** |
406 |
/** |
| 373 |
* Returns an observable observing the editable attribute of |
407 |
* @param control |
| 374 |
* the provided <code>control</code>. The supported types are: |
408 |
* @return an observable value tracking the size of the given control |
|
|
409 |
* @since 1.3 |
| 410 |
*/ |
| 411 |
public static ISWTObservableValue observeSize(Control control) { |
| 412 |
return observeControl(control, ControlProperties.size()); |
| 413 |
} |
| 414 |
|
| 415 |
/** |
| 416 |
* @param control |
| 417 |
* @return an observable value tracking the location of the given control |
| 418 |
* @since 1.3 |
| 419 |
*/ |
| 420 |
public static ISWTObservableValue observeLocation(Control control) { |
| 421 |
return observeControl(control, ControlProperties.location()); |
| 422 |
} |
| 423 |
|
| 424 |
/** |
| 425 |
* @param control |
| 426 |
* @return an observable value tracking the focus of the given control |
| 427 |
* @since 1.3 |
| 428 |
*/ |
| 429 |
public static ISWTObservableValue observeFocused(Control control) { |
| 430 |
return observeControl(control, ControlProperties.focused()); |
| 431 |
} |
| 432 |
|
| 433 |
/** |
| 434 |
* @param control |
| 435 |
* @return an observable value tracking the bounds of the given control |
| 436 |
* @since 1.3 |
| 437 |
*/ |
| 438 |
public static ISWTObservableValue observeBounds(Control control) { |
| 439 |
return observeControl(control, ControlProperties.bounds()); |
| 440 |
} |
| 441 |
|
| 442 |
/** |
| 443 |
* Returns an observable observing the editable attribute of the provided |
| 444 |
* <code>control</code>. The supported types are: |
| 375 |
* <ul> |
445 |
* <ul> |
| 376 |
* <li>org.eclipse.swt.widgets.Text</li> |
446 |
* <li>org.eclipse.swt.widgets.Text</li> |
| 377 |
* </ul> |
447 |
* </ul> |
|
Lines 382-393
Link Here
|
| 382 |
* if <code>control</code> type is unsupported |
452 |
* if <code>control</code> type is unsupported |
| 383 |
*/ |
453 |
*/ |
| 384 |
public static ISWTObservableValue observeEditable(Control control) { |
454 |
public static ISWTObservableValue observeEditable(Control control) { |
|
|
455 |
IValueProperty property; |
| 385 |
if (control instanceof Text) { |
456 |
if (control instanceof Text) { |
| 386 |
return new TextEditableObservableValue((Text) control); |
457 |
property = TextProperties.editable(); |
|
|
458 |
} else { |
| 459 |
throw new IllegalArgumentException( |
| 460 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
| 387 |
} |
461 |
} |
| 388 |
|
462 |
|
| 389 |
throw new IllegalArgumentException( |
463 |
return observeControl(control, property); |
| 390 |
"Widget [" + control.getClass().getName() + "] is not supported."); //$NON-NLS-1$//$NON-NLS-2$ |
|
|
| 391 |
} |
464 |
} |
| 392 |
|
465 |
|
| 393 |
private static class DisplayRealm extends Realm { |
466 |
private static class DisplayRealm extends Realm { |