diff options
author | jlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-31 11:43:58 +0000 |
---|---|---|
committer | jlin16 <jlin16@6f19259b-4bc3-4df7-8a09-765794883524> | 2007-01-31 11:43:58 +0000 |
commit | fd0f684ffa1f4a39f6e67b6209cef11f490017ed (patch) | |
tree | 48f53d2486169c6b4403fdf65b02b3875a0e544d /Tools/Java | |
parent | 9e011eacdbc44b753abac2cb77998f84412a7d10 (diff) | |
download | edk2-platforms-fd0f684ffa1f4a39f6e67b6209cef11f490017ed.tar.xz |
Optimize library instance selection algorithm.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2342 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Java')
2 files changed, 88 insertions, 49 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 594390c328..adc6d265a1 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 @@ -786,9 +786,24 @@ public class FpdFileContents { String[][] saa = new String[count][5];
getLibraryInstances (key, saa);
for (int i = 0; i < count; ++i) {
- if (mg.equalsIgnoreCase(saa[i][1]) && mv.equalsIgnoreCase(saa[i][2]) && pg.equalsIgnoreCase(saa[i][3]) && pv.equalsIgnoreCase(saa[i][4])) {
+ if (mg.equalsIgnoreCase(saa[i][1]) && pg.equalsIgnoreCase(saa[i][3])) {
+ boolean modVerMatch = false;
+ boolean pkgVerMatch = false;
+ if ((mv.equals("null") || saa[i][2] == null)) {
+ modVerMatch = true;
+ }
+ if (pv.equals("null") || saa[i][4] == null) {
+ pkgVerMatch = true;
+ }
+ if (modVerMatch && pkgVerMatch) {
return true;
}
+ else {
+ if (mv.equals(saa[i][2]) && pv.equals(saa[i][4])) {
+ return true;
+ }
+ }
+ }
}
}
return false;
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 d6b13238af..102dd3dc46 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 @@ -41,6 +41,7 @@ import java.util.ArrayList; import java.util.HashMap;
import java.util.Iterator;
import java.util.ListIterator;
+import java.util.Set;
import java.util.Stack;
import java.util.Vector;
@@ -201,27 +202,18 @@ public class FpdModuleSA extends JDialog implements ActionListener { libInstanceTableModel.setRowCount(0);
selectedInstancesTableModel.setRowCount(0);
Vector<String> errorMsg = new Vector<String>();
- try {
- //
- // display library classes that need to be resolved. also potential instances for them.
- //
- resolveLibraryInstances(moduleKey, true, errorMsg);
- } catch (Exception e) {
- String exceptionMsg = e.getCause() + " " + e.getMessage();
- errorMsg.add(exceptionMsg);
- JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), exceptionMsg);
- }
- //
- // display lib instances already selected for key
- //
+ Vector<ModuleIdentification> newInstances = new Vector<ModuleIdentification>();
+
+ addConsumedClassFromModule (key);
+ addProducedClassFromModule (key);
int instanceCount = ffc.getLibraryInstancesCount(key);
if (instanceCount != 0) {
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]);
+ 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.
@@ -232,19 +224,48 @@ 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], true, errorMsg);
- } catch (Exception e) {
- String exceptionMsg = e.getCause() + " " + e.getMessage();
- if (!errorMsg.contains(exceptionMsg)) {
- JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), e.getCause() + " " + e.getMessage());
- }
- }
+ addConsumedClassFromModule (libInstanceKey);
+ addProducedClassFromModule (libInstanceKey);
selectedInstancesTableModel.addRow(saa[i]);
}
}
}
-
+
+ Set<LibraryClassDescriptor> sLcd = this.classConsumed.keySet();
+ Iterator<LibraryClassDescriptor> iter = sLcd.iterator();
+ Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>();
+ while (iter.hasNext()) {
+ LibraryClassDescriptor lcd = iter.next();
+ if (isBoundedClass(lcd, errorMsg)) {
+ continue;
+ }
+
+ if (!lcdStack.contains(lcd)) {
+ lcdStack.push(lcd);
+ }
+ }
+
+ try {
+ resolveLibraryInstances(lcdStack, true, errorMsg, newInstances);
+ } catch (Exception e) {
+ String exceptionMsg = e.getCause() + " " + e.getMessage();
+ if (!errorMsg.contains(exceptionMsg)) {
+ JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), e.getCause() + " " + e.getMessage());
+ }
+ }
+
+ String newInstancesAddedMsg = "Library instance automatically added to this module :\n";
+ for (int i = 0; i < newInstances.size(); ++i) {
+ ModuleIdentification libMi = newInstances.get(i);
+ newInstancesAddedMsg += libMi.getName();
+ newInstancesAddedMsg += " ";
+ }
+ if (newInstances.size() > 0) {
+ JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), newInstancesAddedMsg);
+ }
+
+ showClassToResolved();
+
if (errorMsg.size() > 0) {
String errors = "";
for (int i = 0; i < errorMsg.size(); ++i) {
@@ -383,7 +404,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { private Vector<LibraryClassDescriptor> addConsumedClassFromModule (String key) {
ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
// PackageIdentification[] depPkgList = null;
-
+
//
// Get dependency pkg list into which we will search lib instances.
//
@@ -412,20 +433,11 @@ public class FpdModuleSA extends JDialog implements ActionListener { return vClassConsumed;
}
- private void resolveLibraryInstances(String key, boolean autoSelectSingleInstance, Vector<String> errorMsg) throws MultipleInstanceException, NoInstanceException{
-
- Vector<LibraryClassDescriptor> vLcd = addConsumedClassFromModule (key);
- addProducedClassFromModule (key);
-
- Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>();
- for (int i = 0; i < vLcd.size(); ++i) {
- LibraryClassDescriptor cls = vLcd.get(i);
- lcdStack.push(cls);
- }
+ private void resolveLibraryInstances(Stack<LibraryClassDescriptor> lcdStack, boolean autoSelectSingleInstance, Vector<String> errorMsg, Vector<ModuleIdentification> newInstances) throws MultipleInstanceException, NoInstanceException{
if (classInstanceMap == null) {
classInstanceMap = new HashMap<LibraryClassDescriptor, ArrayList<String>>();
- }
+ }
while (!lcdStack.empty()) {
LibraryClassDescriptor cls = lcdStack.pop();
if (isBoundedClass(cls, errorMsg)) {
@@ -449,13 +461,16 @@ public class FpdModuleSA extends JDialog implements ActionListener { libMi.getPackageId().getGuid(), libMi.getPackageId().getVersion()};
if (!ffc.instanceExistsInModuleSA(moduleKey, row[1]+"", row[2]+"", row[3]+"", row[4]+"")) {
addLibInstance(libMi);
+ newInstances.add(libMi);
docConsole.setSaved(false);
selectedInstancesTableModel.addRow(row);
addProducedClassFromModule (instanceInfo);
- vLcd = addConsumedClassFromModule(instanceInfo);
+ Vector<LibraryClassDescriptor> vLcd = addConsumedClassFromModule(instanceInfo);
for (int i = 0; i < vLcd.size(); ++i) {
LibraryClassDescriptor lcd = vLcd.get(i);
- lcdStack.push(lcd);
+ if (!lcdStack.contains(lcd)) {
+ lcdStack.push(lcd);
+ }
}
}
}
@@ -466,9 +481,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { }
}
}
-
- showClassToResolved();
- }
+ }
//
/**Search classProduced map to see if this class has been produced by some instance (module).
@@ -590,8 +603,6 @@ public class FpdModuleSA extends JDialog implements ActionListener { }
- showClassToResolved();
-
}
@@ -637,7 +648,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { libClassTableModel.addRow(s);
}
}
-
+
if (errorMsg.size() > 0) {
String errors = "";
for (int i = 0; i < errorMsg.size(); ++i) {
@@ -1255,11 +1266,11 @@ public class FpdModuleSA extends JDialog implements ActionListener { return;
}
- String instanceValue = libInstanceTableModel.getValueAt(row, 1) + " " +
+ String libInstanceKey = libInstanceTableModel.getValueAt(row, 1) + " " +
libInstanceTableModel.getValueAt(row, 2) + " " +
libInstanceTableModel.getValueAt(row, 3) + " " +
libInstanceTableModel.getValueAt(row, 4);
- ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceValue);
+ ModuleIdentification libMi = WorkspaceProfile.getModuleId(libInstanceKey);
try {
addLibInstance (libMi);
}
@@ -1273,14 +1284,27 @@ public class FpdModuleSA extends JDialog implements ActionListener { libInstanceTableModel.getValueAt(row, 4)};
selectedInstancesTableModel.addRow(s);
+ Vector<LibraryClassDescriptor> vLcd = addConsumedClassFromModule (libInstanceKey);
+ addProducedClassFromModule (libInstanceKey);
+
Vector<String> errorMsg = new Vector<String>();
+ Vector<ModuleIdentification> newInstances = new Vector<ModuleIdentification>();
+ Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>();
+ for (int i = 0; i < vLcd.size(); ++i) {
+ LibraryClassDescriptor lcd = vLcd.get(i);
+ if (!lcdStack.contains(lcd)) {
+ lcdStack.push(lcd);
+ }
+ }
try {
- resolveLibraryInstances(instanceValue, true, errorMsg);
+ resolveLibraryInstances(lcdStack, true, errorMsg, newInstances);
}
catch (Exception exp) {
JOptionPane.showMessageDialog(FpdModuleSA.this, exp.getMessage());
}
+ showClassToResolved();
+
if (errorMsg.size() > 0) {
String errors = "";
for (int i = 0; i < errorMsg.size(); ++i) {
@@ -1317,7 +1341,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { selectedInstancesTableModel.getValueAt(row, 4));
ffc.removeLibraryInstance(moduleKey, row);
selectedInstancesTableModel.removeRow(row);
-
+ showClassToResolved();
}
});
}
|