Exemplo n.º 1
0
 public PropertyDescriptor[] getPropertyDescriptors() {
   try {
     PropertyDescriptor _domainId =
         new PropertyDescriptor("domainId", beanClass, "getDomainId", "setDomainId");
     PropertyDescriptor _leftMargin =
         new PropertyDescriptor("leftMargin", beanClass, "getLeftMargin", "setLeftMargin");
     PropertyDescriptor _rightMargin =
         new PropertyDescriptor("rightMargin", beanClass, "getRightMargin", "setRightMargin");
     PropertyDescriptor _topMargin =
         new PropertyDescriptor("topMargin", beanClass, "getTopMargin", "setTopMargin");
     PropertyDescriptor _bottomMargin =
         new PropertyDescriptor("bottomMargin", beanClass, "getBottomMargin", "setBottomMargin");
     PropertyDescriptor _columnName =
         new PropertyDescriptor("columnName", beanClass, "getColumnName", "setColumnName");
     _columnName.setPropertyEditorClass(AttributeNameEditor.class);
     PropertyDescriptor[] pds =
         new PropertyDescriptor[] {
           _bottomMargin, _columnName, _domainId, _leftMargin, _rightMargin, _topMargin
         };
     return pds;
   } catch (IntrospectionException ex) {
     ex.printStackTrace();
     return null;
   }
 }
Exemplo n.º 2
0
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor _toolTipText =
          new PropertyDescriptor("toolTipText", beanClass, "getToolTipText", "setToolTipText");
      _toolTipText.setDisplayName("toolTipText");
      _toolTipText.setShortDescription("toolTipText");
      PropertyDescriptor _fillColor =
          new PropertyDescriptor("fillColor", beanClass, "getFillColor", "setFillColor");
      _fillColor.setDisplayName("fillColor");
      _fillColor.setShortDescription("fillColor");
      _fillColor.setPropertyEditorClass(GeColorEditor.class);
      PropertyDescriptor _borderColor =
          new PropertyDescriptor("borderColor", beanClass, "getBorderColor", "setBorderColor");
      _borderColor.setDisplayName("borderColor");
      _borderColor.setShortDescription("borderColor");
      _borderColor.setPropertyEditorClass(GeColorEditor.class);
      PropertyDescriptor _colorTone =
          new PropertyDescriptor("colorTone", beanClass, "getColorTone", "setColorTone");
      _colorTone.setDisplayName("colorTone");
      _colorTone.setShortDescription("colorTone");
      _colorTone.setPropertyEditorClass(GeColorToneEditor.class);
      PropertyDescriptor _colorShift =
          new PropertyDescriptor("colorShift", beanClass, "getColorShift", "setColorShift");
      _colorShift.setDisplayName("colorShift");
      _colorShift.setShortDescription("colorShift");
      _colorShift.setPropertyEditorClass(GeColorShiftEditor.class);
      PropertyDescriptor _colorBrightness =
          new PropertyDescriptor(
              "colorBrightness", beanClass, "getColorBrightness", "setColorBrightness");
      _colorBrightness.setDisplayName("colorBrightness");
      _colorBrightness.setShortDescription("colorBrightness");
      _colorBrightness.setPropertyEditorClass(GeColorBrightnessEditor.class);
      PropertyDescriptor _colorIntensity =
          new PropertyDescriptor(
              "colorIntensity", beanClass, "getColorIntensity", "setColorIntensity");
      _colorIntensity.setDisplayName("colorIntensity");
      _colorIntensity.setShortDescription("colorIntensity");
      _colorIntensity.setPropertyEditorClass(GeColorIntensityEditor.class);
      PropertyDescriptor _rotate =
          new PropertyDescriptor("rotate", beanClass, "getRotate", "setRotate");
      _rotate.setDisplayName("rotate");
      _rotate.setShortDescription("rotate");
      PropertyDescriptor[] pds =
          new PropertyDescriptor[] {
            _toolTipText,
            _fillColor,
            _borderColor,
            _colorTone,
            _colorShift,
            _colorBrightness,
            _colorIntensity,
            _rotate
          };
      return pds;

    } catch (IntrospectionException ex) {
      ex.printStackTrace();
      return null;
    }
  }
Exemplo n.º 3
0
  /**
   * Load bean information into a cache, because this operation will be slow.
   *
   * @param clazz
   * @throws IntrospectionException
   */
  protected PropertyDescriptor[] loadIntrospectionForClass(Class<?> clazz) {
    if (null == clazz) {
      throw new IllegalArgumentException("No bean class specified");
    }

    PropertyDescriptor[] descriptors = null;
    descriptors = introspectionCache.get(clazz);
    if (descriptors != null) {
      return descriptors;
    }

    BeanInfo beanInfo = null;
    try {
      beanInfo = Introspector.getBeanInfo(clazz);

      descriptors = beanInfo.getPropertyDescriptors();
      if (null == descriptors) {
        descriptors = new PropertyDescriptor[0];
      }
    } catch (IntrospectionException e) {
      e.printStackTrace();
      descriptors = new PropertyDescriptor[0];
    }

    introspectionCache.put(clazz, descriptors);
    return descriptors;
  }
  /**
   * Descripción de Método
   *
   * @return
   */
  public PropertyDescriptor[] getPropertyDescriptors() {

    try {

      PropertyDescriptor _background =
          new PropertyDescriptor("background", beanClass, null, "setBackground");
      PropertyDescriptor _display =
          new PropertyDescriptor("display", beanClass, "getDisplay", null);
      PropertyDescriptor _mandatory =
          new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory");
      PropertyDescriptor _readWrite =
          new PropertyDescriptor("readWrite", beanClass, "isReadWrite", "setReadWrite");
      PropertyDescriptor _value =
          new PropertyDescriptor("value", beanClass, "getValue", "setValue");
      PropertyDescriptor _visible =
          new PropertyDescriptor("visible", beanClass, null, "setVisible");
      PropertyDescriptor[] pds =
          new PropertyDescriptor[] {
            _background, _display, _mandatory, _readWrite, _value, _visible
          };

      return pds;

    } catch (IntrospectionException ex) {

      ex.printStackTrace();

      return null;
    }
  }
  public PropertyDescriptor[] getPropertyDescriptors() {
    try {
      PropertyDescriptor _background =
          new PropertyDescriptor("background", beanClass, null, "setBackground");
      PropertyDescriptor _border = new PropertyDescriptor("border", beanClass, null, "setBorder");
      PropertyDescriptor _display =
          new PropertyDescriptor("display", beanClass, "getDisplay", null);
      PropertyDescriptor _editable =
          new PropertyDescriptor("editable", beanClass, "isEditable", "setEditable");
      PropertyDescriptor _font = new PropertyDescriptor("font", beanClass, null, "setFont");
      PropertyDescriptor _foreground =
          new PropertyDescriptor("foreground", beanClass, null, "setForeground");
      PropertyDescriptor _mandatory =
          new PropertyDescriptor("mandatory", beanClass, "isMandatory", "setMandatory");
      PropertyDescriptor _value =
          new PropertyDescriptor("value", beanClass, "getValue", "setValue");
      PropertyDescriptor[] pds =
          new PropertyDescriptor[] {
            _background, _border, _display, _editable, _font, _foreground, _mandatory, _value
          };
      return pds;

    } catch (IntrospectionException ex) {
      ex.printStackTrace();
      return null;
    }
  }
  public void setBeanInfo() {
    BeanInfo info = null;
    try {
      info = Introspector.getBeanInfo(bean.getClass());
    } catch (IntrospectionException ex) {
      ex.printStackTrace();
    }

    for (PropertyDescriptor pd : info.getPropertyDescriptors()) {
      if (!pd.getName().equals("class")) {
        try {
          Object value = null;
          if (properties.get(pd.getName()) != null) {
            value = properties.get(pd.getName());
            if (value.equals("false") || value.equals("true")) {
              pd.getWriteMethod().invoke(bean, new Object[] {Boolean.valueOf((String) value)});
            } else {
              pd.getWriteMethod().invoke(bean, new Object[] {value});
            }
          } else {
            value = pd.getReadMethod().invoke(bean, new Object[] {});
            pd.getWriteMethod().invoke(bean, new Object[] {value});
          }
        } catch (IllegalArgumentException ex) {
          ex.printStackTrace();
        } catch (IllegalAccessException ex) {
          ex.printStackTrace();
        } catch (InvocationTargetException ex) {
          ex.printStackTrace();
        }
      }
    }
  }
  /**
   * Implementation of getPropertyDescriptors.
   *
   * @see java.beans.BeanInfo#getPropertyDescriptors()
   */
  public PropertyDescriptor[] getPropertyDescriptors() {
    PropertyDescriptor[] pd2 = super.getPropertyDescriptors();
    ResourceBundle resourceBundle = getResourceBundle(PointLineAbstractValidation.class);

    if (pd2 == null) {
      pd2 = new PropertyDescriptor[0];
    }

    PropertyDescriptor[] pd = new PropertyDescriptor[pd2.length + 2];
    int i = 0;

    for (; i < pd2.length; i++) pd[i] = pd2[i];

    try {
      pd[i] =
          createPropertyDescriptor(
              "restrictedLineTypeRef", PointLineAbstractValidation.class, resourceBundle);
      pd[i].setExpert(false);
      pd[i + 1] =
          createPropertyDescriptor(
              "pointTypeRef", PointLineAbstractValidation.class, resourceBundle);
      pd[i + 1].setExpert(false);
    } catch (IntrospectionException e) {
      pd = pd2;

      // TODO error, log here
      e.printStackTrace();
    }

    return pd;
  }
Exemplo n.º 8
0
  @Override
  public PropertyDescriptor[] getPropertyDescriptors() {
    List<PropertyDescriptor> descs = new LinkedList<PropertyDescriptor>();
    Field[] fields = OFMatch.class.getDeclaredFields();
    String name;
    for (int i = 0; i < fields.length; i++) {
      int mod = fields[i].getModifiers();
      if (Modifier.isFinal(mod)
          || // don't expose static or final fields
          Modifier.isStatic(mod)) continue;

      name = fields[i].getName();
      Class<?> type = fields[i].getType();

      try {
        descs.add(
            new PropertyDescriptor(
                name, name2getter(OFMatch.class, name), name2setter(OFMatch.class, name, type)));
      } catch (IntrospectionException e) {
        e.printStackTrace();
        throw new RuntimeException(e);
      }
    }

    return descs.toArray(new PropertyDescriptor[0]);
  }
  // ***** *****
  public MethodDescriptor[] getMethodDescriptors() {
    try {
      MethodDescriptor md1 =
          new MethodDescriptor(
              getMethod(
                  com.ibm.HostPublisher.IntegrationObject.HPubCommon.class, "processRequest"));
      String procReqDesc = res.getString("procReqDesc");
      md1.setShortDescription(procReqDesc);

      MethodDescriptor md2 =
          new MethodDescriptor(
              getMethod(
                  com.ibm.HostPublisher.IntegrationObject.HPubCommon.class, "doHPTransaction"));
      String doHPTransDesc = res.getString("doHPTransDesc");
      md2.setShortDescription(doHPTransDesc);

      // method for receiving event
      MethodDescriptor md3 =
          new MethodDescriptor(
              getMethod(
                  com.ibm.HostPublisher.IntegrationObject.HPubCommon.class, "hPubStartPerformed"));
      String hPubStartPerfDesc = res.getString("hPubStartPerfDesc");
      md3.setShortDescription(hPubStartPerfDesc);

      MethodDescriptor[] arrayOfMDs = {md1, md2, md3};
      return arrayOfMDs;

    } catch (IntrospectionException e) {
      e.printStackTrace();
    }
    return null;
  }
 public BeanInfo[] getAdditionalBeanInfo() {
   try {
     // Do not pick up general stuff from ProcessExecutor:
     return new BeanInfo[] {Introspector.getBeanInfo(org.openide.execution.Executor.class)};
   } catch (IntrospectionException ie) {
     if (Boolean.getBoolean("netbeans.debug.exceptions")) ie.printStackTrace();
     return null;
   }
 }
Exemplo n.º 11
0
 /**
  * 获取PropertyDescriptor[]对象
  *
  * @param clazz : 对象
  */
 public static <T> PropertyDescriptor[] getPropertyDescriptor(Class<T> clazz) {
   BeanInfo bi = null;
   try {
     bi = Introspector.getBeanInfo(clazz, Object.class);
   } catch (IntrospectionException e) {
     e.printStackTrace();
   }
   PropertyDescriptor[] props = bi.getPropertyDescriptors();
   return props;
 }
 public BeanInfo[] getAdditionalBeanInfo() {
   Class superclass = beanClass.getSuperclass();
   try {
     BeanInfo superBeanInfo = Introspector.getBeanInfo(superclass);
     return new BeanInfo[] {superBeanInfo};
   } catch (IntrospectionException ex) {
     ex.printStackTrace();
     return null;
   }
 }
 private static void initializeDescriptors() {
   try {
     descriptors =
         new PropertyDescriptor[] {
           createDescriptor(
               "displayName", "getDisplayName", null, "PROP_Name", "HINT_Name"), // NOI18N
         };
   } catch (IntrospectionException e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 14
0
 /**
  * Ignores reflection exceptions while using reflection to fill public fields and Bean properties
  * of the target object from the source Map.
  */
 public static void tryFill(Object target, Map<String, Object> source) {
   try {
     fill(target, source);
   } catch (IntrospectionException ie) {
     ie.printStackTrace();
   } catch (IllegalAccessException iae) {
     iae.printStackTrace();
   } catch (InvocationTargetException ite) {
     ite.printStackTrace();
   }
 }
Exemplo n.º 15
0
 @Override
 public final PropertyDescriptor[] getPropertyDescriptors() {
   try {
     final PropertyDescriptor[] res = {
       expertProp("Visible", "whether this layer is visible", FORMAT),
     };
     return res;
   } catch (final IntrospectionException e) {
     e.printStackTrace();
     return super.getPropertyDescriptors();
   }
 }
  public BeanInfo[] getAdditionalBeanInfo() {
    try {
      BeanInfo hPubBi1 = Introspector.getBeanInfo(RestitutionCompGetData.class.getSuperclass());

      BeanInfo[] arrayOfBIs = {hPubBi1};
      return arrayOfBIs;
    } catch (IntrospectionException e) {
      e.printStackTrace();
    }

    return null;
  }
  public BeanInfo[] getAdditionalBeanInfo() {
    try {
      BeanInfo hPubBi1 = Introspector.getBeanInfo(LastActionHistoryResults.class.getSuperclass());

      BeanInfo[] arrayOfBIs = {hPubBi1};
      return arrayOfBIs;
    } catch (IntrospectionException e) {
      e.printStackTrace();
    }

    return null;
  }
  /*lazy PropertyDescriptor*/
  private static PropertyDescriptor[] getPdescriptor() {
    PropertyDescriptor[] properties = new PropertyDescriptor[1];

    try {
      properties[PROPERTY_conexao] =
          new PropertyDescriptor(
              "conexao", factory.ConexaoFactory.class, "getConexao", null); // NOI18N
    } catch (IntrospectionException e) {
      e.printStackTrace();
    } // GEN-HEADEREND:Properties

    // Here you can add code for customizing the properties array.

    return properties;
  } // GEN-LAST:Properties
Exemplo n.º 19
0
 /**
  * @param name
  * @param clazz
  */
 private static PropertyDescriptor findPropertyDescriptor(Class<?> clazz, String name) {
   BeanInfo beanInfo = null;
   try {
     beanInfo = Introspector.getBeanInfo(clazz);
   } catch (IntrospectionException e) {
     e.printStackTrace();
   }
   PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
   for (PropertyDescriptor p : propertyDescriptors) {
     if (name.equals(p.getName())) {
       return p;
     }
   }
   return null;
 }
  /*lazy PropertyDescriptor*/
  private static PropertyDescriptor[] getPdescriptor() {
    PropertyDescriptor[] properties = new PropertyDescriptor[6];

    try {
      properties[PROPERTY_columnForValue] =
          new PropertyDescriptor(
              "columnForValue",
              fdln.kproject.component.button.CButton.class,
              "getColumnForValue",
              "setColumnForValue"); // NOI18N
      properties[PROPERTY_queryParams] =
          new PropertyDescriptor(
              "queryParams",
              fdln.kproject.component.button.CButton.class,
              "getQueryParams",
              "setQueryParams"); // NOI18N
      properties[PROPERTY_resultTo] =
          new PropertyDescriptor(
              "resultTo",
              fdln.kproject.component.button.CButton.class,
              "getResultTo",
              "setResultTo"); // NOI18N
      properties[PROPERTY_searchColumnIndex] =
          new PropertyDescriptor(
              "searchColumnIndex",
              fdln.kproject.component.button.CButton.class,
              "getSearchColumnIndex",
              "setSearchColumnIndex"); // NOI18N
      properties[PROPERTY_stringQuery] =
          new PropertyDescriptor(
              "stringQuery",
              fdln.kproject.component.button.CButton.class,
              "getStringQuery",
              "setStringQuery"); // NOI18N
      properties[PROPERTY_tableUse] =
          new PropertyDescriptor(
              "tableUse",
              fdln.kproject.component.button.CButton.class,
              "getTableUse",
              "setTableUse"); // NOI18N
    } catch (IntrospectionException e) {
      e.printStackTrace();
    } // GEN-HEADEREND:Properties

    // Here you can add code for customizing the properties array.

    return properties;
  } // GEN-LAST:Properties
Exemplo n.º 21
0
    /**
     * editable GUI properties for our participant
     *
     * @return property descriptions
     */
    public java.beans.PropertyDescriptor[] getPropertyDescriptors() {
      try {
        final java.beans.PropertyDescriptor[] res = {
          prop("Speed", "the speed we transit at (kts)"),
          prop("Course", "the course to travel at (degs)"),
          prop("Distance", "the distance we travel"),
          prop("Height", "the height to travel at (or -999 to ignore depth)"),
          prop("Name", "the name of this transit model"),
        };

        return res;
      } catch (java.beans.IntrospectionException e) {
        e.printStackTrace();
        return super.getPropertyDescriptors();
      }
    }
Exemplo n.º 22
0
  public static <T> Map<String, BeanField<T>> readFields(Class<T> beanClass) {
    Map<String, BeanField<T>> fields = new HashMap<String, BeanField<T>>();

    PropertyDescriptor[] descriptors = new PropertyDescriptor[0];
    try {
      descriptors = Introspector.getBeanInfo(beanClass).getPropertyDescriptors();
    } catch (IntrospectionException e) {
      e.printStackTrace();
    }
    for (PropertyDescriptor descriptor : descriptors) {
      if (descriptor.getWriteMethod() != null && descriptor.getReadMethod() != null) {
        fields.put(descriptor.getName(), new BeanField<T>(descriptor, beanClass));
      }
    }

    return fields;
  }
  static {
    try {
      descr = new BeanDescriptor(AppletExecutor.class);
      ResourceBundle bundle = NbBundle.getBundle(AppletExecutorBeanInfo.class);

      descr.setName(bundle.getString("CTL_Exec_Name"));

      prop = new PropertyDescriptor[1];
      prop[0] = new PropertyDescriptor("externalExecutor", AppletExecutor.class); // 0
      prop[0].setDisplayName(bundle.getString("PROP_External_path"));
      prop[0].setShortDescription(bundle.getString("HINT_External_path"));
    } catch (IntrospectionException ex) {
      if (Boolean.getBoolean("netbeans.debug.exceptions")) {
        ex.printStackTrace();
      }
    }
  }
Exemplo n.º 24
0
 public void init(WoProps props, int studId, int classId) throws SQLException {
   super.init(props, studId, classId);
   try {
     dbWorker.load(studId, this, TABLE_NAME, TABLE_COLS, AffectStudentModel.class);
   } catch (NoSuchFieldException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   } catch (IllegalAccessException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   } catch (IntrospectionException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   } catch (InvocationTargetException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   }
 }
Exemplo n.º 25
0
	/**
	 * 使用反射机制进行设置值.
	 * 
	 * @param o
	 *            对象
	 * @param name
	 *            要设置的属性
	 * @param value
	 *            要设置的value
	 */
	public static void setPro(Object o, String name, String value) {
		PropertyDescriptor[] props;
		try {
			props = Introspector.getBeanInfo(o.getClass(), Object.class)
					.getPropertyDescriptors();
			for (int temp = 0; temp < props.length; temp++) {
				if (name.equals(props[temp].getName())) {
					try {
						props[temp].getWriteMethod().invoke(o, value);
					} catch (Exception e) {
					}
					break;
				}
			}
		} catch (IntrospectionException e1) {
			e1.printStackTrace();
		}
	}
Exemplo n.º 26
0
  private void bean(Object object) {
    add("{");
    BeanInfo info;
    boolean addedSomething = false;
    try {
      info = Introspector.getBeanInfo(object.getClass());
      PropertyDescriptor[] props = info.getPropertyDescriptors();
      for (int i = 0; i < props.length; ++i) {
        PropertyDescriptor prop = props[i];
        String name = prop.getName();
        Method accessor = prop.getReadMethod();
        if ((emitClassName || !"class".equals(name)) && accessor != null) {
          if (!accessor.isAccessible()) accessor.setAccessible(true);
          Object value = accessor.invoke(object, (Object[]) null);
          if (value == null) continue;
          if (addedSomething) add(',');

          if (useApiStyle) {
            name = StringUtils.toUnderlineStyle(name);
          }

          add(name, value);
          addedSomething = true;
        }
      }
      Field[] ff = object.getClass().getFields();
      for (int i = 0; i < ff.length; ++i) {
        Field field = ff[i];
        Object value = field.get(object);
        if (value == null) continue;
        if (addedSomething) add(',');
        add(field.getName(), value);
        addedSomething = true;
      }
    } catch (IllegalAccessException iae) {
      iae.printStackTrace();
    } catch (InvocationTargetException ite) {
      ite.getCause().printStackTrace();
      ite.printStackTrace();
    } catch (IntrospectionException ie) {
      ie.printStackTrace();
    }
    add("}");
  }
Exemplo n.º 27
0
  /*lazy PropertyDescriptor*/
  private static PropertyDescriptor[] getPdescriptor() {
    PropertyDescriptor[] properties = new PropertyDescriptor[1];

    try {
      properties[PROPERTY_logical] =
          new PropertyDescriptor(
              "logical",
              org.yccheok.jstock.analysis.LogicalOperator.class,
              "getLogical",
              "setLogical"); // NOI18N
      properties[PROPERTY_logical].setShortDescription(
          "Type of logical operation to be performed.");
    } catch (IntrospectionException e) {
      e.printStackTrace();
    } // GEN-HEADEREND:Properties

    // Here you can add code for customizing the properties array.

    return properties;
  } // GEN-LAST:Properties
Exemplo n.º 28
0
 /** {@inheritDoc} */
 @Override
 public Object clone() throws CloneNotSupportedException {
   try {
     final GUIObject clonedObject = this.getClass().newInstance();
     final BeanInfo beanInfo =
         Introspector.getBeanInfo(this.getClass(), GUIObject.class.getSuperclass());
     final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
     for (int i = 0; i < descriptors.length; i++) {
       /* get from original */
       Object aValue = null;
       final Method getter = descriptors[i].getReadMethod();
       Class<?>[] paramTypes = getter.getParameterTypes();
       Object[] args = new Object[paramTypes.length];
       aValue = getter.invoke(this, args);
       /* set on clone */
       if (aValue != null) {
         final Method setter = descriptors[i].getWriteMethod();
         paramTypes = setter.getParameterTypes();
         args = new Object[paramTypes.length];
         args[0] = aValue;
         setter.invoke(clonedObject, args);
       }
     }
     return clonedObject;
   } catch (final InstantiationException e) {
     e.printStackTrace();
     throw new AssertionError(e);
   } catch (final IllegalAccessException e) {
     e.printStackTrace();
     throw new AssertionError(e);
   } catch (final IntrospectionException e) {
     e.printStackTrace();
     throw new AssertionError(e);
   } catch (final IllegalArgumentException e) {
     e.printStackTrace();
     throw new AssertionError(e);
   } catch (final InvocationTargetException e) {
     e.printStackTrace();
     throw new AssertionError(e);
   }
 }
    @Override
    public PropertyDescriptor[] getPropertyDescriptors() {
      PropertyDescriptor[] p = new PropertyDescriptor[1];

      try {
        p[0] = new PropertyDescriptor("x", Base.class, "getX", null);
        p[0].setShortDescription("BASEPROPERTY");
        p[0].setBound(baseFlag);
        p[0].setExpert(baseFlag);
        p[0].setHidden(baseFlag);
        p[0].setPreferred(baseFlag);
        p[0].setValue("required", baseFlag);
        p[0].setValue("visualUpdate", baseFlag);
        p[0].setValue(
            "enumerationValues", new Object[] {"TOP", 1, "javax.swing.SwingConstants.TOP"});
      } catch (IntrospectionException e) {
        e.printStackTrace();
      }

      return p;
    }
Exemplo n.º 30
0
  /**
   * Retrieves the getter/setter for a given field using reflection and the JavaBeans Introspection
   * API. If no corresponding method exists, nothing will be returned.
   *
   * @param field The field for which getter/setter are to be retrieved
   * @param flag An indicator to which method should be retrieved; <code>true</code> returns the
   *     getter, while <code>false</code> returns the setter.
   * @return The getter/setter for the provided field, if available; or <code>null</code>,
   *     otherwise.
   */
  private Method retrieveAttributeGetterSetter(Field field, boolean flag) {
    Method result = null;

    BeanInfo bi = null;
    try {
      bi = Introspector.getBeanInfo(this.getClass());
    } // try
    catch (IntrospectionException e) {
      e.printStackTrace(); // TODO: not implemented yet.
    } // catch

    assert bi != null;
    PropertyDescriptor[] pds = bi.getPropertyDescriptors();
    for (PropertyDescriptor pd : pds) {
      if (pd.getName().equals(field.getName())) {
        result = (flag ? pd.getReadMethod() : pd.getWriteMethod());
        break;
      } // if
    } // for

    return result;
  }