Package java.beans

Examples of java.beans.PropertyEditorSupport


        BindStatusHelper helper = new BindStatusHelper("office.employees[0].matriculationCode", this.office);
        assertEquals("abc", helper.getStatusValue());
    }
   
    public void testGetStatusValueWithPropertyEditor() {
        PropertyEditor editor = new PropertyEditorSupport() {
           public String getAsText() {
               Employee emp = (Employee) this.getValue();
               return emp.getFirstname() + " " + emp.getSurname();
          
        };
View Full Code Here


                            language = (String)getPrimaryFile().getAttribute(LANGUAGE);
                        return language;
                    }
                   
                    public PropertyEditor getPropertyEditor() {
                        return new PropertyEditorSupport() {
                            public String[] getTags() {
                                return languages;
                            }
                               
                            public void setAsText(String text) {
View Full Code Here

                    public Object getValue() {
                        return filter;
                    }
                   
                    public PropertyEditor getPropertyEditor() {
                        return new PropertyEditorSupport() {
                            public String[] getTags() {
                                String[] tags = new String[availableFilters.length];
                               
                                for (int i = 0; i < availableFilters.length; i++)
                                    tags[i] = availableFilters[i].toString();
View Full Code Here

*/
public class getSource implements Testlet
{
  public void test(TestHarness harness)
  {
    PropertyEditorSupport pes;
   
    pes = new PropertyEditorSupport();

    // pes-non argument: using the non-argument form of
    // PropertyEditorSupport the event source should be the
    // PropertyEditorSupport instance itself
    harness.check(pes.getSource(), pes, "pes-non argument");
   
    // pes-single argument: using the single argument constructor of
    // PropertyEditorSupport the event source should be set to the given
    // Object instance.
    Object eventSource = new Object();
    pes = new PropertyEditorSupport(eventSource);

    harness.check(pes.getSource(), eventSource, "pes-single argument");
  }
View Full Code Here

    public void test(final TestHarness harness)
    {
        // for 1.4 compatibility it is needed to subclass PropertyEditorSupport because the constructors are
        // 'protected' (they are 'public' in 1.5)
        pes = new PropertyEditorSupport()
        {};

        final Object newValue = "new value";

        pes.addPropertyChangeListener(new PropertyChangeListener()
        {
            public void propertyChange(PropertyChangeEvent event)
            {
                nonNullPropertyChanged = true;

                // the PropertyEditorSupport instance should be the event source
                // (according to documentation of its zero argument constructor)
                harness.check(
                    event.getSource(),
                    pes,
                    "pes1-event-event source");

                // the property name for an PropertyEditorSupport object is always null
                harness.check(
                    event.getPropertyName(),
                    null,
                    "pes1-event-property name");

                // according to documentation of PropertyChangeEvent the old and new value should be
                // null if the property name is null.
                harness.check(
                    event.getOldValue(),
                    null,
                    "pes1-event-old value");
                harness.check(
                    event.getNewValue(),
                    null,
                    "pes1-event-new value");

                // at this point the PropertyEditorSupport instance should have been updated to the new value already
                harness.check(pes.getValue(), newValue, "pes1-new value");
            }

        });

        // this method should trigger the calling of anonymous PropertyChangeListener above
        pes.setValue(newValue);

        harness.check(
            nonNullPropertyChanged,
            "pes1-PropertyChangeListener call");

        // creates another PropertyEditorSupport instance for a slightly different test
        pes = new PropertyEditorSupport()
        {};

        pes.addPropertyChangeListener(new PropertyChangeListener()
        {
View Full Code Here

  }

  public void testCustomEditorForSingleProperty() {
    TestBean tb = new TestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(String.class, "name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
    });
    bw.setPropertyValue("name", "value");
View Full Code Here

  }

  public void testCustomEditorForAllStringProperties() {
    TestBean tb = new TestBean();
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
    });
    bw.setPropertyValue("name", "value");
View Full Code Here

  public void testCustomEditorForSingleNestedProperty() {
    TestBean tb = new TestBean();
    tb.setSpouse(new TestBean());
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(String.class, "spouse.name", new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
    });
    bw.setPropertyValue("spouse.name", "value");
View Full Code Here

  public void testCustomEditorForAllNestedStringProperties() {
    TestBean tb = new TestBean();
    tb.setSpouse(new TestBean());
    BeanWrapper bw = new BeanWrapperImpl(tb);
    bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
    });
    bw.setPropertyValue("spouse.name", "value");
View Full Code Here

  }

  public void testIndexedPropertiesWithCustomEditorForType() {
    IndexedTestBean bean = new IndexedTestBean();
    BeanWrapper bw = new BeanWrapperImpl(bean);
    bw.registerCustomEditor(String.class, new PropertyEditorSupport() {
      public void setAsText(String text) throws IllegalArgumentException {
        setValue("prefix" + text);
      }
    });
    TestBean tb0 = bean.getArray()[0];
View Full Code Here

TOP

Related Classes of java.beans.PropertyEditorSupport

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.