Package java.beans

Examples of java.beans.PropertyDescriptor


    handler.setBeanPropertyName("integerProperty");
    handler.setConverter(new StandardBeanUtilsConverter());
    handler.setConversionHandler(new DefaultConversionHandler());

    // needed for binding outwards
    PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(new BindableBean(), "intProperty");
    handler.setPropertyDescriptor(propertyDescriptor);

  }
View Full Code Here


    bindable.setIntegerValue("5");

    Object property = PropertyUtils.getProperty(bindable, "nestedBindableBean.integerValue");
    System.out.println(property);

    PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(bindable,
        "nestedBindableBean.integerValue");
    System.out.println(propertyDescriptor);

    // now try get property descriptor null
    // bindable.setNestedBindableBean(null);
View Full Code Here

    NestedBindableBean nested = new NestedBindableBean();
    BindableBean bindable = new BindableBean();
    bindable.setNestedBindableBean(nested);
    Object targetBean = PropertyUtils.getProperty(bindable, "nestedBindableBean");
    PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(targetBean, "integerValue");

    assert propertyDescriptor.getPropertyType().equals(Integer.class);

  }
View Full Code Here

    Converter converter = new StandardBeanUtilsConverter();
    handler.setConverter(converter);
    converter.setTargetClass(Integer.class);

    // needed for binding outwards
    PropertyDescriptor propertyDescriptor = PropertyUtils.getPropertyDescriptor(new BindableBean(), "selectedId");
    handler.setPropertyDescriptor(propertyDescriptor);

  }
View Full Code Here

    //    System.err.println("wasModified");
    if (evt.getSource() instanceof PropertyEditor) {
      PropertyEditor editor = (PropertyEditor) evt.getSource();
      for (int i = 0 ; i < m_Editors.length; i++) {
  if (m_Editors[i] == editor) {
    PropertyDescriptor property = m_Properties[i];
    Object value = editor.getValue();
    m_Values[i] = value;
    Method setter = property.getWriteMethod();
    try {
      Object args[] = { value };
      args[0] = value;
      setter.invoke(m_Target, args);
    } catch (InvocationTargetException ex) {
      if (ex.getTargetException()
    instanceof PropertyVetoException) {
              String message = "WARNING: Vetoed; reason is: "
                               + ex.getTargetException().getMessage();
        System.err.println(message);
             
              Component jf;
              if(evt.getSource() instanceof JPanel)
                  jf = ((JPanel)evt.getSource()).getParent();
              else
                  jf = new JFrame();
              JOptionPane.showMessageDialog(jf, message,
                                            "error",
                                            JOptionPane.WARNING_MESSAGE);
              if(jf instanceof JFrame)
                  ((JFrame)jf).dispose();

            } else {
        System.err.println(ex.getTargetException().getClass().getName()+
         " while updating "+ property.getName() +": "+
         ex.getTargetException().getMessage());
              Component jf;
              if(evt.getSource() instanceof JPanel)
                  jf = ((JPanel)evt.getSource()).getParent();
              else
                  jf = new JFrame();
              JOptionPane.showMessageDialog(jf,
                                            ex.getTargetException().getClass().getName()+
                                            " while updating "+ property.getName()+
                                            ":\n"+
                                            ex.getTargetException().getMessage(),
                                            "error",
                                            JOptionPane.WARNING_MESSAGE);
              if(jf instanceof JFrame)
                  ((JFrame)jf).dispose();

            }
    } catch (Exception ex) {
      System.err.println("Unexpected exception while updating "
      + property.getName());
    }
    if (m_Views[i] != null && m_Views[i] instanceof PropertyPanel) {
      //System.err.println("Trying to repaint the property canvas");
      m_Views[i].repaint();
      revalidate();
View Full Code Here

              InjectionHandlerFactory.class);
         
          if (wrapper == null)
          {
            InjectionSetter inputSetter = createSetter(actionClass, m);
            PropertyDescriptor propertyDescriptor = BeanUtils.findPropertyForMethod(m);
           
            if (propertyDescriptor == null)
            {
              throw new ApplicationConfigurationException("Method " + m.getName() + " has no valid property descriptor. Is this a valid property");
            }
View Full Code Here

  @Test
  public void testPropertyValueSetter2() throws Exception
  {
    TestAction action = new TestAction();
    Method setterMethod = getSetter(action, "setIntegerInput", Integer.class);
    PropertyDescriptor descriptor = BeanUtils.findPropertyForMethod(setterMethod);

    PropertyValueSetter.setPropertyValue(action, descriptor, new Integer(1));
    assert action.getIntegerInput().equals(1);
  }
View Full Code Here

        Type[] types = ((ParameterizedType)method.getGenericReturnType()).getActualTypeArguments();
        if(types.length == 1){
          try{
            Class<?> clazz = (Class<?>) types[0];
            PropertyDescriptor[]   props       = getBeanProperties(clazz);
                  PropertyDescriptor    keyProperty    = null;
                  PropertyDescriptor    valueProperty  = null;
                  for(PropertyDescriptor prop : props){
                    if(listMapKey.matcher(clazz.getName() + "." + prop.getName()).find()){
                      keyProperty = prop;
                      break;
                    }
                  }
                  if(listMapValue != null){
                    for(PropertyDescriptor prop : props){
                      if(listMapValue.matcher(clazz.getName() + "." + prop.getName()).find()){
                        valueProperty = prop;
                        break;
                      }
                    }
                  }
                  if(keyProperty != null){
                    Method keyReadMethod   = keyProperty.getReadMethod();
                    Method valueReadMethod   = valueProperty != null ? valueProperty.getReadMethod() : null;
                    HashMap<String,Object> map = new LinkedHashMap<String,Object>();
                    while(iterator.hasNext()){
                      Object ob = iterator.next();
                      map.put(String.valueOf(keyReadMethod.invoke(ob)), valueReadMethod != null ? valueReadMethod.invoke(ob) : ob);
                    }
View Full Code Here

  /**
   * Gets getter corresponding with setter method
   */
  public static Method getGetter(Method setterMethod)
  {
    PropertyDescriptor property = BeanUtils.findPropertyForMethod(setterMethod);
    if (property == null)
    {
      return null;
    }
    else
    {
      return property.getReadMethod();
    }
  }
View Full Code Here

  /**
   * Gets setter corresponding with getter method
   */
  public static Method getSetter(Method getterMethod)
  {
    PropertyDescriptor property = BeanUtils.findPropertyForMethod(getterMethod);
    if (property == null)
    {
      return null;
    }
    else
    {
      return property.getWriteMethod();
    }
  }
View Full Code Here

TOP

Related Classes of java.beans.PropertyDescriptor

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.