]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/LibraryClassDefsDlg.java
1. Fix EDKT303: Give warning if no library instances that support the required the...
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / dialog / LibraryClassDefsDlg.java
index c475b4ab1bdcbeff159832fa15d0ca4454fcfc3e..0c8d66343427db8aa3e63f6c5a2d953cc2378ac6 100644 (file)
@@ -30,6 +30,7 @@ import org.tianocore.frameworkwizard.common.DataValidation;
 import org.tianocore.frameworkwizard.common.EnumerationData;\r
 import org.tianocore.frameworkwizard.common.Log;\r
 import org.tianocore.frameworkwizard.common.Tools;\r
+import org.tianocore.frameworkwizard.common.find.Find;\r
 import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r
 import org.tianocore.frameworkwizard.common.ui.IDialog;\r
 import org.tianocore.frameworkwizard.common.ui.IFrame;\r
@@ -37,6 +38,7 @@ import org.tianocore.frameworkwizard.common.ui.StarLabel;
 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;\r
+import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassVector;\r
 import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r
 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r
 \r
@@ -213,7 +215,7 @@ public class LibraryClassDefsDlg extends IDialog {
     private JTextField getJTextFieldFeatureFlag() {\r
         if (jTextFieldFeatureFlag == null) {\r
             jTextFieldFeatureFlag = new JTextField();\r
-            jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168,197,320,20));\r
+            jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 197, 320, 20));\r
             jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r
             jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r
             jTextFieldFeatureFlag.setEnabled(false);\r
@@ -304,7 +306,8 @@ public class LibraryClassDefsDlg extends IDialog {
      This is the default constructor\r
      \r
      **/\r
-    public LibraryClassDefsDlg(LibraryClassIdentification inLibraryClassIdentification, IFrame iFrame, ModuleIdentification mid) {\r
+    public LibraryClassDefsDlg(LibraryClassIdentification inLibraryClassIdentification, IFrame iFrame,\r
+                               ModuleIdentification mid) {\r
         super(iFrame, true);\r
         init(inLibraryClassIdentification, mid);\r
     }\r
@@ -329,22 +332,27 @@ public class LibraryClassDefsDlg extends IDialog {
     private void init(LibraryClassIdentification inLibraryClassIdentification, ModuleIdentification mid) {\r
         init();\r
         this.lcid = inLibraryClassIdentification;\r
-        \r
+\r
         //\r
         // Init arch with module's arch\r
         //\r
         this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r
-        \r
+\r
         //\r
         // Get defined library classes from dependent packages\r
         //\r
         Vector<PackageIdentification> vpid = wt.getPackageDependenciesOfModule(mid);\r
         if (vpid.size() <= 0) {\r
-            Log.wrn("Init Library Class", "This module hasn't defined any package dependency, so there is no library class can be added");\r
+            Log.wrn("Init Library Class",\r
+                    "This module hasn't defined any package dependency, so there is no library class can be added");\r
         }\r
-        \r
-        Tools.generateComboBoxByVector(this.jComboBoxLibraryClassName,\r
-                                       wt.getAllLibraryClassDefinitionsFromPackages(wt.getPackageDependenciesOfModule(mid)));\r
+\r
+        Tools\r
+             .generateComboBoxByVector(\r
+                                       this.jComboBoxLibraryClassName,\r
+                                       wt\r
+                                         .getAllLibraryClassDefinitionsFromPackages(wt\r
+                                                                                      .getPackageDependenciesOfModule(mid)));\r
 \r
         if (lcid != null) {\r
             this.jComboBoxLibraryClassName.setSelectedItem(lcid.getLibraryClassName());\r
@@ -393,7 +401,7 @@ public class LibraryClassDefsDlg extends IDialog {
             jLabelArch.setBounds(new java.awt.Rectangle(12, 87, 168, 20));\r
             jLabelArch.setText("Supported Architectures");\r
             jLabelFeatureFlag = new JLabel();\r
-            jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12,197,168,20));\r
+            jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 197, 168, 20));\r
             jLabelFeatureFlag.setText("Feature Flag Expression");\r
             jLabelFeatureFlag.setEnabled(false);\r
             jLabelRecommendedInstanceGuid = new JLabel();\r
@@ -498,6 +506,32 @@ public class LibraryClassDefsDlg extends IDialog {
             return false;\r
         }\r
 \r
+        //\r
+        // Check if the library is produced\r
+        //\r
+        String strUsage = this.jComboBoxUsage.getSelectedItem().toString();\r
+        //\r
+        // Check only when the library class is consumed\r
+        //\r
+        if (strUsage.equals(DataType.USAGE_TYPE_ALWAYS_CONSUMED) || strUsage.equals(DataType.USAGE_TYPE_SOMETIMES_CONSUMED)) {\r
+            LibraryClassVector v = Find.getAllLibraryClassVector();\r
+            boolean isFind = false;\r
+            for (int index = 0; index < v.size(); index++) {\r
+                LibraryClassIdentification lid = v.getLibraryClass(index);\r
+                if (lid.getLibraryClassName().equals(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {\r
+                    if (lid.getUsage().equals(DataType.USAGE_TYPE_ALWAYS_PRODUCED)\r
+                        || lid.getUsage().equals(DataType.USAGE_TYPE_SOMETIMES_PRODUCED)) {\r
+                        isFind = true;\r
+                        break;\r
+                    }\r
+                }\r
+            }\r
+            if (!isFind) {\r
+                Log.wrn("Update Library Class Definitions", "This Library Class has no instance yet.");\r
+                return false;\r
+            }\r
+        }\r
+        \r
         //\r
         // Check RecommendedInstanceVersion\r
         //\r