Search in sources :

Example 16 with IBindingInfo

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);
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) ValueBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ValueBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 17 with IBindingInfo

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");
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) ValueBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ValueBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 18 with IBindingInfo

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);
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) ValueBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ValueBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 19 with IBindingInfo

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());
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) ValueBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ValueBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Example 20 with IBindingInfo

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);
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) ValueBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ValueBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)

Aggregations

IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)81 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)51 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)48 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)38 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)18 TreeViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)16 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)14 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)14 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)14 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)14 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)14 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)14 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)13 CheckedElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo)13 ViewerObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo)13 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)12 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)12 ViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ViewerInputBindingInfo)12 MultiSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo)12 SingleSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)12