import java.awt.Dimension;\r
import java.awt.Toolkit;\r
\r
-import javax.swing.JFrame;\r
import javax.swing.JOptionPane;\r
import javax.swing.JPanel;\r
import javax.swing.JDialog;\r
import javax.swing.table.TableColumn;\r
import javax.swing.table.TableModel;\r
\r
+import org.tianocore.frameworkwizard.FrameworkWizardUI;\r
import org.tianocore.frameworkwizard.common.DataValidation;\r
import org.tianocore.frameworkwizard.common.GlobalData;\r
import org.tianocore.frameworkwizard.common.IDefaultTableModel;\r
* \r
*/\r
private static final long serialVersionUID = 1L;\r
- static JFrame frame;\r
private JPanel jContentPane = null;\r
private JTabbedPane jTabbedPane = null;\r
private JPanel jPanelPcd = null;\r
private DefaultTableModel optionsTableModel = null;\r
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
* This is the default constructor\r
*/\r
public FpdModuleSA() {\r
- super();\r
+ super(FrameworkWizardUI.getInstance());\r
initialize();\r
}\r
public FpdModuleSA(FpdFileContents ffc) {\r
classConsumed = null;\r
jTabbedPane.setSelectedIndex(0);\r
initPcdBuildDefinition(i);\r
- ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
- if (mi == null) {\r
+ moduleId = WorkspaceProfile.getModuleId(moduleKey);\r
+ if (moduleId == null) {\r
return;\r
}\r
int tabIndex = jTabbedPane.indexOfTab("Libraries");\r
- if (mi.isLibrary()) {\r
+ if (moduleId.isLibrary()) {\r
jTabbedPane.setEnabledAt(tabIndex, false);\r
}\r
else {\r
} catch (Exception e) {\r
String exceptionMsg = e.getCause() + " " + e.getMessage();\r
errorMsg.add(exceptionMsg);\r
- JOptionPane.showMessageDialog(frame, exceptionMsg);\r
+ JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), exceptionMsg);\r
}\r
//\r
// display lib instances already selected for key\r
} catch (Exception e) {\r
String exceptionMsg = e.getCause() + " " + e.getMessage();\r
if (!errorMsg.contains(exceptionMsg)) {\r
- JOptionPane.showMessageDialog(frame, e.getCause() + " " + e.getMessage());\r
+ JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), e.getCause() + " " + e.getMessage());\r
}\r
}\r
selectedInstancesTableModel.addRow(saa[i]);\r
for (int i = 0; i < errorMsg.size(); ++i) {\r
errors += " " + errorMsg.get(i) + "\n";\r
}\r
- JOptionPane.showMessageDialog(frame, errors);\r
+ JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), errors);\r
}\r
showClassToResolved();\r
}\r
//\r
// Get dependency pkg list into which we will search lib instances.\r
//\r
- depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi);\r
+ //depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi);\r
//\r
// Get the lib class consumed, produced by this module itself.\r
//\r
Vector<LibraryClassDescriptor> vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);\r
+ for (int i = 0; i < vClassConsumed.size(); ++i) {\r
+ vClassConsumed.get(i).supModTypes = WorkspaceProfile.getModuleType(moduleId);\r
+ }\r
filterClassConsumedByArch(vClassConsumed);\r
if (this.classConsumed == null) {\r
this.classConsumed = new HashMap<LibraryClassDescriptor, ArrayList<String>>();\r
Iterator<LibraryClassDescriptor> lic = this.classConsumed.keySet().iterator();\r
while (lic.hasNext()) {\r
LibraryClassDescriptor cls = lic.next();\r
- if (isBoundedClass(cls)) {\r
+ if (isBoundedClass(cls, errorMsg)) {\r
continue;\r
}\r
ArrayList<String> instances = getInstancesForClass(cls, depPkgList);\r
* @param cls\r
* @return\r
*/\r
- private boolean isBoundedClass (LibraryClassDescriptor cls) {\r
- if (this.classProduced.containsKey(cls)) {\r
- return true;\r
- }\r
+ private boolean isBoundedClass (LibraryClassDescriptor cls, Vector<String> errorMsg) {\r
+// if (this.classProduced.containsKey(cls)) {\r
+// return true;\r
+// }\r
Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();\r
while (lcdi.hasNext()) {\r
LibraryClassDescriptor lcd = lcdi.next();\r
- if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) {\r
- return true;\r
+ if (cls.className.equals(lcd.className)) {\r
+ if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) {\r
+ return true;\r
+ }\r
+ else {\r
+ ArrayList<String> producedBy = this.classProduced.get(lcd);\r
+ String instancesName = "";\r
+ for (int i = 0; i < producedBy.size(); ++i) {\r
+ ModuleIdentification mi = WorkspaceProfile.getModuleId(producedBy.get(i));\r
+ instancesName += mi.getName();\r
+ instancesName += " ";\r
+ }\r
+ String msg = new ImproperInstanceException(lcd.className, instancesName, lcd.supArchs, lcd.supModTypes).getMessage();\r
+ if (!errorMsg.contains(msg)) {\r
+ errorMsg.add(msg);\r
+ }\r
+ }\r
}\r
}\r
\r
isPotential = true;\r
}\r
\r
- if (hasBeenProduced(lcd)) {\r
+ if (isPotential && hasBeenProduced(lcd)) {\r
isPotential = false;\r
break;\r
}\r
Iterator<LibraryClassDescriptor> lcdi = this.classProduced.keySet().iterator();\r
while (lcdi.hasNext()) {\r
LibraryClassDescriptor lcd = lcdi.next();\r
- if (cls.hasInterSectionWith(lcd)) {\r
+ if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) {\r
return true;\r
}\r
}\r
}\r
\r
private void showClassToResolved(){\r
+ Vector<String> errorMsg = new Vector<String>();\r
libClassTableModel.setRowCount(0);\r
libInstanceTableModel.setRowCount(0);\r
if (classConsumed == null || classConsumed.size() == 0) {\r
continue;\r
}\r
\r
- if (!isBoundedClass(lcd)){\r
+ if (!isBoundedClass(lcd, errorMsg)){\r
libClassTableModel.addRow(s);\r
}\r
}\r
\r
+ if (errorMsg.size() > 0) {\r
+ String errors = "";\r
+ for (int i = 0; i < errorMsg.size(); ++i) {\r
+ errors += " " + errorMsg.get(i) + "\n";\r
+ }\r
+ JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), errors);\r
+ }\r
}\r
\r
+ private String getModuleArch () {\r
+ String arch = "";\r
+ String[] moduleInfo = moduleKey.split(" ");\r
+ for (int i = 4; i < moduleInfo.length; ++i) {\r
+ arch += moduleInfo[i];\r
+ arch += " ";\r
+ }\r
+ return arch.trim();\r
+ }\r
private void addLibInstance (ModuleIdentification libMi) throws Exception{\r
\r
//\r
// Add pcd information of selected instance to current moduleSA\r
//\r
- ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));\r
+ ffc.addFrameworkModulesPcdBuildDefs(libMi, getModuleArch(), ffc.getModuleSA(moduleKey));\r
\r
ffc.genLibraryInstance(libMi, moduleKey);\r
}\r
jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(selectedRow, 6)+"")+"");\r
}\r
catch(Exception except){\r
- JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "Unacceptable PCD Value: " + except.getMessage());\r
}\r
}\r
else{\r
addLibInstance (libMi);\r
}\r
catch (Exception exception) {\r
- JOptionPane.showMessageDialog(frame, "Adding Instance " + libMi.getName() + " : \n"+ exception.getMessage());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "Adding Instance " + libMi.getName() + " : \n"+ exception.getMessage());\r
return;\r
}\r
docConsole.setSaved(false);\r
resolveLibraryInstances(instanceValue, errorMsg);\r
}\r
catch (Exception exp) {\r
- JOptionPane.showMessageDialog(frame, exp.getMessage());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, exp.getMessage());\r
}\r
\r
if (errorMsg.size() > 0) {\r
for (int i = 0; i < errorMsg.size(); ++i) {\r
errors += " " + errorMsg.get(i) + "\n";\r
}\r
- JOptionPane.showMessageDialog(frame, errors);\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, errors);\r
}\r
showClassToResolved();\r
}\r
}\r
if (newFileGuid.length() > 0) {\r
if (!DataValidation.isGuid(newFileGuid)) {\r
- JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type.");\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "FFS File Guid is NOT GUID Type.");\r
return;\r
}\r
}\r
vArch.add("EBC");\r
vArch.add("ARM");\r
vArch.add("PPC");\r
- jTableModuleSaOptions.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch));\r
+ jTableModuleSaOptions.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch, FrameworkWizardUI.getInstance()));\r
\r
- jTableModuleSaOptions.getColumnModel().getColumn(5).setCellEditor(new LongTextEditor());\r
+ jTableModuleSaOptions.getColumnModel().getColumn(5).setCellEditor(new LongTextEditor(FrameworkWizardUI.getInstance()));\r
\r
jTableModuleSaOptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
jTableModuleSaOptions.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
ffc.addDynamicPcdBuildData(cName, model.getValueAt(jTablePcd.getSelectedRow(), 3), tsGuid, "DYNAMIC", model.getValueAt(jTablePcd.getSelectedRow(), 5)+"", jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+"");\r
}\r
catch(Exception e){\r
- JOptionPane.showMessageDialog(frame, "PCD value format: " + e.getMessage());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "PCD value format: " + e.getMessage());\r
}\r
}\r
\r
jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(newValue)+"");\r
}\r
catch (Exception exp) {\r
- JOptionPane.showMessageDialog(frame, "PCD Value MalFormed: " + exp.getMessage());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "PCD Value MalFormed: " + exp.getMessage());\r
return;\r
}\r
}\r
try {\r
boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo);\r
if (!changable) {\r
- JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName());\r
return;\r
}\r
}\r
catch (Exception exp) {\r
- JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage());\r
+ JOptionPane.showMessageDialog(FpdModuleSA.this, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage());\r
return;\r
}\r
\r
\r
}\r
\r
+class ImproperInstanceException extends Exception {\r
+\r
+ /**\r
+ * \r
+ */\r
+ private static final long serialVersionUID = -5279700566993277033L;\r
+ private String className = null;\r
+ private String libInstance = null;\r
+ private String instanceSupArch = null;\r
+ private String instanceSupModType = null;\r
+ \r
+ ImproperInstanceException (String libClass, String instance1, String arch, String type) {\r
+ super();\r
+ className = libClass;\r
+ libInstance = instance1;\r
+ instanceSupArch = arch;\r
+ instanceSupModType = type;\r
+ }\r
+\r
+ /* (non-Javadoc)\r
+ * @see java.lang.Throwable#getMessage()\r
+ */\r
+ @Override\r
+ public String getMessage() {\r
+ // TODO Auto-generated method stub\r
+ return " Library Class " + className + " Produced by Library Instance: " \r
+ + libInstance + "\nOnly Supports " + instanceSupArch + " and Module Type " + instanceSupModType + ".\n This instance should be removed.\n";\r
+ }\r
+ \r
+}\r
+\r
class NoInstanceException extends Exception {\r
\r
/**\r