Do not display token number for Pcd in ModuleSA and Dynamic Pcd editors for FPD file.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdDynamicPcdBuildDefinitions.java
CommitLineData
a13899c5 1package org.tianocore.frameworkwizard.platform.ui;\r
2\r
3import java.awt.BorderLayout;\r
4\r
5import javax.swing.ButtonGroup;\r
2a23019d 6import javax.swing.JOptionPane;\r
a13899c5 7import javax.swing.JPanel;\r
a13899c5 8import javax.swing.JScrollPane;\r
9import javax.swing.JTable;\r
10import javax.swing.ListSelectionModel;\r
11import javax.swing.event.ListSelectionEvent;\r
12import javax.swing.event.ListSelectionListener;\r
13import javax.swing.table.DefaultTableModel;\r
2cd33eaf 14import javax.swing.table.TableColumn;\r
a13899c5 15\r
16import org.tianocore.PlatformSurfaceAreaDocument;\r
2a23019d 17import org.tianocore.frameworkwizard.common.DataValidation;\r
18import org.tianocore.frameworkwizard.common.Tools;\r
d6d24759 19import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;\r
a13899c5 20import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
21import javax.swing.JCheckBox;\r
a13899c5 22import javax.swing.JRadioButton;\r
23import javax.swing.JButton;\r
24import javax.swing.JLabel;\r
25import javax.swing.JTextField;\r
a0783edc 26import java.awt.GridLayout;\r
50d4c727 27import java.util.ArrayList;\r
a13899c5 28\r
29public class FpdDynamicPcdBuildDefinitions extends IInternalFrame {\r
30\r
44053733 31 /**\r
32 * \r
33 */\r
34 private static final long serialVersionUID = 1L;\r
a13899c5 35 private JPanel jContentPane = null;\r
4da2e625 36 private JScrollPane jScrollPaneDynPcd = null;\r
37 private JTable jTableDynPcd = null;\r
38 private DynPcdTableModel modelPcd = null; \r
39 private DynPcdTableModel modelSku = null;\r
a13899c5 40 private FpdFileContents ffc = null;\r
d6d24759 41 private OpeningPlatformType docConsole = null;\r
4da2e625 42 private JPanel jPanelSkuInfo = null;\r
43 private JCheckBox jCheckBoxSkuEnable = null;\r
44 private JPanel jPanelDynPcdValue = null;\r
45 private JRadioButton jRadioButtonHii = null;\r
46 private JRadioButton jRadioButtonVpd = null;\r
47 private JScrollPane jScrollPaneSkuInfo = null;\r
48 private JTable jTableSkuInfo = null;\r
49 private JButton jButtonSkuInfoUpdate = null;\r
50 private JLabel jLabelVarName = null;\r
51 private JTextField jTextFieldVarName = null;\r
52 private JLabel jLabelVarGuid = null;\r
53 private JTextField jTextFieldVarGuid = null;\r
54 private JLabel jLabelPad = null;\r
55 private JLabel jLabelVarOffset = null;\r
56 private JTextField jTextFieldVarOffset = null;\r
57 private JLabel jLabelHiiDefaultValue = null;\r
58 private JTextField jTextFieldHiiDefaultValue = null;\r
59 private JTextField jTextFieldVpdOffset = null;\r
60 private JLabel jLabelVpdOffset = null;\r
61 private JTextField jTextFieldDefaultValue = null;\r
62 private JRadioButton jRadioButtonDefaultValue = null;\r
a13899c5 63 private ButtonGroup bg = new ButtonGroup();\r
4da2e625 64 private JLabel jLabelPadd = null;\r
a0783edc 65 private JLabel jLabelPad1 = null;\r
50d4c727 66 private JScrollPane jScrollPane = null;\r
a13899c5 67 /**\r
68 * This is the default constructor\r
69 */\r
70 public FpdDynamicPcdBuildDefinitions() {\r
71 super();\r
72 initialize();\r
73 }\r
74\r
75 public FpdDynamicPcdBuildDefinitions(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){\r
76 this();\r
77 init(fpd);\r
78 }\r
79 \r
d6d24759 80 public FpdDynamicPcdBuildDefinitions(OpeningPlatformType opt) {\r
81 this(opt.getXmlFpd());\r
82 docConsole = opt;\r
83 }\r
84 \r
a13899c5 85 public void init(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r
86 if (ffc == null) {\r
87 ffc = new FpdFileContents(fpd);\r
2cd33eaf 88 ffc.initDynPcdMap();\r
a13899c5 89 }\r
90 String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];\r
91 ffc.getDynamicPcdBuildData(saa);\r
92 for (int i = 0; i < saa.length; ++i) {\r
4da2e625 93 modelPcd.addRow(saa[i]);\r
a13899c5 94 }\r
95 \r
96 saa = new String[ffc.getPlatformDefsSkuInfoCount()][2];\r
97 ffc.getPlatformDefsSkuInfos(saa);\r
98 for (int i = 0; i < saa.length; ++i) {\r
4da2e625 99 modelSku.addRow(saa[i]);\r
a13899c5 100 }\r
101 \r
102 }\r
103 /**\r
104 * This method initializes this\r
105 * \r
106 * @return void\r
107 */\r
108 private void initialize() {\r
109 this.setSize(661, 558);\r
110 this.setTitle("Dynamic PCD Build Definitions");\r
111 this.setContentPane(getJContentPane());\r
112 this.setVisible(true);\r
113 }\r
114\r
115 /**\r
116 * This method initializes jContentPane\r
117 * \r
118 * @return javax.swing.JPanel\r
119 */\r
120 private JPanel getJContentPane() {\r
121 if (jContentPane == null) {\r
122 jContentPane = new JPanel();\r
123 jContentPane.setLayout(new BorderLayout());\r
a0783edc 124 jContentPane.add(getJScrollPaneDynPcd(), java.awt.BorderLayout.NORTH);\r
125 jContentPane.add(getJPanelSkuInfo(), java.awt.BorderLayout.CENTER);\r
a13899c5 126 }\r
127 return jContentPane;\r
128 }\r
129\r
a13899c5 130 /**\r
131 * This method initializes jScrollPane \r
132 * \r
133 * @return javax.swing.JScrollPane \r
134 */\r
4da2e625 135 private JScrollPane getJScrollPaneDynPcd() {\r
136 if (jScrollPaneDynPcd == null) {\r
137 jScrollPaneDynPcd = new JScrollPane();\r
50d4c727 138 jScrollPaneDynPcd.setPreferredSize(new java.awt.Dimension(100,250));\r
4da2e625 139 jScrollPaneDynPcd.setViewportView(getJTableDynPcd());\r
a13899c5 140 }\r
4da2e625 141 return jScrollPaneDynPcd;\r
a13899c5 142 }\r
143\r
144 /**\r
145 * This method initializes jTable \r
146 * \r
147 * @return javax.swing.JTable \r
148 */\r
4da2e625 149 private JTable getJTableDynPcd() {\r
150 if (jTableDynPcd == null) {\r
151 modelPcd = new DynPcdTableModel();\r
152 modelPcd.addColumn("CName");\r
153 modelPcd.addColumn("Token");\r
154 modelPcd.addColumn("TokenSpaceGuid");\r
155 modelPcd.addColumn("MaxDatumSize");\r
156 modelPcd.addColumn("DatumType");\r
157 jTableDynPcd = new JTable(modelPcd);\r
158 jTableDynPcd.setRowHeight(20);\r
2cd33eaf 159 TableColumn tokenColumn = jTableDynPcd.getColumnModel().getColumn(1);\r
160 jTableDynPcd.removeColumn(tokenColumn);\r
5a502bd4 161 jTableDynPcd.getColumnModel().getColumn(0).setMinWidth(250);\r
162 \r
4da2e625 163 jTableDynPcd.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
164 jTableDynPcd.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
a13899c5 165 public void valueChanged(ListSelectionEvent e) {\r
166 if (e.getValueIsAdjusting()){\r
167 return;\r
168 }\r
169 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
170 if (lsm.isSelectionEmpty()) {\r
171 return;\r
172 }\r
173 else{\r
174 int selectedRow = lsm.getMinSelectionIndex();\r
fb464577 175 jTextFieldDefaultValue.setText("");\r
176 jTextFieldVpdOffset.setText("");\r
177 jTextFieldVarName.setText("");\r
178 jTextFieldVarGuid.setText("");\r
179 jTextFieldVarOffset.setText("");\r
180 jTextFieldHiiDefaultValue.setText("");\r
a13899c5 181 displayDetails(selectedRow);\r
182 }\r
183 }\r
184 });\r
185 }\r
4da2e625 186 return jTableDynPcd;\r
a13899c5 187 }\r
188 //\r
189 // should display default sku info here, as no selection event of table1 will be triggered when change selection of rows in table. \r
190 //\r
191 private void displayDetails(int i) {\r
4da2e625 192 jTableSkuInfo.changeSelection(0, 1, false, false);\r
a13899c5 193 int skuCount = ffc.getDynamicPcdSkuInfoCount(i);\r
194 String defaultVal = ffc.getDynamicPcdBuildDataValue(i);\r
195 if (defaultVal != null) {\r
4da2e625 196 jRadioButtonDefaultValue.setSelected(true);\r
197 jTextFieldDefaultValue.setText(defaultVal);\r
a13899c5 198 if ( skuCount == 1) {\r
4da2e625 199 jCheckBoxSkuEnable.setSelected(false);\r
a13899c5 200 }\r
201 else{\r
4da2e625 202 jCheckBoxSkuEnable.setSelected(true);\r
a13899c5 203 }\r
204 }\r
205 \r
206 else if (ffc.getDynamicPcdBuildDataVpdOffset(i) != null) {\r
4da2e625 207 jRadioButtonVpd.setSelected(true);\r
208 jTextFieldVpdOffset.setText(ffc.getDynamicPcdBuildDataVpdOffset(i));\r
a13899c5 209 if (skuCount ==1) {\r
4da2e625 210 jCheckBoxSkuEnable.setSelected(false);\r
a13899c5 211 \r
212 }\r
213 else{\r
4da2e625 214 jCheckBoxSkuEnable.setSelected(true);\r
a13899c5 215 }\r
216 }\r
217 else {\r
4da2e625 218 jRadioButtonHii.setSelected(true);\r
a13899c5 219 String[][] saa = new String[ffc.getDynamicPcdSkuInfoCount(i)][7];\r
220 ffc.getDynamicPcdSkuInfos(i, saa);\r
2a23019d 221 \r
222 String varDisplayName = Tools.convertUnicodeHexStringToString(saa[0][1]);\r
223 jTextFieldVarName.setText(varDisplayName);\r
224 \r
4da2e625 225 jTextFieldVarGuid.setText(saa[0][2]);\r
226 jTextFieldVarOffset.setText(saa[0][3]);\r
227 jTextFieldHiiDefaultValue.setText(saa[0][4]);\r
a13899c5 228 if (skuCount ==1) {\r
4da2e625 229 jCheckBoxSkuEnable.setSelected(false);\r
a13899c5 230 }\r
231 else{\r
4da2e625 232 jCheckBoxSkuEnable.setSelected(true);\r
a13899c5 233 }\r
234 }\r
235 \r
236 }\r
237 \r
238 private void displaySkuInfoDetails(int i) {\r
4da2e625 239 int pcdSelected = jTableDynPcd.getSelectedRow();\r
a13899c5 240 if (pcdSelected < 0) {\r
241 return;\r
242 }\r
243 \r
244 String[][] saa = new String[ffc.getDynamicPcdSkuInfoCount(pcdSelected)][7];\r
245 ffc.getDynamicPcdSkuInfos(pcdSelected, saa);\r
246 \r
247 if (saa[i][5] != null){\r
4da2e625 248 jRadioButtonVpd.setSelected(true);\r
249 jTextFieldVpdOffset.setText(saa[i][5]);\r
a13899c5 250 } \r
251 \r
252 else if (saa[i][1] != null) {\r
4da2e625 253 jRadioButtonHii.setSelected(true);\r
2a23019d 254 String varDisplayName = Tools.convertUnicodeHexStringToString(saa[i][1]);\r
255 jTextFieldVarName.setText(varDisplayName);\r
4da2e625 256 jTextFieldVarGuid.setText(saa[i][2]);\r
257 jTextFieldVarOffset.setText(saa[i][3]);\r
258 jTextFieldHiiDefaultValue.setText(saa[i][4]);\r
a13899c5 259 }\r
260 \r
261 else{\r
4da2e625 262 jRadioButtonDefaultValue.setSelected(true);\r
263 jTextFieldDefaultValue.setText(saa[i][6]);\r
a13899c5 264 }\r
265 \r
266 }\r
267\r
268 /**\r
269 * This method initializes jPanel3 \r
270 * \r
271 * @return javax.swing.JPanel \r
272 */\r
4da2e625 273 private JPanel getJPanelSkuInfo() {\r
274 if (jPanelSkuInfo == null) {\r
4da2e625 275 jPanelSkuInfo = new JPanel();\r
50d4c727 276 jPanelSkuInfo.setLayout(new BorderLayout());\r
4da2e625 277 jPanelSkuInfo.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));\r
50d4c727 278 jPanelSkuInfo.setPreferredSize(new java.awt.Dimension(600,120));\r
279\r
280// jPanelSkuInfo.add(getJPanelSkuInfoN(), java.awt.BorderLayout.NORTH);\r
281 jPanelSkuInfo.add(getJScrollPane(), java.awt.BorderLayout.NORTH);\r
282 jPanelSkuInfo.add(getJScrollPaneSkuInfo(), java.awt.BorderLayout.CENTER);\r
283 \r
284 \r
285// jPanelSkuInfo.add(getJPanelDynPcdValue(), java.awt.BorderLayout.SOUTH);\r
4da2e625 286 }\r
287 return jPanelSkuInfo;\r
a13899c5 288 }\r
289\r
290 /**\r
291 * This method initializes jCheckBox \r
292 * \r
293 * @return javax.swing.JCheckBox \r
294 */\r
4da2e625 295 private JCheckBox getJCheckBoxSkuEnable() {\r
296 if (jCheckBoxSkuEnable == null) {\r
297 jCheckBoxSkuEnable = new JCheckBox();\r
298 jCheckBoxSkuEnable.setText("SKU Enable");\r
299 jCheckBoxSkuEnable.addItemListener(new java.awt.event.ItemListener() {\r
a13899c5 300 public void itemStateChanged(java.awt.event.ItemEvent e) {\r
4da2e625 301 jTableSkuInfo.setEnabled(jCheckBoxSkuEnable.isSelected());\r
a13899c5 302 }\r
303 });\r
304 }\r
4da2e625 305 return jCheckBoxSkuEnable;\r
a13899c5 306 }\r
307\r
308 \r
309 /**\r
310 * This method initializes jPanel4 \r
311 * \r
312 * @return javax.swing.JPanel \r
313 */\r
4da2e625 314 private JPanel getJPanelDynPcdValue() {\r
315 if (jPanelDynPcdValue == null) {\r
a0783edc 316 jLabelPad1 = new JLabel();\r
317 jLabelPad1.setText(" ");\r
318 GridLayout gridLayout = new GridLayout();\r
319 gridLayout.setColumns(5);\r
320 gridLayout.setRows(4);\r
50d4c727 321 gridLayout.setHgap(20);\r
322 gridLayout.setVgap(20);\r
a0783edc 323 \r
4da2e625 324 jLabelVpdOffset = new JLabel();\r
325 jLabelVpdOffset.setPreferredSize(new java.awt.Dimension(80,20));\r
326 jLabelVpdOffset.setText("VPD Offset");\r
327 jLabelHiiDefaultValue = new JLabel();\r
328 jLabelHiiDefaultValue.setPreferredSize(new java.awt.Dimension(100,20));\r
329 jLabelHiiDefaultValue.setText("HII Default Value");\r
330 jLabelVarOffset = new JLabel();\r
331 jLabelVarOffset.setText("Variable Offset");\r
332 jLabelVarOffset.setPreferredSize(new java.awt.Dimension(90,20));\r
333 jLabelPad = new JLabel();\r
334 jLabelPad.setText(" ");\r
335 jLabelVarGuid = new JLabel();\r
336 jLabelVarGuid.setText("Variable GUID");\r
337 jLabelVarGuid.setPreferredSize(new java.awt.Dimension(100,20));\r
338 jLabelVarName = new JLabel();\r
339 jLabelVarName.setText("Variable Name");\r
340 jLabelVarName.setToolTipText("");\r
341 jLabelVarName.setPreferredSize(new java.awt.Dimension(90,20));\r
4da2e625 342 jPanelDynPcdValue = new JPanel();\r
343 jPanelDynPcdValue.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));\r
50d4c727 344 jPanelDynPcdValue.setPreferredSize(new java.awt.Dimension(1000,150));\r
a0783edc 345 jPanelDynPcdValue.setLayout(gridLayout);\r
4da2e625 346 jPanelDynPcdValue.add(getJRadioButtonHii(), null);\r
347 jPanelDynPcdValue.add(jLabelVarName, null);\r
348 jPanelDynPcdValue.add(getJTextFieldVarName(), null);\r
349 jPanelDynPcdValue.add(jLabelVarGuid, null);\r
350 jPanelDynPcdValue.add(getJTextFieldVarGuid(), null);\r
351 jPanelDynPcdValue.add(jLabelPad, null);\r
352 jPanelDynPcdValue.add(jLabelVarOffset, null);\r
353 jPanelDynPcdValue.add(getJTextFieldVarOffset(), null);\r
354 jPanelDynPcdValue.add(jLabelHiiDefaultValue, null);\r
355 jPanelDynPcdValue.add(getJTextFieldHiiDefaultValue(), null);\r
356 jPanelDynPcdValue.add(getJRadioButtonVpd(), null);\r
357 jPanelDynPcdValue.add(jLabelVpdOffset, null);\r
4da2e625 358 jLabelPadd = new JLabel();\r
359 jLabelPadd.setText(" ");\r
a0783edc 360 jPanelDynPcdValue.add(getJTextFieldVpdOffset(), null);\r
4da2e625 361 jLabelVarName.setEnabled(false);\r
362 jLabelVarGuid.setEnabled(false);\r
363 jLabelHiiDefaultValue.setEnabled(false);\r
364 jLabelVarOffset.setEnabled(false);\r
365 jLabelVpdOffset.setEnabled(false);\r
a0783edc 366 jPanelDynPcdValue.add(jLabelPadd, null);\r
367 jPanelDynPcdValue.add(jLabelPad1, null);\r
4da2e625 368 jPanelDynPcdValue.add(getJRadioButtonDefaultValue(), null);\r
369 jPanelDynPcdValue.add(getJTextFieldDefaultValue(), null);\r
50d4c727 370 jPanelDynPcdValue.add(getJCheckBoxSkuEnable(), null);\r
371 jPanelDynPcdValue.add(getJButtonSkuInfoUpdate(), null);\r
4da2e625 372 bg.add(jRadioButtonHii);\r
373 bg.add(jRadioButtonVpd);\r
a13899c5 374 } \r
375\r
4da2e625 376 return jPanelDynPcdValue;\r
a13899c5 377 }\r
378\r
379 /**\r
380 * This method initializes jRadioButton \r
381 * \r
382 * @return javax.swing.JRadioButton \r
383 */\r
4da2e625 384 private JRadioButton getJRadioButtonHii() {\r
385 if (jRadioButtonHii == null) {\r
386 jRadioButtonHii = new JRadioButton();\r
387 jRadioButtonHii.setText("HII Enable");\r
388 jRadioButtonHii.addItemListener(new java.awt.event.ItemListener() {\r
a13899c5 389 public void itemStateChanged(java.awt.event.ItemEvent e) {\r
4da2e625 390 boolean selected = jRadioButtonHii.isSelected();\r
391 jLabelVarName.setEnabled(selected);\r
392 jLabelVarGuid.setEnabled(selected);\r
393 jLabelPad.setEnabled(selected);\r
394 jLabelVarOffset.setEnabled(selected);\r
395 jLabelHiiDefaultValue.setEnabled(selected);\r
396 jTextFieldVarName.setEnabled(selected);\r
397 jTextFieldVarGuid.setEnabled(selected);\r
398 jTextFieldVarOffset.setEnabled(selected);\r
399 jTextFieldHiiDefaultValue.setEnabled(selected);\r
a13899c5 400 }\r
401 });\r
402 }\r
4da2e625 403 return jRadioButtonHii;\r
a13899c5 404 }\r
405\r
406 /**\r
407 * This method initializes jRadioButton1 \r
408 * \r
409 * @return javax.swing.JRadioButton \r
410 */\r
4da2e625 411 private JRadioButton getJRadioButtonVpd() {\r
412 if (jRadioButtonVpd == null) {\r
413 jRadioButtonVpd = new JRadioButton();\r
414 jRadioButtonVpd.setText("VPD Enable");\r
415 jRadioButtonVpd.addItemListener(new java.awt.event.ItemListener() {\r
a13899c5 416 public void itemStateChanged(java.awt.event.ItemEvent e) {\r
4da2e625 417 boolean selected = jRadioButtonVpd.isSelected();\r
418 jTextFieldVpdOffset.setEnabled(selected);\r
419 jLabelVpdOffset.setEnabled(selected);\r
a13899c5 420 }\r
421 });\r
422 }\r
4da2e625 423 return jRadioButtonVpd;\r
a13899c5 424 }\r
425\r
426 /**\r
427 * This method initializes jScrollPane1 \r
428 * \r
429 * @return javax.swing.JScrollPane \r
430 */\r
4da2e625 431 private JScrollPane getJScrollPaneSkuInfo() {\r
432 if (jScrollPaneSkuInfo == null) {\r
433 jScrollPaneSkuInfo = new JScrollPane();\r
50d4c727 434 jScrollPaneSkuInfo.setPreferredSize(new java.awt.Dimension(300,50));\r
4da2e625 435 jScrollPaneSkuInfo.setViewportView(getJTableSkuInfo());\r
a13899c5 436 }\r
4da2e625 437 return jScrollPaneSkuInfo;\r
a13899c5 438 }\r
439\r
440 /**\r
441 * This method initializes jTable1 \r
442 * \r
443 * @return javax.swing.JTable \r
444 */\r
4da2e625 445 private JTable getJTableSkuInfo() {\r
446 if (jTableSkuInfo == null) {\r
447 modelSku = new DynPcdTableModel();\r
448 jTableSkuInfo = new JTable(modelSku);\r
449 modelSku.addColumn("SKU ID");\r
450 modelSku.addColumn("SKU Name");\r
a13899c5 451 \r
4da2e625 452 jTableSkuInfo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
453 jTableSkuInfo.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
a13899c5 454 public void valueChanged(ListSelectionEvent e) {\r
4da2e625 455 if (jTableDynPcd.getSelectedRow() < 0) {\r
a13899c5 456 return;\r
457 }\r
458 if (e.getValueIsAdjusting()){\r
459 return;\r
460 }\r
461 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
462 if (lsm.isSelectionEmpty()) {\r
463 return;\r
464 }\r
465 else{\r
1bf9fa5a 466 jTextFieldDefaultValue.setText("");\r
467 jTextFieldVpdOffset.setText("");\r
468 jTextFieldVarName.setText("");\r
469 jTextFieldVarGuid.setText("");\r
470 jTextFieldVarOffset.setText("");\r
471 jTextFieldHiiDefaultValue.setText("");\r
a13899c5 472 int selected = lsm.getMinSelectionIndex();\r
44053733 473 displaySkuInfoDetails(selected);\r
a13899c5 474 }\r
475 }\r
476 });\r
477 }\r
4da2e625 478 return jTableSkuInfo;\r
a13899c5 479 }\r
480\r
481 /**\r
482 * This method initializes jButton \r
483 * \r
484 * @return javax.swing.JButton \r
485 */\r
4da2e625 486 private JButton getJButtonSkuInfoUpdate() {\r
487 if (jButtonSkuInfoUpdate == null) {\r
488 jButtonSkuInfoUpdate = new JButton();\r
489 jButtonSkuInfoUpdate.setPreferredSize(new java.awt.Dimension(180,20));\r
490 jButtonSkuInfoUpdate.setText(" Update SKU Information");\r
491 jButtonSkuInfoUpdate.addActionListener(new java.awt.event.ActionListener() {\r
a13899c5 492 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 493 int pcdSelected = jTableDynPcd.getSelectedRow();\r
a13899c5 494 if (pcdSelected < 0) {\r
495 return;\r
496 }\r
d6d24759 497 docConsole.setSaved(false);\r
a13899c5 498 updateSkuInfo(pcdSelected);\r
499 \r
500 }\r
501 });\r
502 }\r
4da2e625 503 return jButtonSkuInfoUpdate;\r
a13899c5 504 }\r
2a23019d 505 \r
a13899c5 506 private void updateSkuInfo (int pcdSelected) {\r
507 int skuCount = ffc.getDynamicPcdSkuInfoCount(pcdSelected);\r
50d4c727 508 String cName = modelPcd.getValueAt(pcdSelected, 0)+"";\r
509 String tsGuid = modelPcd.getValueAt(pcdSelected, 2)+"";\r
a13899c5 510 \r
511 String varName = null;\r
512 String varGuid = null;\r
513 String varOffset = null;\r
514 String hiiDefault = null;\r
515 String value = null;\r
516 String vpdOffset = null;\r
4da2e625 517 if (jRadioButtonHii.isSelected()) {\r
2a23019d 518 varName = Tools.convertStringToUnicodeHexString(jTextFieldVarName.getText());\r
519 if (varName.length() == 0) {\r
520 JOptionPane.showMessageDialog(this, "Variable Name is Empty.");\r
521 return;\r
522 }\r
4da2e625 523 varGuid = jTextFieldVarGuid.getText();\r
2a23019d 524 if (varGuid.length() == 0) {\r
525 JOptionPane.showMessageDialog(this, "Variable GUID is Empty.");\r
526 return;\r
527 }\r
4da2e625 528 varOffset = jTextFieldVarOffset.getText();\r
2a23019d 529 if (!DataValidation.isHex64BitDataType(varOffset)) {\r
530 JOptionPane.showMessageDialog(this, "Variable Offset is NOT Hex64BitDataType.");\r
531 return;\r
532 }\r
4da2e625 533 hiiDefault = jTextFieldHiiDefaultValue.getText();\r
2a23019d 534 if (!DataValidation.isDefaultValueType(hiiDefault)) {\r
535 JOptionPane.showMessageDialog(this, "Default Value is NOT DefaultValueType.");\r
536 return;\r
537 }\r
a13899c5 538 }\r
4da2e625 539 if (jRadioButtonVpd.isSelected()) {\r
540 vpdOffset = jTextFieldVpdOffset.getText();\r
2a23019d 541 if (!DataValidation.isHex64BitDataType(vpdOffset)) {\r
542 JOptionPane.showMessageDialog(this, "VPD Offset is NOT Hex64BitDataType.");\r
543 return;\r
544 }\r
a13899c5 545 }\r
4da2e625 546 if (jRadioButtonDefaultValue.isSelected()) {\r
547 value = jTextFieldDefaultValue.getText();\r
2a23019d 548 if (!DataValidation.isDefaultValueType(value)) {\r
549 JOptionPane.showMessageDialog(this, "Value is NOT DefaultValueType.");\r
550 return;\r
551 }\r
a13899c5 552 }\r
553 //\r
554 // SKU disabled. only modify data for default SKU.\r
555 //\r
4da2e625 556 if (!jCheckBoxSkuEnable.isSelected()) {\r
a13899c5 557 if (true) {\r
558 ffc.removeDynamicPcdBuildDataSkuInfo(pcdSelected);\r
4da2e625 559 if (jRadioButtonHii.isSelected()) {\r
a13899c5 560 ffc.genDynamicPcdBuildDataSkuInfo("0", varName, varGuid, varOffset, hiiDefault, null, null, pcdSelected);\r
50d4c727 561 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
2cd33eaf 562 if (al == null) {\r
563 return;\r
564 }\r
50d4c727 565 for (int i = 0; i < al.size(); ++i) {\r
566 String mKey = moduleInfo (al.get(i));\r
567 ffc.updatePcdData(mKey, cName, tsGuid, null, null, hiiDefault);\r
568 }\r
a13899c5 569 }\r
4da2e625 570 else if (jRadioButtonVpd.isSelected()){\r
a13899c5 571 ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, vpdOffset, null, pcdSelected);\r
50d4c727 572 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
2cd33eaf 573 if (al == null) {\r
574 return;\r
575 }\r
50d4c727 576 for (int i = 0; i < al.size(); ++i) {\r
577 String mKey = moduleInfo (al.get(i));\r
578 ffc.updatePcdData(mKey, cName, tsGuid, null, null, vpdOffset);\r
579 }\r
a13899c5 580 }\r
581 else{\r
582 ffc.genDynamicPcdBuildDataSkuInfo("0", null, null, null, null, null, value, pcdSelected);\r
50d4c727 583 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
2cd33eaf 584 if (al == null) {\r
585 return;\r
586 }\r
50d4c727 587 for (int i = 0; i < al.size(); ++i) {\r
588 String mKey = moduleInfo (al.get(i));\r
589 ffc.updatePcdData(mKey, cName, tsGuid, null, null, value);\r
590 }\r
a13899c5 591 }\r
592 }\r
593 }\r
594 //\r
595 // SKU Enabled, need add data to all SKUs.\r
596 //\r
4da2e625 597 if (jCheckBoxSkuEnable.isSelected()) {\r
a13899c5 598 if (skuCount == 1) {\r
599 \r
4da2e625 600 for (int i = 1; i < jTableSkuInfo.getRowCount(); ++i) {\r
601 ffc.genDynamicPcdBuildDataSkuInfo(jTableSkuInfo.getValueAt(i, 0)+"", varName, varGuid, varOffset, hiiDefault, vpdOffset, value, pcdSelected);\r
a13899c5 602 }\r
603 }\r
604 else {\r
4da2e625 605 int row = jTableSkuInfo.getSelectedRow();\r
a13899c5 606 if (row < 0) {\r
607 return;\r
608 }\r
4da2e625 609 ffc.updateDynamicPcdBuildDataSkuInfo(jTableSkuInfo.getValueAt(row, 0)+"", varName, varGuid, varOffset, hiiDefault, vpdOffset, value, pcdSelected);\r
a13899c5 610 }\r
611 }\r
612 }\r
50d4c727 613 \r
614 private String moduleInfo (String pcdInfo) {\r
615 \r
616 return pcdInfo.substring(0, pcdInfo.lastIndexOf(" "));\r
617 }\r
a13899c5 618 /**\r
619 * This method initializes jTextField \r
620 * \r
621 * @return javax.swing.JTextField \r
622 */\r
4da2e625 623 private JTextField getJTextFieldVarName() {\r
624 if (jTextFieldVarName == null) {\r
625 jTextFieldVarName = new JTextField();\r
626 jTextFieldVarName.setPreferredSize(new java.awt.Dimension(150,20));\r
627 jTextFieldVarName.setEnabled(false);\r
a13899c5 628 }\r
4da2e625 629 return jTextFieldVarName;\r
a13899c5 630 }\r
631\r
632 /**\r
633 * This method initializes jTextField1 \r
634 * \r
635 * @return javax.swing.JTextField \r
636 */\r
4da2e625 637 private JTextField getJTextFieldVarGuid() {\r
638 if (jTextFieldVarGuid == null) {\r
639 jTextFieldVarGuid = new JTextField();\r
640 jTextFieldVarGuid.setPreferredSize(new java.awt.Dimension(150,20));\r
641 jTextFieldVarGuid.setEnabled(false);\r
a13899c5 642 }\r
4da2e625 643 return jTextFieldVarGuid;\r
a13899c5 644 }\r
645\r
646 /**\r
647 * This method initializes jTextField2 \r
648 * \r
649 * @return javax.swing.JTextField \r
650 */\r
4da2e625 651 private JTextField getJTextFieldVarOffset() {\r
652 if (jTextFieldVarOffset == null) {\r
653 jTextFieldVarOffset = new JTextField();\r
654 jTextFieldVarOffset.setPreferredSize(new java.awt.Dimension(150,20));\r
655 jTextFieldVarOffset.setEnabled(false);\r
a13899c5 656 }\r
4da2e625 657 return jTextFieldVarOffset;\r
a13899c5 658 }\r
659\r
660 /**\r
661 * This method initializes jTextField3 \r
662 * \r
663 * @return javax.swing.JTextField \r
664 */\r
4da2e625 665 private JTextField getJTextFieldHiiDefaultValue() {\r
666 if (jTextFieldHiiDefaultValue == null) {\r
667 jTextFieldHiiDefaultValue = new JTextField();\r
668 jTextFieldHiiDefaultValue.setPreferredSize(new java.awt.Dimension(150,20));\r
669 jTextFieldHiiDefaultValue.setEnabled(false);\r
a13899c5 670 }\r
4da2e625 671 return jTextFieldHiiDefaultValue;\r
a13899c5 672 }\r
673\r
674 /**\r
675 * This method initializes jTextField4 \r
676 * \r
677 * @return javax.swing.JTextField \r
678 */\r
4da2e625 679 private JTextField getJTextFieldVpdOffset() {\r
680 if (jTextFieldVpdOffset == null) {\r
681 jTextFieldVpdOffset = new JTextField();\r
682 jTextFieldVpdOffset.setPreferredSize(new java.awt.Dimension(150,20));\r
683 jTextFieldVpdOffset.setEnabled(false);\r
a13899c5 684 }\r
4da2e625 685 return jTextFieldVpdOffset;\r
a13899c5 686 }\r
687\r
688 /**\r
689 * This method initializes jTextField5 \r
690 * \r
691 * @return javax.swing.JTextField \r
692 */\r
4da2e625 693 private JTextField getJTextFieldDefaultValue() {\r
694 if (jTextFieldDefaultValue == null) {\r
695 jTextFieldDefaultValue = new JTextField();\r
696 jTextFieldDefaultValue.setPreferredSize(new java.awt.Dimension(150,20));\r
a13899c5 697 }\r
4da2e625 698 return jTextFieldDefaultValue;\r
a13899c5 699 }\r
700\r
701 /**\r
702 * This method initializes jRadioButton2 \r
703 * \r
704 * @return javax.swing.JRadioButton \r
705 */\r
4da2e625 706 private JRadioButton getJRadioButtonDefaultValue() {\r
707 if (jRadioButtonDefaultValue == null) {\r
708 jRadioButtonDefaultValue = new JRadioButton();\r
709 jRadioButtonDefaultValue.setText("Default PCD Value");\r
710 jRadioButtonDefaultValue.setSelected(true);\r
711 jRadioButtonDefaultValue.setPreferredSize(new java.awt.Dimension(175,20));\r
712 jRadioButtonDefaultValue.addItemListener(new java.awt.event.ItemListener() {\r
a13899c5 713 public void itemStateChanged(java.awt.event.ItemEvent e) {\r
4da2e625 714 jTextFieldDefaultValue.setEnabled(jRadioButtonDefaultValue.isSelected());\r
a13899c5 715 }\r
716 });\r
4da2e625 717 bg.add(jRadioButtonDefaultValue);\r
a13899c5 718 }\r
4da2e625 719 return jRadioButtonDefaultValue;\r
a13899c5 720 }\r
721\r
50d4c727 722 /**\r
723 * This method initializes jScrollPane \r
724 * \r
725 * @return javax.swing.JScrollPane \r
726 */\r
727 private JScrollPane getJScrollPane() {\r
728 if (jScrollPane == null) {\r
729 jScrollPane = new JScrollPane();\r
730 jScrollPane.setPreferredSize(new java.awt.Dimension(1003,180));\r
731 jScrollPane.setViewportView(getJPanelDynPcdValue());\r
732 }\r
733 return jScrollPane;\r
734 }\r
735\r
a13899c5 736} // @jve:decl-index=0:visual-constraint="10,10"\r
737\r
738class DynPcdTableModel extends DefaultTableModel {\r
44053733 739 /**\r
740 * \r
741 */\r
742 private static final long serialVersionUID = 1L;\r
743\r
a13899c5 744 public boolean isCellEditable(int row, int col) {\r
745 \r
746 return false;\r
747 }\r
748}\r