/**
   * @param templatePreferencePart
   * @param newValue
   */
  private void enableTemplateItems(
      final TemplatePreferencePart templatePreferencePart,
      final Object newValueOfFirstTemplateItem) {
    if (isEmpty(this.currentValueOf2ndTemplateItem)) {
      this.currentValueOf2ndTemplateItem = this.prefValueOf2ndTempalteItem;
    }
    if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.Class.getValue())) {
      this.classSelected = true;
      templatePreferencePart.secondTemplateRadioButton.setEnabled(true, getFieldEditorParent());
      if (this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.field.getValue())
          || this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.both.getValue())
          || this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.custom.getValue())) {

        templatePreferencePart.getterSetterRadioButton.setEnabled(true, getFieldEditorParent());

      } else if (this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.method.getValue())
          || this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.none.getValue())) {
        getPreferenceStore()
            .setValue(
                getTemplatePreferenceKey(
                    templatePreferencePart.templateName, P_TEMPLATE_GETTER_SETTER),
                GETTER_SETTER.NONE.getValue());
        templatePreferencePart.getterSetterRadioButton.setEnabled(false, getFieldEditorParent());
      }
      templatePreferencePart.numberOfRequiredClassesField.setEnabled(true, getFieldEditorParent());
    } else if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.File.getValue())) {
      this.fileSelected = true;
      getPreferenceStore()
          .setValue(
              getTemplatePreferenceKey(
                  templatePreferencePart.templateName, P_TEMPLATE_SECOND_TEMPLATE_ITEM),
              SECOND_TEMPLATE.none.getValue());
      templatePreferencePart.secondTemplateRadioButton.setEnabled(false, getFieldEditorParent());
      getPreferenceStore()
          .setValue(
              getTemplatePreferenceKey(
                  templatePreferencePart.templateName, P_TEMPLATE_GETTER_SETTER),
              GETTER_SETTER.NONE.getValue());
      templatePreferencePart.getterSetterRadioButton.setEnabled(false, getFieldEditorParent());
      templatePreferencePart.numberOfRequiredClassesField.setEnabled(false, getFieldEditorParent());
    } else if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.Package.getValue())
        || newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.Folder.getValue())) {
      if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.Package.getValue())) {
        this.pkgSelected = true;
      } else if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.Folder.getValue())) {
        this.fldrSelected = true;
      }

      templatePreferencePart.secondTemplateRadioButton.setEnabled(true, getFieldEditorParent());
      templatePreferencePart.getterSetterRadioButton.setEnabled(false, getFieldEditorParent());
      templatePreferencePart.numberOfRequiredClassesField.setEnabled(false, getFieldEditorParent());
    } else if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.Enumeration.getValue())) {
      this.enumSelected = true;
      templatePreferencePart.secondTemplateRadioButton.setEnabled(true, getFieldEditorParent());
      if (this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.field.getValue())) {
        templatePreferencePart.getterSetterRadioButton.setEnabled(true, getFieldEditorParent());
      } else if (this.currentValueOf2ndTemplateItem.equals(SECOND_TEMPLATE.none.getValue())) {
        getPreferenceStore()
            .setValue(
                getTemplatePreferenceKey(
                    templatePreferencePart.templateName, P_TEMPLATE_GETTER_SETTER),
                GETTER_SETTER.NONE.getValue());
        templatePreferencePart.getterSetterRadioButton.setEnabled(false, getFieldEditorParent());
      }
      templatePreferencePart.numberOfRequiredClassesField.setEnabled(true, getFieldEditorParent());
    } else if (newValueOfFirstTemplateItem.equals(FIRST_TEMPLATE.None.getValue())) {
      getPreferenceStore()
          .setValue(
              getTemplatePreferenceKey(
                  templatePreferencePart.templateName, P_TEMPLATE_SECOND_TEMPLATE_ITEM),
              SECOND_TEMPLATE.none.getValue());
      getPreferenceStore()
          .setValue(
              getTemplatePreferenceKey(
                  templatePreferencePart.templateName, P_TEMPLATE_GETTER_SETTER),
              GETTER_SETTER.NONE.getValue());
      templatePreferencePart.secondTemplateRadioButton.setEnabled(false, getFieldEditorParent());
      templatePreferencePart.getterSetterRadioButton.setEnabled(false, getFieldEditorParent());
      templatePreferencePart.numberOfRequiredClassesField.setEnabled(false, getFieldEditorParent());
    }
  }
  /** @param event */
  @Override
  public void propertyChange(final PropertyChangeEvent event) {
    super.propertyChange(event);
    final Object source = event.getSource();
    final Object newValue = event.getNewValue();
    this.classSelected = false;
    this.fileSelected = false;
    this.pkgSelected = false;
    this.fldrSelected = false;
    this.enumSelected = false;
    final GlobalSettings globalSettings = GlobalSettings.getInstance();

    for (int i = 0; i < this.TEMPLATES_LIST.length; i++) {
      this.prefValueOf1stTemplateItem =
          getPreferenceStore()
              .getString(
                  getTemplatePreferenceKey(
                      this.templatePreferenceParts[i].templateName,
                      P_TEMPLATE_FIRST_TEMPLATE_ITEM));
      this.prefValueOf2ndTempalteItem =
          getPreferenceStore()
              .getString(
                  getTemplatePreferenceKey(
                      this.templatePreferenceParts[i].templateName,
                      P_TEMPLATE_SECOND_TEMPLATE_ITEM));
      if (source == this.templatePreferenceParts[i].enableTemplateCheckBox) {
        final boolean enbale = (Boolean) newValue;
        enableFields(this.templatePreferenceParts[i], enbale);
        break;
      } else if (source == this.templatePreferenceParts[i].allowMultipleVariationCheckBox) {
        this.templatePreferenceParts[i].templateVariationField.setEmptyStringAllowed(
            !(Boolean) newValue);
        if (FALSE_STR.equalsIgnoreCase(
            globalSettings.getPropertyValue(DEFAULT_TEMPLATE_VARIATION_FIELD, TRUE_STR))) {
          this.templatePreferenceParts[i].templateVariationFieldNameField.setEmptyStringAllowed(
              !(Boolean) newValue);
        }
        break;
      } else if (source == this.templatePreferenceParts[i].templateVariationField) {
        if (FALSE_STR.equalsIgnoreCase(
            globalSettings.getPropertyValue(DEFAULT_TEMPLATE_VARIATION_FIELD, TRUE_STR))) {
          this.templatePreferenceParts[i].templateVariationFieldNameField.setEmptyStringAllowed(
              isEmpty((String) newValue));
        }
        break;
      } else if (source == this.templatePreferenceParts[i].templateVariationFieldNameField) {
        final boolean isErr =
            ((String) newValue).endsWith(" ") || ((String) newValue).endsWith("\t");
        setErrorMessage(isErr ? "Variation Field cannot end with whitespace" : null);
        this.templatePreferenceParts[i].templateVariationField.setEmptyStringAllowed(
            isEmpty((String) newValue));
        break;
      } else if (source == this.templatePreferenceParts[i].firstTemplateRadioButton) {
        setErrorMessage(null);
        this.currentValueOf1stTemplateItem = (String) newValue;
        enableTemplateItems(this.templatePreferenceParts[i], newValue);

        validateSecondTemplateItem(this.currentValueOf2ndTemplateItem);
        break;
      } else if (source == this.templatePreferenceParts[i].secondTemplateRadioButton) {
        this.currentValueOf2ndTemplateItem = (String) newValue;

        if (newValue.equals(SECOND_TEMPLATE.field.getValue())
            || newValue.equals(SECOND_TEMPLATE.both.getValue())
            || newValue.equals(SECOND_TEMPLATE.custom.getValue())) {
          this.templatePreferenceParts[i].getterSetterRadioButton.setEnabled(
              true, getFieldEditorParent());
        } else if (newValue.equals(SECOND_TEMPLATE.method.getValue())
            || newValue.equals(SECOND_TEMPLATE.none.getValue())) {
          getPreferenceStore()
              .setValue(
                  getTemplatePreferenceKey(
                      this.templatePreferenceParts[i].templateName, P_TEMPLATE_GETTER_SETTER),
                  GETTER_SETTER.NONE.getValue());
          this.templatePreferenceParts[i].getterSetterRadioButton.setEnabled(
              false, getFieldEditorParent());
        }
        if (isEmpty(this.currentValueOf1stTemplateItem)) {
          this.currentValueOf1stTemplateItem = this.prefValueOf1stTemplateItem;
        }
        this.classSelected =
            this.currentValueOf1stTemplateItem.equals(FIRST_TEMPLATE.Class.getValue());
        this.fileSelected =
            this.currentValueOf1stTemplateItem.equals(FIRST_TEMPLATE.File.getValue());
        this.pkgSelected =
            this.currentValueOf1stTemplateItem.equals(FIRST_TEMPLATE.Package.getValue());
        this.fldrSelected =
            this.currentValueOf1stTemplateItem.equals(FIRST_TEMPLATE.Folder.getValue());
        this.enumSelected =
            this.currentValueOf1stTemplateItem.equals(FIRST_TEMPLATE.Enumeration.getValue());
        validateSecondTemplateItem(newValue);
        break;
      } else if (source == this.templatePreferenceParts[i].additionalParametersField) {
        if (!isEmpty(newValue.toString())) {
          try {
            parseAdditonalParam(newValue.toString());
          } catch (final FastCodeException ex) {
            // throw new Exception(ex);
          }
          /*final String addtnlParams[] = newValue.toString().split("\\s+");
          final Map<String, String> addtnParamMap = new HashMap<String, String>();
          for (final String params : addtnlParams) {
          	if (params.contains(COLON)) {
          		final String parseParam[] = params.split(COLON);
          		if (parseParam.length == 2) {
          			final String type = parseParam[1].trim().toLowerCase();
          			if (isEmpty(type)
          					|| !(type.equalsIgnoreCase(FIRST_TEMPLATE.Class.getValue())
          							|| type.equalsIgnoreCase(FIRST_TEMPLATE.File.getValue())
          							|| type.equalsIgnoreCase(FIRST_TEMPLATE.Package.getValue())
          							|| type.equalsIgnoreCase(FIRST_TEMPLATE.Folder.getValue())
          							|| type.equalsIgnoreCase(RETURN_TYPES.JAVAPROJECT.getValue())
          							|| type.equalsIgnoreCase(RETURN_TYPES.PROJECT.getValue())
          							|| type.equalsIgnoreCase(RETURN_TYPES.LOCALVAR.getValue()) || type
          								.equalsIgnoreCase(RETURN_TYPES.BOOLEAN.getValue()))) {
          				setErrorMessage("Additional Parameter type can be only class/file/package/folder/project/javaProject/localvar/boolean.");
          			} else {
          				setErrorMessage(null);
          			}
          			if (addtnParamMap.containsKey(parseParam[0])) {
          				setErrorMessage("Duplicate place holder name " + parseParam[0]);
          			}
          			addtnParamMap.put(parseParam[0], type);
          		} else if (parseParam.length == 1) {
          			setErrorMessage("Additional Parameter must have type class/file/package/folder/project/javaProject/localvar/boolean.");
          		}
          	}
          }*/
        }
      }
    }
  }