a. Add support arch. filter for library instance selection in FPD file.

b. add sync. operation for modifying dynamic pcd values to set the new value to all pcd entries in ModuleSA.
c. Make line wrap for SPD, FPD header copyright text area.
d. give warning of default section added when user add new Sections under FPD build options.
e. not generating the empty build targets when user creating a new entry for build options.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1804 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-10-20 17:36:45 +00:00
parent 3fabe9752d
commit 50d4c727a8
8 changed files with 531 additions and 156 deletions

View File

@ -437,6 +437,7 @@ public class SpdHeader extends IInternalFrame {
if (jCopyrightTextArea == null) {
jCopyrightTextArea = new JTextArea();
jCopyrightTextArea.setWrapStyleWord(true);
jCopyrightTextArea.setLineWrap(true);
jCopyrightTextArea.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {

View File

@ -1150,6 +1150,7 @@ public class FpdBuildOptions extends IInternalFrame {
String[] row = { "" };
sectionsTableModel.addRow(row);
ffc.genBuildOptionsFfsSectionsSections(jTableFfs.getSelectedRow(), "");
JOptionPane.showMessageDialog(frame, "Add Default Section Type EFI_SECTION_PE32 into the New Sections Entry.");
}
});
}
@ -1693,9 +1694,9 @@ public class FpdBuildOptions extends IInternalFrame {
jTextFieldOptionContents.getText() };
optionsTableModel.addRow(o);
docConsole.setSaved(false);
ffc.genBuildOptionsOpt(stringToVector(jTextFieldBuildTargets.getText()),
ffc.genBuildOptionsOpt(stringToVector(jTextFieldBuildTargets.getText().trim()),
jTextFieldToolChainFamily.getText(), jTextFieldTagName.getText(),
jTextFieldToolCmd.getText(), stringToVector(s),
jTextFieldToolCmd.getText(), stringToVector(s.trim()),
jTextFieldOptionContents.getText());
}
});
@ -1854,7 +1855,7 @@ public class FpdBuildOptions extends IInternalFrame {
private Vector<Object> stringToVector(String s) {
String[] sArray = s.split(" ");
Vector<Object> v = null;
if (s.length() > 0) {
if (s.length() > 0 && !s.trim().equalsIgnoreCase("")) {
v = new Vector<Object>();
for (int i = 0; i < sArray.length; ++i) {
v.add(sArray[i]);
@ -1883,9 +1884,7 @@ public class FpdBuildOptions extends IInternalFrame {
if (bool[5]) {
s += "PPC ";
}
if (s.equals(" ")) {
s += "IA32";
}
return s.trim();
}

View File

@ -18,12 +18,12 @@ import org.tianocore.frameworkwizard.common.Tools;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import javax.swing.JCheckBox;
import java.awt.FlowLayout;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.GridLayout;
import java.util.ArrayList;
public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
@ -62,6 +62,7 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
private ButtonGroup bg = new ButtonGroup();
private JLabel jLabelPadd = null;
private JLabel jLabelPad1 = null;
private JScrollPane jScrollPane = null;
/**
* This is the default constructor
*/
@ -120,7 +121,6 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJScrollPaneDynPcd(), java.awt.BorderLayout.NORTH);
jContentPane.add(getJPanelSkuInfo(), java.awt.BorderLayout.CENTER);
jContentPane.add(getJPanelDynPcdValue(), java.awt.BorderLayout.SOUTH);
}
return jContentPane;
}
@ -133,7 +133,7 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
private JScrollPane getJScrollPaneDynPcd() {
if (jScrollPaneDynPcd == null) {
jScrollPaneDynPcd = new JScrollPane();
jScrollPaneDynPcd.setPreferredSize(new java.awt.Dimension(100,300));
jScrollPaneDynPcd.setPreferredSize(new java.awt.Dimension(100,250));
jScrollPaneDynPcd.setViewportView(getJTableDynPcd());
}
return jScrollPaneDynPcd;
@ -269,15 +269,17 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
*/
private JPanel getJPanelSkuInfo() {
if (jPanelSkuInfo == null) {
FlowLayout flowLayout = new FlowLayout();
flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
jPanelSkuInfo = new JPanel();
jPanelSkuInfo.setLayout(new BorderLayout());
jPanelSkuInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
jPanelSkuInfo.setLayout(flowLayout);
jPanelSkuInfo.setPreferredSize(new java.awt.Dimension(600,100));
jPanelSkuInfo.add(getJCheckBoxSkuEnable(), null);
jPanelSkuInfo.add(getJScrollPaneSkuInfo(), null);
jPanelSkuInfo.add(getJButtonSkuInfoUpdate(), null);
jPanelSkuInfo.setPreferredSize(new java.awt.Dimension(600,120));
// jPanelSkuInfo.add(getJPanelSkuInfoN(), java.awt.BorderLayout.NORTH);
jPanelSkuInfo.add(getJScrollPane(), java.awt.BorderLayout.NORTH);
jPanelSkuInfo.add(getJScrollPaneSkuInfo(), java.awt.BorderLayout.CENTER);
// jPanelSkuInfo.add(getJPanelDynPcdValue(), java.awt.BorderLayout.SOUTH);
}
return jPanelSkuInfo;
}
@ -313,8 +315,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
GridLayout gridLayout = new GridLayout();
gridLayout.setColumns(5);
gridLayout.setRows(4);
gridLayout.setHgap(5);
gridLayout.setVgap(5);
gridLayout.setHgap(20);
gridLayout.setVgap(20);
jLabelVpdOffset = new JLabel();
jLabelVpdOffset.setPreferredSize(new java.awt.Dimension(80,20));
@ -336,8 +338,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
jLabelVarName.setPreferredSize(new java.awt.Dimension(90,20));
jPanelDynPcdValue = new JPanel();
jPanelDynPcdValue.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
jPanelDynPcdValue.setPreferredSize(new java.awt.Dimension(1000,150));
jPanelDynPcdValue.setLayout(gridLayout);
jPanelDynPcdValue.setPreferredSize(new java.awt.Dimension(600,120));
jPanelDynPcdValue.add(getJRadioButtonHii(), null);
jPanelDynPcdValue.add(jLabelVarName, null);
jPanelDynPcdValue.add(getJTextFieldVarName(), null);
@ -362,6 +364,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
jPanelDynPcdValue.add(jLabelPad1, null);
jPanelDynPcdValue.add(getJRadioButtonDefaultValue(), null);
jPanelDynPcdValue.add(getJTextFieldDefaultValue(), null);
jPanelDynPcdValue.add(getJCheckBoxSkuEnable(), null);
jPanelDynPcdValue.add(getJButtonSkuInfoUpdate(), null);
bg.add(jRadioButtonHii);
bg.add(jRadioButtonVpd);
}
@ -424,7 +428,7 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
private JScrollPane getJScrollPaneSkuInfo() {
if (jScrollPaneSkuInfo == null) {
jScrollPaneSkuInfo = new JScrollPane();
jScrollPaneSkuInfo.setPreferredSize(new java.awt.Dimension(300,80));
jScrollPaneSkuInfo.setPreferredSize(new java.awt.Dimension(300,50));
jScrollPaneSkuInfo.setViewportView(getJTableSkuInfo());
}
return jScrollPaneSkuInfo;
@ -498,6 +502,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
private void updateSkuInfo (int pcdSelected) {
int skuCount = ffc.getDynamicPcdSkuInfoCount(pcdSelected);
String cName = modelPcd.getValueAt(pcdSelected, 0)+"";
String tsGuid = modelPcd.getValueAt(pcdSelected, 2)+"";
String varName = null;
String varGuid = null;
@ -549,12 +555,27 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
ffc.removeDynamicPcdBuildDataSkuInfo(pcdSelected);
if (jRadioButtonHii.isSelected()) {
ffc.genDynamicPcdBuildDataSkuInfo("0", varName, varGuid, varOffset, hiiDefault, null, null, pcdSelected);
ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
for (int i = 0; i < al.size(); ++i) {
String mKey = moduleInfo (al.get(i));
ffc.updatePcdData(mKey, cName, tsGuid, null, null, hiiDefault);
}
}
else if (jRadioButtonVpd.isSelected()){
ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, vpdOffset, null, pcdSelected);
ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
for (int i = 0; i < al.size(); ++i) {
String mKey = moduleInfo (al.get(i));
ffc.updatePcdData(mKey, cName, tsGuid, null, null, vpdOffset);
}
}
else{
ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, null, value, pcdSelected);
ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
for (int i = 0; i < al.size(); ++i) {
String mKey = moduleInfo (al.get(i));
ffc.updatePcdData(mKey, cName, tsGuid, null, null, value);
}
}
}
}
@ -577,6 +598,11 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
}
}
}
private String moduleInfo (String pcdInfo) {
return pcdInfo.substring(0, pcdInfo.lastIndexOf(" "));
}
/**
* This method initializes jTextField
*
@ -681,6 +707,20 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {
return jRadioButtonDefaultValue;
}
/**
* This method initializes jScrollPane
*
* @return javax.swing.JScrollPane
*/
private JScrollPane getJScrollPane() {
if (jScrollPane == null) {
jScrollPane = new JScrollPane();
jScrollPane.setPreferredSize(new java.awt.Dimension(1003,180));
jScrollPane.setViewportView(getJPanelDynPcdValue());
}
return jScrollPane;
}
} // @jve:decl-index=0:visual-constraint="10,10"
class DynPcdTableModel extends DefaultTableModel {

View File

@ -578,12 +578,21 @@ public class FpdFileContents {
//
// change item type while not updating dynPcdData????
//
if (itemType != null) {
pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));
if(pcdData.getDatumType().equals("VOID*")) {
}
if(pcdData.getDatumType().equals("VOID*") && maxSize != null) {
pcdData.setMaxDatumSize(new Integer(maxSize));
}
//
// if value input is null, keep old value untouched.
//
if (value != null) {
pcdData.setValue(value);
defaultPcdValue.put(cName + " " + tsGuid, value);
}
break;
}
}

View File

@ -463,6 +463,7 @@ public class FpdHeader extends IInternalFrame {
if (jCopyrightTextArea == null) {
jCopyrightTextArea = new JTextArea();
jCopyrightTextArea.setWrapStyleWord(true);
jCopyrightTextArea.setLineWrap(true);
jCopyrightTextArea.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {

View File

@ -21,12 +21,14 @@ import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import org.tianocore.frameworkwizard.common.DataValidation;
import org.tianocore.frameworkwizard.common.GlobalData;
import org.tianocore.frameworkwizard.common.IDefaultTableModel;
import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
import org.tianocore.frameworkwizard.platform.ui.global.LibraryClassDescriptor;
import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
@ -93,9 +95,13 @@ public class FpdModuleSA extends JDialog implements ActionListener {
private FpdFileContents ffc = null;
private String moduleKey = null;
private int moduleSaNum = -1;
private HashMap<String, ArrayList<String>> classInstanceMap = null;
private ArrayList<String> classProduced = null;
private HashMap<String, ArrayList<String>> classConsumed = null;
private HashMap<LibraryClassDescriptor, ArrayList<String>> classInstanceMap = null;
//
// map of <{libName, supArch, supMod}, list of Module information>
//
private HashMap<LibraryClassDescriptor, ArrayList<String>> classConsumed = null;
private HashMap<LibraryClassDescriptor, ArrayList<String>> classProduced = null;
private JPanel jPanelModuleSaOpts = null;
private JLabel jLabelFvBinding = null;
private JTextField jTextFieldFvBinding = null;
@ -148,10 +154,19 @@ public class FpdModuleSA extends JDialog implements ActionListener {
this.moduleKey = k;
moduleSaNum = i;
this.docConsole = dc;
classInstanceMap = null;
classProduced = null;
classConsumed = null;
jTabbedPane.setSelectedIndex(0);
initPcdBuildDefinition(i);
ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
int tabIndex = jTabbedPane.indexOfTab("Libraries");
if (mi.isLibrary()) {
jTabbedPane.setEnabledAt(tabIndex, false);
}
else {
jTabbedPane.setEnabledAt(tabIndex, true);
}
}
/**
@ -178,10 +193,14 @@ public class FpdModuleSA extends JDialog implements ActionListener {
}
public void initLibraries(String key) {
try {
//
// display library classes that need to be resolved. also potential instances for them.
//
resolveLibraryInstances(moduleKey);
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, e.getMessage());
}
//
// display lib instances already selected for key
//
@ -191,7 +210,8 @@ public class FpdModuleSA extends JDialog implements ActionListener {
String[][] saa = new String[instanceCount][5];
ffc.getLibraryInstances(key, saa);
for (int i = 0; i < saa.length; ++i) {
ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3]
+ " " + saa[i][4]);
if (mi != null) {
//
// ToDo: verify this instance first.
@ -202,11 +222,16 @@ public class FpdModuleSA extends JDialog implements ActionListener {
//
// re-evaluate lib instance usage when adding a already-selected lib instance.
//
try {
resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
} catch (Exception e) {
JOptionPane.showMessageDialog(frame, e.getMessage());
}
selectedInstancesTableModel.addRow(saa[i]);
}
}
}
showClassToResolved();
}
@ -241,10 +266,66 @@ public class FpdModuleSA extends JDialog implements ActionListener {
}
}
private void resolveLibraryInstances(String key) {
private void filterClassConsumedByArch (Vector<LibraryClassDescriptor> v) {
String[] moduleInfo = moduleKey.split(" ");
Vector<String> vModuleArchs = new Vector<String>();
//
// Skip guid, version information, get archs to check.
//
for (int i = 4; i < moduleInfo.length; ++i) {
vModuleArchs.add(moduleInfo[i]);
}
//
// if module will be built on all platforms, no filter needed for lib classes.
//
if (vModuleArchs.size() == 0) {
return;
}
for (int j = 0; j < v.size(); ++j) {
LibraryClassDescriptor libInfo = v.get(j);
Vector<String> vSupArchs = libInfo.getVectorFromString(libInfo.supArchs);
if (vSupArchs.size() == 0 || (vSupArchs.size() == 1 && vSupArchs.get(0).equalsIgnoreCase(""))) {
//
// update lib info to module archs only.
//
libInfo.supArchs = "";
for (int i = 0; i < vModuleArchs.size(); ++i) {
libInfo.supArchs += vModuleArchs.get(i);
libInfo.supArchs += " ";
}
libInfo.supArchs.trim();
continue;
}
//
// only retain those lib class used by module archs.
//
vSupArchs.retainAll(vModuleArchs);
if (vSupArchs.size() > 0) {
//
// update lib info to reflect which kind of arch need to select instance.
//
libInfo.supArchs = "";
for (int i = 0; i < vSupArchs.size(); ++i) {
libInfo.supArchs += vSupArchs.get(i);
libInfo.supArchs += " ";
}
libInfo.supArchs.trim();
continue;
}
//
// remove this lib definition if it supports no archs module will be built under.
//
v.iterator().remove();
}
}
private void resolveLibraryInstances(String key) throws MultipleInstanceException, NoInstanceException{
ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
PackageIdentification[] depPkgList = null;
try{
//
// Get dependency pkg list into which we will search lib instances.
//
@ -252,13 +333,13 @@ public class FpdModuleSA extends JDialog implements ActionListener {
//
// Get the lib class consumed, produced by this module itself.
//
Vector<String> vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
Vector<LibraryClassDescriptor> vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
filterClassConsumedByArch(vClassConsumed);
if (this.classConsumed == null) {
this.classConsumed = new HashMap<String, ArrayList<String>>();
this.classConsumed = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
}
for(int i = 0; i < vClassConsumed.size(); ++i){
for (int i = 0; i < vClassConsumed.size(); ++i) {
ArrayList<String> consumedBy = this.classConsumed.get(vClassConsumed.get(i));
if (consumedBy == null) {
consumedBy = new ArrayList<String>();
@ -267,45 +348,83 @@ public class FpdModuleSA extends JDialog implements ActionListener {
this.classConsumed.put(vClassConsumed.get(i), consumedBy);
}
Vector<String> vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
Vector<LibraryClassDescriptor> vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
if (this.classProduced == null) {
this.classProduced = new ArrayList<String>();
this.classProduced = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
}
for(int i = 0; i < vClassProduced.size(); ++i){
if (!this.classProduced.contains(vClassProduced.get(i))){
this.classProduced.add(vClassProduced.get(i));
for (int i = 0; i < vClassProduced.size(); ++i) {
ArrayList<String> producedBy = this.classProduced.get(vClassProduced.get(i));
if (producedBy == null) {
producedBy = new ArrayList<String>();
}
//
// class already produced by previous module (lib instance).
/*
if (producedBy.size() == 1) {
String instanceKey = producedBy.get(0);
ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceKey);
throw new MultipleInstanceException (vClassProduced.get(i).className, libMi.getName(), mi.getName());
}
Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if (vClassProduced.get(i).hasInterSectionWith(lcd)) {
ArrayList<String> alreadyProducedBy = this.classProduced.get(lcd);
String instanceKey = alreadyProducedBy.get(0);
ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceKey);
throw new MultipleInstanceException (vClassProduced.get(i).className, libMi.getName(), mi.getName());
}
}
*/
// normal case.
//
producedBy.add(key);
this.classProduced.put(vClassProduced.get(i), producedBy);
}
//
// find potential instances in all pkgs for classes still in classConsumed.
//
if (classInstanceMap == null){
classInstanceMap = new HashMap<String, ArrayList<String>>();
if (classInstanceMap == null) {
classInstanceMap = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
}
Iterator<String> lic = this.classConsumed.keySet().iterator();
while(lic.hasNext()){
String cls = lic.next();
if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {
Iterator<LibraryClassDescriptor> lic = this.classConsumed.keySet().iterator();
while (lic.hasNext()) {
LibraryClassDescriptor cls = lic.next();
if (isBoundedClass(cls)) {
continue;
}
ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
if (instances.size() == 0){
JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " +
cls + ", Platform Build will Fail.");
if (instances.size() == 0) {
throw new NoInstanceException (cls.className);
}
classInstanceMap.put(cls, instances);
}
// showClassToResolved();
}
catch(Exception e) {
e.printStackTrace();
/**Search classProduced map to see if this class has been produced by some instance (module).
* @param cls
* @return
*/
private boolean isBoundedClass (LibraryClassDescriptor cls) {
if (this.classProduced.containsKey(cls)) {
return true;
}
Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) {
return true;
}
}
private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{
return false;
}
private ArrayList<String> getInstancesForClass(LibraryClassDescriptor cls, PackageIdentification[] depPkgList){
ArrayList<String> al = new ArrayList<String>();
// for (int i = 0; i < depPkgList.length; ++i) {
@ -315,17 +434,17 @@ public class FpdModuleSA extends JDialog implements ActionListener {
// if (!mi.getPackageId().getGuid().equalsIgnoreCase(depPkgList[i].getGuid())) {
// continue;
// }
String[] clsProduced = getClassProduced(mi);
Vector<LibraryClassDescriptor> clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
boolean isPotential = false;
for (int j = 0; j < clsProduced.length; ++j) {
if (clsProduced[j] == null) {
continue;
}
if (clsProduced[j].equals(cls)){
Iterator<LibraryClassDescriptor> lcdi = clsProduced.iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)){
isPotential = true;
}
if (classProduced.contains(clsProduced[j])) {
if (hasBeenProduced(lcd)) {
isPotential = false;
break;
}
@ -340,6 +459,28 @@ public class FpdModuleSA extends JDialog implements ActionListener {
return al;
}
private boolean hasBeenProduced (LibraryClassDescriptor cls) {
Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if (cls.hasInterSectionWith(lcd)) {
return true;
}
}
return false;
}
private ArrayList<String> getConsumedBy (String className) {
Iterator<LibraryClassDescriptor> lcdi = this.classConsumed.keySet().iterator();
while (lcdi.hasNext()) {
LibraryClassDescriptor lcd = lcdi.next();
if (lcd.className.equals(className)) {
return this.classConsumed.get(lcd);
}
}
return null;
}
private void removeInstance(String key) {
ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
//
@ -349,26 +490,22 @@ public class FpdModuleSA extends JDialog implements ActionListener {
//
// remove class produced by this instance and add back these produced class to be bound.
//
String[] clsProduced = getClassProduced(mi);
for (int i = 0; i < clsProduced.length; ++i) {
Vector<LibraryClassDescriptor> clsProduced = getClassProduced(mi);
for (int i = 0; i < clsProduced.size(); ++i) {
classProduced.remove(clsProduced[i]);
classProduced.remove(clsProduced.get(i));
}
//
// remove class consumed by this instance. we do not need to bound it now.
//
String[] clsConsumed = getClassConsumed(mi);
for (int i = 0; i < clsConsumed.length; ++i) {
ArrayList<String> al = classConsumed.get(clsConsumed[i]);
ArrayList<String> al = getConsumedBy (clsConsumed[i]);
if (al == null ) {
classConsumed.remove(clsConsumed[i]);
continue;
}
al.remove(key);
if (al.size() == 0) {
classConsumed.remove(clsConsumed[i]);
}
}
@ -377,54 +514,41 @@ public class FpdModuleSA extends JDialog implements ActionListener {
}
private String[] getClassProduced(ModuleIdentification mi){
try{
Vector<String> clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
String[] sClassProduced = new String[clsProduced.size()];
for (int i = 0; i < clsProduced.size(); ++i) {
sClassProduced[i] = clsProduced.get(i);
}
return sClassProduced;
}catch (Exception e) {
e.printStackTrace();
}
return new String[0];
private Vector<LibraryClassDescriptor> getClassProduced(ModuleIdentification mi){
Vector<LibraryClassDescriptor> clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
return clsProduced;
// String[] sClassProduced = new String[clsProduced.size()];
// for (int i = 0; i < clsProduced.size(); ++i) {
// sClassProduced[i] = clsProduced.get(i).className;
// }
// return sClassProduced;
}
private String[] getClassConsumed(ModuleIdentification mi){
try{
Vector<String> clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
Vector<LibraryClassDescriptor> clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
String[] sClassConsumed = new String[clsConsumed.size()];
for (int i = 0; i < clsConsumed.size(); ++i) {
sClassConsumed[i] = clsConsumed.get(i);
sClassConsumed[i] = clsConsumed.get(i).className;
}
return sClassConsumed;
}catch (Exception e) {
e.printStackTrace();
}
return new String[0];
}
private void showClassToResolved(){
libClassTableModel.setRowCount(0);
if (classConsumed.size() == 0) {
if (classConsumed == null || classConsumed.size() == 0) {
return;
}
Iterator<String> li = classConsumed.keySet().iterator();
Iterator<LibraryClassDescriptor> li = classConsumed.keySet().iterator();
while(li.hasNext()){
LibraryClassDescriptor lcd = li.next();
String[] s = {lcd.className, lcd.supArchs, lcd.supModTypes};
if (classConsumed.get(lcd) == null || classConsumed.get(lcd).size() == 0) {
continue;
}
String[] s = {li.next()};
// if (classConsumed.get(s[0]) == null) {
// continue;
// }
// if (classConsumed.get(s[0]).size() == 0) {
// continue;
// }
if (!classProduced.contains(s[0])){
if (!isBoundedClass(lcd)){
libClassTableModel.addRow(s);
}
}
@ -850,10 +974,18 @@ public class FpdModuleSA extends JDialog implements ActionListener {
if (jTableLibClass == null) {
libClassTableModel = new IDefaultTableModel();
libClassTableModel.addColumn("LibraryClass");
libClassTableModel.addColumn("Arch");
libClassTableModel.addColumn("ModType");
jTableLibClass = new JTable(libClassTableModel);
jTableLibClass.setRowHeight(20);
jTableLibClass.setShowGrid(false);
jTableLibClass.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TableColumn column = jTableLibClass.getColumnModel().getColumn(1);
jTableLibClass.getColumnModel().removeColumn(column);
column = jTableLibClass.getColumnModel().getColumn(1);
jTableLibClass.getColumnModel().removeColumn(column);
jTableLibClass.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
public void valueChanged(ListSelectionEvent e) {
if (e.getValueIsAdjusting()){
@ -873,7 +1005,12 @@ public class FpdModuleSA extends JDialog implements ActionListener {
//
libInstanceTableModel.setRowCount(0);
String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();
ArrayList<String> al = classInstanceMap.get(cls);
String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString();
String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString();
ArrayList<String> al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType));
if (al == null) {
return;
}
ListIterator<String> li = al.listIterator();
while(li.hasNext()) {
String instance = li.next();
@ -1029,7 +1166,12 @@ public class FpdModuleSA extends JDialog implements ActionListener {
libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),
libInstanceTableModel.getValueAt(row, 4)};
selectedInstancesTableModel.addRow(s);
try {
resolveLibraryInstances(instanceValue);
}
catch (Exception exp) {
JOptionPane.showMessageDialog(frame, exp.getMessage());
}
showClassToResolved();
}
});
@ -1076,7 +1218,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
if (jButtonOk == null) {
jButtonOk = new JButton();
jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
jButtonOk.setText("Ok");
jButtonOk.setText("Close");
jButtonOk.addActionListener(this);
}
return jButtonOk;
@ -1351,7 +1493,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
public void actionPerformed(java.awt.event.ActionEvent e) {
String[] row = {"", "", "", "", "", ""};
optionsTableModel.addRow(row);
Vector<Object> v = new Vector<Object>();
Vector<Object> v = null;
Vector<Object> v1 = null;
docConsole.setSaved(false);
ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");
@ -1526,6 +1668,7 @@ private void pcdDynamicToNonDynamic(String cName, String tsGuid) {
ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);
for (int i = 0; i < al.size(); ++i) {
String mKey = moduleInfo (al.get(i));
value = null;
ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", maxSize, value);
String itemType = jComboBoxItemType.getSelectedItem()+"";
al.set(i, mKey + " " + itemType);
@ -1709,3 +1852,51 @@ private JPanel getJPanelLibraryCenterC() {
} // @jve:decl-index=0:visual-constraint="10,10"
class MultipleInstanceException extends Exception {
/**
*
*/
private static final long serialVersionUID = -9148463005930920297L;
private String className = null;
private String libInstance1 = null;
private String libInstance2 = null;
MultipleInstanceException (String libClass, String instance1, String instance2) {
super();
className = libClass;
libInstance1 = instance1;
libInstance2 = instance2;
}
/* (non-Javadoc)
* @see java.lang.Throwable#getMessage()
*/
@Override
public String getMessage() {
// TODO Auto-generated method stub
return "Library Class " + className + "is Produced by Two Instances: "
+ libInstance1 + " and " + libInstance2 + ". Platform Build will Fail.";
}
}
class NoInstanceException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1987122786598970598L;
private String className = null;
NoInstanceException (String libClass) {
className = libClass;
}
public String getMessage() {
return "No Applicable Instance for Library Class " + className
+ ", Platform Build will Fail.";
}
}

View File

@ -0,0 +1,132 @@
/** @file
This file is for surface area information retrieval.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.frameworkwizard.platform.ui.global;
import java.util.Vector;
public class LibraryClassDescriptor {
public String className = "";
public String supArchs = "";
public String supModTypes = "";
public LibraryClassDescriptor (String s1, String s2, String s3) {
className = s1;
if (s2 != null) {
supArchs = s2;
}
if (s3 != null) {
supModTypes = s3;
}
}
public boolean equals(Object obj) {
if (obj instanceof LibraryClassDescriptor) {
LibraryClassDescriptor id = (LibraryClassDescriptor)obj;
if (className.equals(id.className) && sameArchs (supArchs, id.supArchs) && sameModTypes(supModTypes, id.supModTypes)) {
return true;
}
return false;
}
else {
return super.equals(obj);
}
}
public int hashCode(){
return (className + supArchs + supModTypes).toLowerCase().hashCode();
}
public String toString() {
return "Library Class "+ className + " [SupArchs: " + supArchs + " SupModTypes: " + supModTypes + "]";
}
public boolean isSubSetByArchs (LibraryClassDescriptor lcd) {
if (className.equals(lcd.className)) {
Vector<String> vArchs1 = getVectorFromString(supArchs);
Vector<String> vArchs2 = getVectorFromString(lcd.supArchs);
if (isSubSet(vArchs1, vArchs2)) {
return true;
}
}
return false;
}
public boolean isSubSetByModTypes (LibraryClassDescriptor lcd) {
if (className.equals(lcd.className)) {
Vector<String> vModTypes1 = getVectorFromString(supModTypes);
Vector<String> vModTypes2 = getVectorFromString(lcd.supModTypes);
if (isSubSet(vModTypes1, vModTypes2)) {
return true;
}
}
return false;
}
public boolean hasInterSectionWith (LibraryClassDescriptor lcd) {
if (className.equals(lcd.className)) {
Vector<String> vArchs1 = getVectorFromString(supArchs);
Vector<String> vArchs2 = getVectorFromString(lcd.supArchs);
if (vArchs1.size() == 0 || (vArchs1.size() == 1 && vArchs1.get(0).equalsIgnoreCase(""))) {
return true;
}
if (vArchs2.size() == 0 || (vArchs2.size() == 1 && vArchs2.get(0).equalsIgnoreCase(""))) {
return true;
}
vArchs1.retainAll(vArchs2);
if (vArchs1.size() > 0) {
return true;
}
}
return false;
}
private boolean isSubSet (Vector<String> v1, Vector<String> v2) {
if (v2.size() == 0 || (v2.size() == 1 && v2.get(0).equalsIgnoreCase(""))) {
return true;
}
if (v2.containsAll(v1)) {
return true;
}
return false;
}
public Vector<String> getVectorFromString (String s) {
if (s == null || s.equals("null")) {
s = "";
}
String[] sa1 = s.split(" ");
Vector<String> v = new Vector<String>();
for (int i = 0; i < sa1.length; ++i) {
v.add(sa1[i]);
}
return v;
}
private boolean sameArchs (String archs1, String archs2) {
Vector<String> vArchs1 = getVectorFromString(archs1);
Vector<String> vArchs2 = getVectorFromString(archs2);
if (vArchs1.containsAll(vArchs2) && vArchs2.containsAll(vArchs1)) {
return true;
}
return false;
}
private boolean sameModTypes (String modTypes1, String modTypes2) {
return sameArchs(modTypes1, modTypes2);
}
}

View File

@ -317,7 +317,7 @@ public class SurfaceAreaQuery {
* @returns null if nothing is there
*/
public static PackageIdentification[] getDependencePkg(String arch, ModuleIdentification mi) throws Exception{
public static PackageIdentification[] getDependencePkg(String arch, ModuleIdentification mi){
String packageGuid = null;
String packageVersion = null;
@ -375,11 +375,11 @@ public class SurfaceAreaQuery {
* xpath
* @returns null if nothing is there
*/
public static Vector<String> getLibraryClasses(String usage, ModuleIdentification mi) throws Exception{
public static Vector<LibraryClassDescriptor> getLibraryClasses(String usage, ModuleIdentification mi){
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);
Vector<String> libraryClassName = new Vector<String>();
Vector<LibraryClassDescriptor> libraryClassInfo = new Vector<LibraryClassDescriptor>();
if (msa.getLibraryClassDefinitions() == null) {
return libraryClassName;
return libraryClassInfo;
}
int size = msa.getLibraryClassDefinitions().getLibraryClassList().size();
@ -387,11 +387,12 @@ public class SurfaceAreaQuery {
for (int i = 0; i < size; i++) {
LibraryClassDocument.LibraryClass libClass = msa.getLibraryClassDefinitions().getLibraryClassList().get(i);
if (usage.equals(libClass.getUsage().toString())) {
libraryClassName.add(libClass.getKeyword());
libraryClassInfo.add(new LibraryClassDescriptor(libClass.getKeyword(), libClass.getSupArchList()+"", libClass.getSupModuleList()+""));
}
}
return libraryClassName;
return libraryClassInfo;
}
public static XmlObject[] getSpdPcdDeclarations(PackageIdentification pi) {
@ -409,3 +410,4 @@ public class SurfaceAreaQuery {
}
}