blob: 067901d6b7438f14c8b46e0a6d11b959b7132225 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/*******************************************************************************
* Copyright (c) 2007, 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Matthew Hall - bug 213145, 194734, 195222
*******************************************************************************/
package org.eclipse.jface.tests.internal.databinding.swt;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.eclipse.core.databinding.observable.IObservable;
import org.eclipse.core.databinding.observable.Realm;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.jface.databinding.conformance.delegate.AbstractObservableValueContractDelegate;
import org.eclipse.jface.databinding.conformance.swt.SWTMutableObservableValueContractTest;
import org.eclipse.jface.databinding.swt.WidgetProperties;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
/**
* @since 3.2
*/
public class TextObservableValueModifyTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite(TextObservableValueModifyTest.class
.toString());
suite.addTest(SWTMutableObservableValueContractTest
.suite(new Delegate()));
return suite;
}
/* package */static class Delegate extends
AbstractObservableValueContractDelegate {
private Shell shell;
private Text text;
public void setUp() {
shell = new Shell();
text = new Text(shell, SWT.NONE);
}
public void tearDown() {
shell.dispose();
}
public IObservableValue createObservableValue(Realm realm) {
return WidgetProperties.text(SWT.Modify).observe(realm, text);
}
public Object getValueType(IObservableValue observable) {
return String.class;
}
public void change(IObservable observable) {
text.setFocus();
IObservableValue observableValue = (IObservableValue) observable;
text.setText((String) createValue(observableValue));
}
public Object createValue(IObservableValue observable) {
String value = (String) observable.getValue();
return value + "a";
}
}
}
|