]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
a. Enhanced toolchain setting UI for ModuleSa build options and global build options.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 12dd2fd4453ac086629e177aa64f16e21d7213ec..9e2f955599a4130847bee90aac003e4b48a78ad6 100644 (file)
@@ -988,7 +988,9 @@ public class FpdFileContents {
             \r
             if (opt.getSupArchList() != null){\r
                 saa[i][4] = listToString(opt.getSupArchList());\r
-\r
+            }\r
+            else {\r
+                saa[i][4] = "";\r
             }\r
             \r
             saa[i][5] = opt.getStringValue();\r
@@ -2589,7 +2591,19 @@ public class FpdFileContents {
     }\r
     \r
     public void getFvImagesFvImageFvImageNames (Vector<String> vImageNames) {\r
+        FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r
+        if (fis == null || fis.getFvImageList() == null) {\r
+            return;\r
+        }\r
         \r
+        ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();\r
+        while (li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = li.next();\r
+            if (fi.getType().toString().equals("ImageName")) {\r
+                vImageNames.addAll(fi.getFvImageNamesList());\r
+                return;\r
+            }\r
+        }\r
     }\r
     \r
     public void AddFvImageFvImageNames (String[] fvNames) {\r
@@ -2672,6 +2686,10 @@ public class FpdFileContents {
         cursor.dispose();\r
     }\r
     \r
+    /**\r
+     * @param oldFvName\r
+     * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.\r
+     */\r
     public void updateFvImageNameAll (String oldFvName, String newFvName) {\r
         if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r
             return;\r
@@ -2683,6 +2701,11 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    /**\r
+     * @param fi\r
+     * @param oldFvName The FV Name to be replaced.\r
+     * @param newFvName The New FV Name. If null, remove the old FvImageNames entry.\r
+     */\r
     public void updateFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String oldFvName, String newFvName) {\r
         QName qFvImageNames = new QName(xmlNs, "FvImageNames");\r
         XmlCursor cursor = fi.newCursor();\r
@@ -2690,7 +2713,18 @@ public class FpdFileContents {
         if (cursor.toChild(qFvImageNames)) {\r
             do {\r
                 if (cursor.getTextValue().equals(oldFvName)){\r
-                    cursor.setTextValue(newFvName);\r
+                    if (newFvName != null) {\r
+                        cursor.setTextValue(newFvName);\r
+                    }\r
+                    else {\r
+                        if (fi.getFvImageNamesList().size() == 1) {\r
+                            removeElement(fi);\r
+                            break;\r
+                        }\r
+                        else {\r
+                            cursor.removeXml();\r
+                        }\r
+                    }\r
                 }\r
             }while (cursor.toNextSibling(qFvImageNames));\r
         }\r
@@ -2738,18 +2772,50 @@ public class FpdFileContents {
         cursor.dispose();\r
     }\r
     \r
-    public int getFvImagesFvImageCount() {\r
+    public int getFvImagesFvImageCount(String type) {\r
         \r
         if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r
             return 0;\r
         }\r
-        return getfpdFlash().getFvImages().getFvImageList().size();\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        ListIterator li = l.listIterator();\r
+        int i = 0;\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            \r
+            ++i;\r
+        }\r
+        \r
+        return i;\r
     }\r
     \r
-    /**Only Get Fv image setting - name and type.\r
+    public Vector<FvImagesDocument.FvImages.FvImage> getFvImagesFvImageWithName (String fvName, String type) {\r
+        Vector<FvImagesDocument.FvImages.FvImage> vFvImage = new Vector<FvImagesDocument.FvImages.FvImage>();\r
+        if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r
+            return vFvImage;\r
+        }\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        ListIterator li = l.listIterator();\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            if (fi.getFvImageNamesList().contains(fvName)) {\r
+                vFvImage.add(fi);\r
+            }\r
+        }\r
+        \r
+        return vFvImage;\r
+    }\r
+    /**\r
      * @param saa\r
+     * @param type "ALL" means all FvImage types: ImageName, Options, Attributes, Components.\r
      */\r
-    public void getFvImagesFvImages(String[][] saa) {\r
+    public void getFvImagesFvImages(String[][] saa, String type) {\r
     \r
         if (getfpdFlash().getFvImages() == null) {\r
             return;\r
@@ -2762,6 +2828,9 @@ public class FpdFileContents {
         int i = 0;\r
         while(li.hasNext()) {\r
             FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
             //\r
             // get FvImageNames array, space separated\r
             //\r
@@ -2780,6 +2849,108 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    /**Add name-value pair to FvImage element with type.\r
+     * @param fvName FV name to add name-value pair.\r
+     * @param type FvImage attribute.\r
+     * @param name\r
+     * @param value\r
+     */\r
+    public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) {\r
+        if (getfpdFlash().getFvImages() == null) {\r
+            return;\r
+        }\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        if (l == null) {\r
+            return;\r
+        }\r
+        ListIterator li = l.listIterator();\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            if (!fi.getFvImageNamesList().contains(fvName)) {\r
+                continue;\r
+            }\r
+            setFvImagesFvImageNameValue (fi, name, value, null);\r
+        }\r
+    }\r
+    \r
+    /**Add to all FvImage elements with type, the name-value pair.\r
+     * @param type\r
+     * @param name\r
+     * @param value\r
+     */\r
+    public void setTypedFvImageNameValue (String type, String name, String value) {\r
+        if (getfpdFlash().getFvImages() == null) {\r
+            return;\r
+        }\r
+        List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r
+        if (l == null) {\r
+            return;\r
+        }\r
+        ListIterator li = l.listIterator();\r
+        while(li.hasNext()) {\r
+            FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r
+            if (!fi.getType().toString().equals(type) && !type.equals("ALL")) {\r
+                continue;\r
+            }\r
+            setFvImagesFvImageNameValue (fi, name, value, null);\r
+        }\r
+    }\r
+    \r
+    /**Add to FvImage the name-value pair, or replace old name with newName, or generate new name-value pair if not exists before.\r
+     * @param fi\r
+     * @param name\r
+     * @param value\r
+     * @param newName\r
+     */\r
+    public void setFvImagesFvImageNameValue (FvImagesDocument.FvImages.FvImage fi, String name, String value, String newName) {\r
+        if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+            return;\r
+        }\r
+        \r
+        XmlCursor cursor = fi.getFvImageOptions().newCursor();\r
+        if (cursor.toFirstChild()) {\r
+            do {\r
+                FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = (FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue)cursor.getObject();\r
+                if (nv.getName().equals(name)) {\r
+                    nv.setValue(value);\r
+                    if (newName != null) {\r
+                        nv.setName(newName);\r
+                    }\r
+                    cursor.dispose();\r
+                    return;\r
+                }\r
+            }while (cursor.toNextSibling());\r
+        }\r
+        \r
+        FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fi.getFvImageOptions().addNewNameValue();\r
+        nv.setName(name);\r
+        nv.setValue(value);\r
+        if (newName != null) {\r
+            nv.setName(newName);\r
+        }\r
+        cursor.dispose();\r
+    }\r
+    \r
+    public void getFvImagesFvImageOptions (String fvName, Map<String, String> m) {\r
+        Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName (fvName, "Options");\r
+        for (int i = 0; i < vFvImage.size(); ++i) {\r
+            FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r
+            if (fi == null || fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null) {\r
+                continue;\r
+            }\r
+\r
+            ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions()\r
+                                                                                            .getNameValueList()\r
+                                                                                            .listIterator();\r
+            while (li.hasNext()) {\r
+                FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r
+                m.put(nv.getName(), nv.getValue());\r
+            }\r
+        }\r
+    }\r
     /**Get FvImage Options for FvImage i\r
      * @param i the ith FvImage\r
      */\r