diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java index f0b337b383..ad7783268a 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdHeader.java @@ -437,6 +437,7 @@ public class SpdHeader extends IInternalFrame { if (jCopyrightTextArea == null) { jCopyrightTextArea = new JTextArea(); jCopyrightTextArea.setWrapStyleWord(true); + jCopyrightTextArea.setLineWrap(true); jCopyrightTextArea.addFocusListener(new FocusAdapter() { public void focusLost(FocusEvent e) { if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) { diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java index 8af4bea28a..ecaf8587a6 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdBuildOptions.java @@ -1150,6 +1150,7 @@ public class FpdBuildOptions extends IInternalFrame { String[] row = { "" }; sectionsTableModel.addRow(row); ffc.genBuildOptionsFfsSectionsSections(jTableFfs.getSelectedRow(), ""); + JOptionPane.showMessageDialog(frame, "Add Default Section Type EFI_SECTION_PE32 into the New Sections Entry."); } }); } @@ -1693,9 +1694,9 @@ public class FpdBuildOptions extends IInternalFrame { jTextFieldOptionContents.getText() }; optionsTableModel.addRow(o); docConsole.setSaved(false); - ffc.genBuildOptionsOpt(stringToVector(jTextFieldBuildTargets.getText()), + ffc.genBuildOptionsOpt(stringToVector(jTextFieldBuildTargets.getText().trim()), jTextFieldToolChainFamily.getText(), jTextFieldTagName.getText(), - jTextFieldToolCmd.getText(), stringToVector(s), + jTextFieldToolCmd.getText(), stringToVector(s.trim()), jTextFieldOptionContents.getText()); } }); @@ -1854,7 +1855,7 @@ public class FpdBuildOptions extends IInternalFrame { private Vector stringToVector(String s) { String[] sArray = s.split(" "); Vector v = null; - if (s.length() > 0) { + if (s.length() > 0 && !s.trim().equalsIgnoreCase("")) { v = new Vector(); for (int i = 0; i < sArray.length; ++i) { v.add(sArray[i]); @@ -1883,9 +1884,7 @@ public class FpdBuildOptions extends IInternalFrame { if (bool[5]) { s += "PPC "; } - if (s.equals(" ")) { - s += "IA32"; - } + return s.trim(); } diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java index bbd24f2f79..c846160ca8 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdDynamicPcdBuildDefinitions.java @@ -18,12 +18,12 @@ import org.tianocore.frameworkwizard.common.Tools; import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType; import org.tianocore.frameworkwizard.common.ui.IInternalFrame; import javax.swing.JCheckBox; -import java.awt.FlowLayout; import javax.swing.JRadioButton; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt.GridLayout; +import java.util.ArrayList; public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { @@ -62,6 +62,7 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { private ButtonGroup bg = new ButtonGroup(); private JLabel jLabelPadd = null; private JLabel jLabelPad1 = null; + private JScrollPane jScrollPane = null; /** * This is the default constructor */ @@ -120,7 +121,6 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { jContentPane.setLayout(new BorderLayout()); jContentPane.add(getJScrollPaneDynPcd(), java.awt.BorderLayout.NORTH); jContentPane.add(getJPanelSkuInfo(), java.awt.BorderLayout.CENTER); - jContentPane.add(getJPanelDynPcdValue(), java.awt.BorderLayout.SOUTH); } return jContentPane; } @@ -133,7 +133,7 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { private JScrollPane getJScrollPaneDynPcd() { if (jScrollPaneDynPcd == null) { jScrollPaneDynPcd = new JScrollPane(); - jScrollPaneDynPcd.setPreferredSize(new java.awt.Dimension(100,300)); + jScrollPaneDynPcd.setPreferredSize(new java.awt.Dimension(100,250)); jScrollPaneDynPcd.setViewportView(getJTableDynPcd()); } return jScrollPaneDynPcd; @@ -269,15 +269,17 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { */ private JPanel getJPanelSkuInfo() { if (jPanelSkuInfo == null) { - FlowLayout flowLayout = new FlowLayout(); - flowLayout.setAlignment(java.awt.FlowLayout.LEFT); jPanelSkuInfo = new JPanel(); + jPanelSkuInfo.setLayout(new BorderLayout()); jPanelSkuInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED)); - jPanelSkuInfo.setLayout(flowLayout); - jPanelSkuInfo.setPreferredSize(new java.awt.Dimension(600,100)); - jPanelSkuInfo.add(getJCheckBoxSkuEnable(), null); - jPanelSkuInfo.add(getJScrollPaneSkuInfo(), null); - jPanelSkuInfo.add(getJButtonSkuInfoUpdate(), null); + jPanelSkuInfo.setPreferredSize(new java.awt.Dimension(600,120)); + +// jPanelSkuInfo.add(getJPanelSkuInfoN(), java.awt.BorderLayout.NORTH); + jPanelSkuInfo.add(getJScrollPane(), java.awt.BorderLayout.NORTH); + jPanelSkuInfo.add(getJScrollPaneSkuInfo(), java.awt.BorderLayout.CENTER); + + +// jPanelSkuInfo.add(getJPanelDynPcdValue(), java.awt.BorderLayout.SOUTH); } return jPanelSkuInfo; } @@ -313,8 +315,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { GridLayout gridLayout = new GridLayout(); gridLayout.setColumns(5); gridLayout.setRows(4); - gridLayout.setHgap(5); - gridLayout.setVgap(5); + gridLayout.setHgap(20); + gridLayout.setVgap(20); jLabelVpdOffset = new JLabel(); jLabelVpdOffset.setPreferredSize(new java.awt.Dimension(80,20)); @@ -336,8 +338,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { jLabelVarName.setPreferredSize(new java.awt.Dimension(90,20)); jPanelDynPcdValue = new JPanel(); jPanelDynPcdValue.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED)); + jPanelDynPcdValue.setPreferredSize(new java.awt.Dimension(1000,150)); jPanelDynPcdValue.setLayout(gridLayout); - jPanelDynPcdValue.setPreferredSize(new java.awt.Dimension(600,120)); jPanelDynPcdValue.add(getJRadioButtonHii(), null); jPanelDynPcdValue.add(jLabelVarName, null); jPanelDynPcdValue.add(getJTextFieldVarName(), null); @@ -362,6 +364,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { jPanelDynPcdValue.add(jLabelPad1, null); jPanelDynPcdValue.add(getJRadioButtonDefaultValue(), null); jPanelDynPcdValue.add(getJTextFieldDefaultValue(), null); + jPanelDynPcdValue.add(getJCheckBoxSkuEnable(), null); + jPanelDynPcdValue.add(getJButtonSkuInfoUpdate(), null); bg.add(jRadioButtonHii); bg.add(jRadioButtonVpd); } @@ -424,7 +428,7 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { private JScrollPane getJScrollPaneSkuInfo() { if (jScrollPaneSkuInfo == null) { jScrollPaneSkuInfo = new JScrollPane(); - jScrollPaneSkuInfo.setPreferredSize(new java.awt.Dimension(300,80)); + jScrollPaneSkuInfo.setPreferredSize(new java.awt.Dimension(300,50)); jScrollPaneSkuInfo.setViewportView(getJTableSkuInfo()); } return jScrollPaneSkuInfo; @@ -498,6 +502,8 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { private void updateSkuInfo (int pcdSelected) { int skuCount = ffc.getDynamicPcdSkuInfoCount(pcdSelected); + String cName = modelPcd.getValueAt(pcdSelected, 0)+""; + String tsGuid = modelPcd.getValueAt(pcdSelected, 2)+""; String varName = null; String varGuid = null; @@ -549,12 +555,27 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { ffc.removeDynamicPcdBuildDataSkuInfo(pcdSelected); if (jRadioButtonHii.isSelected()) { ffc.genDynamicPcdBuildDataSkuInfo("0", varName, varGuid, varOffset, hiiDefault, null, null, pcdSelected); + 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, null, null, hiiDefault); + } } else if (jRadioButtonVpd.isSelected()){ ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, vpdOffset, null, pcdSelected); + 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, null, null, vpdOffset); + } } else{ ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, null, value, pcdSelected); + 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, null, null, value); + } } } } @@ -577,6 +598,11 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { } } } + + private String moduleInfo (String pcdInfo) { + + return pcdInfo.substring(0, pcdInfo.lastIndexOf(" ")); + } /** * This method initializes jTextField * @@ -681,6 +707,20 @@ public class FpdDynamicPcdBuildDefinitions extends IInternalFrame { return jRadioButtonDefaultValue; } + /** + * This method initializes jScrollPane + * + * @return javax.swing.JScrollPane + */ + private JScrollPane getJScrollPane() { + if (jScrollPane == null) { + jScrollPane = new JScrollPane(); + jScrollPane.setPreferredSize(new java.awt.Dimension(1003,180)); + jScrollPane.setViewportView(getJPanelDynPcdValue()); + } + return jScrollPane; + } + } // @jve:decl-index=0:visual-constraint="10,10" class DynPcdTableModel extends DefaultTableModel { 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 3903f97de0..fc49cd4151 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 @@ -578,12 +578,21 @@ public class FpdFileContents { // // change item type while not updating dynPcdData???? // - pcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); - if(pcdData.getDatumType().equals("VOID*")) { + if (itemType != null) { + pcdData.setItemType(PcdItemTypes.Enum.forString(itemType)); + } + + if(pcdData.getDatumType().equals("VOID*") && maxSize != null) { pcdData.setMaxDatumSize(new Integer(maxSize)); } - pcdData.setValue(value); - defaultPcdValue.put(cName + " " + tsGuid, value); + // + // if value input is null, keep old value untouched. + // + if (value != null) { + pcdData.setValue(value); + defaultPcdValue.put(cName + " " + tsGuid, value); + } + break; } } diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java index a422ba2cfc..bcb0e6f5c9 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/FpdHeader.java @@ -463,6 +463,7 @@ public class FpdHeader extends IInternalFrame { if (jCopyrightTextArea == null) { jCopyrightTextArea = new JTextArea(); jCopyrightTextArea.setWrapStyleWord(true); + jCopyrightTextArea.setLineWrap(true); jCopyrightTextArea.addFocusListener(new FocusAdapter(){ public void focusLost(FocusEvent e) { if (!DataValidation.isCopyright(jCopyrightTextArea.getText())) { 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 27a52b66cd..ac8841c790 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; @@ -148,10 +154,19 @@ 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); + int tabIndex = jTabbedPane.indexOfTab("Libraries"); + if (mi.isLibrary()) { + jTabbedPane.setEnabledAt(tabIndex, false); + } + else { + jTabbedPane.setEnabledAt(tabIndex, true); + } } /** @@ -178,10 +193,14 @@ 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); + try { + // + // display library classes that need to be resolved. also potential instances for them. + // + resolveLibraryInstances(moduleKey); + } catch (Exception e) { + JOptionPane.showMessageDialog(frame, e.getMessage()); + } // // display lib instances already selected for key // @@ -191,7 +210,8 @@ public class FpdModuleSA extends JDialog implements ActionListener { 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. @@ -202,11 +222,16 @@ 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]); + } catch (Exception e) { + JOptionPane.showMessageDialog(frame, e.getMessage()); + } selectedInstancesTableModel.addRow(saa[i]); } } } + showClassToResolved(); } @@ -241,71 +266,165 @@ public class FpdModuleSA extends JDialog implements ActionListener { } } - private void resolveLibraryInstances(String key) { - ModuleIdentification mi = WorkspaceProfile.getModuleId(key); - PackageIdentification[] depPkgList = null; - try{ - // - // 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); - - 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(); - } - consumedBy.add(key); - this.classConsumed.put(vClassConsumed.get(i), consumedBy); - } - - Vector vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi); - if (this.classProduced == null) { - this.classProduced = new ArrayList(); - } - for(int i = 0; i < vClassProduced.size(); ++i){ - if (!this.classProduced.contains(vClassProduced.get(i))){ - this.classProduced.add(vClassProduced.get(i)); - } - } - - // - // 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()){ - 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."); - } - classInstanceMap.put(cls, instances); - - } - -// showClassToResolved(); + 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]); } - catch(Exception e) { - e.printStackTrace(); + // + // if module will be built on all platforms, no filter needed for lib classes. + // + if (vModuleArchs.size() == 0) { + return; + } + + for (int j = 0; j < v.size(); ++j) { + LibraryClassDescriptor libInfo = v.get(j); + + 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; + } + // + // only retain those lib class used by module archs. + // + 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; + } + // + // remove this lib definition if it supports no archs module will be built under. + // + v.iterator().remove(); } } - private ArrayList getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{ + private void resolveLibraryInstances(String key) 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(); + } + 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(); + } + // + // 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()); + } + 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. + // + 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; + } + ArrayList instances = getInstancesForClass(cls, depPkgList); + if (instances.size() == 0) { + throw new NoInstanceException (cls.className); + } + 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; + } + 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(LibraryClassDescriptor cls, PackageIdentification[] depPkgList){ ArrayList al = new ArrayList(); // for (int i = 0; i < depPkgList.length; ++i) { @@ -315,17 +434,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; } @@ -340,6 +459,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); // @@ -349,82 +490,65 @@ 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) { + 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); } } @@ -850,10 +974,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()){ @@ -873,7 +1005,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(); @@ -1029,7 +1166,12 @@ public class FpdModuleSA extends JDialog implements ActionListener { libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3), libInstanceTableModel.getValueAt(row, 4)}; selectedInstancesTableModel.addRow(s); - resolveLibraryInstances(instanceValue); + try { + resolveLibraryInstances(instanceValue); + } + catch (Exception exp) { + JOptionPane.showMessageDialog(frame, exp.getMessage()); + } showClassToResolved(); } }); @@ -1076,7 +1218,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; @@ -1351,7 +1493,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, ""); @@ -1526,6 +1668,7 @@ 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)); + value = null; ffc.updatePcdData(mKey, cName, tsGuid, jComboBoxItemType.getSelectedItem()+"", maxSize, value); String itemType = jComboBoxItemType.getSelectedItem()+""; al.set(i, mKey + " " + itemType); @@ -1709,3 +1852,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."; + } +} diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/LibraryClassDescriptor.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/LibraryClassDescriptor.java new file mode 100644 index 0000000000..df689c6ef1 --- /dev/null +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/LibraryClassDescriptor.java @@ -0,0 +1,132 @@ +/** @file + This file is for surface area information retrieval. + + Copyright (c) 2006, Intel Corporation + All rights reserved. This program and the accompanying materials + are licensed and made available under the terms and conditions of the BSD License + which accompanies this distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + + **/ +package org.tianocore.frameworkwizard.platform.ui.global; + +import java.util.Vector; + +public class LibraryClassDescriptor { + public String className = ""; + public String supArchs = ""; + public String supModTypes = ""; + + public LibraryClassDescriptor (String s1, String s2, String s3) { + className = s1; + if (s2 != null) { + supArchs = s2; + } + if (s3 != null) { + supModTypes = s3; + } + + } + + public boolean equals(Object obj) { + if (obj instanceof LibraryClassDescriptor) { + LibraryClassDescriptor id = (LibraryClassDescriptor)obj; + if (className.equals(id.className) && sameArchs (supArchs, id.supArchs) && sameModTypes(supModTypes, id.supModTypes)) { + return true; + } + return false; + } + else { + return super.equals(obj); + } + } + + public int hashCode(){ + return (className + supArchs + supModTypes).toLowerCase().hashCode(); + } + + public String toString() { + return "Library Class "+ className + " [SupArchs: " + supArchs + " SupModTypes: " + supModTypes + "]"; + } + + public boolean isSubSetByArchs (LibraryClassDescriptor lcd) { + if (className.equals(lcd.className)) { + Vector vArchs1 = getVectorFromString(supArchs); + Vector vArchs2 = getVectorFromString(lcd.supArchs); + + if (isSubSet(vArchs1, vArchs2)) { + return true; + } + } + return false; + } + + public boolean isSubSetByModTypes (LibraryClassDescriptor lcd) { + if (className.equals(lcd.className)) { + Vector vModTypes1 = getVectorFromString(supModTypes); + Vector vModTypes2 = getVectorFromString(lcd.supModTypes); + + if (isSubSet(vModTypes1, vModTypes2)) { + return true; + } + } + return false; + } + + public boolean hasInterSectionWith (LibraryClassDescriptor lcd) { + if (className.equals(lcd.className)) { + Vector vArchs1 = getVectorFromString(supArchs); + Vector vArchs2 = getVectorFromString(lcd.supArchs); + if (vArchs1.size() == 0 || (vArchs1.size() == 1 && vArchs1.get(0).equalsIgnoreCase(""))) { + return true; + } + if (vArchs2.size() == 0 || (vArchs2.size() == 1 && vArchs2.get(0).equalsIgnoreCase(""))) { + return true; + } + vArchs1.retainAll(vArchs2); + if (vArchs1.size() > 0) { + return true; + } + } + return false; + } + + private boolean isSubSet (Vector v1, Vector v2) { + if (v2.size() == 0 || (v2.size() == 1 && v2.get(0).equalsIgnoreCase(""))) { + return true; + } + if (v2.containsAll(v1)) { + return true; + } + return false; + } + + public 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; + } + + private boolean sameArchs (String archs1, String archs2) { + Vector vArchs1 = getVectorFromString(archs1); + Vector vArchs2 = getVectorFromString(archs2); + + if (vArchs1.containsAll(vArchs2) && vArchs2.containsAll(vArchs1)) { + return true; + } + return false; + } + + private boolean sameModTypes (String modTypes1, String modTypes2) { + return sameArchs(modTypes1, modTypes2); + } +} \ No newline at end of file diff --git a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java index 85b406621c..ad0e82ca3f 100644 --- a/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java +++ b/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/platform/ui/global/SurfaceAreaQuery.java @@ -317,7 +317,7 @@ public class SurfaceAreaQuery { * @returns null if nothing is there */ - public static PackageIdentification[] getDependencePkg(String arch, ModuleIdentification mi) throws Exception{ + public static PackageIdentification[] getDependencePkg(String arch, ModuleIdentification mi){ String packageGuid = null; String packageVersion = null; @@ -375,11 +375,11 @@ public class SurfaceAreaQuery { * xpath * @returns null if nothing is there */ - public static Vector getLibraryClasses(String usage, ModuleIdentification mi) throws Exception{ + public static Vector getLibraryClasses(String usage, ModuleIdentification mi){ ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi); - Vector libraryClassName = new Vector(); + Vector libraryClassInfo = new Vector(); if (msa.getLibraryClassDefinitions() == null) { - return libraryClassName; + return libraryClassInfo; } int size = msa.getLibraryClassDefinitions().getLibraryClassList().size(); @@ -387,11 +387,12 @@ public class SurfaceAreaQuery { for (int i = 0; i < size; i++) { LibraryClassDocument.LibraryClass libClass = msa.getLibraryClassDefinitions().getLibraryClassList().get(i); if (usage.equals(libClass.getUsage().toString())) { - libraryClassName.add(libClass.getKeyword()); + + libraryClassInfo.add(new LibraryClassDescriptor(libClass.getKeyword(), libClass.getSupArchList()+"", libClass.getSupModuleList()+"")); } } - return libraryClassName; + return libraryClassInfo; } public static XmlObject[] getSpdPcdDeclarations(PackageIdentification pi) { @@ -408,4 +409,5 @@ public class SurfaceAreaQuery { return returns; } -} \ No newline at end of file +} +