X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FJava%2FSource%2FFrameworkWizard%2Fsrc%2Forg%2Ftianocore%2Fframeworkwizard%2Fplatform%2Fui%2FFpdModuleSA.java;h=9b5ec73b6565684e9d5f4a31a141d1191bc36438;hb=25232e9cb3642ca69dd0e75145ae47fc2f8c8f56;hp=5d26337411a6b7c22bcf4d3236e7249117ee81c2;hpb=91621725935f62c2c50be3695f7fee4966f08ab0;p=mirror_edk2.git 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 5d26337411..9b5ec73b65 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 @@ -4,7 +4,6 @@ import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Toolkit; -import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JDialog; @@ -24,6 +23,7 @@ import javax.swing.table.DefaultTableModel; import javax.swing.table.TableColumn; import javax.swing.table.TableModel; +import org.tianocore.frameworkwizard.FrameworkWizardUI; import org.tianocore.frameworkwizard.common.DataValidation; import org.tianocore.frameworkwizard.common.GlobalData; import org.tianocore.frameworkwizard.common.IDefaultTableModel; @@ -53,7 +53,6 @@ public class FpdModuleSA extends JDialog implements ActionListener { * */ private static final long serialVersionUID = 1L; - static JFrame frame; private JPanel jContentPane = null; private JTabbedPane jTabbedPane = null; private JPanel jPanelPcd = null; @@ -94,6 +93,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { private DefaultTableModel optionsTableModel = null; private FpdFileContents ffc = null; private String moduleKey = null; + private ModuleIdentification moduleId = null; private int moduleSaNum = -1; private HashMap> classInstanceMap = null; // @@ -142,7 +142,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { * This is the default constructor */ public FpdModuleSA() { - super(); + super(FrameworkWizardUI.getInstance()); initialize(); } public FpdModuleSA(FpdFileContents ffc) { @@ -159,9 +159,12 @@ public class FpdModuleSA extends JDialog implements ActionListener { classConsumed = null; jTabbedPane.setSelectedIndex(0); initPcdBuildDefinition(i); - ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey); + moduleId = WorkspaceProfile.getModuleId(moduleKey); + if (moduleId == null) { + return; + } int tabIndex = jTabbedPane.indexOfTab("Libraries"); - if (mi.isLibrary()) { + if (moduleId.isLibrary()) { jTabbedPane.setEnabledAt(tabIndex, false); } else { @@ -193,18 +196,24 @@ public class FpdModuleSA extends JDialog implements ActionListener { } public void initLibraries(String key) { + 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); + resolveLibraryInstances(moduleKey, errorMsg); } catch (Exception e) { - JOptionPane.showMessageDialog(frame, e.getMessage()); + String exceptionMsg = e.getCause() + " " + e.getMessage(); + errorMsg.add(exceptionMsg); + JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), 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]; @@ -223,15 +232,25 @@ public class FpdModuleSA extends JDialog implements ActionListener { // re-evaluate lib instance usage when adding a already-selected lib instance. // try { - resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]); + resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4], errorMsg); } catch (Exception e) { - JOptionPane.showMessageDialog(frame, e.getMessage()); + String exceptionMsg = e.getCause() + " " + e.getMessage(); + if (!errorMsg.contains(exceptionMsg)) { + JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), 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(FrameworkWizardUI.getInstance(), errors); + } showClassToResolved(); } @@ -282,8 +301,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { return; } - for (int j = 0; j < v.size(); ++j) { - LibraryClassDescriptor libInfo = v.get(j); + Iterator iter = v.iterator(); + while (iter.hasNext()) { + LibraryClassDescriptor libInfo = iter.next(); Vector vSupArchs = libInfo.getVectorFromString(libInfo.supArchs); @@ -318,22 +338,25 @@ public class FpdModuleSA extends JDialog implements ActionListener { // // remove this lib definition if it supports no archs module will be built under. // - v.iterator().remove(); + iter.remove(); } } - private void resolveLibraryInstances(String key) throws MultipleInstanceException, NoInstanceException{ + 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); + //depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi); // // Get the lib class consumed, produced by this module itself. // Vector vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi); + for (int i = 0; i < vClassConsumed.size(); ++i) { + vClassConsumed.get(i).supModTypes = WorkspaceProfile.getModuleType(moduleId); + } filterClassConsumedByArch(vClassConsumed); if (this.classConsumed == null) { this.classConsumed = new HashMap>(); @@ -392,12 +415,17 @@ public class FpdModuleSA extends JDialog implements ActionListener { Iterator lic = this.classConsumed.keySet().iterator(); while (lic.hasNext()) { LibraryClassDescriptor cls = lic.next(); - if (isBoundedClass(cls)) { + if (isBoundedClass(cls, errorMsg)) { continue; } ArrayList instances = getInstancesForClass(cls, depPkgList); if (instances.size() == 0) { - throw new NoInstanceException (cls.className); +// throw new NoInstanceException (cls.className); + String exceptionMsg = new NoInstanceException (cls.className).getMessage(); + if (!errorMsg.contains(exceptionMsg)) { + errorMsg.add(exceptionMsg); + } + } classInstanceMap.put(cls, instances); @@ -409,15 +437,30 @@ public class FpdModuleSA extends JDialog implements ActionListener { * @param cls * @return */ - private boolean isBoundedClass (LibraryClassDescriptor cls) { - if (this.classProduced.containsKey(cls)) { - return true; - } + private boolean isBoundedClass (LibraryClassDescriptor cls, Vector errorMsg) { +// 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; + if (cls.className.equals(lcd.className)) { + if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) { + return true; + } + else { + ArrayList producedBy = this.classProduced.get(lcd); + String instancesName = ""; + for (int i = 0; i < producedBy.size(); ++i) { + ModuleIdentification mi = WorkspaceProfile.getModuleId(producedBy.get(i)); + instancesName += mi.getName(); + instancesName += " "; + } + String msg = new ImproperInstanceException(lcd.className, instancesName, lcd.supArchs, lcd.supModTypes).getMessage(); + if (!errorMsg.contains(msg)) { + errorMsg.add(msg); + } + } } } @@ -444,7 +487,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { isPotential = true; } - if (hasBeenProduced(lcd)) { + if (isPotential && hasBeenProduced(lcd)) { isPotential = false; break; } @@ -463,7 +506,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { Iterator lcdi = this.classProduced.keySet().iterator(); while (lcdi.hasNext()) { LibraryClassDescriptor lcd = lcdi.next(); - if (cls.hasInterSectionWith(lcd)) { + if (cls.isSubSetByArchs(lcd) && cls.isSubSetByModTypes(lcd)) { return true; } } @@ -474,7 +517,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { Iterator lcdi = this.classConsumed.keySet().iterator(); while (lcdi.hasNext()) { LibraryClassDescriptor lcd = lcdi.next(); - if (lcd.className.equals(className)) { + if ((lcd.className != null) && lcd.className.equals(className)) { return this.classConsumed.get(lcd); } } @@ -536,7 +579,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { } private void showClassToResolved(){ + Vector errorMsg = new Vector(); libClassTableModel.setRowCount(0); + libInstanceTableModel.setRowCount(0); if (classConsumed == null || classConsumed.size() == 0) { return; } @@ -548,19 +593,35 @@ public class FpdModuleSA extends JDialog implements ActionListener { continue; } - if (!isBoundedClass(lcd)){ + if (!isBoundedClass(lcd, errorMsg)){ libClassTableModel.addRow(s); } } - libInstanceTableModel.setRowCount(0); + + if (errorMsg.size() > 0) { + String errors = ""; + for (int i = 0; i < errorMsg.size(); ++i) { + errors += " " + errorMsg.get(i) + "\n"; + } + JOptionPane.showMessageDialog(FrameworkWizardUI.getInstance(), errors); + } } + private String getModuleArch () { + String arch = ""; + String[] moduleInfo = moduleKey.split(" "); + for (int i = 4; i < moduleInfo.length; ++i) { + arch += moduleInfo[i]; + arch += " "; + } + return arch.trim(); + } private void addLibInstance (ModuleIdentification libMi) throws Exception{ // // Add pcd information of selected instance to current moduleSA // - ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey)); + ffc.addFrameworkModulesPcdBuildDefs(libMi, getModuleArch(), ffc.getModuleSA(moduleKey)); ffc.genLibraryInstance(libMi, moduleKey); } @@ -688,6 +749,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { 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(){ @@ -709,16 +773,17 @@ 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(model.getValueAt(selectedRow, 4)+""); jTextFieldPcdDefault.setEnabled(true); jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+""); - if (model.getValueAt(selectedRow, 5).equals("VOID*")) { + if ((model.getValueAt(selectedRow, 5) != null) && model.getValueAt(selectedRow, 5).equals("VOID*")) { if (pcdInfo[1].equals("FEATURE_FLAG")) { jTextFieldMaxDatumSize.setVisible(false); } @@ -728,7 +793,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(model.getValueAt(selectedRow, 6)+"")+""); } catch(Exception except){ - JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage()); + JOptionPane.showMessageDialog(FpdModuleSA.this, "Unacceptable PCD Value: " + except.getMessage()); } } else{ @@ -765,15 +830,16 @@ 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); } } @@ -782,17 +848,17 @@ public class FpdModuleSA extends JDialog implements ActionListener { * @param tsGuid * @param sa sa[0]: HelpText; sa[1]: itemType in Msa; sa[2]: isBinary; */ - private void getPcdInfo(String cName, String tsGuid, String[] sa) { + 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; } } @@ -1158,7 +1224,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { addLibInstance (libMi); } catch (Exception exception) { - JOptionPane.showMessageDialog(frame, "Adding Instance" + libMi.getName() + ": "+ exception.getMessage()); + JOptionPane.showMessageDialog(FpdModuleSA.this, "Adding Instance " + libMi.getName() + " : \n"+ exception.getMessage()); return; } docConsole.setSaved(false); @@ -1166,11 +1232,21 @@ public class FpdModuleSA extends JDialog implements ActionListener { libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3), libInstanceTableModel.getValueAt(row, 4)}; selectedInstancesTableModel.addRow(s); + + Vector errorMsg = new Vector(); try { - resolveLibraryInstances(instanceValue); + resolveLibraryInstances(instanceValue, errorMsg); } catch (Exception exp) { - JOptionPane.showMessageDialog(frame, exp.getMessage()); + JOptionPane.showMessageDialog(FpdModuleSA.this, exp.getMessage()); + } + + if (errorMsg.size() > 0) { + String errors = ""; + for (int i = 0; i < errorMsg.size(); ++i) { + errors += " " + errorMsg.get(i) + "\n"; + } + JOptionPane.showMessageDialog(FpdModuleSA.this, errors); } showClassToResolved(); } @@ -1325,7 +1401,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { // oldFvList.removeAll(newFvList); for (int j = 0; j < oldFvList.size(); ++j) { - ffc.removeModuleInBuildOptionsUserExtensions(oldFvList.get(j), moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]); + 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. @@ -1333,7 +1409,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { oldFvList = getVectorFromString (originalFvBinding); newFvList.removeAll(oldFvList); for (int i = 0; i < newFvList.size(); ++i) { - ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]); + ffc.addModuleIntoBuildOptionsUserExtensions(newFvList.get(i), "IMAGES", 1, moduleInfo[0], moduleInfo[1], moduleInfo[2], moduleInfo[3], moduleInfo[4]); } docConsole.setSaved(false); } @@ -1364,7 +1440,7 @@ public class FpdModuleSA extends JDialog implements ActionListener { } if (newFileGuid.length() > 0) { if (!DataValidation.isGuid(newFileGuid)) { - JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type."); + JOptionPane.showMessageDialog(FpdModuleSA.this, "FFS File Guid is NOT GUID Type."); return; } } @@ -1459,9 +1535,9 @@ public class FpdModuleSA extends JDialog implements ActionListener { vArch.add("EBC"); vArch.add("ARM"); vArch.add("PPC"); - jTableModuleSaOptions.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch)); + jTableModuleSaOptions.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch, FrameworkWizardUI.getInstance())); - jTableModuleSaOptions.getColumnModel().getColumn(5).setCellEditor(new LongTextEditor()); + jTableModuleSaOptions.getColumnModel().getColumn(5).setCellEditor(new LongTextEditor(FrameworkWizardUI.getInstance())); jTableModuleSaOptions.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jTableModuleSaOptions.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); @@ -1656,23 +1732,19 @@ private JComboBox getJComboBoxItemType() { 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())) { + if (row < 0) { return; } - if (jComboBoxItemType.getItemCount() == 3) { - if (!jComboBoxItemType.getSelectedItem().equals("DYNAMIC")) { - - if (jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) { - jTextFieldPcdDefault.setText(""); - jTextFieldPcdDefault.setEnabled(true); - } - } - else{ - } + if (jComboBoxItemType.getSelectedItem() != null && jComboBoxItemType.getSelectedItem().equals("FIXED_AT_BUILD")) { + jTextFieldPcdDefault.setEnabled(true); } - } + else { + jTextFieldPcdDefault.setEnabled(false); + } + } }); } return jComboBoxItemType; @@ -1695,8 +1767,8 @@ private void pcdDynamicToNonDynamic(String cName, String 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()+""; + ffc.updatePcdData(mKey, cName, tsGuid, itemType, maxSize, value); al.set(i, mKey + " " + itemType); } @@ -1707,15 +1779,25 @@ 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{ - ffc.addDynamicPcdBuildData(cName, jTablePcd.getValueAt(jTablePcd.getSelectedRow(), 3), tsGuid, "DYNAMIC", jTablePcd.getValueAt(jTablePcd.getSelectedRow(), 5)+"", jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+""); + ffc.addDynamicPcdBuildData(cName, model.getValueAt(jTablePcd.getSelectedRow(), 3), tsGuid, "DYNAMIC", model.getValueAt(jTablePcd.getSelectedRow(), 5)+"", jTextFieldPcdDefault.isVisible() ? jTextFieldPcdDefault.getText() : jComboBoxFeatureFlagValue.getSelectedItem()+""); } catch(Exception e){ - JOptionPane.showMessageDialog(frame, "PCD value format: " + e.getMessage()); + JOptionPane.showMessageDialog(FpdModuleSA.this, "PCD value format: " + e.getMessage()); + } +} + +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); } } @@ -1764,37 +1846,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(jTextFieldPcdDefault.isVisible()? jTextFieldPcdDefault.getText():jComboBoxFeatureFlagValue.getSelectedItem(), row, 6); + 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 = {"", "", ""}; - getPcdInfo (model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", 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(model.getValueAt(row, 6)+"")+""); + jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(newValue)+""); } catch (Exception exp) { - JOptionPane.showMessageDialog(frame, "PCD Value MalFormed: " + exp.getMessage()); + JOptionPane.showMessageDialog(FpdModuleSA.this, "PCD Value MalFormed: " + exp.getMessage()); return; } } - model.setValueAt(jTextFieldMaxDatumSize.getText(), row, 4); + String newMaxDatumSize = jTextFieldMaxDatumSize.getText(); - if (oldItemType.equals("DYNAMIC") && !newItemType.equals("DYNAMIC")) { - pcdDynamicToNonDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+""); - } - if (!oldItemType.equals("DYNAMIC") && newItemType.equals("DYNAMIC")) { - pcdNonDynamicToDynamic(model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+""); + if (!newItemType.equals(oldItemType)) { + Vector moduleInfo = new Vector(); + try { + boolean changable = itemTypeCouldBeChanged (cName, tsGuid, newItemType, moduleInfo); + if (!changable) { + JOptionPane.showMessageDialog(FpdModuleSA.this, "Can NOT Change Pcd Type in: " + moduleInfo.get(0).getName() + " contained in package " + moduleInfo.get(0).getPackageId().getName()); + return; + } + } + catch (Exception exp) { + JOptionPane.showMessageDialog(FpdModuleSA.this, "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 * @@ -1902,12 +2046,43 @@ class MultipleInstanceException extends Exception { @Override public String getMessage() { // TODO Auto-generated method stub - return "Library Class " + className + "is Produced by Two Instances: " + return " Library Class " + className + "is Produced by Two Instances: " + libInstance1 + " and " + libInstance2 + ". Platform Build will Fail."; } } +class ImproperInstanceException extends Exception { + + /** + * + */ + private static final long serialVersionUID = -5279700566993277033L; + private String className = null; + private String libInstance = null; + private String instanceSupArch = null; + private String instanceSupModType = null; + + ImproperInstanceException (String libClass, String instance1, String arch, String type) { + super(); + className = libClass; + libInstance = instance1; + instanceSupArch = arch; + instanceSupModType = type; + } + + /* (non-Javadoc) + * @see java.lang.Throwable#getMessage() + */ + @Override + public String getMessage() { + // TODO Auto-generated method stub + return " Library Class " + className + " Produced by Library Instance: " + + libInstance + "\nOnly Supports " + instanceSupArch + " and Module Type " + instanceSupModType + ".\n This instance should be removed.\n"; + } + +} + class NoInstanceException extends Exception { /**