X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdFrameworkModules.java;h=214c56b1e62f8474587804a9642f7abb3da270b8;hb=9babb67e6845c6a0722858b6059471a096f47a33;hp=6ba80c42fe43b0421b65ea99262195d316329f42;hpb=e7cc0547dd6a0a4aa2d9e2f31bc9b22643e8aa3a;p=mirror_edk2.git diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java index 6ba80c42fe..214c56b1e6 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -30,19 +30,20 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableModel; import org.tianocore.PlatformSurfaceAreaDocument; +import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; import org.tianocore.frameworkwizard.common.ui.IInternalFrame; +import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery; import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile; -import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification; -import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification; +import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; import java.awt.FlowLayout; -import java.io.File; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.Set; import java.util.Vector; public class FpdFrameworkModules extends IInternalFrame { @@ -52,6 +53,12 @@ public class FpdFrameworkModules extends IInternalFrame { */ private static final long serialVersionUID = 1L; + private static final int timeToWait = 2000; + + private long savedMs = 0; + + String searchField = ""; + public static final int forceDbgColForFpdModTable = 7; static JFrame frame; @@ -208,7 +215,7 @@ public class FpdFrameworkModules extends IInternalFrame { private JPanel getJPanelTop() { if (jPanelTop == null) { jLabel = new JLabel(); - jLabel.setText("Modules in Workspace"); + jLabel.setText(" Modules in Workspace"); jPanelTop = new JPanel(); jPanelTop.setLayout(new BorderLayout()); jPanelTop.add(jLabel, java.awt.BorderLayout.NORTH); @@ -228,7 +235,7 @@ public class FpdFrameworkModules extends IInternalFrame { private JPanel getJPanelBottom() { if (jPanelBottom == null) { jLabelModulesAdded = new JLabel(); - jLabelModulesAdded.setText("Modules Added"); + jLabelModulesAdded.setText(" Modules Added into Platform"); jPanelBottom = new JPanel(); jPanelBottom.setLayout(new BorderLayout()); jPanelBottom.add(jLabelModulesAdded, java.awt.BorderLayout.NORTH); @@ -298,10 +305,62 @@ public class FpdFrameworkModules extends IInternalFrame { jTableAllModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableAllModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jTableAllModules.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + java.awt.Point p = e.getPoint(); + int rowIndex = jTableAllModules.rowAtPoint(p); + TableSorter sorter = (TableSorter) jTableAllModules.getModel(); + rowIndex = sorter.getModelRowIndex(rowIndex); + addModuleIntoPlatform (rowIndex); + } + } + }); + jTableAllModules.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int selectedRow = jTableAllModules.getSelectedRow(); + if (selectedRow < 0) { + return; + } + TableSorter sorter = (TableSorter) jTableAllModules.getModel(); + selectedRow = sorter.getModelRowIndex(selectedRow); + addModuleIntoPlatform (selectedRow); + } + } + }); + + jTableAllModules.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent e) { + if (System.currentTimeMillis() - savedMs < timeToWait) { + searchField += e.getKeyChar(); + } + else { + searchField = "" + e.getKeyChar(); + } + + int viewIndex = gotoFoundRow (searchField, jTableAllModules); + if (viewIndex >= 0){ + jTableAllModules.changeSelection(viewIndex, 0, false, false); + } + savedMs = System.currentTimeMillis(); + } + }); + + } return jTableAllModules; } + + private int gotoFoundRow (String s, JTable model) { + for (int i = 0; i < model.getRowCount(); ++i) { + if (model.getValueAt(i, 0) != null && model.getValueAt(i, 0).toString().regionMatches(true, 0, s, 0, s.length())) { + return i; + } + } + return -1; + } /** * This method initializes jPanelTopSouth @@ -320,6 +379,109 @@ public class FpdFrameworkModules extends IInternalFrame { } return jPanelTopSouth; } + + private void addModuleIntoPlatform (int selectedRow) { + String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + ""; + ModuleIdentification mi = miList.get(selectedRow); + Vector vArchs = null; + try { + vArchs = WorkspaceProfile.getModuleSupArchs(mi); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getMessage()); + } + + if (vArchs == null) { + JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file."); + return; + } + + String archsAdded = ""; + String mg = mi.getGuid(); + String mv = mi.getVersion(); + String pg = mi.getPackageId().getGuid(); + String pv = mi.getPackageId().getVersion(); + String mType = SurfaceAreaQuery.getModuleType(mi); + + ArrayList al = fpdMsa.get(mg + mv + pg + pv); + if (al == null) { + // + // if existing ModuleSA does not specify version info. + // + al = fpdMsa.get(mg + "null" + pg + "null"); + if (al == null) { + al = fpdMsa.get(mg + "null" + pg + pv); + if (al == null){ + al = fpdMsa.get(mg + mv + pg + "null"); + if (al == null) { + al = new ArrayList(); + fpdMsa.put(mg + mv + pg + pv, al); + } + } + } + } + // + // filter from module SupArchs what archs has been added. + // + for (int i = 0; i < al.size(); ++i) { + vArchs.remove(al.get(i)); + } + // + // check whether archs conform to SupArch of platform. + // + Vector platformSupArch = new Vector(); + ffc.getPlatformDefsSupportedArchs(platformSupArch); + vArchs.retainAll(platformSupArch); + // + // Archs this Module supported have already been added. + // + if (vArchs.size() == 0) { + JOptionPane.showMessageDialog(frame, "This Module has already been added."); + return; + } + //ToDo put Arch instead of null + boolean errorOccurred = false; + for (int i = 0; i < vArchs.size(); ++i) { + String arch = vArchs.get(i); + al.add(arch); + archsAdded += arch + " "; + String[] row = { "", "", "", "", "", "", "" }; + + if (mi != null) { + row[modNameColForFpdModTable] = mi.getName(); + row[pkgNameColForFpdModTable] = mi.getPackageId().getName(); + row[pathColForFpdModTable] = path; + row[archColForFpdModTable] = arch; + row[pkgVerColForFpdModTable] = pv; + row[modVerColForFpdModTable] = mv; + row[typeColForFpdModTable] = mType; + + } + modelFpdModules.addRow(row); + + docConsole.setSaved(false); + try { + //ToDo : specify archs need to add. + ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null); + } catch (Exception exception) { + JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch + + ": " + exception.getMessage()); + errorOccurred = true; + } + } + + String s = "This Module with Architecture " + archsAdded; + if (errorOccurred) { + s += " was added with Error. Platform may NOT Build."; + } else { + s += " was added Successfully."; + } + JOptionPane.showMessageDialog(frame, s); + TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel(); + int viewIndex = sorterFpdModules.getViewIndexArray()[modelFpdModules.getRowCount() - 1]; + jTableFpdModules.changeSelection(viewIndex, 0, false, false); + + } /** * This method initializes jButtonAddModule @@ -340,105 +502,7 @@ public class FpdFrameworkModules extends IInternalFrame { TableSorter sorter = (TableSorter) jTableAllModules.getModel(); selectedRow = sorter.getModelRowIndex(selectedRow); - String path = modelAllModules.getValueAt(selectedRow, pathColForAllModTable) + ""; - ModuleIdentification mi = miList.get(selectedRow); - Vector vArchs = null; - try { - vArchs = WorkspaceProfile.getModuleSupArchs(mi); - } - catch (Exception exp) { - JOptionPane.showMessageDialog(frame, exp.getMessage()); - } - - if (vArchs == null) { - JOptionPane.showMessageDialog(frame, "No Supported Architectures specified in MSA file."); - return; - } - - String archsAdded = ""; - String mg = mi.getGuid(); - String mv = mi.getVersion(); - String pg = mi.getPackage().getGuid(); - String pv = mi.getPackage().getVersion(); - String mType = mi.getModuleType(); - - ArrayList al = fpdMsa.get(mg + mv + pg + pv); - if (al == null) { - // - // if existing ModuleSA does not specify version info. - // - al = fpdMsa.get(mg + "null" + pg + "null"); - if (al == null) { - al = fpdMsa.get(mg + "null" + pg + pv); - if (al == null){ - al = fpdMsa.get(mg + mv + pg + "null"); - if (al == null) { - al = new ArrayList(); - fpdMsa.put(mg + mv + pg + pv, al); - } - } - } - } - // - // filter from module SupArchs what archs has been added. - // - for (int i = 0; i < al.size(); ++i) { - vArchs.remove(al.get(i)); - } - // - // check whether archs conform to SupArch of platform. - // - Vector platformSupArch = new Vector(); - ffc.getPlatformDefsSupportedArchs(platformSupArch); - vArchs.retainAll(platformSupArch); - // - // Archs this Module supported have already been added. - // - if (vArchs.size() == 0) { - JOptionPane.showMessageDialog(frame, "This Module has already been added."); - return; - } - //ToDo put Arch instead of null - boolean errorOccurred = false; - for (int i = 0; i < vArchs.size(); ++i) { - String arch = vArchs.get(i); - al.add(arch); - archsAdded += arch + " "; - String[] row = { "", "", "", "", "", "", "" }; - - if (mi != null) { - row[modNameColForFpdModTable] = mi.getName(); - row[pkgNameColForFpdModTable] = mi.getPackage().getName(); - row[pathColForFpdModTable] = path; - row[archColForFpdModTable] = arch; - row[pkgVerColForFpdModTable] = pv; - row[modVerColForFpdModTable] = mv; - row[typeColForFpdModTable] = mType; - - } - modelFpdModules.addRow(row); - - docConsole.setSaved(false); - try { - //ToDo : specify archs need to add. - ffc.addFrameworkModulesPcdBuildDefs(mi, arch, null); - } catch (Exception exception) { - JOptionPane.showMessageDialog(frame, "Adding " + row[modNameColForFpdModTable] + " with Supporting Architectures: " + arch - + ": " + exception.getMessage()); - errorOccurred = true; - } - } - - String s = "This Module with Architecture " + archsAdded; - if (errorOccurred) { - s += " was added with Error. Platform may NOT Build."; - } else { - s += " was added Successfully."; - } - JOptionPane.showMessageDialog(frame, s); - TableSorter sorterFpdModules = (TableSorter)jTableFpdModules.getModel(); - int viewIndex = sorterFpdModules.getViewIndexArray()[modelFpdModules.getRowCount() - 1]; - jTableFpdModules.changeSelection(viewIndex, 0, false, false); + addModuleIntoPlatform (selectedRow); } }); } @@ -531,6 +595,50 @@ public class FpdFrameworkModules extends IInternalFrame { jTableFpdModules.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableFpdModules.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); + jTableFpdModules.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent e) { + if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { + java.awt.Point p = e.getPoint(); + int rowIndex = jTableFpdModules.rowAtPoint(p); + TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); + rowIndex = sorter.getModelRowIndex(rowIndex); + showSettingsDlg (rowIndex); + } + } + }); + + jTableFpdModules.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER) { + int selectedRow = jTableFpdModules.getSelectedRow(); + if (selectedRow < 0) { + return; + } + TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); + selectedRow = sorter.getModelRowIndex(selectedRow); + showSettingsDlg (selectedRow); + } + } + }); + + jTableFpdModules.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyTyped(java.awt.event.KeyEvent e) { + + if (System.currentTimeMillis() - savedMs < timeToWait) { + searchField += e.getKeyChar(); + } + else { + searchField = "" + e.getKeyChar(); + } + + int viewIndex = gotoFoundRow (searchField, jTableFpdModules); + if (viewIndex >= 0){ + jTableFpdModules.changeSelection(viewIndex, 0, false, false); + } + savedMs = System.currentTimeMillis(); + } + }); + jTableFpdModules.getModel().addTableModelListener(this); } return jTableFpdModules; @@ -551,6 +659,32 @@ public class FpdFrameworkModules extends IInternalFrame { docConsole.setSaved(false); } } + + private void showSettingsDlg (int row) { + try { + if (ffc.adjustPcd(row)) { + docConsole.setSaved(false); + } + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getMessage()); + return; + } + + if (settingDlg == null) { + settingDlg = new FpdModuleSA(ffc); + } + + String[] sa = new String[5]; + ffc.getFrameworkModuleInfo(row, sa); + String mg = sa[ffcModGuid]; + String mv = sa[ffcModVer]; + String pg = sa[ffcPkgGuid]; + String pv = sa[ffcPkgVer]; + String arch = sa[ffcModArch]; + settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, row, docConsole); + settingDlg.setVisible(true); + } /** * This method initializes jButtonSettings * @@ -570,29 +704,7 @@ public class FpdFrameworkModules extends IInternalFrame { TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); selectedRow = sorter.getModelRowIndex(selectedRow); - try { - if (ffc.adjustPcd(selectedRow)) { - docConsole.setSaved(false); - } - } - catch (Exception exp) { - JOptionPane.showMessageDialog(frame, exp.getMessage()); - return; - } - - if (settingDlg == null) { - settingDlg = new FpdModuleSA(ffc); - } - - String[] sa = new String[5]; - ffc.getFrameworkModuleInfo(selectedRow, sa); - String mg = sa[ffcModGuid]; - String mv = sa[ffcModVer]; - String pg = sa[ffcPkgGuid]; - String pv = sa[ffcPkgVer]; - String arch = sa[ffcModArch]; - settingDlg.setKey(mg + " " + mv + " " + pg + " " + pv + " " + arch, selectedRow, docConsole); - settingDlg.setVisible(true); + showSettingsDlg (selectedRow); } }); } @@ -615,7 +727,7 @@ public class FpdFrameworkModules extends IInternalFrame { if (selectedRow < 0) { return; } - docConsole.setSaved(false); + TableSorter sorter = (TableSorter) jTableFpdModules.getModel(); selectedRow = sorter.getModelRowIndex(selectedRow); @@ -627,23 +739,48 @@ public class FpdFrameworkModules extends IInternalFrame { String pg = sa[ffcPkgGuid]; String pv = sa[ffcPkgVer]; String arch = sa[ffcModArch]; + // + // sync. module order list in BuildOptions-UserExtensions. + // + String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch; + String fvBindings = ffc.getFvBinding(moduleKey); + if (fvBindings != null) { + String[] fvArray = fvBindings.split(" "); + for (int i = 0; i < fvArray.length; ++i) { + ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), mg, mv, pg, pv, arch); + } + } + ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv + " " + arch); - mv = mi.getVersion(); - pv = mi.getPackage().getVersion(); - modelFpdModules.removeRow(selectedRow); + if (mi != null) { + mv = mi.getVersion(); + pv = mi.getPackageId().getVersion(); + } + + try { + ffc.removeModuleSA(selectedRow); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getCause() + exp.getMessage()); + return; + } + if (arch == null) { // if no arch specified in ModuleSA fpdMsa.remove(mg + mv + pg + pv); } else { ArrayList al = fpdMsa.get(mg + mv + pg + pv); - al.remove(arch); - if (al.size() == 0) { - fpdMsa.remove(mg + mv + pg + pv); + if (al != null) { + al.remove(arch); + if (al.size() == 0) { + fpdMsa.remove(mg + mv + pg + pv); + } } } - - ffc.removeModuleSA(selectedRow); + + modelFpdModules.removeRow(selectedRow); + docConsole.setSaved(false); } }); } @@ -679,12 +816,6 @@ public class FpdFrameworkModules extends IInternalFrame { } private void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) { - try { - WorkspaceProfile.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db", System.getenv("WORKSPACE")); - } - catch(Exception e){ - JOptionPane.showMessageDialog(frame, "Error occurred when getting module data."); - } if (ffc == null) { ffc = new FpdFileContents(fpd); @@ -705,14 +836,12 @@ public class FpdFrameworkModules extends IInternalFrame { if (mi != null) { row[modNameColForFpdModTable] = mi.getName(); row[modVerColForFpdModTable] = mi.getVersion(); - row[typeColForFpdModTable] = mi.getModuleType(); - row[pkgNameColForFpdModTable] = mi.getPackage().getName(); - row[pkgVerColForFpdModTable] = mi.getPackage().getVersion(); + row[typeColForFpdModTable] = SurfaceAreaQuery.getModuleType(mi); + row[pkgNameColForFpdModTable] = mi.getPackageId().getName(); + row[pkgVerColForFpdModTable] = mi.getPackageId().getVersion(); row[archColForFpdModTable] = saa[i][ffcModArch]; try { - row[pathColForFpdModTable] = WorkspaceProfile.getMsaFile(mi).getPath().substring( - System.getenv("WORKSPACE") - .length() + 1); + row[pathColForFpdModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1); } catch (Exception e) { JOptionPane.showMessageDialog(frame, "Show FPD Modules:" + e.getMessage()); } @@ -726,6 +855,13 @@ public class FpdFrameworkModules extends IInternalFrame { } al.add(saa[i][ffcModArch]); } + else { + row[modNameColForFpdModTable] = saa[i][ffcModGuid]; + row[modVerColForFpdModTable] = saa[i][ffcModVer]; + row[pkgNameColForFpdModTable] = saa[i][ffcPkgGuid]; + row[pkgVerColForFpdModTable] = saa[i][ffcPkgVer]; + row[archColForFpdModTable] = saa[i][ffcModArch]; + } row[forceDbgColForFpdModTable] = ffc.getModuleSAForceDebug(i); modelFpdModules.addRow(row); @@ -743,32 +879,26 @@ public class FpdFrameworkModules extends IInternalFrame { if (miList == null) { miList = new ArrayList(); } - Set spi = WorkspaceProfile.getPackageList(); - Iterator ispi = spi.iterator(); - while (ispi.hasNext()) { - PackageIdentification pi = (PackageIdentification) ispi.next(); String[] s = { "", "", "", "", "", "" }; - - Set smi = WorkspaceProfile.getModules(pi); - Iterator ismi = smi.iterator(); + + Iterator ismi = GlobalData.vModuleList.iterator(); while (ismi.hasNext()) { ModuleIdentification mi = (ModuleIdentification) ismi.next(); s[modNameColForAllModTable] = mi.getName(); s[modVerColForAllModTable] = mi.getVersion(); - s[typeColForAllModTable] = mi.getModuleType(); - s[pkgNameColForAllModTable] = pi.getName(); - s[pkgVerColForAllModTable] = pi.getVersion(); + s[typeColForAllModTable] = SurfaceAreaQuery.getModuleType(mi); + s[pkgNameColForAllModTable] = mi.getPackageId().getName(); + s[pkgVerColForAllModTable] = mi.getPackageId().getVersion(); try { - s[pathColForAllModTable] = WorkspaceProfile.getMsaFile(mi).getPath() - .substring(System.getenv("WORKSPACE").length() + 1); + s[pathColForAllModTable] = mi.getPath().substring(System.getenv("WORKSPACE").length() + 1); } catch (Exception e) { JOptionPane.showMessageDialog(frame, "Show All Modules:" + e.getMessage()); } modelAllModules.addRow(s); miList.add(mi); } - } + TableSorter sorter = (TableSorter)jTableAllModules.getModel(); sorter.setSortState(modNameColForAllModTable, TableSorter.ASCENDING);