use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindValueTest method strategy_converter.
private void strategy_converter(String line0, String line1, String testString) throws Exception {
createModelCompilationUnit("test", "TestConverter.java", DatabindingTestUtils.getTestSource("public class TestConverter extends Converter {", " public TestConverter() {", " super(null, null);", " }", " public Object convert(Object fromObject) {", " return null;", " }", "}"));
waitForAutoBuild();
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " DataBindingContext bindingContext = new DataBindingContext();", " UpdateValueStrategy strategy = new UpdateValueStrategy();", line0, line1, " bindingContext.bindValue(observeWidget, observeValue, null, strategy);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ValueBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateValueStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
//
assertStrategy(binding.getModelStrategy(), "strategy", UpdateStrategyInfo.StrategyType.DefaultConstructor, UpdateValueStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE", testString, null, null, null);
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindValueTest method test_strategy_policy_variable.
public void test_strategy_policy_variable() throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " int m_policy = UpdateValueStrategy.POLICY_NEVER;", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " DataBindingContext bindingContext = new DataBindingContext();", " int policy = UpdateValueStrategy.POLICY_UPDATE;", " UpdateValueStrategy strategy0 = new UpdateValueStrategy(policy);", " UpdateValueStrategy strategy1 = new UpdateValueStrategy(m_policy);", " bindingContext.bindValue(observeWidget, observeValue, strategy0, strategy1);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ValueBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertStrategy(binding.getTargetStrategy(), "strategy0", UpdateStrategyInfo.StrategyType.IntConstructor, UpdateValueStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
//
assertStrategy(binding.getModelStrategy(), "strategy1", UpdateStrategyInfo.StrategyType.IntConstructor, UpdateValueStrategyInfo.Value.POLICY_NEVER, "POLICY_NEVER|POLICY_NEVER");
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindValueTest method strategy_validator.
private void strategy_validator(String line0, String line1, String testString0, String testString1, String testString2) throws Exception {
createModelCompilationUnit("test", "TestValidator.java", DatabindingTestUtils.getTestSource("public class TestValidator implements IValidator {", " public org.eclipse.core.runtime.IStatus validate(Object value) {", " return null;", " }", "}"));
waitForAutoBuild();
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " DataBindingContext bindingContext = new DataBindingContext();", " UpdateValueStrategy strategy = new UpdateValueStrategy();", line0, line1, " bindingContext.bindValue(observeWidget, observeValue, null, strategy);", " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ValueBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.Null, UpdateValueStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
//
assertStrategy(binding.getModelStrategy(), "strategy", UpdateStrategyInfo.StrategyType.DefaultConstructor, UpdateValueStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE", null, testString0, testString1, testString2);
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindValueTest method bindValue_variable.
private void bindValue_variable(String line0, String line1, String testString) throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "import org.eclipse.core.databinding.Binding;", "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", line0, " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " DataBindingContext bindingContext = new DataBindingContext();", line1, " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ValueBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertNotNull(binding.getVariableIdentifier());
assertEquals(testString, binding.getVariableIdentifier());
}
use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.
the class BindValueTest method strategy_constructors.
private void strategy_constructors(String line, Object value, String presentation) throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue = BeansObservables.observeValue(getClass(), \"name\");", " IObservableValue observeWidget = SWTObservables.observeText(m_shell);", " DataBindingContext bindingContext = new DataBindingContext();", line, " return bindingContext;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
assertInstanceOf(ValueBindingInfo.class, bindings.get(0));
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertStrategy(binding.getTargetStrategy(), null, UpdateStrategyInfo.StrategyType.DefaultConstructor, UpdateValueStrategyInfo.Value.POLICY_UPDATE, "POLICY_UPDATE|POLICY_UPDATE");
//
assertStrategy(binding.getModelStrategy(), null, UpdateStrategyInfo.StrategyType.IntConstructor, value, presentation);
}
Aggregations