]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/MsaHeader.java
1. Fix EDKT273 "Externs are not being grouped together in MSA Files"
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / MsaHeader.java
index 9cf0d380e0244fd1ee3ada129b8d7657657ae039..70e2166fbe98d43128b8ca77b61ae34d096ac5a5 100644 (file)
@@ -29,10 +29,12 @@ import javax.swing.JScrollPane;
 import javax.swing.JTextArea;\r
 import javax.swing.JTextField;\r
 \r
+import org.tianocore.ExternsDocument;\r
 import org.tianocore.ModuleDefinitionsDocument;\r
 import org.tianocore.ModuleSurfaceAreaDocument;\r
 import org.tianocore.ModuleTypeDef;\r
 import org.tianocore.MsaHeaderDocument;\r
+import org.tianocore.PcdDriverTypes;\r
 import org.tianocore.LicenseDocument.License;\r
 import org.tianocore.frameworkwizard.common.DataType;\r
 import org.tianocore.frameworkwizard.common.DataValidation;\r
@@ -58,9 +60,9 @@ public class MsaHeader extends IInternalFrame {
     private static final long serialVersionUID = -8152099582923006900L;\r
 \r
     private int dialogWidth = 500;\r
-    \r
+\r
     private int dialogHeight = 630;\r
-    \r
+\r
     //\r
     //Define class members\r
     //\r
@@ -152,8 +154,6 @@ public class MsaHeader extends IInternalFrame {
 \r
     private StarLabel jStarLabel14 = null;\r
 \r
-//    private StarLabel jStarLabel15 = null;\r
-\r
     private JCheckBox jCheckBoxIa32 = null;\r
 \r
     private JCheckBox jCheckBoxX64 = null;\r
@@ -165,7 +165,13 @@ public class MsaHeader extends IInternalFrame {
     private JCheckBox jCheckBoxArm = null;\r
 \r
     private JCheckBox jCheckBoxPpc = null;\r
-    \r
+\r
+    private JComboBox jComboBoxPcdIsDriver = null;\r
+\r
+    private JCheckBox jCheckBoxPcd = null;\r
+\r
+    private JCheckBox jCheckBoxFlashMap = null;\r
+\r
     //\r
     // Not used for UI\r
     //\r
@@ -175,6 +181,8 @@ public class MsaHeader extends IInternalFrame {
 \r
     private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;\r
 \r
+    private ExternsDocument.Externs ex = null;\r
+\r
     private OpeningModuleType omt = null;\r
 \r
     private EnumerationData ed = new EnumerationData();\r
@@ -394,12 +402,11 @@ public class MsaHeader extends IInternalFrame {
     private JTextField getJTextFieldSpecification() {\r
         if (jTextFieldSpecification == null) {\r
             jTextFieldSpecification = new JTextField();\r
-            \r
+\r
             jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20));\r
             jTextFieldSpecification.setText("FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052");\r
             jTextFieldSpecification.setBorder(null);\r
-            \r
-            \r
+\r
             jTextFieldSpecification.setSize(new java.awt.Dimension(320, 20));\r
             jTextFieldSpecification.setLocation(new java.awt.Point(2, dialogHeight - 30));\r
             jTextFieldSpecification.setEditable(false);\r
@@ -622,6 +629,23 @@ public class MsaHeader extends IInternalFrame {
         return jTextFieldOutputFileBasename;\r
     }\r
 \r
+    /**\r
+     * This method initializes jComboBoxPcdIsDriver \r
+     *  \r
+     * @return javax.swing.JComboBox    \r
+     */\r
+    private JComboBox getJComboBoxPcdIsDriver() {\r
+        if (jComboBoxPcdIsDriver == null) {\r
+            jComboBoxPcdIsDriver = new JComboBox();\r
+            jComboBoxPcdIsDriver.setPreferredSize(new java.awt.Dimension(320, 20));\r
+            jComboBoxPcdIsDriver.setBounds(new java.awt.Rectangle(160, 530, 320, 20));\r
+            jComboBoxPcdIsDriver.addItemListener(this);\r
+            jComboBoxPcdIsDriver.setEnabled(false);\r
+            Tools.generateComboBoxByVector(jComboBoxPcdIsDriver, ed.getVPcdDriverTypes());\r
+        }\r
+        return jComboBoxPcdIsDriver;\r
+    }\r
+\r
     /**\r
      This is the default constructor\r
      \r
@@ -654,8 +678,14 @@ public class MsaHeader extends IInternalFrame {
             md.setSupportedArchitectures(ed.getVSupportedArchitectures());\r
             msa.setModuleDefinitions(md);\r
         }\r
+\r
+        //\r
+        // Init items of Header, Definitions and Externs\r
+        //\r
         init(msa.getMsaHeader());\r
         init(msa.getModuleDefinitions());\r
+        init(msa.getExterns());\r
+\r
         this.setVisible(true);\r
         this.setViewMode(false);\r
     }\r
@@ -767,6 +797,25 @@ public class MsaHeader extends IInternalFrame {
         }\r
     }\r
 \r
+    /**\r
+     This method initializes this\r
+     Fill values to all fields if these values are not empty\r
+     \r
+     @param inEx  The input data of ExternsDocument.Externs\r
+     \r
+     **/\r
+    private void init(ExternsDocument.Externs inEx) {\r
+        if (inEx != null) {\r
+            this.ex = inEx;\r
+            if (ex.getPcdIsDriver() != null) {\r
+                this.jCheckBoxPcd.setSelected(true);\r
+                this.jComboBoxPcdIsDriver.setEnabled(true);\r
+                this.jComboBoxPcdIsDriver.setSelectedItem(ex.getPcdIsDriver());\r
+            }\r
+            this.jCheckBoxFlashMap.setSelected(ex.getTianoR8FlashMapH());\r
+        }\r
+    }\r
+\r
     /**\r
      This method initializes jContentPane\r
      \r
@@ -827,7 +876,7 @@ public class MsaHeader extends IInternalFrame {
             jContentPane = new JPanel();\r
             jContentPane.setLayout(null);\r
             jContentPane.setPreferredSize(new java.awt.Dimension(dialogWidth - 10, dialogHeight - 10));\r
-            \r
+\r
             jContentPane.addFocusListener(this);\r
 \r
             jContentPane.add(jLabelBaseName, null);\r
@@ -840,7 +889,7 @@ public class MsaHeader extends IInternalFrame {
             jContentPane.add(jLabelLicense, null);\r
             jContentPane.add(jLabelCopyright, null);\r
             jContentPane.add(jLabelDescription, null);\r
-//            jContentPane.add(jLabelSpecification, null);\r
+            //            jContentPane.add(jLabelSpecification, null);\r
             jContentPane.add(getJTextFieldSpecification(), null);\r
             jContentPane.add(getJButtonOk(), null);\r
             jContentPane.add(getJButtonCancel(), null);\r
@@ -880,8 +929,8 @@ public class MsaHeader extends IInternalFrame {
             jStarLabel13.setLocation(new java.awt.Point(0, 480));\r
             jStarLabel14 = new StarLabel();\r
             jStarLabel14.setLocation(new java.awt.Point(0, 505));\r
-//            jStarLabel15 = new StarLabel();\r
-//            jStarLabel15.setLocation(new java.awt.Point(0, 530));\r
+            //            jStarLabel15 = new StarLabel();\r
+            //            jStarLabel15.setLocation(new java.awt.Point(0, 530));\r
 \r
             jContentPane.add(jStarLabel1, null);\r
             jContentPane.add(jStarLabel2, null);\r
@@ -894,7 +943,7 @@ public class MsaHeader extends IInternalFrame {
             jContentPane.add(jStarLabel12, null);\r
             jContentPane.add(jStarLabel13, null);\r
             jContentPane.add(jStarLabel14, null);\r
-//            jContentPane.add(jStarLabel15, null);\r
+            //            jContentPane.add(jStarLabel15, null);\r
             jContentPane.add(getJScrollPaneCopyright(), null);\r
 \r
             jContentPane.add(getJCheckBoxIa32(), null);\r
@@ -903,6 +952,10 @@ public class MsaHeader extends IInternalFrame {
             jContentPane.add(getJCheckBoxEbc(), null);\r
             jContentPane.add(getJCheckBoxArm(), null);\r
             jContentPane.add(getJCheckBoxPpc(), null);\r
+\r
+            jContentPane.add(getJCheckBoxPcd(), null);\r
+            jContentPane.add(getJComboBoxPcdIsDriver(), null);\r
+            jContentPane.add(getJCheckBoxFlashMap(), null);\r
         }\r
         return jContentPane;\r
     }\r
@@ -923,14 +976,20 @@ public class MsaHeader extends IInternalFrame {
             this.setEdited(true);\r
             this.dispose();\r
         }\r
+\r
         if (arg0.getSource() == jButtonCancel) {\r
             this.setEdited(false);\r
         }\r
+\r
         if (arg0.getSource() == jButtonGenerateGuid) {\r
             jTextFieldGuid.setText(Tools.generateUuidString());\r
             jTextFieldGuid.requestFocus();\r
             jButtonGenerateGuid.requestFocus();\r
         }\r
+\r
+        if (arg0.getSource() == this.jCheckBoxPcd) {\r
+            this.jComboBoxPcdIsDriver.setEnabled(this.jCheckBoxPcd.isSelected());\r
+        }\r
     }\r
 \r
     /**\r
@@ -997,7 +1056,8 @@ public class MsaHeader extends IInternalFrame {
             return false;\r
         }\r
         if (!DataValidation.isAbstract(this.jTextFieldAbstract.getText())) {\r
-            Log.wrn("Update Msa Header", "Incorrect data type for Abstract, is should be a sentence describing the module.");\r
+            Log.wrn("Update Msa Header",\r
+                    "Incorrect data type for Abstract, is should be a sentence describing the module.");\r
             //this.jTextFieldAbstract.requestFocus();\r
             return false;\r
         }\r
@@ -1119,9 +1179,10 @@ public class MsaHeader extends IInternalFrame {
         Tools.resizeComponentWidth(this.jComboBoxModuleType, intCurrentWidth, intPreferredWidth);\r
         Tools.resizeComponentWidth(this.jComboBoxBinaryModule, intCurrentWidth, intPreferredWidth);\r
         Tools.resizeComponentWidth(this.jTextFieldOutputFileBasename, intCurrentWidth, intPreferredWidth);\r
+        Tools.resizeComponentWidth(this.jComboBoxPcdIsDriver, intCurrentWidth, intPreferredWidth);\r
 \r
         Tools.relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,\r
-                           DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);\r
+                                 DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);\r
     }\r
 \r
     public void focusLost(FocusEvent arg0) {\r
@@ -1347,6 +1408,92 @@ public class MsaHeader extends IInternalFrame {
             }\r
         }\r
 \r
+        //\r
+        // Check Pcd is Driver\r
+        //\r
+        if (arg0.getSource() == this.jCheckBoxPcd) {\r
+            if ((this.ex == null) && this.jCheckBoxPcd.isSelected()) {\r
+                this.ex = ExternsDocument.Externs.Factory.newInstance();\r
+                this.ex.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()\r
+                                                                                              .toString()));\r
+                this.msa.setExterns(this.ex);\r
+            }\r
+\r
+            if ((this.ex != null) && (this.ex.getPcdIsDriver() == null) && this.jCheckBoxPcd.isSelected()) {\r
+                this.ex.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()\r
+                                                                                              .toString()));\r
+                this.msa.setExterns(this.ex);\r
+            }\r
+\r
+            if ((this.ex != null) && (this.ex.getPcdIsDriver() != null)) {\r
+                if (this.jCheckBoxPcd.isSelected()\r
+                    && !this.jComboBoxPcdIsDriver.getSelectedItem().toString().equals(\r
+                                                                                      this.ex.getPcdIsDriver()\r
+                                                                                             .toString())) {\r
+                    this.ex.setPcdIsDriver(PcdDriverTypes.Enum.forString(this.jComboBoxPcdIsDriver.getSelectedItem()\r
+                                                                                                  .toString()));\r
+                    this.msa.setExterns(this.ex);\r
+                }\r
+                if (!this.jCheckBoxPcd.isSelected()) {\r
+                    ExternsDocument.Externs newEx = ExternsDocument.Externs.Factory.newInstance();\r
+                    if (this.ex.getExternList() != null) {\r
+                        for (int index = 0; index < this.ex.getExternList().size(); index++) {\r
+                            newEx.addNewExtern();\r
+                            newEx.setExternArray(index, this.ex.getExternArray(index));\r
+                        }\r
+                    }\r
+                    if (this.ex.getSpecificationList() != null) {\r
+                        for (int index = 0; index < this.ex.getSpecificationList().size(); index++) {\r
+                            newEx.addNewSpecification();\r
+                            newEx.setSpecificationArray(index, this.ex.getSpecificationArray(index));\r
+                        }\r
+                    }\r
+                    if (this.ex.getTianoR8FlashMapH()) {\r
+                        newEx.setTianoR8FlashMapH(this.ex.getTianoR8FlashMapH());\r
+                    }\r
+                    this.ex = newEx;\r
+                    this.msa.setExterns(this.ex);\r
+                }\r
+            }\r
+        }\r
+\r
+        //\r
+        // Check Flash Map\r
+        //\r
+        if (arg0.getSource() == this.jCheckBoxFlashMap) {\r
+            if ((this.ex == null) && this.jCheckBoxFlashMap.isSelected()) {\r
+                this.ex = ExternsDocument.Externs.Factory.newInstance();\r
+                this.ex.setTianoR8FlashMapH(this.jCheckBoxFlashMap.isSelected());\r
+                this.msa.setExterns(this.ex);\r
+            }\r
+\r
+            if ((this.ex != null) && this.jCheckBoxFlashMap.isSelected()) {\r
+                this.ex.setTianoR8FlashMapH(this.jCheckBoxFlashMap.isSelected());\r
+                this.msa.setExterns(this.ex);\r
+            }\r
+\r
+            if ((this.ex != null) && !this.jCheckBoxFlashMap.isSelected()) {\r
+                ExternsDocument.Externs newEx = ExternsDocument.Externs.Factory.newInstance();\r
+                if (this.ex.getExternList() != null) {\r
+                    for (int index = 0; index < this.ex.getExternList().size(); index++) {\r
+                        newEx.addNewExtern();\r
+                        newEx.setExternArray(index, this.ex.getExternArray(index));\r
+                    }\r
+                }\r
+                if (this.ex.getSpecificationList() != null) {\r
+                    for (int index = 0; index < this.ex.getSpecificationList().size(); index++) {\r
+                        newEx.addNewSpecification();\r
+                        newEx.setSpecificationArray(index, this.ex.getSpecificationArray(index));\r
+                    }\r
+                }\r
+                if (this.ex.getPcdIsDriver() != null) {\r
+                    newEx.setPcdIsDriver(this.ex.getPcdIsDriver());\r
+                }\r
+                this.ex = newEx;\r
+                this.msa.setExterns(this.ex);\r
+            }\r
+        }\r
+\r
         this.save();\r
     }\r
 \r
@@ -1436,4 +1583,35 @@ public class MsaHeader extends IInternalFrame {
             }\r
         }\r
     }\r
+\r
+    /**\r
+     * This method initializes jCheckBoxPcd    \r
+     *         \r
+     * @return javax.swing.JCheckBox   \r
+     */\r
+    private JCheckBox getJCheckBoxPcd() {\r
+        if (jCheckBoxPcd == null) {\r
+            jCheckBoxPcd = new JCheckBox();\r
+            jCheckBoxPcd.setBounds(new java.awt.Rectangle(0, 530, 140, 20));\r
+            jCheckBoxPcd.setText("Is this a PCD Driver?");\r
+            jCheckBoxPcd.addFocusListener(this);\r
+            jCheckBoxPcd.addActionListener(this);\r
+        }\r
+        return jCheckBoxPcd;\r
+    }\r
+\r
+    /**\r
+     * This method initializes jCheckBoxFlashMap       \r
+     *         \r
+     * @return javax.swing.JCheckBox   \r
+     */\r
+    private JCheckBox getJCheckBoxFlashMap() {\r
+        if (jCheckBoxFlashMap == null) {\r
+            jCheckBoxFlashMap = new JCheckBox();\r
+            jCheckBoxFlashMap.setBounds(new java.awt.Rectangle(0, 555, 480, 20));\r
+            jCheckBoxFlashMap.setText("Are you using a legacy FlashMap header file?");\r
+            jCheckBoxFlashMap.addFocusListener(this);\r
+        }\r
+        return jCheckBoxFlashMap;\r
+    }\r
 }\r