public void writeExternal(Element element) throws WriteExternalException {
   final Collection<RunnerAndConfigurationSettings> configurations =
       myManager.getStableConfigurations();
   for (RunnerAndConfigurationSettings configuration : configurations) {
     if (myManager.isConfigurationShared(configuration)) {
       myManager.addConfigurationElement(element, configuration);
     }
   }
   if (myUnloadedElements != null) {
     for (Element unloadedElement : myUnloadedElements) {
       element.addContent((Element) unloadedElement.clone());
     }
   }
 }
  public void readExternal(Element element) throws InvalidDataException {
    myUnloadedElements = null;
    final Set<String> existing = new HashSet<String>();

    final List children = element.getChildren();
    for (final Object child : children) {
      final RunnerAndConfigurationSettings configuration =
          myManager.loadConfiguration((Element) child, true);
      if (configuration == null
          && Comparing.strEqual(element.getName(), RunManagerImpl.CONFIGURATION)) {
        if (myUnloadedElements == null) myUnloadedElements = new ArrayList<Element>(2);
        myUnloadedElements.add(element);
      }

      if (configuration != null) {
        existing.add(RunManagerImpl.getUniqueName(configuration.getConfiguration()));
      }
    }

    myManager.removeNotExistingSharedConfigurations(existing);
    if (myManager.getSelectedConfiguration() == null) {
      final RunConfiguration[] allConfigurations = myManager.getAllConfigurations();
      for (final RunConfiguration configuration : allConfigurations) {
        final RunnerAndConfigurationSettings settings = myManager.getSettings(allConfigurations[0]);
        if (!(configuration instanceof UnknownRunConfiguration)) {
          myManager.setSelectedConfiguration(settings);
          break;
        }
      }
    }

    // IDEA-60004: configs may never be sorted before write, so call it manually after shared
    // configs read
    myManager.setOrdered(false);
    myManager.getSortedConfigurations();
  }