]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java
1. Fix EDKT408: Clone a library class does not copy the library head
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / Clone.java
index 3395434efda5ceef6da95a1f79772f14b5633990..6c9e25a31a61f6ef7f9b2871b0434507baf21330 100644 (file)
@@ -376,7 +376,8 @@ public class Clone extends IDialog {
             this.jLabelBelong.setEnabled(false);\r
             this.jComboBoxExistingPackage.setEnabled(false);\r
             this.jButtonBrowse.setVisible(false);\r
-            this.jTextFieldFilePath.setToolTipText("<html>Input the package's relative path and file name, for example:<br>MdePkg\\MdePkg.spd</html>");\r
+            this.jTextFieldFilePath\r
+                                   .setToolTipText("<html>Input the package's relative path and file name, for example:<br>MdePkg\\MdePkg.spd</html>");\r
             this.jTextFieldFilePath.setSize(320, this.jTextFieldFilePath.getSize().height);\r
             this.jLabelDestinationFile.setText("New Package Path and Filename");\r
         }\r
@@ -407,7 +408,8 @@ public class Clone extends IDialog {
             this.jButtonGenerateGuid.setEnabled(false);\r
             this.jLabelVersion.setEnabled(false);\r
             this.jTextFieldVersion.setEnabled(false);\r
-            this.jTextFieldFilePath.setToolTipText("<html>Input the workspace path, for example:<br>C:\\MyWorkspace</html>");\r
+            this.jTextFieldFilePath\r
+                                   .setToolTipText("<html>Input the workspace path, for example:<br>C:\\MyWorkspace</html>");\r
             this.jLabelDestinationFile.setText("New Workspace Path");\r
         }\r
     }\r
@@ -555,7 +557,9 @@ public class Clone extends IDialog {
             return false;\r
         }\r
         if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {\r
-            Log.wrn("Clone", "<html>Incorrect data type for the Name, it must<br>be a single word, starting with an alpha character.</html>");\r
+            Log\r
+               .wrn("Clone",\r
+                    "<html>Incorrect data type for the Name, it must<br>be a single word, starting with an alpha character.</html>");\r
             return false;\r
         }\r
 \r
@@ -567,7 +571,10 @@ public class Clone extends IDialog {
             return false;\r
         }\r
         if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {\r
-            Log.wrn("Clone", "<html>Incorrect data type for Guid, which must<br>be in registry format (8-4-4-4-12) for example:<br>d3adb123-eef1-466d-39ac-02febcaf5997</html>");\r
+            Log\r
+               .wrn(\r
+                    "Clone",\r
+                    "<html>Incorrect data type for Guid, which must<br>be in registry format (8-4-4-4-12) for example:<br>d3adb123-eef1-466d-39ac-02febcaf5997</html>");\r
             return false;\r
         }\r
 \r
@@ -579,7 +586,10 @@ public class Clone extends IDialog {
             return false;\r
         }\r
         if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {\r
-            Log.wrn("Clone", "<html>Incorrect data type for Version, which must<br>be one or more digits, optionally followed by sequence<br>of one or more dot,  one or more digits; examples:<br>1.0 1.0.1 12.25.256</html>");\r
+            Log\r
+               .wrn(\r
+                    "Clone",\r
+                    "<html>Incorrect data type for Version, which must<br>be one or more digits, optionally followed by sequence<br>of one or more dot,  one or more digits; examples:<br>1.0 1.0.1 12.25.256</html>");\r
             return false;\r
         }\r
 \r
@@ -726,13 +736,29 @@ public class Clone extends IDialog {
             newId.setPath(trg);\r
             vFiles = wt.getAllFilesPathOfModule(src);\r
 \r
+            String oldPackagePath = GlobalData.openingModuleList.getIdByPath(src).getPackageId().getPath();\r
+            String newPackagePath = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getPath();\r
+\r
             //\r
             // First copy all files to new directory\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
+                String newFile = "";\r
+                if (oldFile.indexOf(Tools.getFilePathOnly(src)) > -1) {\r
+                    //\r
+                    // The file is not include header\r
+                    //\r
+                    newFile = oldFile.replace(Tools.getFilePathOnly(src), Tools.getFilePathOnly(trg));\r
+                } else if (oldFile.indexOf(Tools.getFilePathOnly(oldPackagePath)) > -1) {\r
+                    //\r
+                    // The file is include header\r
+                    //\r
+                    newFile = oldFile.replace(Tools.getFilePathOnly(oldPackagePath),\r
+                                              Tools.getFilePathOnly(newPackagePath));\r
+                }\r
+\r
                 FileOperation.copyFile(oldFile, newFile);\r
             }\r
 \r
@@ -753,7 +779,7 @@ public class Clone extends IDialog {
             // Update <Cloned> Section\r
             //\r
             updateModuleClonedId(msa, oldId);\r
-            \r
+\r
             //\r
             // Save to file\r
             //\r
@@ -775,7 +801,7 @@ public class Clone extends IDialog {
             // Update the db file\r
             //\r
             wt.addModuleToPackage(mid, psa);\r
-            \r
+\r
             //\r
             // Update GlobalData\r
             //\r
@@ -838,20 +864,20 @@ public class Clone extends IDialog {
             // Update the db file\r
             //\r
             wt.addPackageToDatabase(pid);\r
-            \r
+\r
             //\r
             // Update GlobalData\r
             //\r
             GlobalData.vPackageList.addElement(pid);\r
             GlobalData.openingPackageList.insertToOpeningPackageList(pid, spd);\r
-            \r
+\r
             //\r
             // Add all cloned modules\r
             //\r
             Vector<String> modulePaths = GlobalData.getAllModulesOfPackage(pid.getPath());\r
             String modulePath = null;\r
             ModuleSurfaceArea msa = null;\r
-            \r
+\r
             for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) {\r
                 try {\r
                     modulePath = modulePaths.get(indexJ);\r
@@ -871,7 +897,7 @@ public class Clone extends IDialog {
                 GlobalData.vModuleList.addElement(mid);\r
                 GlobalData.openingModuleList.insertToOpeningModuleList(mid, msa);\r
             }\r
-            \r
+\r
             this.returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;\r
         }\r
 \r
@@ -908,7 +934,7 @@ public class Clone extends IDialog {
             // Update the db file\r
             //\r
             wt.addPlatformToDatabase(fid);\r
-            \r
+\r
             //\r
             // Update GlobalData\r
             //\r