IDEA-162634 Copyright settings from Template/Default Project not present in new projects
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Mon, 31 Oct 2016 17:25:44 +0000 (18:25 +0100)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Mon, 31 Oct 2016 17:26:56 +0000 (18:26 +0100)
platform/configuration-store-impl/src/ProjectStoreImpl.kt

index a9930e74a67e2229e80786dbbb8b4b1e5b6b2343..3dd08c9e91b32ad8f926418d1bbebdf79ea18cd7 100644 (file)
@@ -107,22 +107,26 @@ abstract class ProjectStoreBase(override final val project: ProjectImpl) : Compo
 
     if (isDirectoryBased) {
       LOG.catchAndLog {
-        val inspectionSettings = element.getChildren("component").find { it.getAttributeValue("name") == "InspectionProjectProfileManager" } ?: return@catchAndLog
-        convertInspectionProfiles(inspectionSettings.getChildren("profile").iterator())
+        for (component in element.getChildren("component")) {
+          when (component.getAttributeValue("name")) {
+            "InspectionProjectProfileManager" -> convertProfiles(component.getChildren("profile").iterator(), true)
+            "CopyrightManager" -> convertProfiles(component.getChildren("copyright").iterator(), false)
+          }
+        }
       }
     }
     (storageManager.getOrCreateStorage(PROJECT_FILE) as XmlElementStorage).setDefaultState(element)
   }
 
-  fun convertInspectionProfiles(profileIterator: MutableIterator<Element>) {
+  fun convertProfiles(profileIterator: MutableIterator<Element>, isInspection: Boolean) {
     for (profile in profileIterator) {
       val schemeName = profile.getChildren("option").find { it.getAttributeValue("name") == "myName" }?.getAttributeValue(
           "value") ?: continue
 
       profileIterator.remove()
-      val wrapper = Element("component").attribute("name", "InspectionProjectProfileManager")
+      val wrapper = Element("component").attribute("name", if (isInspection) "InspectionProjectProfileManager" else "CopyrightManager")
       wrapper.addContent(profile)
-      val path = Paths.get(storageManager.expandMacro(PROJECT_CONFIG_DIR), "inspectionProfiles",
+      val path = Paths.get(storageManager.expandMacro(PROJECT_CONFIG_DIR), if (isInspection) "inspectionProfiles" else "copyright",
           "${FileUtil.sanitizeFileName(schemeName, true)}.xml")
       JDOMUtil.writeParent(wrapper, path.outputStream(), "\n")
     }