private FpdFileContents ffc = null;\r
private String moduleKey = null;\r
private ModuleIdentification moduleId = null;\r
- private int moduleSaNum = -1;\r
private HashMap<LibraryClassDescriptor, ArrayList<String>> classInstanceMap = null;\r
//\r
// map of <{libName, supArch, supMod}, list of Module information>\r
\r
public void setKey(String k, int i, OpeningPlatformType dc){\r
this.moduleKey = k;\r
- moduleSaNum = i;\r
this.docConsole = dc;\r
classInstanceMap = null;\r
classProduced = null;\r
classConsumed = null;\r
jTabbedPane.setSelectedIndex(0);\r
- initPcdBuildDefinition(i);\r
+ initPcdBuildDefinition(moduleKey);\r
moduleId = WorkspaceProfile.getModuleId(moduleKey);\r
if (moduleId == null) {\r
return;\r
init will be called each time FpdModuleSA object is to be shown.\r
@param key Module information.\r
**/\r
- public void initPcdBuildDefinition(int i) {\r
+ public void initPcdBuildDefinition(String key) {\r
//\r
// display pcd for key.\r
//\r
jComboBoxItemType.setSelectedIndex(-1);\r
jTextFieldMaxDatumSize.setText("");\r
jTextFieldPcdDefault.setText("");\r
- int pcdCount = ffc.getPcdDataCount(i);\r
+ int pcdCount = ffc.getPcdDataCount(key);\r
if (pcdCount != 0) {\r
String[][] saa = new String[pcdCount][7];\r
- ffc.getPcdData(i, saa);\r
+ ffc.getPcdData(key, saa);\r
for (int j = 0; j < saa.length; ++j) {\r
model.addRow(saa[j]);\r
}\r
Stack<LibraryClassDescriptor> lcdStack = new Stack<LibraryClassDescriptor>();\r
while (iter.hasNext()) {\r
LibraryClassDescriptor lcd = iter.next();\r
+ if (this.classConsumed.get(lcd) == null || this.classConsumed.get(lcd).size() == 0) {\r
+ continue;\r
+ }\r
if (isBoundedClass(lcd, errorMsg)) {\r
continue;\r
}\r
return null;\r
}\r
\r
+ private ArrayList<String> getProducedBy (String className) {\r
+ Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();\r
+ while (lcdi.hasNext()) {\r
+ LibraryClassDescriptor lcd = lcdi.next();\r
+ if ((lcd.className != null) && lcd.className.equals(className)) {\r
+ return this.classProduced.get(lcd);\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ //\r
+ // Get class name list related with instanceKey from HashMap m<LibraryClass, ArrayList<instanceKey>>.\r
+ //\r
+ private ArrayList<String> getLibraryClassList (String instanceKey, HashMap<LibraryClassDescriptor, ArrayList<String>> m) {\r
+ ArrayList<String> libraryClass = new ArrayList<String>();\r
+ Iterator<LibraryClassDescriptor> lcdi = m.keySet().iterator();\r
+ while (lcdi.hasNext()) {\r
+ LibraryClassDescriptor lcd = lcdi.next();\r
+ if ((m.get(lcd) != null) && m.get(lcd).contains(instanceKey)) {\r
+ libraryClass.add(lcd.className);\r
+ }\r
+ }\r
+ return libraryClass;\r
+ }\r
+ \r
private void removeInstance(String key) {\r
ModuleIdentification mi = WorkspaceProfile.getModuleId(key); \r
//\r
// remove pcd information of instance from current ModuleSA\r
+ // Note that Pcd data SHOULD be removed prior to library instance\r
+ // because Multi-Sourced PCD could not be removed, if we remove library instance first,\r
+ // it will impact the judgement of whether a PCD entry is Multi-Sourced.\r
//\r
ffc.removePcdData(moduleKey, mi);\r
+ ffc.removeLibraryInstance(moduleKey, key);\r
//\r
// remove class produced by this instance and add back these produced class to be bound.\r
//\r
continue;\r
}\r
al.remove(key);\r
- \r
+ if (al.size() == 0) {\r
+ ArrayList<String> from = getProducedBy (clsConsumed[i]);\r
+ if (from == null) {\r
+ continue;\r
+ }\r
+ boolean noUse = true;\r
+ for (int j = 0; j < from.size(); ++j) {\r
+ ArrayList<String> libClasses = getLibraryClassList(from.get(j), classProduced);\r
+ for (int k = 0; k < libClasses.size(); ++k) {\r
+ if (getConsumedBy (libClasses.get(k)) != null && getConsumedBy (libClasses.get(k)).size() > 0) {\r
+ noUse = false;\r
+ }\r
+ }\r
+ if (noUse) {\r
+ removeInstance(from.get(j));\r
+ }\r
+ noUse = true;\r
+ }\r
+ }\r
}\r
\r
}\r
jPanelPcd.add(getJPanelPcdSouth(), java.awt.BorderLayout.SOUTH);\r
jPanelPcd.addComponentListener(new java.awt.event.ComponentAdapter() {\r
public void componentShown(java.awt.event.ComponentEvent e) {\r
- initPcdBuildDefinition(moduleSaNum);\r
+ initPcdBuildDefinition(moduleKey);\r
}\r
});\r
\r
String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();\r
String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString();\r
String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString();\r
- ArrayList<String> al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType));\r
+ LibraryClassDescriptor lcd = new LibraryClassDescriptor(cls, arch, modType);\r
+ ArrayList<String> al = classInstanceMap.get(lcd);\r
if (al == null) {\r
- return;\r
+ al = getInstancesForClass(lcd, null);\r
+ if (al.size() != 0) {\r
+ classInstanceMap.put(lcd, al);\r
+ }\r
+ \r
}\r
ListIterator<String> li = al.listIterator();\r
while(li.hasNext()) {\r
return;\r
}\r
docConsole.setSaved(false);\r
- removeInstance(selectedInstancesTableModel.getValueAt(row, 1) + " " +\r
- selectedInstancesTableModel.getValueAt(row, 2) + " " +\r
- selectedInstancesTableModel.getValueAt(row, 3) + " " +\r
- selectedInstancesTableModel.getValueAt(row, 4));\r
- ffc.removeLibraryInstance(moduleKey, row);\r
- selectedInstancesTableModel.removeRow(row);\r
+ String instanceKey = selectedInstancesTableModel.getValueAt(row, 1) + " "\r
+ + selectedInstancesTableModel.getValueAt(row, 2) + " "\r
+ + selectedInstancesTableModel.getValueAt(row, 3) + " "\r
+ + selectedInstancesTableModel.getValueAt(row, 4);\r
+ removeInstance(instanceKey);\r
+ \r
+ selectedInstancesTableModel.setRowCount(0);\r
+ int instanceCount = ffc.getLibraryInstancesCount(moduleKey);\r
+ if (instanceCount != 0) {\r
+ String[][] saa = new String[instanceCount][5];\r
+ ffc.getLibraryInstances(moduleKey, saa);\r
+ for (int i = 0; i < saa.length; ++i) {\r
+ String libInstanceKey = saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4];\r
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(libInstanceKey);\r
+ if (mi != null) {\r
+ //\r
+ // ToDo: verify this instance first.\r
+ //\r
+ saa[i][0] = mi.getName();\r
+ saa[i][2] = mi.getVersion();\r
+ saa[i][4] = mi.getPackageId().getVersion();\r
+ selectedInstancesTableModel.addRow(saa[i]);\r
+ }\r
+ }\r
+ }\r
showClassToResolved();\r
}\r
});\r