]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/ui/IComboBox.java
1. Fix EDKT496 Framework Wizard should allow user to pick up a Protocol Guid to tag...
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / IComboBox.java
index 68c368e29b16b57ad790742ae8d7a135741a42bd..c5a51fd3e6c35d91c2d7838c59c3a0f906acaa1d 100644 (file)
@@ -192,4 +192,36 @@ public class IComboBox extends JComboBox implements KeyListener, MouseListener,
         this.setEditable(false);\r
         this.getEditor().setItem("");\r
     }\r
+\r
+    /**\r
+     Set the input item as selected\r
+     \r
+     @param item the item which is needed to be set selected\r
+     \r
+     **/\r
+    public void setSelectedItem(Object item) {\r
+        boolean isFind = false;\r
+        //\r
+        // If the input value is not in the default list, add it to the list\r
+        //\r
+        if (item != null) {\r
+            for (int index = 0; index < this.getItemCount(); index++) {\r
+                if (this.getItemAt(index).equals(item)) {\r
+                    isFind = true;\r
+                    break;\r
+                }\r
+            }\r
+            //\r
+            // Add this item to IComboBox if not found\r
+            //\r
+            if (!isFind && !item.toString().equals("")) {\r
+                super.addItem(item);\r
+            }\r
+        }\r
+        \r
+        //\r
+        // Call super function to set the item selected.\r
+        //\r
+        super.setSelectedItem(item);\r
+    }\r
 }\r