]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
Fix Sku Info update UI refresh to update the dynamic pcd value for selected sku id.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFrameworkModules.java
index 2d1142301caaa7f6df4fd184a2a4374650b5f303..2d8b23760e42a7859c9865a53899cbc9f46f5d34 100644 (file)
@@ -15,6 +15,8 @@
 package org.tianocore.frameworkwizard.platform.ui;\r
 \r
 import java.awt.BorderLayout;\r
+import java.awt.Dimension;\r
+import java.awt.FontMetrics;\r
 \r
 import javax.swing.JFrame;\r
 import javax.swing.JOptionPane;\r
@@ -35,9 +37,11 @@ import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
 import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r
+import org.tianocore.frameworkwizard.workspace.Workspace;\r
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 \r
 import java.awt.FlowLayout;\r
+import java.awt.event.ActionEvent;\r
 import java.awt.event.KeyEvent;\r
 import java.awt.event.MouseEvent;\r
 import java.util.ArrayList;\r
@@ -186,6 +190,8 @@ public class FpdFrameworkModules extends IInternalFrame {
     private final int typeMinWidth = 100;\r
     \r
     private final int typeMaxWidth = 155;\r
+\r
+    private JButton jButtonApriori = null;\r
     \r
     /**\r
      * This method initializes jSplitPane\r
@@ -384,18 +390,22 @@ public class FpdFrameworkModules extends IInternalFrame {
         String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + "";\r
         ModuleIdentification mi = miList.get(selectedRow);\r
         Vector<String> vArchs = null;\r
-        try {\r
-            vArchs = WorkspaceProfile.getModuleSupArchs(mi);\r
-        }\r
-        catch (Exception exp) {\r
-            JOptionPane.showMessageDialog(frame, exp.getMessage());\r
-        }\r
+\r
+        vArchs = WorkspaceProfile.getModuleSupArchs(mi);\r
 \r
         if (vArchs == null) {\r
             JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file.");\r
             return;\r
         }\r
 \r
+        Vector<Object> platformSupArch = new Vector<Object>();\r
+        ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
+        platformSupArch.retainAll(vArchs);\r
+        if (platformSupArch.size() == 0) {\r
+            JOptionPane.showMessageDialog(frame, "This Module does not support this platform architectures.");\r
+            return;\r
+        }\r
+        \r
         String archsAdded = "";\r
         String mg = mi.getGuid();\r
         String mv = mi.getVersion();\r
@@ -429,7 +439,7 @@ public class FpdFrameworkModules extends IInternalFrame {
         //\r
         // check whether archs conform to SupArch of platform.\r
         //\r
-        Vector<Object> platformSupArch = new Vector<Object>();\r
+        platformSupArch.removeAllElements();\r
         ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
         vArchs.retainAll(platformSupArch);\r
         //\r
@@ -524,6 +534,7 @@ public class FpdFrameworkModules extends IInternalFrame {
             jPanelBottomSouth.setLayout(flowLayout1);\r
             jPanelBottomSouth.add(getJButtonSettings(), null);\r
             jPanelBottomSouth.add(getJButtonRemoveModule(), null);\r
+            jPanelBottomSouth.add(getJButtonApriori(), null);\r
         }\r
         return jPanelBottomSouth;\r
     }\r
@@ -662,7 +673,9 @@ public class FpdFrameworkModules extends IInternalFrame {
     \r
     private void showSettingsDlg (int row) {\r
         try {\r
-            if (ffc.adjustPcd(row)) {\r
+            Vector<String> vExceptions = new Vector<String>();\r
+            if (ffc.adjustPcd(row, vExceptions)) {\r
+                JOptionPane.showMessageDialog(frame, "Pcd entries sync. with those in MSA files.");\r
                 docConsole.setSaved(false);\r
             }\r
         }\r
@@ -719,8 +732,9 @@ public class FpdFrameworkModules extends IInternalFrame {
     private JButton getJButtonRemoveModule() {\r
         if (jButtonRemoveModule == null) {\r
             jButtonRemoveModule = new JButton();\r
-            jButtonRemoveModule.setPreferredSize(new java.awt.Dimension(130, 20));\r
             jButtonRemoveModule.setText("Remove Module");\r
+            FontMetrics fm = jButtonRemoveModule.getFontMetrics(jButtonRemoveModule.getFont());\r
+            jButtonRemoveModule.setPreferredSize(new Dimension (fm.stringWidth(jButtonRemoveModule.getText()) + 40, 20));\r
             jButtonRemoveModule.addActionListener(new java.awt.event.ActionListener() {\r
                 public void actionPerformed(java.awt.event.ActionEvent e) {\r
                     int selectedRow = jTableFpdModules.getSelectedRow();\r
@@ -747,7 +761,7 @@ public class FpdFrameworkModules extends IInternalFrame {
                     if (fvBindings != null) {\r
                         String[] fvArray = fvBindings.split(" ");\r
                         for (int i = 0; i < fvArray.length; ++i) {\r
-                            ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), mg, mv, pg, pv, arch);\r
+                            ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), "IMAGES", 1, mg, mv, pg, pv, arch);\r
                         }\r
                     }\r
                     \r
@@ -791,6 +805,29 @@ public class FpdFrameworkModules extends IInternalFrame {
         return jButtonRemoveModule;\r
     }\r
 \r
+    /**\r
+     * This method initializes jButtonApriori  \r
+     *         \r
+     * @return javax.swing.JButton     \r
+     */\r
+    private JButton getJButtonApriori() {\r
+        if (jButtonApriori == null) {\r
+            jButtonApriori = new JButton();\r
+            jButtonApriori.setText("Apriori Files");\r
+            FontMetrics fm = jButtonApriori.getFontMetrics(jButtonApriori.getFont());\r
+            int buttonWidth = fm.stringWidth(jButtonApriori.getText()) + 40;\r
+            if (jButtonRemoveModule.getWidth() > buttonWidth) {\r
+                buttonWidth = jButtonRemoveModule.getWidth();\r
+            }\r
+            jButtonApriori.setPreferredSize(new Dimension (buttonWidth, 20));\r
+            jButtonApriori.addActionListener(new java.awt.event.ActionListener() {\r
+                public void actionPerformed(ActionEvent arg0) {\r
+                    new GenAprioriFileDialog(ffc, docConsole).setVisible(true);\r
+                }});\r
+        }\r
+        return jButtonApriori;\r
+    }\r
+\r
     /**\r
      * \r
      * @param args\r
@@ -817,6 +854,18 @@ public class FpdFrameworkModules extends IInternalFrame {
     public FpdFrameworkModules(OpeningPlatformType opt) {\r
         this(opt.getXmlFpd());\r
         docConsole = opt;\r
+        Vector<String> vExceptions = new Vector<String>();\r
+        if (pcdSync(vExceptions)) {\r
+            JOptionPane.showMessageDialog(frame, "PCD in this platform are synchronized with those in MSA files.");    \r
+            docConsole.setSaved(false);\r
+        }\r
+        if (vExceptions.size() > 0) {\r
+            String errorMsg = "";\r
+            for (int i = 0; i < vExceptions.size(); ++i) {\r
+                errorMsg += " " + vExceptions.get(i) + "\n";\r
+            }\r
+            JOptionPane.showMessageDialog(frame, "Error occurred during synchronization:" + errorMsg);\r
+        }\r
     }\r
 \r
     private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
@@ -845,7 +894,7 @@ public class FpdFrameworkModules extends IInternalFrame {
                     row[pkgVerColForFpdModTable] = mi.getPackageId().getVersion();\r
                     row[archColForFpdModTable] = saa[i][ffcModArch];\r
                     try {\r
-                        row[pathColForFpdModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+                        row[pathColForFpdModTable] = mi.getPath().substring(Workspace.getCurrentWorkspace().length() + 1);\r
                     } catch (Exception e) {\r
                         JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage());\r
                     }\r
@@ -875,9 +924,26 @@ public class FpdFrameworkModules extends IInternalFrame {
         }\r
 \r
         showAllModules();\r
-\r
+        \r
     }\r
 \r
+    private boolean pcdSync(Vector<String> v) {\r
+        boolean synced = false;\r
+        for (int i = 0; i < jTableFpdModules.getRowCount(); ++i) {\r
+            try {\r
+                if (ffc.adjustPcd(i, v)) {\r
+                    synced = true;\r
+                }\r
+            }\r
+            catch (Exception exp) {\r
+//                JOptionPane.showMessageDialog(frame, exp.getMessage());\r
+                continue;\r
+            }\r
+        }\r
+        return synced;\r
+        \r
+    }\r
+    \r
     private void showAllModules() {\r
 \r
         if (miList == null) {\r
@@ -895,7 +961,7 @@ public class FpdFrameworkModules extends IInternalFrame {
                 s[pkgNameColForAllModTable] = mi.getPackageId().getName();\r
                 s[pkgVerColForAllModTable] = mi.getPackageId().getVersion();\r
                 try {\r
-                    s[pathColForAllModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
+                    s[pathColForAllModTable] = mi.getPath().substring(Workspace.getCurrentWorkspace().length() + 1);\r
                 } catch (Exception e) {\r
                     JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage());\r
                 }\r