Example #1
0
 @Override
 public PropertyDescriptor preparePropertyDescriptor() {
   PropertyDescriptor descriptor = new PropertyDescriptor(getID(), getName());
   descriptor.setLabelProvider(
       new LabelProvider() {
         public String getText(Object element) {
           Point point = (Point) element;
           StringBuffer buf = new StringBuffer();
           buf.append("[");
           buf.append(point.x);
           buf.append(",  ");
           buf.append(point.y);
           buf.append("]");
           return buf.toString();
         }
       });
   return descriptor;
 }
  /** @return a List of PropertyDescriptors of parameters. */
  protected List<IPropertyDescriptor> createParamDescriptors() {
    if (m_paramPropDescList.isEmpty()) {
      PropertyDescriptor propDes;
      //      init Parameters
      final IParamNodePO paramNodePO = (IParamNodePO) getPoNode();
      List<IParamDescriptionPO> paramList = paramNodePO.getParameterList();
      IParamNameMapper activeParamNameMapper = getActiveParamNameMapper();
      for (IParamDescriptionPO paramDescr : paramList) {
        ParamValueSet valueSet =
            ParamTextPropertyDescriptor.getValuesSet(paramNodePO, paramDescr.getUniqueId());
        propDes =
            TestDataControlFactory.createValuePropertyDescriptor(
                new ParameterValueController(this, paramDescr, activeParamNameMapper),
                getParameterNameDescr(paramDescr),
                ParamTextPropertyDescriptor.getValues(valueSet),
                valueSet != null ? valueSet.isCombinable() : false);
        propDes.setCategory(P_PARAMETER_CAT);
        propDes.setLabelProvider(new ParameterValueLabelProvider(INCOMPL_DATA_IMAGE));
        m_paramPropDescList.add(propDes);
      }
    }

    return m_paramPropDescList;
  }
  static {
    descriptors = new Vector();
    PropertyDescriptor propertyDescriptor;

    ///
    propertyDescriptor = new TextPropertyDescriptor(P_ID_PHONENUMBER, P_PHONENUMBER);
    propertyDescriptor.setCategory(P_CONTACTINFO);
    propertyDescriptor.setHelpContextIds(PHONE_NUMBER_CONTEXT);
    descriptors.addElement(propertyDescriptor);

    ///
    propertyDescriptor = new PropertyDescriptor(P_ID_ADDRESS, P_ADDRESS);
    propertyDescriptor.setCategory(P_CONTACTINFO);
    propertyDescriptor.setHelpContextIds(ADDRESS_CONTEXT);
    descriptors.addElement(propertyDescriptor);

    ///
    propertyDescriptor = new TextPropertyDescriptor(P_ID_EMAIL, P_EMAIL);
    propertyDescriptor.setCategory(P_CONTACTINFO);
    propertyDescriptor.setHelpContextIds(EMAIL_CONTEXT);
    propertyDescriptor.setValidator(new EmailAddressValidator());
    descriptors.addElement(propertyDescriptor);

    ///
    propertyDescriptor = new TextPropertyDescriptor(P_ID_FULLNAME, P_FULLNAME);
    propertyDescriptor.setCategory(P_PERSONELINFO);
    propertyDescriptor.setHelpContextIds(FULL_NAME_CONTEXT);
    descriptors.addElement(propertyDescriptor);

    ///
    propertyDescriptor = new PropertyDescriptor(P_ID_BDAY, P_BDAY);
    propertyDescriptor.setCategory(P_PERSONELINFO);
    propertyDescriptor.setHelpContextIds(BIRTHDAY_CONTEXT);
    descriptors.addElement(propertyDescriptor);

    ///
    propertyDescriptor =
        new ComboBoxPropertyDescriptor(
            P_ID_COOP, P_COOP, new String[] {P_VALUE_TRUE_LABEL, P_VALUE_FALSE_LABEL});
    propertyDescriptor.setCategory(P_PERSONELINFO);
    propertyDescriptor.setHelpContextIds(COOP_CONTEXT);
    propertyDescriptor.setLabelProvider(new BooleanLabelProvider());
    descriptors.addElement(propertyDescriptor);

    ///
    propertyDescriptor = new TextPropertyDescriptor(P_ID_SALARY, P_SALARY);
    // add custom validator to propertyDescriptor limiting salary values to be
    // greator than zero
    propertyDescriptor.setHelpContextIds(new Object[] {SALARY_CONTEXT});
    propertyDescriptor.setFilterFlags(new String[] {IPropertySheetEntry.FILTER_ID_EXPERT});
    propertyDescriptor.setValidator(
        new ICellEditorValidator() {
          public String isValid(Object value) {
            if (value == null) return MessageUtil.getString("salary_is_invalid"); // $NON-NLS-1$
            //
            Float trySalary;
            try {
              trySalary = new Float(Float.parseFloat((String) value));
            } catch (NumberFormatException e) {
              return MessageUtil.getString("salary_is_invalid"); // $NON-NLS-1$
            }
            if (trySalary.floatValue() < 0.0)
              return MessageUtil.getString("salary_must_be_greator_than_zero"); // $NON-NLS-1$
            return null;
          }
        });
    propertyDescriptor.setCategory(P_PERSONELINFO);
    descriptors.addElement(propertyDescriptor);

    /// HairColor
    propertyDescriptor = new ColorPropertyDescriptor(P_ID_HAIRCOLOR, P_HAIRCOLOR);
    propertyDescriptor.setCategory(P_PERSONALINFO);
    propertyDescriptor.setHelpContextIds(HAIR_COLOR__CONTEXT);
    descriptors.addElement(propertyDescriptor);

    /// EyeColor
    propertyDescriptor = new ColorPropertyDescriptor(P_ID_EYECOLOR, P_EYECOLOR);
    propertyDescriptor.setCategory(P_PERSONALINFO);
    propertyDescriptor.setHelpContextIds(EYE_COLOR_CONTEXT);
    descriptors.addElement(propertyDescriptor);

    // gets descriptors from parent, warning name-space collision may occur
    Vector parentDescriptors = OrganizationElement.getDescriptors();
    for (int i = 0; i < parentDescriptors.size(); i++) {
      descriptors.addElement(parentDescriptors.elementAt(i));
    }
  }