]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java
Changed the output message when handling dummy files in msa.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / Clone.java
index baf03795ee463b5de41dbbb95f28c32e144a4037..8f1ec6c6bab4e9ab0257256769cc3a00bdb9af4a 100644 (file)
@@ -17,6 +17,7 @@ package org.tianocore.frameworkwizard;
 import java.awt.event.ActionEvent;\r
 import java.io.File;\r
 import java.io.IOException;\r
+import java.math.BigInteger;\r
 import java.util.Vector;\r
 \r
 import javax.swing.JFileChooser;\r
@@ -36,14 +37,14 @@ import org.tianocore.frameworkwizard.common.DataType;
 import org.tianocore.frameworkwizard.common.DataValidation;\r
 import org.tianocore.frameworkwizard.common.FileOperation;\r
 import org.tianocore.frameworkwizard.common.IFileFilter;\r
-import org.tianocore.frameworkwizard.common.Identification;\r
 import org.tianocore.frameworkwizard.common.Log;\r
-import org.tianocore.frameworkwizard.common.OpenFile;\r
 import org.tianocore.frameworkwizard.common.SaveFile;\r
 import org.tianocore.frameworkwizard.common.Tools;\r
+import org.tianocore.frameworkwizard.common.Identifications.Identification;\r
+import org.tianocore.frameworkwizard.common.Identifications.OpenFile;\r
 import org.tianocore.frameworkwizard.common.ui.IDialog;\r
 import org.tianocore.frameworkwizard.common.ui.IFrame;\r
-import org.tianocore.frameworkwizard.module.Identification.ModuleIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
 import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r
 import org.tianocore.frameworkwizard.workspace.Workspace;\r
@@ -589,6 +590,20 @@ public class Clone extends IDialog {
         // Check for Module\r
         //\r
         if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
+//            if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) {\r
+//                Log.err("The module name must include a path");\r
+//                return false;\r
+//            }\r
+            trg = this.getModulePath();\r
+            if (src.equals(trg)) {\r
+                Log.err("The source and destination couldn't be same");\r
+                return false;\r
+            }\r
+            trgFile = new File(trg);\r
+            if (trgFile.exists()) {\r
+                Log.err("The target module already exists");\r
+                return false;\r
+            }\r
             return checkId();\r
         }\r
 \r
@@ -635,6 +650,7 @@ public class Clone extends IDialog {
     private void save() throws IOException, XmlException, Exception {\r
         String src = this.jTextFieldSource.getText();\r
         String trg = this.jTextFieldFilePath.getText();\r
+        Vector<String> vFiles = new Vector<String>();\r
         \r
         //\r
         // Clone Workspace\r
@@ -659,16 +675,17 @@ public class Clone extends IDialog {
             //\r
             trg = getModulePath();\r
             newId.setPath(trg);\r
+            vFiles = wt.getAllModuleFilesPath(src);\r
             \r
             //\r
             // First copy all files to new directory\r
             //\r
-            FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
-\r
-            //\r
-            // Delete old spd file\r
-            //\r
-            FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));\r
+            FileOperation.copyFile(src, trg);\r
+            for (int index = 1; index < vFiles.size(); index++) {\r
+                String oldFile = vFiles.get(index);\r
+                String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+                FileOperation.copyFile(oldFile, newFile);\r
+            }\r
 \r
             //\r
             // Create new msa file\r
@@ -721,16 +738,24 @@ public class Clone extends IDialog {
             //\r
             trg = this.getPackagePath();\r
             newId.setPath(trg);\r
+            vFiles = wt.getAllPakcageFilesPath(src);\r
+            \r
+            FileOperation.copyFile(src, trg);\r
+            for (int index = 1; index < vFiles.size(); index++) {\r
+                String oldFile = vFiles.get(index);\r
+                String newFile = vFiles.get(index).replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+                FileOperation.copyFile(oldFile, newFile);\r
+            }\r
             \r
             //\r
             // First copy all files to new directory\r
             //\r
-            FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+            //FileOperation.copyFolder(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
 \r
             //\r
             // Delete old spd file\r
             //\r
-            FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));\r
+            //FileOperation.delFile(Tools.getFilePathOnly(trg) + DataType.FILE_SEPARATOR + Tools.getFileNameOnly(src));\r
 \r
             //\r
             // Create new spd file\r
@@ -804,6 +829,7 @@ public class Clone extends IDialog {
 \r
             this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;\r
         }\r
+        vFiles = null;\r
     }\r
     \r
     private String getSelectPackagePath() {\r
@@ -813,7 +839,7 @@ public class Clone extends IDialog {
     private String getModulePath() {\r
         String trg = this.jTextFieldFilePath.getText();\r
         trg = Tools.addPathExt(trg, mode);\r
-        trg = getSelectPackagePath() + DataType.FILE_SEPARATOR + trg;\r
+        trg = Tools.addFileSeparator(getSelectPackagePath()) + trg;\r
         Tools.convertPathToCurrentOsType(trg);\r
         return trg;\r
     }\r
@@ -821,7 +847,7 @@ public class Clone extends IDialog {
     private String getPackagePath() {\r
         String trg = this.jTextFieldFilePath.getText();\r
         trg = Tools.addPathExt(trg, mode);\r
-        trg = Workspace.getCurrentWorkspace() + DataType.FILE_SEPARATOR + trg;\r
+        trg = Tools.addFileSeparator(Workspace.getCurrentWorkspace()) + trg;\r
         trg = Tools.convertPathToCurrentOsType(trg);\r
         return trg;\r
     }\r
@@ -849,10 +875,18 @@ public class Clone extends IDialog {
         // Get ClonedFrom then\r
         //\r
         ModuleDefinitions.ClonedFrom cf = null;\r
+        BigInteger count = new BigInteger("-1");\r
         if (pd.getClonedFrom() == null) {\r
             cf = ModuleDefinitions.ClonedFrom.Factory.newInstance();\r
         } else {\r
             cf = pd.getClonedFrom();\r
+            if (cf != null) {\r
+                for (int index = 0; index < cf.getClonedList().size(); index++) {\r
+                    if (cf.getClonedList().get(index).getId() != null) {\r
+                        count = count.max(cf.getClonedList().get(index).getId());\r
+                    }\r
+                }\r
+            }\r
         }\r
 \r
         //\r
@@ -861,6 +895,9 @@ public class Clone extends IDialog {
         ModuleDefinitions.ClonedFrom.Cloned c = ModuleDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
         c.setModuleGuid(id.getGuid());\r
         c.setModuleVersion(id.getVersion());\r
+        c.setPackageGuid(wt.getPackageIdByModuleId(oldId).getGuid());\r
+        c.setPackageVersion(wt.getPackageIdByModuleId(oldId).getVersion());\r
+        c.setId(count.add(new BigInteger("1")));\r
 \r
         cf.addNewCloned();\r
         cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
@@ -892,10 +929,18 @@ public class Clone extends IDialog {
         // Get ClonedFrom then\r
         //\r
         PackageDefinitions.ClonedFrom cf = null;\r
+        BigInteger count = new BigInteger("-1");\r
         if (pd.getClonedFrom() == null) {\r
             cf = PackageDefinitions.ClonedFrom.Factory.newInstance();\r
         } else {\r
             cf = pd.getClonedFrom();\r
+            if (cf != null) {\r
+                for (int index = 0; index < cf.getClonedList().size(); index++) {\r
+                    if (cf.getClonedList().get(index).getId() != null) {\r
+                        count = count.max(cf.getClonedList().get(index).getId());\r
+                    }\r
+                }\r
+            }\r
         }\r
 \r
         //\r
@@ -904,6 +949,7 @@ public class Clone extends IDialog {
         PackageDefinitions.ClonedFrom.Cloned c = PackageDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
         c.setPackageGuid(id.getGuid());\r
         c.setPackageVersion(id.getVersion());\r
+        c.setId(count.add(new BigInteger("1")));\r
 \r
         cf.addNewCloned();\r
         cf.setClonedArray(cf.getClonedList().size() - 1, c);\r
@@ -935,10 +981,18 @@ public class Clone extends IDialog {
         // Get ClonedFrom then\r
         //\r
         PlatformDefinitions.ClonedFrom cf = null;\r
+        BigInteger count = new BigInteger("-1");\r
         if (pd.getClonedFrom() == null) {\r
             cf = PlatformDefinitions.ClonedFrom.Factory.newInstance();\r
         } else {\r
             cf = pd.getClonedFrom();\r
+            if (cf != null) {\r
+                for (int index = 0; index < cf.getClonedList().size(); index++) {\r
+                    if (cf.getClonedList().get(index).getId() != null) {\r
+                        count = count.max(cf.getClonedList().get(index).getId());\r
+                    }\r
+                }\r
+            }\r
         }\r
 \r
         //\r
@@ -947,6 +1001,7 @@ public class Clone extends IDialog {
         PlatformDefinitions.ClonedFrom.Cloned c = PlatformDefinitions.ClonedFrom.Cloned.Factory.newInstance();\r
         c.setPlatformGuid(id.getGuid());\r
         c.setPlatformVersion(id.getVersion());\r
+        c.setId(count.add(new BigInteger("1")));\r
 \r
         cf.addNewCloned();\r
         cf.setClonedArray(cf.getClonedList().size() - 1, c);\r