Provide UI for generating Apriori file of PEI or DXE phase. The module order information are put into BuildOptions->UserExtensions with UserId as "APRIORI" and Identifier as "0" for PEI phase and "1" for DXE phase. Build tools will use these UserExtensions information to produce the Apriori files that will be placed into each FV image.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1912 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-11-08 02:59:31 +00:00
parent 15d449ba23
commit 99125b466d
5 changed files with 925 additions and 677 deletions

View File

@ -1800,15 +1800,15 @@ public class FpdFileContents {
return fpdBuildOpts;
}
public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {
public void genBuildOptionsUserExtensions(String fvName, String userId, String id, String outputFileName, Vector<String[]> includeModules) {
QName elementFvName = new QName (xmlNs, "FvName");
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName elementInfFileName = new QName(xmlNs, "InfFileName");
QName elementModule = new QName(xmlNs, "Module");
UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();
userExts.setUserID("IMAGES");
userExts.setIdentifier(new BigInteger("1"));
userExts.setUserID(userId);
userExts.setIdentifier(new BigInteger(id));
XmlCursor cursor = userExts.newCursor();
cursor.toEndToken();
@ -1817,7 +1817,7 @@ public class FpdFileContents {
cursor.toNextToken();
cursor.beginElement(elementInfFileName);
cursor.insertChars(fvName + ".inf");
cursor.insertChars(outputFileName);
cursor.toNextToken();
cursor.beginElement(elementIncludeModules);
@ -1839,15 +1839,19 @@ public class FpdFileContents {
cursor.dispose();
}
public int getUserExtsIncModCount (String fvName) {
public int getUserExtsIncModCount (String fvName, String userId, int id) {
if (getfpdBuildOpts().getUserExtensionsList() == null) {
return -1;
}
ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
while (li.hasNext()) {
UserExtensionsDocument.UserExtensions ues = li.next();
if (!ues.getUserID().equals("IMAGES")) {
if (!ues.getUserID().equals(userId)) {
continue;
}
if (ues.getIdentifier() == null || ues.getIdentifier().intValue() != id) {
continue;
}
XmlCursor cursor = ues.newCursor();
@ -1869,14 +1873,15 @@ public class FpdFileContents {
return -1;
}
public void getUserExtsIncMods(String fvName, String[][] saa) {
public void getUserExtsIncMods(String fvName, String userId, int id, String[][] saa) {
if (getfpdBuildOpts().getUserExtensionsList() == null) {
return;
}
XmlCursor cursor = getfpdBuildOpts().newCursor();
QName elementUserExts = new QName (xmlNs, "UserExtensions");
QName attribUserId = new QName ("UserID");
QName attribId = new QName ("Identifier");
QName elementFvName = new QName (xmlNs, "FvName");
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName attribModuleGuid = new QName("ModuleGuid");
@ -1888,7 +1893,7 @@ public class FpdFileContents {
if (cursor.toChild(elementUserExts)) {
do {
cursor.push();
if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {
if (cursor.getAttributeText(attribUserId).equals(userId) && cursor.getAttributeText(attribId).equals(id+"")) {
cursor.toChild(elementFvName);
String elementName = cursor.getTextValue();
if (elementName.equals(fvName)) {
@ -1935,15 +1940,18 @@ public class FpdFileContents {
}
public void removeBuildOptionsUserExtensions (String fvName) {
public void removeBuildOptionsUserExtensions (String fvName, String userId, int id) {
if (getfpdBuildOpts().getUserExtensionsList() == null) {
return;
}
ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
while (li.hasNext()) {
UserExtensionsDocument.UserExtensions ues = li.next();
if (!ues.getUserID().equals("IMAGES")) {
if (!ues.getUserID().equals(userId)) {
continue;
}
if (ues.getIdentifier()== null || ues.getIdentifier().intValue() != id) {
continue;
}
XmlCursor cursor = ues.newCursor();
@ -1974,13 +1982,13 @@ public class FpdFileContents {
return false;
}
public boolean moduleInBuildOptionsUserExtensions (String fvName, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) {
public boolean moduleInBuildOptionsUserExtensions (String fvName, String userId, int id, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) {
boolean inList = false;
if (getUserExtsIncModCount(fvName) > 0) {
if (getUserExtsIncModCount(fvName, userId, id) > 0) {
XmlCursor cursor = getfpdBuildOpts().newCursor();
QName elementUserExts = new QName (xmlNs, "UserExtensions");
QName attribUserId = new QName ("UserID");
QName attribId = new QName ("Identifier");
QName elementFvName = new QName (xmlNs, "FvName");
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName attribModuleGuid = new QName("ModuleGuid");
@ -1992,7 +2000,7 @@ public class FpdFileContents {
if (cursor.toChild(elementUserExts)) {
do {
cursor.push();
if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {
if (cursor.getAttributeText(attribUserId).equals(userId) && cursor.getAttributeText(attribId).equals(id+"")) {
cursor.toChild(elementFvName);
String elementName = cursor.getTextValue();
if (elementName.equals(fvName)) {
@ -2035,21 +2043,21 @@ public class FpdFileContents {
return inList;
}
public void removeModuleInBuildOptionsUserExtensions (String fvName, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) {
public void removeModuleInBuildOptionsUserExtensions (String fvName, String userId, int id, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) {
//
// if there is only one module before remove operation, the whole user extension should be removed.
//
int moduleAmount = getUserExtsIncModCount(fvName);
int moduleAmount = getUserExtsIncModCount(fvName, userId, id);
if (moduleAmount == 1) {
removeBuildOptionsUserExtensions(fvName);
removeBuildOptionsUserExtensions(fvName, userId, id);
return;
}
if (moduleAmount > 1) {
XmlCursor cursor = getfpdBuildOpts().newCursor();
QName elementUserExts = new QName (xmlNs, "UserExtensions");
QName attribUserId = new QName ("UserID");
QName attribId = new QName ("Identifier");
QName elementFvName = new QName (xmlNs, "FvName");
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName attribModuleGuid = new QName("ModuleGuid");
@ -2061,7 +2069,7 @@ public class FpdFileContents {
if (cursor.toChild(elementUserExts)) {
do {
cursor.push();
if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {
if (cursor.getAttributeText(attribUserId).equals(userId) && cursor.getAttributeText(attribId).equals(id+"")) {
cursor.toChild(elementFvName);
String elementName = cursor.getTextValue();
if (elementName.equals(fvName)) {
@ -2102,16 +2110,20 @@ public class FpdFileContents {
}
}
public void addModuleIntoBuildOptionsUserExtensions (String fvName, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) {
if (moduleInBuildOptionsUserExtensions (fvName, moduleGuid, moduleVersion, packageGuid, packageVersion, arch)) {
public void addModuleIntoBuildOptionsUserExtensions (String fvName, String userId, int id, String moduleGuid, String moduleVersion, String packageGuid, String packageVersion, String arch) {
if (moduleInBuildOptionsUserExtensions (fvName, userId, id, moduleGuid, moduleVersion, packageGuid, packageVersion, arch)) {
return;
}
ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();
QName elementIncludeModules = new QName(xmlNs, "IncludeModules");
QName elementModule = new QName(xmlNs, "Module");
while (li.hasNext()) {
UserExtensionsDocument.UserExtensions ues = li.next();
if (!ues.getUserID().equals("IMAGES")) {
if (!ues.getUserID().equals(userId)) {
continue;
}
if (ues.getIdentifier() == null || ues.getIdentifier().intValue() != id) {
continue;
}
XmlCursor cursor = ues.newCursor();

View File

@ -40,6 +40,7 @@ import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
@ -188,6 +189,8 @@ public class FpdFrameworkModules extends IInternalFrame {
private final int typeMinWidth = 100;
private final int typeMaxWidth = 155;
private JButton jButtonApriori = null;
/**
* This method initializes jSplitPane
@ -526,6 +529,7 @@ public class FpdFrameworkModules extends IInternalFrame {
jPanelBottomSouth.setLayout(flowLayout1);
jPanelBottomSouth.add(getJButtonSettings(), null);
jPanelBottomSouth.add(getJButtonRemoveModule(), null);
jPanelBottomSouth.add(getJButtonApriori(), null);
}
return jPanelBottomSouth;
}
@ -751,7 +755,7 @@ public class FpdFrameworkModules extends IInternalFrame {
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);
ffc.removeModuleInBuildOptionsUserExtensions(fvArray[i].trim(), "IMAGES", 1, mg, mv, pg, pv, arch);
}
}
@ -795,6 +799,29 @@ public class FpdFrameworkModules extends IInternalFrame {
return jButtonRemoveModule;
}
/**
* This method initializes jButtonApriori
*
* @return javax.swing.JButton
*/
private JButton getJButtonApriori() {
if (jButtonApriori == null) {
jButtonApriori = new JButton();
jButtonApriori.setText("Apriori Files");
FontMetrics fm = jButtonApriori.getFontMetrics(jButtonApriori.getFont());
int buttonWidth = fm.stringWidth(jButtonApriori.getText()) + 40;
if (jButtonRemoveModule.getWidth() > buttonWidth) {
buttonWidth = jButtonRemoveModule.getWidth();
}
jButtonApriori.setPreferredSize(new Dimension (buttonWidth, 20));
jButtonApriori.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent arg0) {
new GenAprioriFileDialog(ffc, docConsole).setVisible(true);
}});
}
return jButtonApriori;
}
/**
*
* @param args

View File

@ -1331,7 +1331,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
//
oldFvList.removeAll(newFvList);
for (int j = 0; j < oldFvList.size(); ++j) {
ffc.removeModuleInBuildOptionsUserExtensions(oldFvList.get(j), moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
ffc.removeModuleInBuildOptionsUserExtensions(oldFvList.get(j), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
}
//
// add module to Fvs that were not in oldFvList.
@ -1339,7 +1339,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
oldFvList = getVectorFromString (originalFvBinding);
newFvList.removeAll(oldFvList);
for (int i = 0; i < newFvList.size(); ++i) {
ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]);
}
docConsole.setSaved(false);
}

View File

@ -0,0 +1,265 @@
/**
*
*/
package org.tianocore.frameworkwizard.platform.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JPanel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTabbedPane;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
/**
* @author jlin16
*
*/
public class GenAprioriFileDialog extends JDialog implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 3627991301208644354L;
private JPanel jContentPane = null;
private JPanel jPanelN = null;
private JLabel jLabelFvName = null;
private JComboBox jComboBoxFvNames = null;
private JTabbedPane jTabbedPane = null;
private FpdFileContents ffc = null;
private OpeningPlatformType docConsole = null;
/**
* This is the default constructor
*/
public GenAprioriFileDialog(FpdFileContents inputFfc, OpeningPlatformType dc) {
super();
ffc = inputFfc;
docConsole = dc;
initialize();
}
/**
* This method initializes this
*
* @return void
*/
private void initialize() {
this.setSize(670, 670);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
this.setTitle("Apriori Files");
this.setContentPane(getJContentPane());
this.setResizable(false);
this.setModal(true);
String fvName = jComboBoxFvNames.getSelectedItem()+"";
if (fvName.length() > 0) {
jTabbedPane.removeAll();
AprioriModuleOrderPane peiPane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, true);
peiPane.showModulesInFv(fvName);
peiPane.showAllModulesInPlatform();
jTabbedPane.addTab("PEIMs", peiPane);
AprioriModuleOrderPane dxePane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, false);
dxePane.showModulesInFv(fvName);
dxePane.showAllModulesInPlatform();
jTabbedPane.addTab("DXE Drivers", dxePane);
}
this.centerWindow();
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJPanelN(), java.awt.BorderLayout.NORTH);
jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
}
return jContentPane;
}
public void actionPerformed(ActionEvent arg0) {
// TODO Auto-generated method stub
if (arg0.getActionCommand().equals("ModuleOrderPaneOk")) {
docConsole.setSaved(false);
return;
}
if (arg0.getActionCommand().equals("ModuleOrderPaneCancel")) {
this.dispose();
}
}
/**
Start the window at the center of screen
**/
protected void centerWindow(int intWidth, int intHeight) {
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);
}
/**
Start the window at the center of screen
**/
protected void centerWindow() {
centerWindow(this.getSize().width, this.getSize().height);
}
/**
* This method initializes jPanelN
*
* @return javax.swing.JPanel
*/
private JPanel getJPanelN() {
if (jPanelN == null) {
jLabelFvName = new JLabel();
jLabelFvName.setText("FV Name");
jPanelN = new JPanel();
jPanelN.add(jLabelFvName, null);
jPanelN.add(getJComboBoxFvNames(), null);
}
return jPanelN;
}
/**
* This method initializes jComboBoxFvNames
*
* @return javax.swing.JComboBox
*/
private JComboBox getJComboBoxFvNames() {
if (jComboBoxFvNames == null) {
jComboBoxFvNames = new JComboBox();
jComboBoxFvNames.setPreferredSize(new java.awt.Dimension(200,20));
Vector<String> vFvNames = new Vector<String>();
ffc.getFvImagesFvImageFvImageNames(vFvNames);
for (int i = 0; i < vFvNames.size(); ++i) {
jComboBoxFvNames.addItem(vFvNames.get(i));
}
// if (jComboBoxFvNames.getItemCount() > 0) {
// jComboBoxFvNames.setSelectedIndex(0);
//
// }
jComboBoxFvNames.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
String fvName = jComboBoxFvNames.getSelectedItem()+"";
if (fvName.length() > 0) {
jTabbedPane.removeAll();
AprioriModuleOrderPane peiPane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, true);
peiPane.showModulesInFv(fvName);
peiPane.showAllModulesInPlatform();
jTabbedPane.addTab("PEIMs", peiPane);
AprioriModuleOrderPane dxePane = new AprioriModuleOrderPane(fvName, "", GenAprioriFileDialog.this, false);
dxePane.showModulesInFv(fvName);
dxePane.showAllModulesInPlatform();
jTabbedPane.addTab("DXE Drivers", dxePane);
}
}
});
}
return jComboBoxFvNames;
}
/**
* This method initializes jTabbedPane
*
* @return javax.swing.JTabbedPane
*/
private JTabbedPane getJTabbedPane() {
if (jTabbedPane == null) {
jTabbedPane = new JTabbedPane();
}
return jTabbedPane;
}
private class AprioriModuleOrderPane extends ModuleOrderPane {
/**
*
*/
private static final long serialVersionUID = -7952853414833230546L;
private boolean forPEI = false;
private String fvName = null;
AprioriModuleOrderPane (String fvName, String file, ActionListener action, boolean b) {
super(fvName, file, ffc, action);
this.fvName = fvName;
forPEI = b;
getJTableModInFv().getColumnModel().getColumn(0).setHeaderValue("Modules in Apriori File");
getJButtonOk().setText("Save");
getJButtonCancel().setText("Close");
}
public void showModulesInFv (String fvName) {
int id = 1;
if (forPEI) {
id = 0;
}
int size = ffc.getUserExtsIncModCount(fvName, "APRIORI", id);
if (size != -1) {
String[][] saa = new String[size][5];
ffc.getUserExtsIncMods(fvName, "APRIORI", id, saa);
for (int i = 0; i < size; ++i) {
String moduleKey = saa[i][0] + " " + saa[i][1] + " " + saa[i][2] + " " + saa[i][3];
ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
String name = "N/A";
if (mi != null) {
name = mi.getName();
}
String[] row = { name, saa[i][0] , saa[i][1], saa[i][2] , saa[i][3], saa[i][4] };
getModInFvTableModel().addRow(row);
}
}
}
public void actionPerformed(ActionEvent arg0) {
if (arg0.getActionCommand().equals("ModuleOrderPaneOk")) {
int id = 1;
if (forPEI) {
id = 0;
}
Vector<String[]> vModInFv = new Vector<String[]>();
for (int i = 0; i < getJTableModInFv().getRowCount(); ++i) {
String moduleName = getModInFvTableModel().getValueAt(i, 0)+"";
if (moduleName.length() == 0 || moduleName.equals("N/A")) {
continue;
}
String mg = getModInFvTableModel().getValueAt(i, 1)+"";
String mv = getModInFvTableModel().getValueAt(i, 2)+"";
String pg = getModInFvTableModel().getValueAt(i, 3)+"";
String pv = getModInFvTableModel().getValueAt(i, 4)+"";
String arch = getModInFvTableModel().getValueAt(i, 5)+"";
String[] sa = { mg, mv, pg, pv, arch};
vModInFv.add(sa);
}
ffc.removeBuildOptionsUserExtensions(fvName, "APRIORI", id);
ffc.genBuildOptionsUserExtensions(fvName, "APRIORI", id+"", "", vModInFv);
}
}
}
} // @jve:decl-index=0:visual-constraint="10,10"