X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FJava%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdModuleSA.java;h=e46a9bbeaff6377fcdf5b3d93b18ee8b7f6f2ef5;hp=0b190ae2dbaa378bb9e7f46382085ee15ccb0c8b;hb=8cc715257a4ff625a9db7c51b051a3c36c194598;hpb=31095724f167213b99fab10c58507fd869975eda 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 0b190ae2db..e46a9bbeaf 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 @@ -21,12 +21,14 @@ import javax.swing.event.ListSelectionListener; import javax.swing.event.TableModelEvent; import javax.swing.event.TableModelListener; import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; import javax.swing.table.TableModel; import org.tianocore.frameworkwizard.common.DataValidation; import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.IDefaultTableModel; import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; +import org.tianocore.frameworkwizard.platform.ui.global.LibraryClassDescriptor; import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile; import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery; import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification; @@ -93,9 +95,13 @@ public class FpdModuleSA extends JDialog implements ActionListener { private FpdFileContents ffc = null; private String moduleKey = null; private int moduleSaNum = -1; - private HashMap> classInstanceMap = null; - private ArrayList classProduced = null; - private HashMap> classConsumed = null; + private HashMap> classInstanceMap = null; + // + // map of <{libName, supArch, supMod}, list of Module information> + // + private HashMap> classConsumed = null; + private HashMap> classProduced = null; + private JPanel jPanelModuleSaOpts = null; private JLabel jLabelFvBinding = null; private JTextField jTextFieldFvBinding = null; @@ -124,6 +130,14 @@ public class FpdModuleSA extends JDialog implements ActionListener { private JPanel jPanelToolchainS = null; private JPanel jPanelLibraryCenterN = null; private JPanel jPanelLibraryCenterC = null; // @jve:decl-index=0:visual-constraint="20,224" + + private final int buildTargetWidth = 150; + private final int toolChainFamilyWidth = 150; + private final int supportArchWidth = 150; + private final int toolCmdCodeWidth = 200; + private final int tagNameWidth = 150; + private final int argWidth = 400; + /** * This is the default constructor */ @@ -140,10 +154,22 @@ public class FpdModuleSA extends JDialog implements ActionListener { this.moduleKey = k; moduleSaNum = i; this.docConsole = dc; + classInstanceMap = null; classProduced = null; classConsumed = null; jTabbedPane.setSelectedIndex(0); initPcdBuildDefinition(i); + ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey); + if (mi == null) { + return; + } + int tabIndex = jTabbedPane.indexOfTab("Libraries"); + if (mi.isLibrary()) { + jTabbedPane.setEnabledAt(tabIndex, false); + } + else { + jTabbedPane.setEnabledAt(tabIndex, true); + } } /** @@ -170,20 +196,31 @@ public class FpdModuleSA extends JDialog implements ActionListener { } public void initLibraries(String key) { - // - // display library classes that need to be resolved. also potential instances for them. - // - resolveLibraryInstances(moduleKey); + libClassTableModel.setRowCount(0); + 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, errorMsg); + } catch (Exception e) { + String exceptionMsg = e.getCause() + " " + e.getMessage(); + errorMsg.add(exceptionMsg); + JOptionPane.showMessageDialog(frame, exceptionMsg); + } // // display lib instances already selected for key // - selectedInstancesTableModel.setRowCount(0); + 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]); + ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + + " " + saa[i][4]); if (mi != null) { // // ToDo: verify this instance first. @@ -194,11 +231,26 @@ public class FpdModuleSA extends JDialog implements ActionListener { // // re-evaluate lib instance usage when adding a already-selected lib instance. // - resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]); + try { + resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4], errorMsg); + } catch (Exception e) { + String exceptionMsg = e.getCause() + " " + e.getMessage(); + if (!errorMsg.contains(exceptionMsg)) { + JOptionPane.showMessageDialog(frame, e.getCause() + " " + e.getMessage()); + } + } selectedInstancesTableModel.addRow(saa[i]); } } } + + if (errorMsg.size() > 0) { + String errors = ""; + for (int i = 0; i < errorMsg.size(); ++i) { + errors += " " + errorMsg.get(i) + "\n"; + } + JOptionPane.showMessageDialog(frame, errors); + } showClassToResolved(); } @@ -233,71 +285,171 @@ public class FpdModuleSA extends JDialog implements ActionListener { } } - private void resolveLibraryInstances(String key) { - ModuleIdentification mi = WorkspaceProfile.getModuleId(key); - PackageIdentification[] depPkgList = null; - try{ + private void filterClassConsumedByArch (Vector v) { + String[] moduleInfo = moduleKey.split(" "); + Vector vModuleArchs = new Vector(); + // + // Skip guid, version information, get archs to check. + // + for (int i = 4; i < moduleInfo.length; ++i) { + vModuleArchs.add(moduleInfo[i]); + } + // + // if module will be built on all platforms, no filter needed for lib classes. + // + if (vModuleArchs.size() == 0) { + return; + } + + Iterator iter = v.iterator(); + while (iter.hasNext()) { + LibraryClassDescriptor libInfo = iter.next(); + + Vector vSupArchs = libInfo.getVectorFromString(libInfo.supArchs); + + if (vSupArchs.size() == 0 || (vSupArchs.size() == 1 && vSupArchs.get(0).equalsIgnoreCase(""))) { + // + // update lib info to module archs only. + // + libInfo.supArchs = ""; + for (int i = 0; i < vModuleArchs.size(); ++i) { + libInfo.supArchs += vModuleArchs.get(i); + libInfo.supArchs += " "; + } + libInfo.supArchs.trim(); + continue; + } // - // Get dependency pkg list into which we will search lib instances. + // only retain those lib class used by module archs. // - depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi); + vSupArchs.retainAll(vModuleArchs); + if (vSupArchs.size() > 0) { + // + // update lib info to reflect which kind of arch need to select instance. + // + libInfo.supArchs = ""; + for (int i = 0; i < vSupArchs.size(); ++i) { + libInfo.supArchs += vSupArchs.get(i); + libInfo.supArchs += " "; + } + libInfo.supArchs.trim(); + continue; + } // - // Get the lib class consumed, produced by this module itself. + // remove this lib definition if it supports no archs module will be built under. // - Vector vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi); - - if (this.classConsumed == null) { - this.classConsumed = new HashMap>(); + iter.remove(); + } + } + + private void resolveLibraryInstances(String key, Vector errorMsg) throws MultipleInstanceException, NoInstanceException{ + ModuleIdentification mi = WorkspaceProfile.getModuleId(key); + PackageIdentification[] depPkgList = null; + + // + // Get dependency pkg list into which we will search lib instances. + // + depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi); + // + // Get the lib class consumed, produced by this module itself. + // + Vector vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi); + filterClassConsumedByArch(vClassConsumed); + if (this.classConsumed == null) { + this.classConsumed = new HashMap>(); + } + + for (int i = 0; i < vClassConsumed.size(); ++i) { + ArrayList consumedBy = this.classConsumed.get(vClassConsumed.get(i)); + if (consumedBy == null) { + consumedBy = new ArrayList(); } - - for(int i = 0; i < vClassConsumed.size(); ++i){ - ArrayList consumedBy = this.classConsumed.get(vClassConsumed.get(i)); - if (consumedBy == null) { - consumedBy = new ArrayList(); - } - consumedBy.add(key); - this.classConsumed.put(vClassConsumed.get(i), consumedBy); + consumedBy.add(key); + this.classConsumed.put(vClassConsumed.get(i), consumedBy); + } + + Vector vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi); + if (this.classProduced == null) { + this.classProduced = new HashMap>(); + } + for (int i = 0; i < vClassProduced.size(); ++i) { + ArrayList producedBy = this.classProduced.get(vClassProduced.get(i)); + if (producedBy == null) { + producedBy = new ArrayList(); } - - Vector vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi); - if (this.classProduced == null) { - this.classProduced = new ArrayList(); + // + // class already produced by previous module (lib instance). + /* + if (producedBy.size() == 1) { + String instanceKey = producedBy.get(0); + ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceKey); + throw new MultipleInstanceException (vClassProduced.get(i).className, libMi.getName(), mi.getName()); } - for(int i = 0; i < vClassProduced.size(); ++i){ - if (!this.classProduced.contains(vClassProduced.get(i))){ - this.classProduced.add(vClassProduced.get(i)); + Iterator lcdi = this.classProduced.keySet().iterator(); + while (lcdi.hasNext()) { + LibraryClassDescriptor lcd = lcdi.next(); + if (vClassProduced.get(i).hasInterSectionWith(lcd)) { + ArrayList alreadyProducedBy = this.classProduced.get(lcd); + String instanceKey = alreadyProducedBy.get(0); + ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceKey); + throw new MultipleInstanceException (vClassProduced.get(i).className, libMi.getName(), mi.getName()); } } - + */ + // normal case. // - // find potential instances in all pkgs for classes still in classConsumed. - // - if (classInstanceMap == null){ - classInstanceMap = new HashMap>(); + producedBy.add(key); + this.classProduced.put(vClassProduced.get(i), producedBy); + + } + + // + // find potential instances in all pkgs for classes still in classConsumed. + // + if (classInstanceMap == null) { + classInstanceMap = new HashMap>(); + } + Iterator lic = this.classConsumed.keySet().iterator(); + while (lic.hasNext()) { + LibraryClassDescriptor cls = lic.next(); + if (isBoundedClass(cls)) { + continue; } - Iterator lic = this.classConsumed.keySet().iterator(); - while(lic.hasNext()){ - String cls = lic.next(); - if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) { - continue; - } - ArrayList instances = getInstancesForClass(cls, depPkgList); - if (instances.size() == 0){ - JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " + - cls + ", Platform Build will Fail."); + ArrayList instances = getInstancesForClass(cls, depPkgList); + if (instances.size() == 0) { +// throw new NoInstanceException (cls.className); + String exceptionMsg = new NoInstanceException (cls.className).getMessage(); + if (!errorMsg.contains(exceptionMsg)) { + errorMsg.add(exceptionMsg); } - classInstanceMap.put(cls, instances); } - + classInstanceMap.put(cls, instances); + + } // showClassToResolved(); + } + + /**Search classProduced map to see if this class has been produced by some instance (module). + * @param cls + * @return + */ + private boolean isBoundedClass (LibraryClassDescriptor cls) { + if (this.classProduced.containsKey(cls)) { + return true; } - catch(Exception e) { - e.printStackTrace(); + Iterator lcdi = this.classProduced.keySet().iterator(); + while (lcdi.hasNext()) { + LibraryClassDescriptor lcd = lcdi.next(); + if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) { + return true; + } } + + return false; } - private ArrayList getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{ + private ArrayList getInstancesForClass(LibraryClassDescriptor cls, PackageIdentification[] depPkgList){ ArrayList al = new ArrayList(); // for (int i = 0; i < depPkgList.length; ++i) { @@ -307,17 +459,17 @@ public class FpdModuleSA extends JDialog implements ActionListener { // if (!mi.getPackageId().getGuid().equalsIgnoreCase(depPkgList[i].getGuid())) { // continue; // } - String[] clsProduced = getClassProduced(mi); + Vector clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi); boolean isPotential = false; - for (int j = 0; j < clsProduced.length; ++j) { - if (clsProduced[j] == null) { - continue; - } - if (clsProduced[j].equals(cls)){ + Iterator lcdi = clsProduced.iterator(); + while (lcdi.hasNext()) { + LibraryClassDescriptor lcd = lcdi.next(); + if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)){ isPotential = true; } - if (classProduced.contains(clsProduced[j])) { + + if (hasBeenProduced(lcd)) { isPotential = false; break; } @@ -332,6 +484,28 @@ public class FpdModuleSA extends JDialog implements ActionListener { return al; } + private boolean hasBeenProduced (LibraryClassDescriptor cls) { + Iterator lcdi = this.classProduced.keySet().iterator(); + while (lcdi.hasNext()) { + LibraryClassDescriptor lcd = lcdi.next(); + if (cls.hasInterSectionWith(lcd)) { + return true; + } + } + return false; + } + + private ArrayList getConsumedBy (String className) { + Iterator lcdi = this.classConsumed.keySet().iterator(); + while (lcdi.hasNext()) { + LibraryClassDescriptor lcd = lcdi.next(); + if (lcd.className.equals(className)) { + return this.classConsumed.get(lcd); + } + } + return null; + } + private void removeInstance(String key) { ModuleIdentification mi = WorkspaceProfile.getModuleId(key); // @@ -341,86 +515,70 @@ public class FpdModuleSA extends JDialog implements ActionListener { // // remove class produced by this instance and add back these produced class to be bound. // - String[] clsProduced = getClassProduced(mi); - for (int i = 0; i < clsProduced.length; ++i) { + Vector clsProduced = getClassProduced(mi); + for (int i = 0; i < clsProduced.size(); ++i) { - classProduced.remove(clsProduced[i]); + classProduced.remove(clsProduced.get(i)); } // // remove class consumed by this instance. we do not need to bound it now. // String[] clsConsumed = getClassConsumed(mi); for (int i = 0; i < clsConsumed.length; ++i) { - ArrayList al = classConsumed.get(clsConsumed[i]); + ArrayList al = getConsumedBy (clsConsumed[i]); if (al == null ) { - classConsumed.remove(clsConsumed[i]); continue; } al.remove(key); - if (al.size() == 0) { - classConsumed.remove(clsConsumed[i]); - } - + } - + showClassToResolved(); } - private String[] getClassProduced(ModuleIdentification mi){ - - try{ - Vector clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi); - String[] sClassProduced = new String[clsProduced.size()]; - for (int i = 0; i < clsProduced.size(); ++i) { - sClassProduced[i] = clsProduced.get(i); - } - return sClassProduced; - - }catch (Exception e) { - e.printStackTrace(); - } - return new String[0]; + private Vector getClassProduced(ModuleIdentification mi){ + Vector clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi); + return clsProduced; +// String[] sClassProduced = new String[clsProduced.size()]; +// for (int i = 0; i < clsProduced.size(); ++i) { +// sClassProduced[i] = clsProduced.get(i).className; +// } +// return sClassProduced; } private String[] getClassConsumed(ModuleIdentification mi){ - try{ - Vector clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi); - String[] sClassConsumed = new String[clsConsumed.size()]; - for (int i = 0; i < clsConsumed.size(); ++i) { - sClassConsumed[i] = clsConsumed.get(i); - } - return sClassConsumed; - }catch (Exception e) { - e.printStackTrace(); + Vector clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi); + String[] sClassConsumed = new String[clsConsumed.size()]; + for (int i = 0; i < clsConsumed.size(); ++i) { + sClassConsumed[i] = clsConsumed.get(i).className; } - return new String[0]; + return sClassConsumed; } private void showClassToResolved(){ libClassTableModel.setRowCount(0); - if (classConsumed.size() == 0) { + libInstanceTableModel.setRowCount(0); + if (classConsumed == null || classConsumed.size() == 0) { return; } - Iterator li = classConsumed.keySet().iterator(); + Iterator li = classConsumed.keySet().iterator(); while(li.hasNext()){ + LibraryClassDescriptor lcd = li.next(); + String[] s = {lcd.className, lcd.supArchs, lcd.supModTypes}; + if (classConsumed.get(lcd) == null || classConsumed.get(lcd).size() == 0) { + continue; + } - String[] s = {li.next()}; -// if (classConsumed.get(s[0]) == null) { -// continue; -// } -// if (classConsumed.get(s[0]).size() == 0) { -// continue; -// } - if (!classProduced.contains(s[0])){ + if (!isBoundedClass(lcd)){ libClassTableModel.addRow(s); } } - libInstanceTableModel.setRowCount(0); + } private void addLibInstance (ModuleIdentification libMi) throws Exception{ @@ -554,6 +712,11 @@ public class FpdModuleSA extends JDialog implements ActionListener { model.addColumn("MaxDatumSize"); model.addColumn("DataType"); model.addColumn("DefaultValue"); + + jTablePcd.getColumnModel().getColumn(0).setMinWidth(250); + + TableColumn tokenColumn = jTablePcd.getColumnModel().getColumn(3); + jTablePcd.removeColumn(tokenColumn); jTablePcd.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTablePcd.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ @@ -575,15 +738,16 @@ public class FpdModuleSA extends JDialog implements ActionListener { // array for pcd related information: helpText, itemType, moduleType. // String[] pcdInfo = {"", "", ""}; - getPcdInfo(cName, tsGuid, pcdInfo); + Vector validPcdTypes = new Vector(); + getPcdInfo(moduleKey, cName, tsGuid, pcdInfo, validPcdTypes); jTextAreaPcdHelp.setText(pcdInfo[0]); - initComboBox(pcdInfo[1], pcdInfo[2]); + initComboBox(pcdInfo[1], pcdInfo[2], validPcdTypes); jComboBoxItemType.setSelectedItem(itemType); jTextFieldMaxDatumSize.setEnabled(true); jTextFieldMaxDatumSize.setVisible(true); - jTextFieldMaxDatumSize.setText(jTablePcd.getValueAt(selectedRow, 4)+""); + jTextFieldMaxDatumSize.setText(model.getValueAt(selectedRow, 4)+""); jTextFieldPcdDefault.setEnabled(true); - jTextFieldPcdDefault.setText(jTablePcd.getValueAt(selectedRow, 6)+""); + jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+""); if (model.getValueAt(selectedRow, 5).equals("VOID*")) { if (pcdInfo[1].equals("FEATURE_FLAG")) { jTextFieldMaxDatumSize.setVisible(false); @@ -591,14 +755,14 @@ public class FpdModuleSA extends JDialog implements ActionListener { else if (pcdInfo[1].equals("FIXED_AT_BUILD")) { try{ jTextFieldMaxDatumSize.setEnabled(false); - jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(jTablePcd.getValueAt(selectedRow, 6)+"")+""); + jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(selectedRow, 6)+"")+""); } catch(Exception except){ JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage()); } } else{ - jTextFieldMaxDatumSize.setText(jTablePcd.getValueAt(selectedRow, 4)+""); + jTextFieldMaxDatumSize.setText(model.getValueAt(selectedRow, 4)+""); } } else { @@ -631,29 +795,35 @@ public class FpdModuleSA extends JDialog implements ActionListener { return jTablePcd; } - private void initComboBox(String originalType, String mType) { + private void initComboBox(String originalType, String mType, Vector validPcdTypes) { jComboBoxItemType.removeAllItems(); - jComboBoxItemType.addItem(originalType); - if (originalType.equals("PATCHABLE_IN_MODULE") && mType.equalsIgnoreCase("false")) { - jComboBoxItemType.addItem("FIXED_AT_BUILD"); - } + if (originalType.equals("DYNAMIC")) { - jComboBoxItemType.addItem("FIXED_AT_BUILD"); - jComboBoxItemType.addItem("PATCHABLE_IN_MODULE"); + for (int i = 0; i < validPcdTypes.size(); ++i) { + jComboBoxItemType.addItem(validPcdTypes.get(i)); + } + } + else { + jComboBoxItemType.addItem(originalType); } } - private void getPcdInfo(String cName, String tsGuid, String[] sa) { + /** + * @param cName + * @param tsGuid + * @param sa sa[0]: HelpText; sa[1]: itemType in Msa; sa[2]: isBinary; + */ + private void getPcdInfo(String moduleKey, String cName, String tsGuid, String[] sa, Vector validPcdTypes) { String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5]; ffc.getLibraryInstances(moduleKey, saa); try{ - if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa)) { + if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa, validPcdTypes)) { return; } for (int j = 0; j < saa.length; ++j) { if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]), - cName, tsGuid, sa)) { + cName, tsGuid, sa, validPcdTypes)) { return; } } @@ -802,6 +972,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { selectedInstancesTableModel.addColumn("PackageVersion"); jTableSelectedInstances = new JTable(selectedInstancesTableModel); jTableSelectedInstances.setRowHeight(20); + + jTableSelectedInstances.getColumnModel().getColumn(0).setMinWidth(250); + jTableSelectedInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); jTableSelectedInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -832,10 +1005,18 @@ public class FpdModuleSA extends JDialog implements ActionListener { if (jTableLibClass == null) { libClassTableModel = new IDefaultTableModel(); libClassTableModel.addColumn("LibraryClass"); + libClassTableModel.addColumn("Arch"); + libClassTableModel.addColumn("ModType"); jTableLibClass = new JTable(libClassTableModel); jTableLibClass.setRowHeight(20); jTableLibClass.setShowGrid(false); jTableLibClass.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + TableColumn column = jTableLibClass.getColumnModel().getColumn(1); + jTableLibClass.getColumnModel().removeColumn(column); + column = jTableLibClass.getColumnModel().getColumn(1); + jTableLibClass.getColumnModel().removeColumn(column); + jTableLibClass.getSelectionModel().addListSelectionListener(new ListSelectionListener(){ public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()){ @@ -855,7 +1036,12 @@ public class FpdModuleSA extends JDialog implements ActionListener { // libInstanceTableModel.setRowCount(0); String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString(); - ArrayList al = classInstanceMap.get(cls); + String arch = libClassTableModel.getValueAt(selectedRow2, 1).toString(); + String modType = libClassTableModel.getValueAt(selectedRow2, 2).toString(); + ArrayList al = classInstanceMap.get(new LibraryClassDescriptor(cls, arch, modType)); + if (al == null) { + return; + } ListIterator li = al.listIterator(); while(li.hasNext()) { String instance = li.next(); @@ -907,6 +1093,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { libInstanceTableModel.addColumn("PackageVersion"); jTableLibInstances = new JTable(libInstanceTableModel); jTableLibInstances.setRowHeight(20); + + jTableLibInstances.getColumnModel().getColumn(0).setMinWidth(250); + jTableLibInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); jTableLibInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); @@ -1008,7 +1197,22 @@ public class FpdModuleSA extends JDialog implements ActionListener { libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3), libInstanceTableModel.getValueAt(row, 4)}; selectedInstancesTableModel.addRow(s); - resolveLibraryInstances(instanceValue); + + Vector errorMsg = new Vector(); + try { + resolveLibraryInstances(instanceValue, errorMsg); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getMessage()); + } + + if (errorMsg.size() > 0) { + String errors = ""; + for (int i = 0; i < errorMsg.size(); ++i) { + errors += " " + errorMsg.get(i) + "\n"; + } + JOptionPane.showMessageDialog(frame, errors); + } showClassToResolved(); } }); @@ -1055,7 +1259,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { if (jButtonOk == null) { jButtonOk = new JButton(); jButtonOk.setPreferredSize(new java.awt.Dimension(80,20)); - jButtonOk.setText("Ok"); + jButtonOk.setText("Close"); jButtonOk.addActionListener(this); } return jButtonOk; @@ -1119,6 +1323,19 @@ public class FpdModuleSA extends JDialog implements ActionListener { } return jPanelModuleSaOpts; } + + private Vector getVectorFromString (String s) { + if (s == null || s.equals("null")) { + s = ""; + } + String[] sa1 = s.split(" "); + Vector v = new Vector(); + for (int i = 0; i < sa1.length; ++i) { + v.add(sa1[i]); + } + return v; + } + /** * This method initializes jTextField * @@ -1139,8 +1356,27 @@ public class FpdModuleSA extends JDialog implements ActionListener { if (newFvBinding.length() == 0 && originalFvBinding == null) { return; } - docConsole.setSaved(false); + + Vector oldFvList = getVectorFromString (originalFvBinding); + Vector newFvList = getVectorFromString (newFvBinding); + String moduleInfo[] = moduleKey.split(" "); ffc.setFvBinding(moduleKey, newFvBinding); + // + // remove module from Fvs that not in newFvList now. + // + oldFvList.removeAll(newFvList); + for (int j = 0; j < oldFvList.size(); ++j) { + ffc.removeModuleInBuildOptionsUserExtensions(oldFvList.get(j), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]); + } + // + // add module to Fvs that were not in oldFvList. + // + oldFvList = getVectorFromString (originalFvBinding); + newFvList.removeAll(oldFvList); + for (int i = 0; i < newFvList.size(); ++i) { + ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]); + } + docConsole.setSaved(false); } }); @@ -1242,6 +1478,12 @@ public class FpdModuleSA extends JDialog implements ActionListener { jTableModuleSaOptions = new JTable(optionsTableModel); jTableModuleSaOptions.setRowHeight(20); + jTableModuleSaOptions.getColumnModel().getColumn(0).setMinWidth(buildTargetWidth); + jTableModuleSaOptions.getColumnModel().getColumn(1).setMinWidth(toolChainFamilyWidth); + jTableModuleSaOptions.getColumnModel().getColumn(2).setMinWidth(tagNameWidth); + jTableModuleSaOptions.getColumnModel().getColumn(3).setMinWidth(toolCmdCodeWidth); + jTableModuleSaOptions.getColumnModel().getColumn(4).setMinWidth(supportArchWidth); + jTableModuleSaOptions.getColumnModel().getColumn(5).setMinWidth(argWidth); // javax.swing.table.TableColumn toolFamilyCol = jTableModuleSaOptions.getColumnModel().getColumn(1); // JComboBox cb = new JComboBox(); // cb.addItem("MSFT"); @@ -1318,7 +1560,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { public void actionPerformed(java.awt.event.ActionEvent e) { String[] row = {"", "", "", "", "", ""}; optionsTableModel.addRow(row); - Vector v = new Vector(); + Vector v = null; Vector v1 = null; docConsole.setSaved(false); ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, ""); @@ -1453,26 +1695,25 @@ private JComboBox getJComboBoxItemType() { if (jComboBoxItemType == null) { jComboBoxItemType = new JComboBox(); jComboBoxItemType.setPreferredSize(new java.awt.Dimension(200,20)); - jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent e) { - int row = jTablePcd.getSelectedRow(); - if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) { - return; - } - if (jComboBoxItemType.getItemCount() == 3) { - if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) { - - if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) { - jTextFieldPcdDefault.setText(""); - jTextFieldPcdDefault.setEnabled(true); - } - } - else{ - - } - } - } - }); +// jComboBoxItemType.addItemListener(new java.awt.event.ItemListener() { +// public void itemStateChanged(java.awt.event.ItemEvent e) { +// +// int row = jTablePcd.getSelectedRow(); +// if (row < 0 || model.getValueAt(row, 2).equals(jComboBoxItemType.getSelectedItem())) { +// return; +// } +// if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) { +// +// if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) { +// jTextFieldPcdDefault.setText(""); +// jTextFieldPcdDefault.setEnabled(true); +// } +// } +// else{ +// +// } +// } +// }); } return jComboBoxItemType; } @@ -1493,8 +1734,9 @@ private void pcdDynamicToNonDynamic(String cName, String tsGuid) { ArrayList al = ffc.getDynPcdMapValue(cName + " " + tsGuid); for (int i = 0; i < al.size(); ++i) { String mKey = moduleInfo (al.get(i)); - ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", maxSize, value); + value = null; String itemType = jComboBoxItemType.getSelectedItem()+""; + ffc.updatePcdData(mKey, cName, tsGuid, itemType, maxSize, value); al.set(i, mKey + " " + itemType); } @@ -1505,8 +1747,8 @@ private void pcdNonDynamicToDynamic(String cName, String tsGuid) { ArrayList al = ffc.getDynPcdMapValue(cName + " " + tsGuid); for (int i = 0; i < al.size(); ++i) { String mKey = moduleInfo (al.get(i)); - ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+""); String itemType = jComboBoxItemType.getSelectedItem()+""; + ffc.updatePcdData(mKey, cName, tsGuid, itemType, jTextFieldMaxDatumSize.getText(), jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+""); al.set(i, mKey + " " + itemType); } try{ @@ -1517,6 +1759,16 @@ private void pcdNonDynamicToDynamic(String cName, String tsGuid) { } } +private void changePcdTypeWithinSameCategory (String cName, String tsGuid) { + ArrayList al = ffc.getDynPcdMapValue(cName + " " + tsGuid); + for (int i = 0; i < al.size(); ++i) { + String mKey = moduleInfo (al.get(i)); + String itemType = jComboBoxItemType.getSelectedItem()+""; + ffc.updatePcdData(mKey, cName, tsGuid, itemType, null, null); + al.set(i, mKey + " " + itemType); + } +} + private String moduleInfo (String pcdInfo) { return pcdInfo.substring(0, pcdInfo.lastIndexOf(" ")); @@ -1562,24 +1814,99 @@ private JButton getJButtonUpdatePcd() { if (row < 0) { return; } - docConsole.setSaved(false); + + String cName = model.getValueAt(row, 0)+""; + String tsGuid = model.getValueAt(row, 1)+""; String oldItemType = model.getValueAt(row, 2)+""; + String dataType = model.getValueAt(row, 5)+""; String newItemType = jComboBoxItemType.getSelectedItem()+""; - model.setValueAt(newItemType, row, 2); - model.setValueAt(jTextFieldMaxDatumSize.getText(), row, 4); - model.setValueAt(jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem(), row, 6); - if (oldItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC")) { - pcdDynamicToNonDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+""); + String newValue = jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem()+""; + if (newValue.length() == 0){ + + if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) { + newValue = "0"; + } + if (dataType.equals("BOOLEAN")){ + newValue = "FALSE"; + } + if (dataType.equals("VOID*")) { + newValue = "L\"\""; + } + } + + String[] pcdInfo = {"", "", ""}; + Vector validPcdTypes = new Vector(); + getPcdInfo (moduleKey, cName, tsGuid, pcdInfo, validPcdTypes); + if (pcdInfo[1].equals("FIXED_AT_BUILD") && model.getValueAt(row, 5).equals("VOID*")) { + try { + jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(newValue)+""); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, "PCD Value MalFormed: " + exp.getMessage()); + return; + } } - if (!oldItemType.equals("DYNAMIC") && newItemType.equals("DYNAMIC")) { - pcdNonDynamicToDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+""); + String newMaxDatumSize = jTextFieldMaxDatumSize.getText(); + + if (!newItemType.equals(oldItemType)) { + Vector moduleInfo = new Vector(); + try { + boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo); + if (!changable) { + JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName()); + return; + } + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName() + " " + exp.getMessage()); + return; + } + + if ((oldItemType.equals("DYNAMIC") || oldItemType.equals("DYNAMIC_EX")) && !newItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC_EX")) { + pcdDynamicToNonDynamic(cName, tsGuid); + } + if (!oldItemType.equals("DYNAMIC") && !oldItemType.equals("DYNAMIC_EX") && (newItemType.equals("DYNAMIC") || newItemType.equals("DYNAMIC_EX"))) { + pcdNonDynamicToDynamic(cName, tsGuid); + } + else { + changePcdTypeWithinSameCategory (cName, tsGuid); + } + model.setValueAt(newItemType, row, 2); } - ffc.updatePcdData(moduleKey, model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+""); + + ffc.updatePcdData(moduleKey, cName, tsGuid, model.getValueAt(row, 2)+"", newMaxDatumSize, newValue); + docConsole.setSaved(false); + model.setValueAt(newValue, row, 6); + model.setValueAt(newMaxDatumSize, row, 4); + } }); } return jButtonUpdatePcd; } + +private boolean itemTypeCouldBeChanged (String cName, String tsGuid, String newItemType, Vector mi) throws Exception{ + ArrayList pcdConsumers = ffc.getDynPcdMapValue(cName + " " + tsGuid); + for (int i = 0; i < pcdConsumers.size(); ++i) { + String consumerInfo = moduleInfo (pcdConsumers.get(i)); + mi.removeAllElements(); + mi.add(WorkspaceProfile.getModuleId(consumerInfo)); + String[] sa = {"", "", ""}; + Vector validPcdTypes = new Vector(); + getPcdInfo (consumerInfo, cName, tsGuid, sa, validPcdTypes); + if (validPcdTypes.size() == 0) { + return false; + } + if (!sa[1].equals("DYNAMIC")) { + return false; + } + if (!validPcdTypes.contains(newItemType)) { + return false; + } + } + return true; +} + /** * This method initializes jComboBoxFeatureFlagValue * @@ -1663,3 +1990,51 @@ private JPanel getJPanelLibraryCenterC() { } // @jve:decl-index=0:visual-constraint="10,10" + +class MultipleInstanceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -9148463005930920297L; + private String className = null; + private String libInstance1 = null; + private String libInstance2 = null; + + MultipleInstanceException (String libClass, String instance1, String instance2) { + super(); + className = libClass; + libInstance1 = instance1; + libInstance2 = instance2; + } + + /* (non-Javadoc) + * @see java.lang.Throwable#getMessage() + */ + @Override + public String getMessage() { + // TODO Auto-generated method stub + return " Library Class " + className + "is Produced by Two Instances: " + + libInstance1 + " and " + libInstance2 + ". Platform Build will Fail."; + } + +} + +class NoInstanceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = 1987122786598970598L; + + private String className = null; + + NoInstanceException (String libClass) { + className = libClass; + } + + public String getMessage() { + return "No Applicable Instance for Library Class " + className + + ", Platform Build will Fail."; + } +}