diff options
author | jlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-02-02 10:11:03 +0000 |
---|---|---|
committer | jlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-02-02 10:11:03 +0000 |
commit | e64872fa8b577189395edb6624b9e178989fd3e5 (patch) | |
tree | 43dcc4652ce69fec6ed80136f8cbd0f766dfe58d /Tools/Java | |
parent | 8d92e94ff5561429773b2e25598a4a0a9f7f0160 (diff) | |
download | edk2-platforms-e64872fa8b577189395edb6624b9e178989fd3e5.tar.xz |
1. Refresh applicable library instances after one illegal library instance is removed.
2.Remove library instances that is only consumed by one library instance when deleting this library instance from a module in platform.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2350 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Java')
3 files changed, 113 insertions, 28 deletions
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java index adc6d265a1..4bca7fe22d 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFileContents.java @@ -58,6 +58,7 @@ import org.tianocore.PlatformHeaderDocument; import org.tianocore.SkuInfoDocument;
import org.tianocore.UserDefinedAntTasksDocument;
import org.tianocore.UserExtensionsDocument;
+import org.tianocore.LibrariesDocument.Libraries.Instance;
import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;
import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
@@ -384,7 +385,7 @@ public class FpdFileContents { cursor.dispose();
}
- public boolean adjustPcd (int seqModuleSa, Vector<String> vExceptions) throws Exception {
+ public boolean adjustPcd (String seqModuleSa, Vector<String> vExceptions) throws Exception {
boolean dataModified = false;
ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);
int pcdCount = getPcdDataCount(seqModuleSa);
@@ -523,8 +524,8 @@ public class FpdFileContents { //
// key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
//
- public int getPcdDataCount (int i){
- ModuleSADocument.ModuleSA msa = getModuleSA(i);
+ public int getPcdDataCount (String key){
+ ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
return 0;
@@ -533,8 +534,8 @@ public class FpdFileContents { }
- public void getPcdData (int i, String[][] saa) {
- ModuleSADocument.ModuleSA msa = getModuleSA(i);
+ public void getPcdData (String key, String[][] saa) {
+ ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){
return;
@@ -553,8 +554,8 @@ public class FpdFileContents { }
}
- public void removePcdData (int seqModuleSa, String cName, String tsGuid) {
- ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);
+ public void removePcdData (String key, String cName, String tsGuid) {
+ ModuleSADocument.ModuleSA moduleSa = getModuleSA(key);
if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){
return;
}
@@ -573,7 +574,7 @@ public class FpdFileContents { PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();
if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {
maintainDynPcdMap(cName + " " + tsGuid, moduleKey);
- if (getPcdDataCount(seqModuleSa) == 1) {
+ if (getPcdDataCount(key) == 1) {
cursor.toParent();
}
cursor.removeXml();
@@ -809,17 +810,21 @@ public class FpdFileContents { return false;
}
- public void removeLibraryInstance(String key, int i) {
+ public void removeLibraryInstance(String key, String instanceKey) {
ModuleSADocument.ModuleSA msa = getModuleSA(key);
if (msa == null || msa.getLibraries() == null){
return ;
}
+ String[] instanceInfo = instanceKey.split(" ");
XmlCursor cursor = msa.getLibraries().newCursor();
if (cursor.toFirstChild()) {
- for (int j = 0; j < i; ++j) {
- cursor.toNextSibling();
+ do {
+ Instance libIns = (Instance)cursor.getObject();
+ if (libIns.getModuleGuid().equalsIgnoreCase(instanceInfo[0]) && libIns.getPackageGuid().equalsIgnoreCase(instanceInfo[2])) {
+ break;
}
+ }while (cursor.toNextSibling());
cursor.push();
while (cursor.hasPrevToken()) {
cursor.toPrevToken();
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java index 7e3faa969b..e219ee3291 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdFrameworkModules.java @@ -928,9 +928,17 @@ public class FpdFrameworkModules extends IInternalFrame { private boolean pcdSync(Vector<String> v) {
boolean synced = false;
+ String[] sa = new String[5];
for (int i = 0; i < jTableFpdModules.getRowCount(); ++i) {
try {
- if (ffc.adjustPcd(i, v)) {
+ ffc.getFrameworkModuleInfo(i, sa);
+ String mg = sa[ffcModGuid];
+ String mv = sa[ffcModVer];
+ String pg = sa[ffcPkgGuid];
+ String pv = sa[ffcPkgVer];
+ String arch = sa[ffcModArch];
+ String key = mg + " " + mv + " " + pg + " " + pv + " " + arch;
+ if (ffc.adjustPcd(key, v)) {
synced = true;
}
}
diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java index 102dd3dc46..b97e0d77e6 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdModuleSA.java @@ -96,7 +96,6 @@ public class FpdModuleSA extends JDialog implements ActionListener { private FpdFileContents ffc = null;
private String moduleKey = null;
private ModuleIdentification moduleId = null;
- private int moduleSaNum = -1;
private HashMap<LibraryClassDescriptor, ArrayList<String>> classInstanceMap = null;
//
// map of <{libName, supArch, supMod}, list of Module information>
@@ -154,13 +153,12 @@ public class FpdModuleSA extends JDialog implements ActionListener { public void setKey(String k, int i, OpeningPlatformType dc){
this.moduleKey = k;
- moduleSaNum = i;
this.docConsole = dc;
classInstanceMap = null;
classProduced = null;
classConsumed = null;
jTabbedPane.setSelectedIndex(0);
- initPcdBuildDefinition(i);
+ initPcdBuildDefinition(moduleKey);
moduleId = WorkspaceProfile.getModuleId(moduleKey);
if (moduleId == null) {
return;
@@ -178,7 +176,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { init will be called each time FpdModuleSA object is to be shown.
@param key Module information.
**/
- public void initPcdBuildDefinition(int i) {
+ public void initPcdBuildDefinition(String key) {
//
// display pcd for key.
//
@@ -187,10 +185,10 @@ public class FpdModuleSA extends JDialog implements ActionListener { jComboBoxItemType.setSelectedIndex(-1);
jTextFieldMaxDatumSize.setText("");
jTextFieldPcdDefault.setText("");
- int pcdCount = ffc.getPcdDataCount(i);
+ int pcdCount = ffc.getPcdDataCount(key);
if (pcdCount != 0) {
String[][] saa = new String[pcdCount][7];
- ffc.getPcdData(i, saa);
+ ffc.getPcdData(key, saa);
for (int j = 0; j < saa.length; ++j) {
model.addRow(saa[j]);
}
@@ -236,6 +234,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>();
while (iter.hasNext()) {
LibraryClassDescriptor lcd = iter.next();
+ if (this.classConsumed.get(lcd) == null || this.classConsumed.get(lcd).size() == 0) {
+ continue;
+ }
if (isBoundedClass(lcd, errorMsg)) {
continue;
}
@@ -575,12 +576,41 @@ public class FpdModuleSA extends JDialog implements ActionListener { return null;
}
+ private ArrayList<String> getProducedBy (String className) {
+ Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();
+ while (lcdi.hasNext()) {
+ LibraryClassDescriptor lcd = lcdi.next();
+ if ((lcd.className != null) && lcd.className.equals(className)) {
+ return this.classProduced.get(lcd);
+ }
+ }
+ return null;
+ }
+ //
+ // Get class name list related with instanceKey from HashMap m<LibraryClass, ArrayList<instanceKey>>.
+ //
+ private ArrayList<String> getLibraryClassList (String instanceKey, HashMap<LibraryClassDescriptor, ArrayList<String>> m) {
+ ArrayList<String> libraryClass = new ArrayList<String>();
+ Iterator<LibraryClassDescriptor> lcdi = m.keySet().iterator();
+ while (lcdi.hasNext()) {
+ LibraryClassDescriptor lcd = lcdi.next();
+ if ((m.get(lcd) != null) && m.get(lcd).contains(instanceKey)) {
+ libraryClass.add(lcd.className);
+ }
+ }
+ return libraryClass;
+ }
+
private void removeInstance(String key) {
ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
//
// remove pcd information of instance from current ModuleSA
+ // Note that Pcd data SHOULD be removed prior to library instance
+ // because Multi-Sourced PCD could not be removed, if we remove library instance first,
+ // it will impact the judgement of whether a PCD entry is Multi-Sourced.
//
ffc.removePcdData(moduleKey, mi);
+ ffc.removeLibraryInstance(moduleKey, key);
//
// remove class produced by this instance and add back these produced class to be bound.
//
@@ -600,7 +630,25 @@ public class FpdModuleSA extends JDialog implements ActionListener { continue;
}
al.remove(key);
-
+ if (al.size() == 0) {
+ ArrayList<String> from = getProducedBy (clsConsumed[i]);
+ if (from == null) {
+ continue;
+ }
+ boolean noUse = true;
+ for (int j = 0; j < from.size(); ++j) {
+ ArrayList<String> libClasses = getLibraryClassList(from.get(j), classProduced);
+ for (int k = 0; k < libClasses.size(); ++k) {
+ if (getConsumedBy (libClasses.get(k)) != null && getConsumedBy (libClasses.get(k)).size() > 0) {
+ noUse = false;
+ }
+ }
+ if (noUse) {
+ removeInstance(from.get(j));
+ }
+ noUse = true;
+ }
+ }
}
}
@@ -738,7 +786,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { jPanelPcd.add(getJPanelPcdSouth(), java.awt.BorderLayout.SOUTH);
jPanelPcd.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent e) {
- initPcdBuildDefinition(moduleSaNum);
+ initPcdBuildDefinition(moduleKey);
}
});
@@ -1124,9 +1172,14 @@ public class FpdModuleSA extends JDialog implements ActionListener { String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();
String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString();
String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString();
- ArrayList<String> al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType));
+ LibraryClassDescriptor lcd = new LibraryClassDescriptor(cls, arch, modType);
+ ArrayList<String> al = classInstanceMap.get(lcd);
if (al == null) {
- return;
+ al = getInstancesForClass(lcd, null);
+ if (al.size() != 0) {
+ classInstanceMap.put(lcd, al);
+ }
+
}
ListIterator<String> li = al.listIterator();
while(li.hasNext()) {
@@ -1335,12 +1388,31 @@ public class FpdModuleSA extends JDialog implements ActionListener { return;
}
docConsole.setSaved(false);
- removeInstance(selectedInstancesTableModel.getValueAt(row, 1) + " " +
- selectedInstancesTableModel.getValueAt(row, 2) + " " +
- selectedInstancesTableModel.getValueAt(row, 3) + " " +
- selectedInstancesTableModel.getValueAt(row, 4));
- ffc.removeLibraryInstance(moduleKey, row);
- selectedInstancesTableModel.removeRow(row);
+ String instanceKey = selectedInstancesTableModel.getValueAt(row, 1) + " "
+ + selectedInstancesTableModel.getValueAt(row, 2) + " "
+ + selectedInstancesTableModel.getValueAt(row, 3) + " "
+ + selectedInstancesTableModel.getValueAt(row, 4);
+ removeInstance(instanceKey);
+
+ selectedInstancesTableModel.setRowCount(0);
+ int instanceCount = ffc.getLibraryInstancesCount(moduleKey);
+ if (instanceCount != 0) {
+ String[][] saa = new String[instanceCount][5];
+ ffc.getLibraryInstances(moduleKey, saa);
+ for (int i = 0; i < saa.length; ++i) {
+ String libInstanceKey = saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4];
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(libInstanceKey);
+ if (mi != null) {
+ //
+ // ToDo: verify this instance first.
+ //
+ saa[i][0] = mi.getName();
+ saa[i][2] = mi.getVersion();
+ saa[i][4] = mi.getPackageId().getVersion();
+ selectedInstancesTableModel.addRow(saa[i]);
+ }
+ }
+ }
showClassToResolved();
}
});
|