]> git.proxmox.com Git - mirror_edk2.git/commitdiff
add multi-source pcd check before adding/deleting lib instance for ModuleSA in platform.
authorjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Sep 2006 00:48:36 +0000 (00:48 +0000)
committerjlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 20 Sep 2006 00:48:36 +0000 (00:48 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1574 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java
Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/WorkspaceProfile.java

index b89f967fa3e53000e18993fbbb172b84a1e35dce..d9c2e69f0c931e5c822907a5d87fe9753e5ab288 100644 (file)
@@ -70,7 +70,7 @@ import org.tianocore.frameworkwizard.packaging.PackageIdentification;
 public class FpdFileContents {\r
 \r
     static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r
-    static final String regNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";\r
+    static final String regExpNewLineAndSpaces = "((\n)|(\r\n)|(\r)|(\u0085)|(\u2028)|(\u2029))(\\s)*";\r
     \r
     private PlatformSurfaceAreaDocument fpdd = null;\r
     \r
@@ -352,7 +352,7 @@ public class FpdFileContents {
                     break;\r
                 }\r
                 String s = cursor.getTextValue();\r
-                if (s.matches(regNewLineAndSpaces)) {\r
+                if (s.matches(regExpNewLineAndSpaces)) {\r
                     continue;\r
                 }\r
             }\r
@@ -401,7 +401,6 @@ public class FpdFileContents {
             vMi.add(libMi);\r
         }\r
         \r
-        try {\r
     nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r
 \r
                 for (int j = 0; j < vMi.size(); ++j) {\r
@@ -413,16 +412,10 @@ public class FpdFileContents {
                 removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r
                 dataModified = true;\r
             }\r
-        }\r
-        catch (Exception e) {\r
-            throw e;\r
-        }\r
         //\r
         // add new Pcd from MSA file to ModuleSA.\r
         //\r
-        try {\r
-       \r
-            for (int i = 0; i < vMi.size(); ++i) {\r
+           for (int i = 0; i < vMi.size(); ++i) {\r
                 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r
                                                                                                                           .getModuleXmlObject(vMi\r
                                                                                                                                                  .get(i));\r
@@ -462,10 +455,6 @@ public class FpdFileContents {
                  }\r
 \r
             }\r
-        }\r
-        catch (Exception e){\r
-           throw e;\r
-        }\r
         \r
         return dataModified;\r
     }\r
@@ -648,12 +637,44 @@ public class FpdFileContents {
         return false;\r
     }\r
     \r
+    private boolean multiSourcePcd (String cName, String tsGuidCName, String moduleKey) {\r
+        int libCount = getLibraryInstancesCount(moduleKey);\r
+        String[][] saaLib = new String[libCount][5];\r
+        getLibraryInstances(moduleKey, saaLib);\r
+        ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
+        Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r
+        //\r
+        // create vector for module & library instance MIs.\r
+        //\r
+        vMi.add(mi);\r
+        for (int j = 0; j < saaLib.length; ++j) {\r
+            String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r
+            ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey);\r
+            vMi.add(libMi);\r
+        }\r
+        \r
+        int pcdSourceCount = 0;\r
+        for (int i = 0; i < vMi.size(); ++i) {\r
+            if (WorkspaceProfile.pcdInMsa(cName, tsGuidCName, vMi.get(i))) {\r
+                pcdSourceCount++;\r
+            }\r
+        }\r
+        \r
+        if (pcdSourceCount < 2) {\r
+            return false;\r
+        }\r
+        else {\r
+            return true;\r
+        }\r
+        \r
+    }\r
+    \r
     /**Remove PCDBuildDefinition entries from ModuleSA\r
      * @param moduleKey identifier of ModuleSA.\r
      * @param consumer where these entries come from.\r
      */\r
     public void removePcdData(String moduleKey, ModuleIdentification consumer) {\r
-        try {\r
+        \r
             ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer);\r
             if (msa.getPcdCoded() == null) {\r
                 return;\r
@@ -672,8 +693,10 @@ public class FpdFileContents {
                         do {\r
                             PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r
                                                                                                                                                           .getObject();\r
-                            if (msaPcd.getCName().equals(pcdData.getCName())\r
-                                && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r
+                            String cName = msaPcd.getCName();\r
+                            String tsGuidCName = msaPcd.getTokenSpaceGuidCName();\r
+                            if (cName.equals(pcdData.getCName())\r
+                                && tsGuidCName.equals(pcdData.getTokenSpaceGuidCName()) && !multiSourcePcd(cName, tsGuidCName, moduleKey)) {\r
 \r
                                 maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r
                                                   moduleKey);\r
@@ -690,12 +713,7 @@ public class FpdFileContents {
                     cursor.dispose();\r
                 }\r
             }\r
-            \r
-        }\r
-        catch (Exception e){\r
-            e.printStackTrace();\r
-            \r
-        }\r
+        \r
     }\r
     //\r
     // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r
@@ -742,7 +760,7 @@ public class FpdFileContents {
                     break;\r
                 }\r
                 String s = cursor.getTextValue();\r
-                if (s.matches(regNewLineAndSpaces)) {\r
+                if (s.matches(regExpNewLineAndSpaces)) {\r
                     continue;\r
                 }\r
             }\r
@@ -1227,15 +1245,24 @@ public class FpdFileContents {
             pcdConsumer = new ArrayList<String>();\r
         }\r
         //\r
+        // Check whether this PCD has already added to ModuleSA, if so, just return.\r
+        //\r
+        String moduleInfo = moduleSa.getModuleGuid().toLowerCase() + " " + moduleSa.getModuleVersion() \r
+        + " " + moduleSa.getPackageGuid().toLowerCase() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r
+        for (int i = 0; i < pcdConsumer.size(); ++i) {\r
+            String pcdInfo = pcdConsumer.get(i);\r
+            if (moduleInfo.equals(pcdInfo.substring(0, pcdInfo.lastIndexOf(" ")))){\r
+                return;\r
+            }\r
+        }\r
+        //\r
         // Using existing Pcd type, if this pcd already exists in other ModuleSA\r
         //\r
         if (pcdConsumer.size() > 0) {\r
             \r
             itemType = itemType (pcdConsumer.get(0));\r
         }\r
-        String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r
-        + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r
-        + " " + itemType;\r
+        String listValue = moduleInfo + " " + itemType;\r
         pcdConsumer.add(listValue);\r
         dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r
         \r
index 57af40ea0719804cb9b1a75802ffbe2fea297d25..7a5a9d134a7c144d1942879eddfa79d6cb325319 100644 (file)
@@ -207,7 +207,7 @@ public class FpdFrameworkModules extends IInternalFrame {
     private JPanel getJPanelTop() {\r
         if (jPanelTop == null) {\r
             jLabel = new JLabel();\r
-            jLabel.setText("Modules in Workspace");\r
+            jLabel.setText("  Modules in Workspace");\r
             jPanelTop = new JPanel();\r
             jPanelTop.setLayout(new BorderLayout());\r
             jPanelTop.add(jLabel, java.awt.BorderLayout.NORTH);\r
@@ -227,7 +227,7 @@ public class FpdFrameworkModules extends IInternalFrame {
     private JPanel getJPanelBottom() {\r
         if (jPanelBottom == null) {\r
             jLabelModulesAdded = new JLabel();\r
-            jLabelModulesAdded.setText("Modules Added");\r
+            jLabelModulesAdded.setText("  Modules Added into Platform");\r
             jPanelBottom = new JPanel();\r
             jPanelBottom.setLayout(new BorderLayout());\r
             jPanelBottom.add(jLabelModulesAdded, java.awt.BorderLayout.NORTH);\r
index e82ed2df8bfca8e662dabd0c9cafa92aef4af879..7c1eb54ba8968c9c7bb77cbeec76acef5fec7dda 100644 (file)
@@ -124,6 +124,8 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JPanel jPanelCustomToolChain = null;\r
     private JPanel jPanelToolchainS = null;\r
     private JPanel jPanelToolchainC = null;\r
+    private JPanel jPanelLibraryCenterN = null;\r
+    private JPanel jPanelLibraryCenterC = null;  //  @jve:decl-index=0:visual-constraint="20,224"\r
     /**\r
      * This is the default constructor\r
      */\r
@@ -420,19 +422,14 @@ public class FpdModuleSA extends JDialog implements ActionListener {
         libInstanceTableModel.setRowCount(0);\r
     }\r
     \r
-    private void addLibInstance (ModuleIdentification libMi) {\r
+    private void addLibInstance (ModuleIdentification libMi) throws Exception{\r
         \r
-        ffc.genLibraryInstance(libMi, moduleKey);\r
         //\r
         // Add pcd information of selected instance to current moduleSA\r
         //\r
-        try{\r
-            ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));\r
-        }\r
-        catch (Exception exception) {\r
-            JOptionPane.showMessageDialog(frame, "Adding Instance" + libMi.getName() + ": "+ exception.getMessage());\r
-        }\r
+        ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));\r
         \r
+        ffc.genLibraryInstance(libMi, moduleKey);\r
     }\r
     /**\r
      * This method initializes this\r
@@ -440,7 +437,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
      * @return void\r
      */\r
     private void initialize() {\r
-        this.setSize(664, 515);\r
+        this.setSize(877, 555);\r
         this.setResizable(false);\r
         this.centerWindow();\r
         this.setModal(true);\r
@@ -488,7 +485,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JPanel getJPanelPcd() {\r
         if (jPanelPcd == null) {\r
             jLabelPcdData = new JLabel();\r
-            jLabelPcdData.setText("PcdData");\r
+            jLabelPcdData.setText(" PCD Data");\r
             jPanelPcd = new JPanel();\r
             jPanelPcd.setLayout(new BorderLayout());\r
             jPanelPcd.add(jLabelPcdData, java.awt.BorderLayout.NORTH);\r
@@ -548,7 +545,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
             model = new IDefaultTableModel();\r
             jTablePcd = new JTable(model);\r
             jTablePcd.setRowHeight(20);\r
-            jTablePcd.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
+            jTablePcd.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);\r
             model.addColumn("CName");\r
             model.addColumn("TokenSpaceGUID");\r
             model.addColumn("ItemType");\r
@@ -783,7 +780,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JScrollPane getJScrollPaneSelectedInstances() {\r
         if (jScrollPaneSelectedInstances == null) {\r
             jScrollPaneSelectedInstances = new JScrollPane();\r
-            jScrollPaneSelectedInstances.setPreferredSize(new java.awt.Dimension(453,150));\r
+            jScrollPaneSelectedInstances.setPreferredSize(new java.awt.Dimension(600,150));\r
             jScrollPaneSelectedInstances.setViewportView(getJTableSelectedInstances());\r
         }\r
         return jScrollPaneSelectedInstances;\r
@@ -888,7 +885,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JScrollPane getJScrollPaneQualifiedInstance() {\r
         if (jScrollPaneQualifiedInstance == null) {\r
             jScrollPaneQualifiedInstance = new JScrollPane();\r
-            jScrollPaneQualifiedInstance.setPreferredSize(new java.awt.Dimension(430,170));\r
+            jScrollPaneQualifiedInstance.setPreferredSize(new java.awt.Dimension(600,170));\r
             jScrollPaneQualifiedInstance.setViewportView(getJTableLibInstances());\r
         }\r
         return jScrollPaneQualifiedInstance;\r
@@ -940,12 +937,11 @@ public class FpdModuleSA extends JDialog implements ActionListener {
             jLabelSelectedInstances = new JLabel();\r
             jLabelSelectedInstances.setText("Selected Instances");\r
             jPanelLibraryCenter = new JPanel();\r
-            jPanelLibraryCenter.add(jLabelInstanceHelp, null);\r
-            jPanelLibraryCenter.add(getJScrollPaneInstanceHelp(), null);\r
-            jPanelLibraryCenter.add(getJButtonAdd(), null);\r
-            jPanelLibraryCenter.add(getJButtonDeleteInstance(), null);\r
-            jPanelLibraryCenter.add(jLabelSelectedInstances, null);\r
-            jPanelLibraryCenter.add(getJScrollPaneSelectedInstances(), null);\r
+            jPanelLibraryCenter.setLayout(new BorderLayout());\r
+\r
+            jPanelLibraryCenter.add(getJPanelLibraryCenterC(), java.awt.BorderLayout.CENTER);\r
+            jPanelLibraryCenter.add(getJPanelLibraryCenterN(), java.awt.BorderLayout.NORTH);\r
+\r
         }\r
         return jPanelLibraryCenter;\r
     }\r
@@ -958,7 +954,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
     private JScrollPane getJScrollPaneInstanceHelp() {\r
         if (jScrollPaneInstanceHelp == null) {\r
             jScrollPaneInstanceHelp = new JScrollPane();\r
-            jScrollPaneInstanceHelp.setPreferredSize(new java.awt.Dimension(300,50));\r
+            jScrollPaneInstanceHelp.setPreferredSize(new java.awt.Dimension(400,50));\r
             jScrollPaneInstanceHelp.setViewportView(getJTextAreaInstanceHelp());\r
         }\r
         return jScrollPaneInstanceHelp;\r
@@ -993,17 +989,24 @@ public class FpdModuleSA extends JDialog implements ActionListener {
                     if (row < 0) {\r
                         return;\r
                     }\r
-                    docConsole.setSaved(false);\r
-                    Object[] s = {libInstanceTableModel.getValueAt(row, 0), libInstanceTableModel.getValueAt(row, 1),\r
-                                  libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),\r
-                                  libInstanceTableModel.getValueAt(row, 4)};\r
-                    selectedInstancesTableModel.addRow(s);\r
+                    \r
                     String instanceValue = libInstanceTableModel.getValueAt(row, 1) + " " +\r
                     libInstanceTableModel.getValueAt(row, 2) + " " +\r
                     libInstanceTableModel.getValueAt(row, 3) + " " +\r
                     libInstanceTableModel.getValueAt(row, 4);\r
                     ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceValue);\r
-                    addLibInstance (libMi);\r
+                    try {\r
+                        addLibInstance (libMi);\r
+                    }\r
+                    catch (Exception exception) {\r
+                        JOptionPane.showMessageDialog(frame, "Adding Instance" + libMi.getName() + ": "+ exception.getMessage());\r
+                        return;\r
+                    }\r
+                    docConsole.setSaved(false);\r
+                    Object[] s = {libInstanceTableModel.getValueAt(row, 0), libInstanceTableModel.getValueAt(row, 1),\r
+                                  libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),\r
+                                  libInstanceTableModel.getValueAt(row, 4)};\r
+                    selectedInstancesTableModel.addRow(s);\r
                     resolveLibraryInstances(instanceValue);\r
                     showClassToResolved();\r
                 }\r
@@ -1634,6 +1637,38 @@ private JPanel getJPanelToolchainC() {
     }\r
     return jPanelToolchainC;\r
 }\r
+/**\r
+ * This method initializes jPanelLibraryCenterN        \r
+ *     \r
+ * @return javax.swing.JPanel  \r
+ */\r
+private JPanel getJPanelLibraryCenterN() {\r
+    if (jPanelLibraryCenterN == null) {\r
+        FlowLayout flowLayout5 = new FlowLayout();\r
+        flowLayout5.setAlignment(java.awt.FlowLayout.CENTER);\r
+        flowLayout5.setHgap(10);\r
+        jPanelLibraryCenterN = new JPanel();\r
+        jPanelLibraryCenterN.setLayout(flowLayout5);\r
+        jPanelLibraryCenterN.add(jLabelInstanceHelp, null);\r
+        jPanelLibraryCenterN.add(getJScrollPaneInstanceHelp(), null);\r
+        jPanelLibraryCenterN.add(getJButtonAdd(), null);\r
+        jPanelLibraryCenterN.add(getJButtonDeleteInstance(), null);\r
+    }\r
+    return jPanelLibraryCenterN;\r
+}\r
+/**\r
+ * This method initializes jPanelLibraryCenterC        \r
+ *     \r
+ * @return javax.swing.JPanel  \r
+ */\r
+private JPanel getJPanelLibraryCenterC() {\r
+    if (jPanelLibraryCenterC == null) {\r
+        jPanelLibraryCenterC = new JPanel();\r
+        jPanelLibraryCenterC.add(jLabelSelectedInstances, null);\r
+        jPanelLibraryCenterC.add(getJScrollPaneSelectedInstances(), null);\r
+    }\r
+    return jPanelLibraryCenterC;\r
+}\r
 \r
 \r
 }  //  @jve:decl-index=0:visual-constraint="10,10"\r
index 162bfd23eb7674bd2d92ac4e5011788fc35424fe..0f79653d85337e4d9a414a5320e0080c89a4c18b 100644 (file)
@@ -130,7 +130,7 @@ public class WorkspaceProfile {
         return msa.getModuleDefinitions().getOutputFileBasename();\r
     }\r
     \r
-    public static boolean pcdInMsa (String cName, String tsGuid, ModuleIdentification mi) throws Exception {\r
+    public static boolean pcdInMsa (String cName, String tsGuid, ModuleIdentification mi) {\r
         ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)getModuleXmlObject(mi);\r
         if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {\r
             return false;\r