Modify FrameworkModules editor for FPD files to meet the new PCD type adjust operation rules:

a. Add a module with PCD type Dyn. 
	If this PCD not exists in platform, 
ModuleSA.PcdType is set as Dyn (choose one from spd).
	Else
		ModuleSA.PcdType is set as existing type ? 
(Give a error message if this module pcd can NOT be set as existing type. And Pcd will not be added for this module into platform.)
		
	If PCD type is determined to be Dyn.
Add PCD to DynamicPcdBuildDefinitions if it not exists there.
SkuId = 0;
SkuInfo.value = MSA default | SPD default | give default based on DatumType.
If DatumType == void*
	Set ModuleSA.PcdMaxDatumSize;


b. Add a module with PCD type DynEx.
If this PCD not exists in platform, 
ModuleSA.PcdType is set as DynEx.
	Else
		ModuleSA.PcdType is set as existing type ? 
(Give a error message if this module pcd can NOT be set as existing type. And Pcd will not be added for this module into platform.)

Add PCD to DynamicPcdBuildDefinitions if it not exists there.
SkuId = 0;
SkuInfo.value = MSA default | SPD default | give default based on DatumType.
If DatumType == void*
	    Set ModuleSA.PcdMaxDatumSize;


c. Add a module with PCD type FixedAtBuild, PIM, FF
If this PCD not exists in platform, 
ModuleSA.PcdType is set as FaB | PIM | FF.
	Else
		ModuleSA.PcdType is set as existing type ? 
(Give a error message if this module pcd can NOT be set as existing type. And Pcd will not be added for this module into platform..)

ModuleSA.PcdValue = MSA default | SPD default | give default based on DatumType.
If DatumType == void*
		Set ModuleSA.PcdMaxDatumSize;


d. Edit ModuleSA.PcdType
	Get the corresponding MSA.PcdType in MSA file for this ModuleSA.
	
	If MSA.PcdType == Dyn.
		ModuleSA.PcdType could be [(valid Pcd types in SPD)]
		
    Else 
		ModuleSA.PcdType can NOT be changed.

	1) Change ModuleSa.PcdType from Dynamic. to [valid Pcd types in SPD]: 
	All same PCDs in FrameworkModules are changed to one of valid Pcd types in SPD according to user selection. 
	Check in whole platform other ModuleSA for the same pcd, if the corresponding MSAes for other ModuleSAes pcd can NOT accept the new type, give error message.
        
Keep old ModuleSA.PcdValue.
	Remove this PCD in DynamicPcdBuildDefintion.

2) Change ModuleSa.PcdType from [FaBor PIM] to Dynamic, DynEx.: 
	All same PCDs in FrameworkModules are changed to Dynamic | DynEx. 
Check in whole platform other ModuleSA for the same pcd, if the corresponding MSAes for other ModuleSAes pcd can NOT accept the new type, give error message.

Keep old ModuleSA.PcdValue?
	Add one new dynamic PCD in DynamicPcdBuildDefintion.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1888 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jlin16 2006-11-02 11:04:27 +00:00
parent bd23689590
commit e4f1ff6cf9
5 changed files with 347 additions and 165 deletions

View File

@ -36,6 +36,8 @@ import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;
import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
import org.tianocore.frameworkwizard.common.ui.StarLabel;
import javax.swing.JCheckBox;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
/**
The class is used to create, update spdHeader of Spd file
@ -44,7 +46,7 @@ import javax.swing.JCheckBox;
@since PackageEditor 1.0
**/
public class SpdHeader extends IInternalFrame {
public class SpdHeader extends IInternalFrame implements DocumentListener{
private int dialogWidth = 560;
@ -185,6 +187,7 @@ public class SpdHeader extends IInternalFrame {
jPackageNameTextField = new JTextField();
jPackageNameTextField.setBounds(new java.awt.Rectangle(valueColumn, rowOne, valueWidth, oneRowHeight));
jPackageNameTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
jPackageNameTextField.getDocument().addDocumentListener(this);
jPackageNameTextField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!DataValidation.isUiNameType(jPackageNameTextField.getText())) {
@ -194,7 +197,6 @@ public class SpdHeader extends IInternalFrame {
if (jPackageNameTextField.getText().equals(sfc.getSpdHdrPkgName())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrPkgName(jPackageNameTextField.getText());
}
});
@ -213,6 +215,7 @@ public class SpdHeader extends IInternalFrame {
jGuidTextField = new JTextField();
jGuidTextField.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, shortValueWidth, oneRowHeight));
jGuidTextField.setPreferredSize(new java.awt.Dimension(shortValueWidth, oneRowHeight));
jGuidTextField.getDocument().addDocumentListener(this);
jGuidTextField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!DataValidation.isGuid(jGuidTextField.getText())) {
@ -222,7 +225,6 @@ public class SpdHeader extends IInternalFrame {
if (jGuidTextField.getText().equals(sfc.getSpdHdrGuidValue())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrGuidValue(jGuidTextField.getText());
}
});
@ -241,6 +243,7 @@ public class SpdHeader extends IInternalFrame {
jVersionTextField = new JTextField();
jVersionTextField.setBounds(new java.awt.Rectangle(valueColumn, rowThree, valueWidth, oneRowHeight));
jVersionTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
jVersionTextField.getDocument().addDocumentListener(this);
jVersionTextField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!DataValidation.isVersion(jVersionTextField.getText())) {
@ -250,7 +253,6 @@ public class SpdHeader extends IInternalFrame {
if (jVersionTextField.getText().equals(sfc.getSpdHdrVer())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrVer(jVersionTextField.getText());
}
});
@ -283,8 +285,8 @@ public class SpdHeader extends IInternalFrame {
private JTextArea getJLicenseTextArea() {
if (jLicenseTextArea == null) {
jLicenseTextArea = new JTextArea();
// jLicenseTextArea.setText("");
jLicenseTextArea.setLineWrap(true);
jLicenseTextArea.getDocument().addDocumentListener(this);
jLicenseTextArea.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (jLicenseTextArea.getText().length() == 0) {
@ -294,7 +296,6 @@ public class SpdHeader extends IInternalFrame {
if (jLicenseTextArea.getText().equals(sfc.getSpdHdrLicense())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrLicense(jLicenseTextArea.getText());
}
});
@ -312,6 +313,7 @@ public class SpdHeader extends IInternalFrame {
if (jDescriptionTextArea == null) {
jDescriptionTextArea = new JTextArea();
jDescriptionTextArea.setLineWrap(true);
jDescriptionTextArea.getDocument().addDocumentListener(this);
jDescriptionTextArea.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (jDescriptionTextArea.getText().length() == 0) {
@ -323,7 +325,6 @@ public class SpdHeader extends IInternalFrame {
if (jDescriptionTextArea.getText().equals(sfc.getSpdHdrDescription())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrDescription(jDescriptionTextArea.getText());
}
});
@ -400,6 +401,7 @@ public class SpdHeader extends IInternalFrame {
jAbstractTextField = new JTextField();
jAbstractTextField.setBounds(new java.awt.Rectangle(valueColumn, rowSeven, valueWidth, oneRowHeight));
jAbstractTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
jAbstractTextField.getDocument().addDocumentListener(this);
jAbstractTextField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!DataValidation.isAbstract(jAbstractTextField.getText())) {
@ -409,7 +411,6 @@ public class SpdHeader extends IInternalFrame {
if (jAbstractTextField.getText().equals(sfc.getSpdHdrAbs())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrAbs(jAbstractTextField.getText());
}
});
@ -438,6 +439,7 @@ public class SpdHeader extends IInternalFrame {
jCopyrightTextArea = new JTextArea();
jCopyrightTextArea.setWrapStyleWord(true);
jCopyrightTextArea.setLineWrap(true);
jCopyrightTextArea.getDocument().addDocumentListener(this);
jCopyrightTextArea.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {
@ -447,7 +449,6 @@ public class SpdHeader extends IInternalFrame {
if (jCopyrightTextArea.getText().equals(sfc.getSpdHdrCopyright())) {
return;
}
docConsole.setSaved(false);
sfc.setSpdHdrCopyright(jCopyrightTextArea.getText());
}
});
@ -465,6 +466,7 @@ public class SpdHeader extends IInternalFrame {
jUrlTextField = new JTextField();
jUrlTextField.setBounds(new java.awt.Rectangle(valueColumn, rowSix, valueWidth, oneRowHeight));
jUrlTextField.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
jUrlTextField.getDocument().addDocumentListener(this);
jUrlTextField.addFocusListener(new FocusAdapter() {
public void focusLost(FocusEvent e) {
if (jUrlTextField.getText().length() == 0 && sfc.getSpdHdrUrl() == null) {
@ -475,7 +477,6 @@ public class SpdHeader extends IInternalFrame {
}
sfc.setSpdHdrLicense(jLicenseTextArea.getText());
sfc.setSpdHdrUrl(jUrlTextField.getText());
docConsole.setSaved(false);
}
});
}
@ -731,7 +732,6 @@ public class SpdHeader extends IInternalFrame {
if (arg0.getSource() == jGenerateGuidButton) {
//ToDo: invoke GuidValueEditor
jGuidTextField.setText(Tools.generateUuidString());
docConsole.setSaved(false);
sfc.setSpdHdrGuidValue(jGuidTextField.getText());
}
}
@ -785,4 +785,32 @@ public class SpdHeader extends IInternalFrame {
}
return topScrollPane;
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
*/
public void changedUpdate(DocumentEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
*/
public void insertUpdate(DocumentEvent arg0) {
// TODO Auto-generated method stub
if (docConsole != null) {
docConsole.setSaved(false);
}
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
*/
public void removeUpdate(DocumentEvent arg0) {
// TODO Auto-generated method stub
if (docConsole != null) {
docConsole.setSaved(false);
}
}
}

View File

@ -389,9 +389,9 @@ public class FpdFileContents {
int pcdCount = getPcdDataCount(seqModuleSa);
String[][] saaModuleSaPcd = new String[pcdCount][7];
getPcdData(seqModuleSa, saaModuleSaPcd);
String mg = moduleSa.getModuleGuid();
String mg = moduleSa.getModuleGuid().toLowerCase();
String mv = moduleSa.getModuleVersion();
String pg = moduleSa.getPackageGuid();
String pg = moduleSa.getPackageGuid().toLowerCase();
String pv = moduleSa.getPackageVersion();
String arch = listToString(moduleSa.getSupArchList());
//
@ -440,7 +440,7 @@ public class FpdFileContents {
ArrayList<String> al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName());
if (al != null) {
for (int j = 0; j < al.size(); ++j) {
if (al.get(j).contains(moduleKey)) {
if (al.get(j).startsWith(moduleKey)) {
continue msaPcdIter;
}
}
@ -462,7 +462,7 @@ public class FpdFileContents {
: msaPcd.getDefaultValue();
genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(),
msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa);
msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa, spdPcd);
dataModified = true;
}
@ -607,54 +607,49 @@ public class FpdFileContents {
* @param sa Results: HelpText, Original item type.
* @return
*/
public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{
try {
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);
if (msa.getPcdCoded() == null) {
return false;
}
Map<String, XmlObject> m = new HashMap<String, XmlObject>();
m.put("ModuleSurfaceArea", msa);
SurfaceAreaQuery.setDoc(m);
PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);
//
// First look through MSA pcd entries.
//
List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
ListIterator li = l.listIterator();
while(li.hasNext()) {
PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
if (!msaPcd.getCName().equals(cName)) {
continue;
}
if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {
continue;
}
PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
if (spdPcd == null) {
//
// ToDo Error
//
throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());
}
//
// Get Pcd help text and original item type.
//
sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();
sa[1] = msaPcd.getPcdItemType()+"";
sa[2] = msa.getModuleDefinitions().getBinaryModule()+"";
return true;
}
public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa, Vector<String> validPcdTypes) throws Exception{
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile
.getModuleXmlObject(mi);
if (msa.getPcdCoded() == null) {
return false;
}
catch (Exception e){
e.printStackTrace();
throw e;
PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);
//
// First look through MSA pcd entries.
//
List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
ListIterator li = l.listIterator();
while (li.hasNext()) {
PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();
if (!msaPcd.getCName().equals(cName)) {
continue;
}
if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {
continue;
}
PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
if (spdPcd == null || spdPcd.getValidUsage() == null) {
//
// ToDo Error
//
throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());
}
//
// Get Pcd help text and original item type.
//
sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();
sa[1] = msaPcd.getPcdItemType() + "";
sa[2] = msa.getModuleDefinitions().getBinaryModule() + "";
ListIterator iter = spdPcd.getValidUsage().listIterator();
while (iter.hasNext()) {
String usage = iter.next().toString();
validPcdTypes.add(usage);
}
return true;
}
return false;
}
@ -1151,46 +1146,40 @@ public class FpdFileContents {
public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {
//ToDo add Arch filter
try {
if (moduleSa == null) {
moduleSa = genModuleSA(mi, arch);
}
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);
if (msa.getPcdCoded() == null) {
return;
}
Map<String, XmlObject> m = new HashMap<String, XmlObject>();
m.put("ModuleSurfaceArea", msa);
SurfaceAreaQuery.setDoc(m);
PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);
//
// Implementing InitializePlatformPcdBuildDefinitions
//
List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
ListIterator li = l.listIterator();
while(li.hasNext()) {
PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();
PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
if (spdPcd == null) {
//
// ToDo Error
//
throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());
}
//
// AddItem to ModuleSA PcdBuildDefinitions
//
String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();
genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);
}
if (moduleSa == null) {
moduleSa = genModuleSA(mi, arch);
}
catch (Exception e){
throw e;
ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile
.getModuleXmlObject(mi);
if (msa.getPcdCoded() == null) {
return;
}
PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);
//
// Implementing InitializePlatformPcdBuildDefinitions
//
List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();
ListIterator li = l.listIterator();
while (li.hasNext()) {
PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();
PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);
if (spdPcd == null) {
//
// ToDo Error
//
throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "
+ mi.getName());
}
//
// AddItem to ModuleSA PcdBuildDefinitions
//
String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();
genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType()
.toString(),
spdPcd.getDatumType() + "", defaultVal, moduleSa, spdPcd);
}
}
@ -1251,7 +1240,25 @@ public class FpdFileContents {
return msa;
}
private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa)
private String chooseDefaultPcdType (List validPcdTypes) {
String choosedType = "";
if (validPcdTypes.contains("FIXED_AT_BUILD")) {
choosedType = "FIXED_AT_BUILD";
}
else if (validPcdTypes.contains("DYNAMIC")) {
choosedType = "DYNAMIC";
}
else if (validPcdTypes.contains("PATCHABLE_IN_MODULE")) {
choosedType = "PATCHABLE_IN_MODULE";
}
else if (validPcdTypes.contains("DYNAMIC_EX")) {
choosedType = "DYNAMIC_EX";
}
return choosedType;
}
private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal,
ModuleSADocument.ModuleSA moduleSa, PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd)
throws PcdItemTypeConflictException, PcdValueMalFormed{
if (moduleSa.getPcdBuildDefinition() == null){
moduleSa.addNewPcdBuildDefinition();
@ -1275,12 +1282,43 @@ public class FpdFileContents {
return;
}
}
// if pcd type from MSA file is Dynamic
// we must choose one default type from SPD file for it.
//
List validPcdTypes = spdPcd.getValidUsage();
//
// Using existing Pcd type, if this pcd already exists in other ModuleSA
//
if (pcdConsumer.size() > 0) {
//
// platform should only contain one type for each pcd.
//
String existingItemType = itemType (pcdConsumer.get(0));
for (int i = 1; i < pcdConsumer.size(); ++i) {
if (!existingItemType.equals(itemType(pcdConsumer.get(i)))) {
throw new PcdItemTypeConflictException (cName, pcdConsumer.get(0), pcdConsumer.get(i));
}
}
itemType = itemType (pcdConsumer.get(0));
if (itemType.equals("DYNAMIC")) {
if (!validPcdTypes.contains(existingItemType)) {
throw new PcdItemTypeConflictException(cName, pcdConsumer.get(0));
}
itemType = existingItemType;
}
else {
if (!itemType.equals(existingItemType)) {
throw new PcdItemTypeConflictException(cName, pcdConsumer.get(0));
}
}
}
//
// if this is the first occurence of this pcd.
//
else {
if (itemType.equals("DYNAMIC")) {
itemType = chooseDefaultPcdType (validPcdTypes);
}
}
String listValue = moduleInfo + " " + itemType;
pcdConsumer.add(listValue);
@ -3636,9 +3674,36 @@ class PcdItemTypeConflictException extends Exception {
private static final long serialVersionUID = 1L;
private String details = null;
PcdItemTypeConflictException(String pcdName, String info){
PcdItemTypeConflictException (String pcdName, String info) {
ModuleIdentification mi = WorkspaceProfile.getModuleId(info);
details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();
if (mi != null) {
details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();
}
else {
details = pcdName + " ItemType Conflicts with " + info;
}
}
PcdItemTypeConflictException (String pcdName, String info1, String info2) {
ModuleIdentification mi1 = WorkspaceProfile.getModuleId(info1);
ModuleIdentification mi2 = WorkspaceProfile.getModuleId(info2);
String moduleInfo1 = "";
String moduleInfo2 = "";
if (mi1 != null) {
moduleInfo1 = mi1.getName() + " in Pkg " + mi1.getPackageId().getName();
}
else {
moduleInfo1 = info1;
}
if (mi2 != null) {
moduleInfo2 = mi2.getName() + " in Pkg " + mi2.getPackageId().getName();
}
else {
moduleInfo2 = info2;
}
details = pcdName + " ItemType Conflicts in " + moduleInfo1 + " and " + moduleInfo2;
}
public String getMessage() {

View File

@ -665,6 +665,7 @@ public class FpdFrameworkModules extends IInternalFrame {
private void showSettingsDlg (int row) {
try {
if (ffc.adjustPcd(row)) {
JOptionPane.showMessageDialog(frame, "Pcd entries sync. with those in MSA files.");
docConsole.setSaved(false);
}
}

View File

@ -30,6 +30,8 @@ import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@ -48,7 +50,7 @@ import org.tianocore.frameworkwizard.common.ui.StarLabel;
@since PackageEditor 1.0
**/
public class FpdHeader extends IInternalFrame {
public class FpdHeader extends IInternalFrame implements DocumentListener{
private int dialogWidth = 560;
@ -181,6 +183,7 @@ public class FpdHeader extends IInternalFrame {
jTextFieldBaseName = new JTextField();
jTextFieldBaseName.setBounds(new java.awt.Rectangle(valueColumn, rowOne, valueWidth, oneRowHeight));
jTextFieldBaseName.setPreferredSize(new java.awt.Dimension(valueWidth,oneRowHeight));
jTextFieldBaseName.getDocument().addDocumentListener(this);
jTextFieldBaseName.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (!DataValidation.isUiNameType(jTextFieldBaseName.getText())) {
@ -190,7 +193,6 @@ public class FpdHeader extends IInternalFrame {
if (jTextFieldBaseName.getText().equals(ffc.getFpdHdrPlatformName())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrPlatformName(jTextFieldBaseName.getText());
}
});
@ -209,6 +211,7 @@ public class FpdHeader extends IInternalFrame {
jTextFieldGuid = new JTextField();
jTextFieldGuid.setBounds(new java.awt.Rectangle(valueColumn, rowTwo, shortValueWidth, oneRowHeight));
jTextFieldGuid.setPreferredSize(new java.awt.Dimension(shortValueWidth,oneRowHeight));
jTextFieldGuid.getDocument().addDocumentListener(this);
jTextFieldGuid.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (!DataValidation.isGuid(jTextFieldGuid.getText())) {
@ -218,7 +221,6 @@ public class FpdHeader extends IInternalFrame {
if (jTextFieldGuid.getText().equals(ffc.getFpdHdrGuidValue())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrGuidValue(jTextFieldGuid.getText());
}
});
@ -237,6 +239,7 @@ public class FpdHeader extends IInternalFrame {
jTextFieldVersion = new JTextField();
jTextFieldVersion.setBounds(new java.awt.Rectangle(valueColumn, rowThree, valueWidth, oneRowHeight));
jTextFieldVersion.setPreferredSize(new java.awt.Dimension(valueWidth,oneRowHeight));
jTextFieldVersion.getDocument().addDocumentListener(this);
jTextFieldVersion.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (!DataValidation.isVersion(jTextFieldVersion.getText())) {
@ -246,7 +249,6 @@ public class FpdHeader extends IInternalFrame {
if (jTextFieldVersion.getText().equals(ffc.getFpdHdrVer())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrVer(jTextFieldVersion.getText());
}
});
@ -281,6 +283,7 @@ public class FpdHeader extends IInternalFrame {
jTextAreaLicense = new JTextArea();
jTextAreaLicense.setText("");
jTextAreaLicense.setLineWrap(true);
jTextAreaLicense.getDocument().addDocumentListener(this);
jTextAreaLicense.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (jTextAreaLicense.getText().length() == 0) {
@ -290,7 +293,6 @@ public class FpdHeader extends IInternalFrame {
if (jTextAreaLicense.getText().equals(ffc.getFpdHdrLicense())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrLicense(jTextAreaLicense.getText());
}
});
@ -308,6 +310,7 @@ public class FpdHeader extends IInternalFrame {
if (jTextAreaDescription == null) {
jTextAreaDescription = new JTextArea();
jTextAreaDescription.setLineWrap(true);
jTextAreaDescription.getDocument().addDocumentListener(this);
jTextAreaDescription.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (jTextAreaDescription.getText().length() == 0) {
@ -317,7 +320,6 @@ public class FpdHeader extends IInternalFrame {
if (jTextAreaDescription.getText().equals(ffc.getFpdHdrDescription())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrDescription(jTextAreaDescription.getText());
}
});
@ -338,11 +340,11 @@ public class FpdHeader extends IInternalFrame {
jTextFieldSpecification.setEditable(false);
jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(specWidth,oneRowHeight));
jTextFieldSpecification.setBorder(null);
jTextFieldSpecification.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
ffc.setFpdHdrSpec(jTextFieldSpecification.getText());
}
});
// jTextFieldSpecification.addFocusListener(new FocusAdapter(){
// public void focusLost(FocusEvent e) {
// ffc.setFpdHdrSpec(jTextFieldSpecification.getText());
// }
// });
}
return jTextFieldSpecification;
}
@ -426,6 +428,7 @@ public class FpdHeader extends IInternalFrame {
jTextFieldAbstract = new JTextField();
jTextFieldAbstract.setBounds(new java.awt.Rectangle(valueColumn,rowSeven,valueWidth,oneRowHeight));
jTextFieldAbstract.setPreferredSize(new java.awt.Dimension(valueWidth, oneRowHeight));
jTextFieldAbstract.getDocument().addDocumentListener(this);
jTextFieldAbstract.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (!DataValidation.isAbstract(jTextFieldAbstract.getText())) {
@ -435,7 +438,6 @@ public class FpdHeader extends IInternalFrame {
if (jTextFieldAbstract.getText().equals(ffc.getFpdHdrAbs())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrAbs(jTextFieldAbstract.getText());
}
});
@ -464,6 +466,7 @@ public class FpdHeader extends IInternalFrame {
jCopyrightTextArea = new JTextArea();
jCopyrightTextArea.setWrapStyleWord(true);
jCopyrightTextArea.setLineWrap(true);
jCopyrightTextArea.getDocument().addDocumentListener(this);
jCopyrightTextArea.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e) {
if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) {
@ -473,7 +476,6 @@ public class FpdHeader extends IInternalFrame {
if (jCopyrightTextArea.getText().equals(ffc.getFpdHdrCopyright())) {
return;
}
docConsole.setSaved(false);
ffc.setFpdHdrCopyright(jCopyrightTextArea.getText());
}
});
@ -491,6 +493,7 @@ public class FpdHeader extends IInternalFrame {
jTextFieldUrl = new JTextField();
jTextFieldUrl.setBounds(new java.awt.Rectangle(valueColumn,rowSix,valueWidth,oneRowHeight));
jTextFieldUrl.setPreferredSize(new Dimension(valueWidth, oneRowHeight));
jTextFieldUrl.getDocument().addDocumentListener(this);
jTextFieldUrl.addFocusListener(new FocusAdapter(){
public void focusLost(FocusEvent e){
if (jTextFieldUrl.getText().length() == 0 && ffc.getFpdHdrUrl() == null) {
@ -501,7 +504,6 @@ public class FpdHeader extends IInternalFrame {
}
ffc.setFpdHdrLicense(jTextAreaLicense.getText());
ffc.setFpdHdrUrl(jTextFieldUrl.getText());
docConsole.setSaved(false);
}
});
}
@ -717,7 +719,6 @@ public class FpdHeader extends IInternalFrame {
public void actionPerformed(ActionEvent arg0) {
if (arg0.getSource() == jButtonGenerateGuid) {
docConsole.setSaved(false);
jTextFieldGuid.setText(Tools.generateUuidString());
ffc.setFpdHdrGuidValue(jTextFieldGuid.getText());
}
@ -756,4 +757,32 @@ public class FpdHeader extends IInternalFrame {
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#changedUpdate(javax.swing.event.DocumentEvent)
*/
public void changedUpdate(DocumentEvent arg0) {
// TODO Auto-generated method stub
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#insertUpdate(javax.swing.event.DocumentEvent)
*/
public void insertUpdate(DocumentEvent arg0) {
// TODO Auto-generated method stub
if (docConsole != null) {
docConsole.setSaved(false);
}
}
/* (non-Javadoc)
* @see javax.swing.event.DocumentListener#removeUpdate(javax.swing.event.DocumentEvent)
*/
public void removeUpdate(DocumentEvent arg0) {
// TODO Auto-generated method stub
if (docConsole != null) {
docConsole.setSaved(false);
}
}
}

View File

@ -282,8 +282,9 @@ public class FpdModuleSA extends JDialog implements ActionListener {
return;
}
for (int j = 0; j < v.size(); ++j) {
LibraryClassDescriptor libInfo = v.get(j);
Iterator<LibraryClassDescriptor> iter = v.iterator();
while (iter.hasNext()) {
LibraryClassDescriptor libInfo = iter.next();
Vector<String> vSupArchs = libInfo.getVectorFromString(libInfo.supArchs);
@ -318,7 +319,7 @@ public class FpdModuleSA extends JDialog implements ActionListener {
//
// remove this lib definition if it supports no archs module will be built under.
//
v.iterator().remove();
iter.remove();
}
}
@ -712,9 +713,10 @@ public class FpdModuleSA extends JDialog implements ActionListener {
// array for pcd related information: helpText, itemType, moduleType.
//
String[] pcdInfo = {"", "", ""};
getPcdInfo(cName, tsGuid, pcdInfo);
Vector<String> validPcdTypes = new Vector<String>();
getPcdInfo(moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);
jTextAreaPcdHelp.setText(pcdInfo[0]);
initComboBox(pcdInfo[1], pcdInfo[2]);
initComboBox(pcdInfo[1], pcdInfo[2], validPcdTypes);
jComboBoxItemType.setSelectedItem(itemType);
jTextFieldMaxDatumSize.setEnabled(true);
jTextFieldMaxDatumSize.setVisible(true);
@ -768,15 +770,16 @@ public class FpdModuleSA extends JDialog implements ActionListener {
return jTablePcd;
}
private void initComboBox(String originalType, String mType) {
private void initComboBox(String originalType, String mType, Vector<String> validPcdTypes) {
jComboBoxItemType.removeAllItems();
jComboBoxItemType.addItem(originalType);
if (originalType.equals("PATCHABLE_IN_MODULE") && mType.equalsIgnoreCase("false")) {
jComboBoxItemType.addItem("FIXED_AT_BUILD");
}
if (originalType.equals("DYNAMIC")) {
jComboBoxItemType.addItem("FIXED_AT_BUILD");
jComboBoxItemType.addItem("PATCHABLE_IN_MODULE");
for (int i = 0; i < validPcdTypes.size(); ++i) {
jComboBoxItemType.addItem(validPcdTypes.get(i));
}
}
else {
jComboBoxItemType.addItem(originalType);
}
}
@ -785,17 +788,17 @@ public class FpdModuleSA extends JDialog implements ActionListener {
* @param tsGuid
* @param sa sa[0]: HelpText; sa[1]: itemType in Msa; sa[2]: isBinary;
*/
private void getPcdInfo(String cName, String tsGuid, String[] sa) {
private void getPcdInfo(String moduleKey, String cName, String tsGuid, String[] sa, Vector<String> validPcdTypes) {
String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];
ffc.getLibraryInstances(moduleKey, saa);
try{
if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa)) {
if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa, validPcdTypes)) {
return;
}
for (int j = 0; j < saa.length; ++j) {
if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
cName, tsGuid, sa)) {
cName, tsGuid, sa, validPcdTypes)) {
return;
}
}
@ -1657,26 +1660,25 @@ private JComboBox getJComboBoxItemType() {
if (jComboBoxItemType == null) {
jComboBoxItemType = new JComboBox();
jComboBoxItemType.setPreferredSize(new java.awt.Dimension(200,20));
jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent e) {
int row = jTablePcd.getSelectedRow();
if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) {
return;
}
if (jComboBoxItemType.getItemCount() == 3) {
if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) {
if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {
jTextFieldPcdDefault.setText("");
jTextFieldPcdDefault.setEnabled(true);
}
}
else{
}
}
}
});
// jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() {
// public void itemStateChanged(java.awt.event.ItemEvent e) {
//
// int row = jTablePcd.getSelectedRow();
// if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) {
// return;
// }
// if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) {
//
// if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) {
// jTextFieldPcdDefault.setText("");
// jTextFieldPcdDefault.setEnabled(true);
// }
// }
// else{
//
// }
// }
// });
}
return jComboBoxItemType;
}
@ -1698,8 +1700,8 @@ private void pcdDynamicToNonDynamic(String cName, String 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()+"";
ffc.updatePcdData(mKey, cName, tsGuid, itemType, maxSize, value);
al.set(i, mKey + " " + itemType);
}
@ -1710,8 +1712,8 @@ private void pcdNonDynamicToDynamic(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));
ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");
String itemType = jComboBoxItemType.getSelectedItem()+"";
ffc.updatePcdData(mKey, cName, tsGuid, itemType, jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");
al.set(i, mKey + " " + itemType);
}
try{
@ -1722,6 +1724,16 @@ private void pcdNonDynamicToDynamic(String cName, String tsGuid) {
}
}
private void changePcdTypeWithinSameCategory (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));
String itemType = jComboBoxItemType.getSelectedItem()+"";
ffc.updatePcdData(mKey, cName, tsGuid, itemType, null, null);
al.set(i, mKey + " " + itemType);
}
}
private String moduleInfo (String pcdInfo) {
return pcdInfo.substring(0, pcdInfo.lastIndexOf(" "));
@ -1767,14 +1779,17 @@ private JButton getJButtonUpdatePcd() {
if (row < 0) {
return;
}
docConsole.setSaved(false);
String cName = model.getValueAt(row, 0)+"";
String tsGuid = model.getValueAt(row, 1)+"";
String oldItemType = model.getValueAt(row, 2)+"";
String newItemType = jComboBoxItemType.getSelectedItem()+"";
model.setValueAt(newItemType, row, 2);
model.setValueAt(jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem(), row, 6);
String[] pcdInfo = {"", "", ""};
getPcdInfo (model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", pcdInfo);
Vector<String> validPcdTypes = new Vector<String>();
getPcdInfo (moduleKey, cName, tsGuid, pcdInfo, validPcdTypes);
if (pcdInfo[1].equals("FIXED_AT_BUILD") && model.getValueAt(row, 5).equals("VOID*")) {
try {
jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(row, 6)+"")+"");
@ -1786,18 +1801,62 @@ private JButton getJButtonUpdatePcd() {
}
model.setValueAt(jTextFieldMaxDatumSize.getText(), row, 4);
if (oldItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC")) {
pcdDynamicToNonDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"");
if (newItemType != oldItemType) {
Vector<ModuleIdentification> moduleInfo = new Vector<ModuleIdentification>();
try {
boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo);
if (!changable) {
JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName());
return;
}
}
catch (Exception exp) {
JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage());
return;
}
if ((oldItemType.equals("DYNAMIC") || oldItemType.equals("DYNAMIC_EX")) && !newItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC_EX")) {
pcdDynamicToNonDynamic(cName, tsGuid);
}
if (!oldItemType.equals("DYNAMIC") && !oldItemType.equals("DYNAMIC_EX") && (newItemType.equals("DYNAMIC") || newItemType.equals("DYNAMIC_EX"))) {
pcdNonDynamicToDynamic(cName, tsGuid);
}
else {
changePcdTypeWithinSameCategory (cName, tsGuid);
}
model.setValueAt(newItemType, row, 2);
}
if (!oldItemType.equals("DYNAMIC") && newItemType.equals("DYNAMIC")) {
pcdNonDynamicToDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"");
}
ffc.updatePcdData(moduleKey, model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");
ffc.updatePcdData(moduleKey, cName, tsGuid, model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");
docConsole.setSaved(false);
}
});
}
return jButtonUpdatePcd;
}
private boolean itemTypeCouldBeChanged (String cName, String tsGuid, String newItemType, Vector<ModuleIdentification> mi) throws Exception{
ArrayList<String> pcdConsumers = ffc.getDynPcdMapValue(cName + " " + tsGuid);
for (int i = 0; i < pcdConsumers.size(); ++i) {
String consumerInfo = moduleInfo (pcdConsumers.get(i));
mi.removeAllElements();
mi.add(WorkspaceProfile.getModuleId(consumerInfo));
String[] sa = {"", "", ""};
Vector<String> validPcdTypes = new Vector<String>();
getPcdInfo (consumerInfo, cName, tsGuid, sa, validPcdTypes);
if (validPcdTypes.size() == 0) {
return false;
}
if (!sa[1].equals("DYNAMIC")) {
return false;
}
if (!validPcdTypes.contains(newItemType)) {
return false;
}
}
return true;
}
/**
* This method initializes jComboBoxFeatureFlagValue
*