]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
FV from FDF file options editor.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
index 20b5c10568c8c7237e260b2504ac49cbd81a3251..c80d758f284f0b3ca92dc051fc6f80aa0a283485 100644 (file)
@@ -2847,6 +2847,22 @@ public class FpdFileContents {
         }\r
     }\r
     \r
+    public void removeTypedNamedFvImageNameValue (String fvName, String type, String optName) {\r
+        Vector<FvImagesDocument.FvImages.FvImage> vFvImage = getFvImagesFvImageWithName(fvName, type);\r
+        for (int i = 0; i < vFvImage.size(); ++i) {\r
+            FvImagesDocument.FvImages.FvImage fi = vFvImage.get(i);\r
+            if (fi.getFvImageOptions() != null && fi.getFvImageOptions().getNameValueList() != null) {\r
+                ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r
+                while (li.hasNext()) {\r
+                    FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r
+                    if (nv.getName().equals(optName)) {\r
+                        li.remove();\r
+                    }\r
+                }\r
+            }\r
+        }\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
@@ -2854,6 +2870,7 @@ public class FpdFileContents {
      * @param value\r
      */\r
     public void setTypedNamedFvImageNameValue (String fvName, String type, String name, String value) {\r
+        boolean fvImageExists = false;\r
         if (getfpdFlash().getFvImages() == null) {\r
             return;\r
         }\r
@@ -2870,8 +2887,15 @@ public class FpdFileContents {
             if (!fi.getFvImageNamesList().contains(fvName)) {\r
                 continue;\r
             }\r
+            fvImageExists = true;\r
             setFvImagesFvImageNameValue (fi, name, value, null);\r
         }\r
+        \r
+        if (!fvImageExists) {\r
+            HashMap<String, String> map = new HashMap<String, String>();\r
+            map.put(name, value);\r
+            genFvImagesFvImage(new String[]{fvName}, type, map);\r
+        }\r
     }\r
     \r
     /**Add to all FvImage elements with type, the name-value pair.\r
@@ -2895,6 +2919,7 @@ public class FpdFileContents {
             }\r
             setFvImagesFvImageNameValue (fi, name, value, null);\r
         }\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