Package org.izi.binding.Binding

Examples of org.izi.binding.Binding.BindingRegistration


   public void shouldUnbindModelValueOnAlternateProperty()
   {
      // given
      ModelForTests model = new ModelForTests();
      ModelForTests output = new ModelForTests();
      BindingRegistration reg = bind().valueOf(model, ModelForTests.FULL_NAME).after(ModelForTests.NAME, ModelForTests.SURNAME).to(output, ModelForTests.NAME);
      model.setName("John");
      model.setSurname("Smith");
      assertEquals("John Smith", output.getName());

      reg.unbind();
      // when
      model.setName("Jane");
      model.setSurname("Doe");
      // then
      assertEquals("John Smith", output.getName());
View Full Code Here


   public void shouldUnbindMultipleModelValues()
   {
      // given
      ModelForTests model = new ModelForTests();
      ModelForTests output = new ModelForTests();
      BindingRegistration to = bind().valueOf(model, ModelForTests.NAME, ModelForTests.SURNAME).through(new MultipleValuesExpression()
      {
         @Expressive
         public String formatName(String name, String sureName)
         {
            return name + " " + sureName;
         }
      }).to(output, ModelForTests.NAME);
      model.setName("John");
      model.setSurname("Smith");
      assertEquals("John Smith", output.getName());
      // when
      to.unbind();
      model.setName("Jane");
      model.setSurname("Doe");
      // then
      assertEquals("John Smith", output.getName());
   }
View Full Code Here

   public void shouldNotPropagateValuesWhenUnbound()
   {
      // given
      JTextField textField = new JTextField();
      ModelForTests model = new ModelForTests();
      BindingRegistration bindingRegistration = bind().valueOf(model, ModelForTests.NAME).toTextOf(textField);
      model.setName("ABC123");
      bindingRegistration.unbind();
      // when
      model.setName("SomeOtherValue");
      // then
      assertEquals("ABC123", textField.getText());
   }
View Full Code Here

   public void shouldNotPropagateValuesWhenUnbound_controlToModelCase()
   {
      // given
      JTextField textField = new JTextField();
      ModelForTests model = new ModelForTests();
      BindingRegistration to = bind().textOf(textField).to(model, ModelForTests.NAME);
      textField.setText("newData");
      to.unbind();
      // when
      textField.setText("someOtherText");
      // then
      assertEquals("newData", model.getName());
   }
View Full Code Here

   public void shouldUnregisterBindOnButtonSelectionChange()
   {
      // given
      ModelForTests model = new ModelForTests();
      JCheckBox checkBox = new JCheckBox();
      BindingRegistration reg = bind().selectedOf(checkBox).to(model, ModelForTests.SELECTED);
      checkBox.setSelected(true);
      assertEquals(Boolean.TRUE, model.getSelected());

      reg.unbind();
      // when
      checkBox.setSelected(false);
      // then
      assertEquals(Boolean.TRUE, model.getSelected());
   }
View Full Code Here

   public void shouldAllowExecutingControlBindingOnDemand()
   {
      // given
      ModelForTests model = new ModelForTests();
      JTextField component = new JTextField();
      BindingRegistration registration =
         bind().textOf(component).after(EventRegistrations.never()).to(model, ModelForTests.VALUE);
      component.setText("Text");
      assertEquals("", model.getValue());
      // when
      registration.execute();
      // then
      assertEquals("Text", model.getValue());
   }
View Full Code Here

   public void shouldAllowExecutingModelBindingOnDemand()
   {
      // given
      ModelForTests from = new ModelForTests();
      ModelForTests to = new ModelForTests();
      BindingRegistration registration =
         bind().valueOf(from, ModelForTests.VALUE).after(EventRegistrations.never())
            .to(to, ModelForTests.VALUE);
      from.setValue("Text");
      assertNull(to.getValue());
      // when
      registration.execute();
      // then
      assertEquals("Text", to.getValue());
   }
View Full Code Here

TOP

Related Classes of org.izi.binding.Binding.BindingRegistration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.