public void writeExternal(final Element element) throws WriteExternalException {
   super.writeExternal(element);
   JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
   writeModule(element);
   DefaultJDOMExternalizer.writeExternal(this, element);
   final Data persistentData = getPersistentData();
   DefaultJDOMExternalizer.writeExternal(persistentData, element);
   EnvironmentVariablesComponent.writeExternal(element, persistentData.getEnvs());
   final String dirName = persistentData.getDirName();
   if (!dirName.isEmpty()) {
     final Element dirNameElement = new Element("dir");
     dirNameElement.setAttribute("value", FileUtil.toSystemIndependentName(dirName));
     element.addContent(dirNameElement);
   }
   final Element patternsElement = new Element(PATTERNS_EL_NAME);
   for (String o : persistentData.getPatterns()) {
     final Element patternElement = new Element(PATTERN_EL_NAME);
     patternElement.setAttribute(TEST_CLASS_ATT_NAME, o);
     patternsElement.addContent(patternElement);
   }
   final String forkMode = getForkMode();
   if (!forkMode.equals("none")) {
     final Element forkModeElement = new Element("fork_mode");
     forkModeElement.setAttribute("value", forkMode);
     element.addContent(forkModeElement);
   }
   element.addContent(patternsElement);
   PathMacroManager.getInstance(getProject()).collapsePathsRecursively(element);
 }
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    super.writeExternal(element);
    JavaRunConfigurationExtensionManager.getInstance().writeExternal(this, element);
    writeModule(element);
    DefaultJDOMExternalizer.writeExternal(this, element);
    DefaultJDOMExternalizer.writeExternal(getPersistantData(), element);
    EnvironmentVariablesComponent.writeExternal(element, getPersistantData().getEnvs());

    Element propertiesElement = element.getChild("properties");

    if (propertiesElement == null) {
      propertiesElement = new Element("properties");
      element.addContent(propertiesElement);
    }

    Map<String, String> properties = getPersistantData().TEST_PROPERTIES;
    for (Map.Entry<String, String> entry : properties.entrySet()) {
      Element property = new Element("property");
      property.setAttribute("name", entry.getKey());
      property.setAttribute("value", entry.getValue());
      propertiesElement.addContent(property);
    }

    Element listenersElement = element.getChild("listeners");
    if (listenersElement == null) {
      listenersElement = new Element("listeners");
      element.addContent(listenersElement);
    }

    List<String> listeners = getPersistantData().TEST_LISTENERS;
    for (String listener : listeners) {
      Element listenerElement = new Element("listener");
      listenerElement.setAttribute("class", listener);
      listenersElement.addContent(listenerElement);
    }
    final Set<String> patterns = getPersistantData().getPatterns();
    if (!patterns.isEmpty()) {
      final Element patternsElement = new Element(PATTERNS_EL_NAME);
      for (String o : patterns) {
        final Element patternElement = new Element(PATTERN_EL_NAME);
        patternElement.setAttribute(TEST_CLASS_ATT_NAME, o);
        patternsElement.addContent(patternElement);
      }
      element.addContent(patternsElement);
    }
  }