]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java
Fix EDKT337,Double click on modules in "Framework Modules" of Platforms should be...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFrameworkModules.java
index 7a5a9d134a7c144d1942879eddfa79d6cb325319..ae74471c21c6dcc0935eb55afa53d19e910601d2 100644 (file)
@@ -38,6 +38,7 @@ import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
 \r
 import java.awt.FlowLayout;\r
+import java.awt.event.MouseEvent;\r
 import java.util.ArrayList;\r
 import java.util.HashMap;\r
 import java.util.Iterator;\r
@@ -297,7 +298,19 @@ public class FpdFrameworkModules extends IInternalFrame {
 \r
             jTableAllModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
             jTableAllModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);\r
-\r
+            jTableAllModules.addMouseListener(new java.awt.event.MouseAdapter() {\r
+                public void mouseClicked(java.awt.event.MouseEvent e) {\r
+                    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {\r
+                        java.awt.Point p = e.getPoint();\r
+                        int rowIndex = jTableAllModules.rowAtPoint(p);\r
+                        TableSorter sorter = (TableSorter) jTableAllModules.getModel();\r
+                        rowIndex = sorter.getModelRowIndex(rowIndex);\r
+                        addModuleIntoPlatform (rowIndex);\r
+                    }\r
+                }\r
+            });\r
+            \r
+            \r
         }\r
         return jTableAllModules;\r
     }\r
@@ -319,6 +332,109 @@ public class FpdFrameworkModules extends IInternalFrame {
         }\r
         return jPanelTopSouth;\r
     }\r
+    \r
+    private void addModuleIntoPlatform (int selectedRow) {\r
+        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
+        if (vArchs == null) {\r
+            JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file.");\r
+            return;\r
+        }\r
+\r
+        String archsAdded = "";\r
+        String mg = mi.getGuid();\r
+        String mv = mi.getVersion();\r
+        String pg = mi.getPackageId().getGuid();\r
+        String pv = mi.getPackageId().getVersion();\r
+        String mType = SurfaceAreaQuery.getModuleType(mi);\r
+\r
+        ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);\r
+        if (al == null) {\r
+            //\r
+            // if existing ModuleSA does not specify version info.\r
+            //\r
+            al = fpdMsa.get(mg + "null" + pg + "null");\r
+            if (al == null) {\r
+                al = fpdMsa.get(mg + "null" + pg + pv);\r
+                if (al == null){\r
+                    al = fpdMsa.get(mg + mv + pg + "null");\r
+                    if (al == null) {\r
+                        al = new ArrayList<String>();\r
+                        fpdMsa.put(mg + mv + pg + pv, al);    \r
+                    }\r
+                }\r
+            }\r
+        }\r
+        //\r
+        // filter from module SupArchs what archs has been added.\r
+        //\r
+        for (int i = 0; i < al.size(); ++i) {\r
+            vArchs.remove(al.get(i));\r
+        }\r
+        //\r
+        // check whether archs conform to SupArch of platform.\r
+        //\r
+        Vector<Object> platformSupArch = new Vector<Object>();\r
+        ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
+        vArchs.retainAll(platformSupArch);\r
+        //\r
+        // Archs this Module supported have already been added.\r
+        //\r
+        if (vArchs.size() == 0) {\r
+            JOptionPane.showMessageDialog(frame, "This Module has already been added.");\r
+            return;\r
+        }\r
+        //ToDo put Arch instead of null\r
+        boolean errorOccurred = false;\r
+        for (int i = 0; i < vArchs.size(); ++i) {\r
+            String arch = vArchs.get(i);\r
+            al.add(arch);\r
+            archsAdded += arch + " ";\r
+            String[] row = { "", "", "", "", "", "", "" };\r
+\r
+            if (mi != null) {\r
+                row[modNameColForFpdModTable] = mi.getName();\r
+                row[pkgNameColForFpdModTable] = mi.getPackageId().getName();\r
+                row[pathColForFpdModTable] = path;\r
+                row[archColForFpdModTable] = arch;\r
+                row[pkgVerColForFpdModTable] = pv;\r
+                row[modVerColForFpdModTable] = mv;\r
+                row[typeColForFpdModTable] = mType;\r
+\r
+            }\r
+            modelFpdModules.addRow(row);\r
+\r
+            docConsole.setSaved(false);\r
+            try {\r
+                //ToDo : specify archs need to add.\r
+                ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null);\r
+            } catch (Exception exception) {\r
+                JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch\r
+                                                     + ": " + exception.getMessage());\r
+                errorOccurred = true;\r
+            }\r
+        }\r
+\r
+        String s = "This Module with Architecture " + archsAdded;\r
+        if (errorOccurred) {\r
+            s += " was added with Error. Platform may NOT Build.";\r
+        } else {\r
+            s += " was added Successfully.";\r
+        }\r
+        JOptionPane.showMessageDialog(frame, s);\r
+        TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel();\r
+        int viewIndex = sorterFpdModules.getViewIndexArray()[modelFpdModules.getRowCount() - 1];\r
+        jTableFpdModules.changeSelection(viewIndex, 0, false, false);\r
+\r
+    }\r
 \r
     /**\r
      * This method initializes jButtonAddModule        \r
@@ -339,105 +455,7 @@ public class FpdFrameworkModules extends IInternalFrame {
 \r
                     TableSorter sorter = (TableSorter) jTableAllModules.getModel();\r
                     selectedRow = sorter.getModelRowIndex(selectedRow);\r
-                    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
-                    if (vArchs == null) {\r
-                        JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file.");\r
-                        return;\r
-                    }\r
-\r
-                    String archsAdded = "";\r
-                    String mg = mi.getGuid();\r
-                    String mv = mi.getVersion();\r
-                    String pg = mi.getPackageId().getGuid();\r
-                    String pv = mi.getPackageId().getVersion();\r
-                    String mType = SurfaceAreaQuery.getModuleType(mi);\r
-\r
-                    ArrayList<String> al = fpdMsa.get(mg + mv + pg + pv);\r
-                    if (al == null) {\r
-                        //\r
-                        // if existing ModuleSA does not specify version info.\r
-                        //\r
-                        al = fpdMsa.get(mg + "null" + pg + "null");\r
-                        if (al == null) {\r
-                            al = fpdMsa.get(mg + "null" + pg + pv);\r
-                            if (al == null){\r
-                                al = fpdMsa.get(mg + mv + pg + "null");\r
-                                if (al == null) {\r
-                                    al = new ArrayList<String>();\r
-                                    fpdMsa.put(mg + mv + pg + pv, al);    \r
-                                }\r
-                            }\r
-                        }\r
-                    }\r
-                    //\r
-                    // filter from module SupArchs what archs has been added.\r
-                    //\r
-                    for (int i = 0; i < al.size(); ++i) {\r
-                        vArchs.remove(al.get(i));\r
-                    }\r
-                    //\r
-                    // check whether archs conform to SupArch of platform.\r
-                    //\r
-                    Vector<Object> platformSupArch = new Vector<Object>();\r
-                    ffc.getPlatformDefsSupportedArchs(platformSupArch);\r
-                    vArchs.retainAll(platformSupArch);\r
-                    //\r
-                    // Archs this Module supported have already been added.\r
-                    //\r
-                    if (vArchs.size() == 0) {\r
-                        JOptionPane.showMessageDialog(frame, "This Module has already been added.");\r
-                        return;\r
-                    }\r
-                    //ToDo put Arch instead of null\r
-                    boolean errorOccurred = false;\r
-                    for (int i = 0; i < vArchs.size(); ++i) {\r
-                        String arch = vArchs.get(i);\r
-                        al.add(arch);\r
-                        archsAdded += arch + " ";\r
-                        String[] row = { "", "", "", "", "", "", "" };\r
-\r
-                        if (mi != null) {\r
-                            row[modNameColForFpdModTable] = mi.getName();\r
-                            row[pkgNameColForFpdModTable] = mi.getPackageId().getName();\r
-                            row[pathColForFpdModTable] = path;\r
-                            row[archColForFpdModTable] = arch;\r
-                            row[pkgVerColForFpdModTable] = pv;\r
-                            row[modVerColForFpdModTable] = mv;\r
-                            row[typeColForFpdModTable] = mType;\r
-\r
-                        }\r
-                        modelFpdModules.addRow(row);\r
-\r
-                        docConsole.setSaved(false);\r
-                        try {\r
-                            //ToDo : specify archs need to add.\r
-                            ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null);\r
-                        } catch (Exception exception) {\r
-                            JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch\r
-                                                                 + ": " + exception.getMessage());\r
-                            errorOccurred = true;\r
-                        }\r
-                    }\r
-\r
-                    String s = "This Module with Architecture " + archsAdded;\r
-                    if (errorOccurred) {\r
-                        s += " was added with Error. Platform may NOT Build.";\r
-                    } else {\r
-                        s += " was added Successfully.";\r
-                    }\r
-                    JOptionPane.showMessageDialog(frame, s);\r
-                    TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel();\r
-                    int viewIndex = sorterFpdModules.getViewIndexArray()[modelFpdModules.getRowCount() - 1];\r
-                    jTableFpdModules.changeSelection(viewIndex, 0, false, false);\r
+                    addModuleIntoPlatform (selectedRow);    \r
                 }\r
             });\r
         }\r
@@ -530,6 +548,18 @@ public class FpdFrameworkModules extends IInternalFrame {
             jTableFpdModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
             jTableFpdModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);\r
             \r
+            jTableFpdModules.addMouseListener(new java.awt.event.MouseAdapter() {\r
+                public void mouseClicked(java.awt.event.MouseEvent e) {\r
+                    if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {\r
+                        java.awt.Point p = e.getPoint();\r
+                        int rowIndex = jTableFpdModules.rowAtPoint(p);\r
+                        TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
+                        rowIndex = sorter.getModelRowIndex(rowIndex);\r
+                        showSettingsDlg (rowIndex);\r
+                    }\r
+                }\r
+            });\r
+            \r
             jTableFpdModules.getModel().addTableModelListener(this);\r
         }\r
         return jTableFpdModules;\r
@@ -550,6 +580,32 @@ public class FpdFrameworkModules extends IInternalFrame {
             docConsole.setSaved(false);\r
         }\r
     }\r
+    \r
+    private void showSettingsDlg (int row) {\r
+        try {\r
+            if (ffc.adjustPcd(row)) {\r
+                docConsole.setSaved(false);\r
+            }\r
+        }\r
+        catch (Exception exp) {\r
+            JOptionPane.showMessageDialog(frame, exp.getMessage());\r
+            return;\r
+        }\r
+        \r
+        if (settingDlg == null) {\r
+            settingDlg = new FpdModuleSA(ffc);\r
+        }\r
+\r
+        String[] sa = new String[5];\r
+        ffc.getFrameworkModuleInfo(row, sa);\r
+        String mg = sa[ffcModGuid];\r
+        String mv = sa[ffcModVer];\r
+        String pg = sa[ffcPkgGuid];\r
+        String pv = sa[ffcPkgVer];\r
+        String arch = sa[ffcModArch];\r
+        settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, row, docConsole);\r
+        settingDlg.setVisible(true);\r
+    }\r
     /**\r
      * This method initializes jButtonSettings\r
      *         \r
@@ -569,29 +625,7 @@ public class FpdFrameworkModules extends IInternalFrame {
 \r
                     TableSorter sorter = (TableSorter) jTableFpdModules.getModel();\r
                     selectedRow = sorter.getModelRowIndex(selectedRow);\r
-                    try {\r
-                        if (ffc.adjustPcd(selectedRow)) {\r
-                            docConsole.setSaved(false);\r
-                        }\r
-                    }\r
-                    catch (Exception exp) {\r
-                        JOptionPane.showMessageDialog(frame, exp.getMessage());\r
-                        return;\r
-                    }\r
-                    \r
-                    if (settingDlg == null) {\r
-                        settingDlg = new FpdModuleSA(ffc);\r
-                    }\r
-\r
-                    String[] sa = new String[5];\r
-                    ffc.getFrameworkModuleInfo(selectedRow, sa);\r
-                    String mg = sa[ffcModGuid];\r
-                    String mv = sa[ffcModVer];\r
-                    String pg = sa[ffcPkgGuid];\r
-                    String pv = sa[ffcPkgVer];\r
-                    String arch = sa[ffcModArch];\r
-                    settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, selectedRow, docConsole);\r
-                    settingDlg.setVisible(true);\r
+                    showSettingsDlg (selectedRow);\r
                 }\r
             });\r
         }\r
@@ -626,6 +660,18 @@ public class FpdFrameworkModules extends IInternalFrame {
                     String pg = sa[ffcPkgGuid];\r
                     String pv = sa[ffcPkgVer];\r
                     String arch = sa[ffcModArch];\r
+                    //\r
+                    // sync. module order list in BuildOptions-UserExtensions.\r
+                    //\r
+                    String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r
+                    String fvBindings = ffc.getFvBinding(moduleKey);\r
+                    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
+                        }\r
+                    }\r
+                    \r
                     ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch);\r
                     if (mi != null) {\r
                         mv = mi.getVersion();\r