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 errorMsg = new Vector(); - 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 newInstances = new Vector(); + + 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 sLcd = this.classConsumed.keySet(); + Iterator iter = sLcd.iterator(); + Stack lcdStack = new Stack(); + 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 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 errorMsg) throws MultipleInstanceException, NoInstanceException{ - - Vector vLcd = addConsumedClassFromModule (key); - addProducedClassFromModule (key); - - Stack lcdStack = new Stack(); - for (int i = 0; i < vLcd.size(); ++i) { - LibraryClassDescriptor cls = vLcd.get(i); - lcdStack.push(cls); - } + private void resolveLibraryInstances(Stack lcdStack, boolean autoSelectSingleInstance, Vector errorMsg, Vector newInstances) throws MultipleInstanceException, NoInstanceException{ if (classInstanceMap == null) { classInstanceMap = new HashMap>(); - } + } 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 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 vLcd = addConsumedClassFromModule (libInstanceKey); + addProducedClassFromModule (libInstanceKey); + Vector errorMsg = new Vector(); + Vector newInstances = new Vector(); + Stack lcdStack = new Stack(); + 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(); } }); }