Esempio n. 1
0
 public static void writeFilters(Element parentNode, @NonNls String tagName, ClassFilter[] filters)
     throws WriteExternalException {
   for (ClassFilter filter : filters) {
     Element element = new Element(tagName);
     parentNode.addContent(element);
     DefaultJDOMExternalizer.writeExternal(filter, element);
   }
 }
 public void writeExternal(Element element) throws WriteExternalException {
   for (final String name : myName2FavoritesRoots.keySet()) {
     Element list = new Element(ELEMENT_FAVORITES_LIST);
     list.setAttribute(ATTRIBUTE_NAME, name);
     writeRoots(list, myName2FavoritesRoots.get(name));
     element.addContent(list);
   }
   DefaultJDOMExternalizer.writeExternal(this, element);
 }
  @Override
  public void writeExternal(Element element) throws WriteExternalException {
    final CodeStyleSettings parentSettings = new CodeStyleSettings();
    DefaultJDOMExternalizer.writeExternal(
        this, element, new DifferenceFilter<CodeStyleSettings>(this, parentSettings));
    List<CustomCodeStyleSettings> customSettings =
        new ArrayList<CustomCodeStyleSettings>(getCustomSettingsValues());

    Collections.sort(
        customSettings,
        new Comparator<CustomCodeStyleSettings>() {
          @Override
          public int compare(final CustomCodeStyleSettings o1, final CustomCodeStyleSettings o2) {
            return o1.getTagName().compareTo(o2.getTagName());
          }
        });

    for (final CustomCodeStyleSettings settings : customSettings) {
      final CustomCodeStyleSettings parentCustomSettings =
          parentSettings.getCustomSettings(settings.getClass());
      if (parentCustomSettings == null) {
        throw new WriteExternalException("Custom settings are null for " + settings.getClass());
      }
      settings.writeExternal(element, parentCustomSettings);
    }

    final FileType[] fileTypes =
        myAdditionalIndentOptions
            .keySet()
            .toArray(new FileType[myAdditionalIndentOptions.keySet().size()]);
    Arrays.sort(
        fileTypes,
        new Comparator<FileType>() {
          @Override
          public int compare(final FileType o1, final FileType o2) {
            return o1.getDefaultExtension().compareTo(o2.getDefaultExtension());
          }
        });

    for (FileType fileType : fileTypes) {
      final IndentOptions indentOptions = myAdditionalIndentOptions.get(fileType);
      Element additionalIndentOptions = new Element(ADDITIONAL_INDENT_OPTIONS);
      indentOptions.serialize(additionalIndentOptions, getDefaultIndentOptions(fileType));
      additionalIndentOptions.setAttribute(FILETYPE, fileType.getDefaultExtension());
      if (!additionalIndentOptions.getChildren().isEmpty()) {
        element.addContent(additionalIndentOptions);
      }
    }

    myCommonSettingsManager.writeExternal(element);
  }
  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 String categoryName = persistentData.getCategory();
    if (!categoryName.isEmpty()) {
      final Element categoryNameElement = new Element("category");
      categoryNameElement.setAttribute("value", categoryName);
      element.addContent(categoryNameElement);
    }

    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);
  }
 @SuppressWarnings({"HardCodedStringLiteral"})
 public void writeExternal(Element element) throws WriteExternalException {
   DefaultJDOMExternalizer.writeExternal(this, element);
   if (ADD_PATHS != null) {
     for (String aADD_PATHS : ADD_PATHS) {
       Element elem = new Element("addpath");
       elem.setAttribute("path", aADD_PATHS);
       element.addContent(elem);
     }
   }
   if (myConfigurationDirectory != null) {
     Element configurationDirectory = new Element("configuration");
     configurationDirectory.setText(myConfigurationDirectory);
     configurationDirectory.setAttribute(
         "useDefault", myIsUseDefaultConfiguration ? "true" : "false");
     element.addContent(configurationDirectory);
   }
   if (myIsKeepLocks) {
     element.addContent(new Element("keepLocks"));
   }
   if (myRemoteStatus) {
     element.addContent(new Element("remoteStatus"));
   }
   if (myUpgradeMode != null) {
     element.addContent(new Element("upgradeMode").setText(myUpgradeMode));
   }
   element.addContent(
       new Element("myIsUseDefaultProxy").setText(myIsUseDefaultProxy ? "true" : "false"));
   if (mySupportOptions != null) {
     element.addContent(new Element("supportedVersion").setText("" + mySupportOptions.myVersion));
   }
   element.setAttribute("maxAnnotateRevisions", "" + myMaxAnnotateRevisions);
   element.setAttribute("myUseAcceleration", "" + myUseAcceleration);
   element.setAttribute("myAutoUpdateAfterCommit", "" + myAutoUpdateAfterCommit);
   element.setAttribute(CLEANUP_ON_START_RUN, "" + myCleanupRun);
   element.setAttribute("SSL_PROTOCOLS", SSL_PROTOCOLS.name());
   if (TREE_CONFLICT_MERGE_THEIRS_NEW_INTO_OLD_PLACE != null) {
     element.setAttribute(
         "TREE_CONFLICT_MERGE_THEIRS_NEW_INTO_OLD_PLACE",
         "" + TREE_CONFLICT_MERGE_THEIRS_NEW_INTO_OLD_PLACE);
   }
 }