]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/Clone.java
1. Add function "Refresh" in main UI
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / Clone.java
index 3d8c267484e5290e81ae4ec9726be05e1c4076c8..3395434efda5ceef6da95a1f79772f14b5633990 100644 (file)
@@ -36,6 +36,7 @@ import org.tianocore.PlatformSurfaceAreaDocument.PlatformSurfaceArea;
 import org.tianocore.frameworkwizard.common.DataType;\r
 import org.tianocore.frameworkwizard.common.DataValidation;\r
 import org.tianocore.frameworkwizard.common.FileOperation;\r
+import org.tianocore.frameworkwizard.common.GlobalData;\r
 import org.tianocore.frameworkwizard.common.IFileFilter;\r
 import org.tianocore.frameworkwizard.common.Log;\r
 import org.tianocore.frameworkwizard.common.OpenFile;\r
@@ -360,7 +361,7 @@ public class Clone extends IDialog {
             initExistingPackage();\r
             this.jButtonBrowse.setVisible(false);\r
             this.jTextFieldFilePath\r
-                                   .setToolTipText("Input module name here. For example, Application\\HelloWorld\\HelloWorld.msa");\r
+                                   .setToolTipText("<html>Input the module's relative path and filename, for example:<br>Application\\HelloWorld\\HelloWorld.msa</html>");\r
             this.jTextFieldFilePath.setSize(320, this.jTextFieldFilePath.getSize().height);\r
             this.jLabelDestinationFile.setText("New Module Path and Filename");\r
         }\r
@@ -375,7 +376,7 @@ public class Clone extends IDialog {
             this.jLabelBelong.setEnabled(false);\r
             this.jComboBoxExistingPackage.setEnabled(false);\r
             this.jButtonBrowse.setVisible(false);\r
-            this.jTextFieldFilePath.setToolTipText("Input package name here. For example, MdePkg\\MdePkg.fpd");\r
+            this.jTextFieldFilePath.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
@@ -388,7 +389,7 @@ public class Clone extends IDialog {
             this.jLabelBelong.setEnabled(false);\r
             this.jComboBoxExistingPackage.setEnabled(false);\r
             this.jTextFieldFilePath\r
-                                   .setToolTipText("Select platform path here. For example, C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd");\r
+                                   .setToolTipText("<html>Select the platform's relative path and filename. For example:<br>C:\\MyWorkspace\\EdkNt32Pkg\\Nt32.fpd</html>");\r
             this.jLabelDestinationFile.setText("New Platform Path and Filename");\r
         }\r
         //\r
@@ -406,7 +407,7 @@ public class Clone extends IDialog {
             this.jButtonGenerateGuid.setEnabled(false);\r
             this.jLabelVersion.setEnabled(false);\r
             this.jTextFieldVersion.setEnabled(false);\r
-            this.jTextFieldFilePath.setToolTipText("Input workspace path here. For example, C:\\MyWorkspace");\r
+            this.jTextFieldFilePath.setToolTipText("<html>Input the workspace path, for example:<br>C:\\MyWorkspace</html>");\r
             this.jLabelDestinationFile.setText("New Workspace Path");\r
         }\r
     }\r
@@ -421,7 +422,7 @@ public class Clone extends IDialog {
         if (jContentPane == null) {\r
             jLabelBelong = new JLabel();\r
             jLabelBelong.setBounds(new java.awt.Rectangle(15, 60, 190, 20));\r
-            jLabelBelong.setText("Clone to Package");\r
+            jLabelBelong.setText("Clone Package");\r
             jLabelVersion = new JLabel();\r
             jLabelVersion.setBounds(new java.awt.Rectangle(15, 160, 190, 20));\r
             jLabelVersion.setText("Version");\r
@@ -550,11 +551,11 @@ public class Clone extends IDialog {
         // Check Basename\r
         //\r
         if (isEmpty(this.jTextFieldBaseName.getText())) {\r
-            Log.wrn("Clone", "Base Name couldn't be empty!");\r
+            Log.wrn("Clone", "The Name is required!");\r
             return false;\r
         }\r
         if (!DataValidation.isBaseName(this.jTextFieldBaseName.getText())) {\r
-            Log.wrn("Clone", "Incorrect data type for Base Name");\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
             return false;\r
         }\r
 \r
@@ -562,11 +563,11 @@ public class Clone extends IDialog {
         // Check Guid\r
         //\r
         if (isEmpty(this.jTextFieldGuid.getText())) {\r
-            Log.wrn("Clone", "Guid couldn't be empty!");\r
+            Log.wrn("Clone", "A Guid is required!!");\r
             return false;\r
         }\r
         if (!DataValidation.isGuid(this.jTextFieldGuid.getText())) {\r
-            Log.wrn("Clone", "Incorrect data type for Guid");\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
             return false;\r
         }\r
 \r
@@ -574,11 +575,11 @@ public class Clone extends IDialog {
         // Check Version\r
         //\r
         if (isEmpty(this.jTextFieldVersion.getText())) {\r
-            Log.wrn("Clone", "Version couldn't be empty!");\r
+            Log.wrn("Clone", "A Version must be entered!");\r
             return false;\r
         }\r
         if (!DataValidation.isVersion(this.jTextFieldVersion.getText())) {\r
-            Log.wrn("Clone", "Incorrect data type for Version");\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
             return false;\r
         }\r
 \r
@@ -610,19 +611,19 @@ public class Clone extends IDialog {
         // Common Check\r
         //\r
         if (!srcFile.exists()) {\r
-            Log.wrn("Clone", "The source doesn't exist");\r
+            Log.wrn("Clone", "The source file does not exist!");\r
             return false;\r
         }\r
         if (isEmpty(trg)) {\r
-            Log.wrn("Clone", "The destination file path couldn't be empty");\r
+            Log.wrn("Clone", "The destination file path must be entered!");\r
             return false;\r
         }\r
         if (src.equals(trg)) {\r
-            Log.wrn("Clone", "The source and destination couldn't be same");\r
+            Log.wrn("Clone", "The source and destination can not be same!");\r
             return false;\r
         }\r
         if (trgFile.exists()) {\r
-            Log.wrn("Clone", "The destination already exists");\r
+            Log.wrn("Clone", "The destination already exists!");\r
             return false;\r
         }\r
 \r
@@ -631,7 +632,7 @@ public class Clone extends IDialog {
         //\r
         if (mode == DataType.RETURN_TYPE_WORKSPACE) {\r
             if (trg.indexOf(src + DataType.FILE_SEPARATOR) == 0) {\r
-                Log.wrn("Clone", "The new workspace couldn't be in current workspace!");\r
+                Log.wrn("Clone", "The new workspace can not be located within the current workspace!");\r
                 return false;\r
             }\r
         }\r
@@ -642,12 +643,12 @@ public class Clone extends IDialog {
         if (mode == DataType.RETURN_TYPE_MODULE_SURFACE_AREA) {\r
             trg = this.getModulePath();\r
             if (src.equals(trg)) {\r
-                Log.wrn("Clone", "The source and destination couldn't be same");\r
+                Log.wrn("Clone", "The source and destination paths for cloning a module must be different!");\r
                 return false;\r
             }\r
             trgFile = new File(trg);\r
             if (trgFile.exists()) {\r
-                Log.wrn("Clone", "The target module already exists");\r
+                Log.wrn("Clone", "The target module already exists!");\r
                 return false;\r
             }\r
             return checkId();\r
@@ -658,17 +659,17 @@ public class Clone extends IDialog {
         //\r
         if (mode == DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA) {\r
             if (trg.indexOf(DataType.DOS_FILE_SEPARATOR) == -1 && trg.indexOf(DataType.UNIX_FILE_SEPARATOR) == -1) {\r
-                Log.wrn("Clone", "The package name must include a path");\r
+                Log.wrn("Clone", "The package name must include a path!");\r
                 return false;\r
             }\r
             trg = this.getPackagePath();\r
             if (Tools.getFilePathOnly(src).equals(Tools.getFilePathOnly(trg))) {\r
-                Log.wrn("Clone", "The source and destination couldn't be same");\r
+                Log.wrn("Clone", "The source and destination paths for cloning a package must be different!");\r
                 return false;\r
             }\r
             trgFile = new File(trg);\r
             if (trgFile.exists()) {\r
-                Log.wrn("Clone", "The target package already exists");\r
+                Log.wrn("Clone", "The target package already exists!");\r
                 return false;\r
             }\r
             return checkId();\r
@@ -679,12 +680,12 @@ public class Clone extends IDialog {
         //\r
         if (mode == DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA) {\r
             if (trg.indexOf(Workspace.getCurrentWorkspace()) != 0) {\r
-                Log.wrn("Clone", "The target platform must be in current workspace");\r
+                Log.wrn("Clone", "The platform clone must be located in the current workspace!");\r
                 return false;\r
             }\r
             trgFile = new File(trg);\r
             if (trgFile.exists()) {\r
-                Log.wrn("Clone", "The target platform already exists");\r
+                Log.wrn("Clone", "The target platform already exists.");\r
                 return false;\r
             }\r
             return checkId();\r
@@ -723,7 +724,7 @@ public class Clone extends IDialog {
             //\r
             trg = getModulePath();\r
             newId.setPath(trg);\r
-            vFiles = wt.getAllModuleFilesPath(src);\r
+            vFiles = wt.getAllFilesPathOfModule(src);\r
 \r
             //\r
             // First copy all files to new directory\r
@@ -752,7 +753,7 @@ public class Clone extends IDialog {
             // Update <Cloned> Section\r
             //\r
             updateModuleClonedId(msa, oldId);\r
-\r
+            \r
             //\r
             // Save to file\r
             //\r
@@ -774,6 +775,12 @@ public class Clone extends IDialog {
             // Update the db file\r
             //\r
             wt.addModuleToPackage(mid, psa);\r
+            \r
+            //\r
+            // Update GlobalData\r
+            //\r
+            GlobalData.vModuleList.addElement(mid);\r
+            GlobalData.openingModuleList.insertToOpeningModuleList(mid, msa);\r
 \r
             this.returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;\r
         }\r
@@ -787,7 +794,7 @@ public class Clone extends IDialog {
             //\r
             trg = this.getPackagePath();\r
             newId.setPath(trg);\r
-            vFiles = wt.getAllPakcageFilesPath(src);\r
+            vFiles = wt.getAllFilesPathOfPakcage(src);\r
 \r
             //\r
             // First copy all files to new directory\r
@@ -831,7 +838,40 @@ 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
+            // Add all cloned modules\r
+            //\r
+            Vector<String> modulePaths = GlobalData.getAllModulesOfPackage(pid.getPath());\r
+            String modulePath = null;\r
+            ModuleSurfaceArea msa = null;\r
+            \r
+            for (int indexJ = 0; indexJ < modulePaths.size(); indexJ++) {\r
+                try {\r
+                    modulePath = modulePaths.get(indexJ);\r
+                    msa = OpenFile.openMsaFile(modulePath);\r
+                } catch (IOException e) {\r
+                    Log.err("Open Module Surface Area " + modulePath, e.getMessage());\r
+                    continue;\r
+                } catch (XmlException e) {\r
+                    Log.err("Open Module Surface Area " + modulePath, e.getMessage());\r
+                    continue;\r
+                } catch (Exception e) {\r
+                    Log.err("Open Module Surface Area " + modulePath, "Invalid file type");\r
+                    continue;\r
+                }\r
+                Identification id = Tools.getId(modulePath, msa);\r
+                mid = new ModuleIdentification(id, pid);\r
+                GlobalData.vModuleList.addElement(mid);\r
+                GlobalData.openingModuleList.insertToOpeningModuleList(mid, msa);\r
+            }\r
+            \r
             this.returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;\r
         }\r
 \r
@@ -868,6 +908,12 @@ public class Clone extends IDialog {
             // Update the db file\r
             //\r
             wt.addPlatformToDatabase(fid);\r
+            \r
+            //\r
+            // Update GlobalData\r
+            //\r
+            GlobalData.vPlatformList.addElement(fid);\r
+            GlobalData.openingPlatformList.insertToOpeningPlatformList(fid, fpd);\r
 \r
             this.returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;\r
         }\r
@@ -1016,7 +1062,7 @@ public class Clone extends IDialog {
         c.setPackageGuid(id.getGuid());\r
         c.setPackageVersion(id.getVersion());\r
         c.setId(count.add(new BigInteger("1")));\r
-        String guid = wt.getModuleFarGuid(oldId);\r
+        String guid = wt.getPackageFarGuid(oldId);\r
         if (guid != null && !guid.equals("")) {\r
             c.setFarGuid(guid);\r
         }\r
@@ -1072,7 +1118,7 @@ public class Clone extends IDialog {
         c.setPlatformGuid(id.getGuid());\r
         c.setPlatformVersion(id.getVersion());\r
         c.setId(count.add(new BigInteger("1")));\r
-        String guid = wt.getModuleFarGuid(oldId);\r
+        String guid = wt.getPlatformFarGuid(oldId);\r
         if (guid != null && !guid.equals("")) {\r
             c.setFarGuid(guid);\r
         }\r