draft UI implementation of module orders in FV.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 73ee69e9a83f498ce0dd135f37c1bfa66266edc2..e60426446fbe826b66cf251432da64e9b5db78e4 100644 (file)
@@ -184,6 +184,32 @@ public class FpdFileContents {
         return fpdFrameworkModules;\r
     }\r
     \r
+    public void getFrameworkModuleGuid (String fvName, Vector<String> vGuid) {\r
+        if (getFrameworkModulesCount() == 0){\r
+            return;\r
+        }\r
+        \r
+        ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
+        while(li.hasNext()) {\r
+            ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+            if (moduleSa.getModuleSaBuildOptions() == null) {\r
+                continue;\r
+            }\r
+            String fvBinding = moduleSa.getModuleSaBuildOptions().getFvBinding();\r
+            if (fvBinding == null) {\r
+                continue;\r
+            }\r
+            \r
+            String[] fvNames = fvBinding.split(" ");\r
+            for (int i = 0; i < fvNames.length; ++i) {\r
+                if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) {\r
+                    vGuid.add(moduleSa.getModuleGuid());\r
+                    break;\r
+                }\r
+            }\r
+        }\r
+    }\r
+    \r
     public int getFrameworkModulesCount() {\r
         if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r
             removeElement(getfpdFrameworkModules());\r
@@ -201,13 +227,13 @@ public class FpdFileContents {
         ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r
         int i = 0;\r
         while(li.hasNext()) {\r
-            ModuleSADocument.ModuleSA msa = (ModuleSADocument.ModuleSA)li.next();\r
-            saa[i][0] = msa.getModuleGuid();\r
-            saa[i][1] = msa.getModuleVersion();\r
+            ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r
+            saa[i][0] = moduleSa.getModuleGuid();\r
+            saa[i][1] = moduleSa.getModuleVersion();\r
             \r
-            saa[i][2] = msa.getPackageGuid();\r
-            saa[i][3] = msa.getPackageVersion();\r
-            saa[i][4] = listToString(msa.getSupArchList());\r
+            saa[i][2] = moduleSa.getPackageGuid();\r
+            saa[i][3] = moduleSa.getPackageVersion();\r
+            saa[i][4] = listToString(moduleSa.getSupArchList());\r
             ++i;\r
         }\r
     }\r
@@ -739,11 +765,18 @@ public class FpdFileContents {
         if (msa == null ) {\r
             return;\r
         }\r
-        if(msa.getModuleSaBuildOptions() == null){\r
-            msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
-            return;\r
+        if (fvBinding == null || fvBinding.length() == 0) {\r
+            if(msa.getModuleSaBuildOptions() != null){\r
+                msa.getModuleSaBuildOptions().unsetFvBinding();\r
+            }\r
+        }\r
+        else {\r
+            if(msa.getModuleSaBuildOptions() == null){\r
+                msa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r
+                return;\r
+            }\r
+            msa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
         }\r
-        msa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r
     }\r
     \r
     public String getFfsFileNameGuid(String moduleKey){\r
@@ -1496,7 +1529,7 @@ public class FpdFileContents {
         return fpdBuildOpts;\r
     }\r
     \r
-    public void genBuildOptionsUserExtensions(String fvName, String infName, String outputFileName, String[][] includeModules) {\r
+    public void genBuildOptionsUserExtensions(String fvName, String outputFileName, String[][] includeModules) {\r
         UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r
         userExts.setUserID("IMAGES");\r
         userExts.setIdentifier(new BigInteger("1"));\r
@@ -1508,7 +1541,7 @@ public class FpdFileContents {
         cursor.toNextToken();\r
         \r
         cursor.beginElement("InfFileName");\r
-        cursor.insertChars(infName);\r
+        cursor.insertChars(fvName + ".inf");\r
         cursor.toNextToken();\r
         \r
         cursor.beginElement("IncludeModules");\r
@@ -1582,6 +1615,32 @@ public class FpdFileContents {
         \r
     }\r
     \r
+    public void removeBuildOptionsUserExtensions (String fvName) {\r
+        if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
+            return;\r
+        }\r
+        \r
+        ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
+        while (li.hasNext()) {\r
+            UserExtensionsDocument.UserExtensions ues = li.next();\r
+            if (!ues.getUserID().equals("IMAGES")) {\r
+                continue;\r
+            }\r
+            XmlCursor cursor = ues.newCursor();\r
+            cursor.toFirstChild();\r
+            String elementName = cursor.getTextValue();\r
+            if (elementName.equals(fvName)) {\r
+                cursor.toParent();\r
+                cursor.removeXml();\r
+                cursor.dispose();\r
+                return;\r
+            }\r
+            cursor.dispose();\r
+        }\r
+        \r
+    }\r
+    \r
+    \r
     public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r
         UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
         if (udats == null) {\r