Exemplo n.º 1
0
  /*
   * see java.beans.FeatureDescriptor#FeatureDescriptor(FeatureDescriptor)
   */
  public static void copyNonMethodProperties(PropertyDescriptor source, PropertyDescriptor target)
      throws IntrospectionException {

    target.setExpert(source.isExpert());
    target.setHidden(source.isHidden());
    target.setPreferred(source.isPreferred());
    target.setName(source.getName());
    target.setShortDescription(source.getShortDescription());
    target.setDisplayName(source.getDisplayName());

    // copy all attributes (emulating behavior of private FeatureDescriptor#addTable)
    Enumeration<String> keys = source.attributeNames();
    while (keys.hasMoreElements()) {
      String key = keys.nextElement();
      target.setValue(key, source.getValue(key));
    }

    // see java.beans.PropertyDescriptor#PropertyDescriptor(PropertyDescriptor)
    target.setPropertyEditorClass(source.getPropertyEditorClass());
    target.setBound(source.isBound());
    target.setConstrained(source.isConstrained());
  }
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor name = new PropertyDescriptor("name", beanClass),
          background = new PropertyDescriptor("background", beanClass),
          foreground = new PropertyDescriptor("foreground", beanClass),
          font = new PropertyDescriptor("font", beanClass),
          enabled = new PropertyDescriptor("enabled", beanClass),
          visible = new PropertyDescriptor("visible", beanClass),
          focusable = new PropertyDescriptor("focusable", beanClass);

      enabled.setExpert(true);
      visible.setHidden(true);

      background.setBound(true);
      foreground.setBound(true);
      font.setBound(true);
      focusable.setBound(true);

      PropertyDescriptor[] rv = {name, background, foreground, font, enabled, visible, focusable};
      return rv;
    } catch (IntrospectionException e) {
      throw new Error(e.toString());
    }
  }