]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java
1. Fix EDKT457 Multiple FPD, MSA or SPD files in a directory is prohibited
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / Clone.java
index 4643bb1e711d9e502b13437bbb47b2194453ec4f..d8030f775ac5cbe6803718133d4aae2564595271 100644 (file)
@@ -569,15 +569,19 @@ public class Clone extends IDialog {
      @retval false  Any one of name, guid and version is invalid\r
      \r
      **/\r
-    private boolean checkId() {\r
+    private boolean checkId(int mode) {\r
+        String name = this.jTextFieldBaseName.getText();\r
+        String guid = this.jTextFieldGuid.getText();\r
+        String version = this.jTextFieldVersion.getText();\r
+        \r
         //\r
         // Check Basename\r
         //\r
-        if (isEmpty(this.jTextFieldBaseName.getText())) {\r
+        if (isEmpty(name)) {\r
             Log.wrn("Clone", "The Name is required!");\r
             return false;\r
         }\r
-        if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {\r
+        if (!DataValidation.isBaseName(name)) {\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
@@ -587,11 +591,11 @@ public class Clone extends IDialog {
         //\r
         // Check Guid\r
         //\r
-        if (isEmpty(this.jTextFieldGuid.getText())) {\r
+        if (isEmpty(guid)) {\r
             Log.wrn("Clone", "A Guid is required!!");\r
             return false;\r
         }\r
-        if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {\r
+        if (!DataValidation.isGuid(guid)) {\r
             Log\r
                .wrn(\r
                     "Clone",\r
@@ -602,17 +606,40 @@ public class Clone extends IDialog {
         //\r
         // Check Version\r
         //\r
-        if (isEmpty(this.jTextFieldVersion.getText())) {\r
+        if (isEmpty(version)) {\r
             Log.wrn("Clone", "A Version must be entered!");\r
             return false;\r
         }\r
-        if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {\r
+        if (!DataValidation.isVersion(version)) {\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
+        if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
+            String packageGuid = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getGuid();\r
+            String packageVersion = packages.elementAt(this.jComboBoxExistingPackage.getSelectedIndex()).getVersion();\r
+            if (GlobalData.findModuleIdByGuidVersion(guid, version, packageGuid, packageVersion) != null) {\r
+                Log.wrn("Clone", "A module with same Guid and same Version already exists, please selece a new Guid or Version!");\r
+                return false;\r
+            }\r
+        }\r
+\r
+        if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {\r
+            if (GlobalData.findPackageIdByGuidVersion(guid, version) != null) {\r
+                Log.wrn("Clone", "A package with same Guid and same Version already exists, please selece a new Guid or Version!");\r
+                return false;\r
+            }\r
+        }\r
+\r
+        if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {\r
+            if (GlobalData.findPlatformIdByGuidVersion(guid, version) != null) {\r
+                Log.wrn("Clone", "A platform with same Guid and same Version already exists, please selece a new Guid or Version!");\r
+                return false;\r
+            }\r
+        }\r
 \r
         //\r
         // Save information to id\r
@@ -673,7 +700,7 @@ public class Clone extends IDialog {
         //\r
         if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
             trg = this.getModulePath();\r
-            if (src.equals(trg)) {\r
+            if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {\r
                 Log.wrn("Clone", "The source and destination paths for cloning a module must be different!");\r
                 return false;\r
             }\r
@@ -682,7 +709,7 @@ public class Clone extends IDialog {
                 Log.wrn("Clone", "The target module already exists!");\r
                 return false;\r
             }\r
-            return checkId();\r
+            return checkId(mode);\r
         }\r
 \r
         //\r
@@ -703,7 +730,7 @@ public class Clone extends IDialog {
                 Log.wrn("Clone", "The target package already exists!");\r
                 return false;\r
             }\r
-            return checkId();\r
+            return checkId(mode);\r
         }\r
 \r
         //\r
@@ -714,12 +741,16 @@ public class Clone extends IDialog {
                 Log.wrn("Clone", "The platform clone must be located in the current workspace!");\r
                 return false;\r
             }\r
+            if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {\r
+                Log.wrn("Clone", "The source and destination paths for cloning a platform must be different!");\r
+                return false;\r
+            }\r
             trgFile = new File(trg);\r
             if (trgFile.exists()) {\r
                 Log.wrn("Clone", "The target platform already exists.");\r
                 return false;\r
             }\r
-            return checkId();\r
+            return checkId(mode);\r
         }\r
 \r
         return true;\r