Remove empty FfsFileNameGuid element under ModuleSaBuildOptions if user input empty...
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdModuleSA.java
CommitLineData
a13899c5 1package org.tianocore.frameworkwizard.platform.ui;\r
2\r
3import java.awt.BorderLayout;\r
f3b0ed9a 4import java.awt.Dimension;\r
5import java.awt.Toolkit;\r
a13899c5 6\r
a13899c5 7import javax.swing.JFrame;\r
8import javax.swing.JOptionPane;\r
9import javax.swing.JPanel;\r
10import javax.swing.JDialog;\r
11import javax.swing.JTabbedPane;\r
12import javax.swing.JLabel;\r
13import javax.swing.JScrollPane;\r
14import javax.swing.JTable;\r
a13899c5 15import javax.swing.JTextArea;\r
16import javax.swing.JSplitPane;\r
17import javax.swing.JButton;\r
18import javax.swing.ListSelectionModel;\r
19import javax.swing.event.ListSelectionEvent;\r
20import javax.swing.event.ListSelectionListener;\r
21import javax.swing.event.TableModelEvent;\r
22import javax.swing.event.TableModelListener;\r
23import javax.swing.table.DefaultTableModel;\r
a13899c5 24import javax.swing.table.TableModel;\r
25\r
26import org.apache.xmlbeans.XmlObject;\r
8f55ea73 27import org.tianocore.frameworkwizard.common.DataValidation;\r
28import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;\r
a13899c5 29import org.tianocore.frameworkwizard.platform.ui.global.GlobalData;\r
30import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
31import org.tianocore.frameworkwizard.platform.ui.id.ModuleIdentification;\r
32import org.tianocore.frameworkwizard.platform.ui.id.PackageIdentification;\r
33\r
34import java.awt.FlowLayout;\r
35import java.awt.event.ActionEvent;\r
36import java.awt.event.ActionListener;\r
37import java.util.ArrayList;\r
38import java.util.HashMap;\r
39import java.util.Iterator;\r
40import java.util.ListIterator;\r
41import java.util.Map;\r
42import java.util.Set;\r
1800d80f 43import java.util.Vector;\r
44\r
6a09eb19 45import javax.swing.JTextField;\r
908b1c05 46import java.awt.GridLayout;\r
47import javax.swing.JComboBox;\r
a13899c5 48\r
49public class FpdModuleSA extends JDialog implements ActionListener {\r
50\r
44053733 51 /**\r
52 * \r
53 */\r
54 private static final long serialVersionUID = 1L;\r
a13899c5 55 static JFrame frame;\r
56 private JPanel jContentPane = null;\r
57 private JTabbedPane jTabbedPane = null;\r
58 private JPanel jPanel = null;\r
59 private JPanel jPanel1 = null;\r
60 private JLabel jLabel = null;\r
61 private JScrollPane jScrollPane = null;\r
62 private JTable jTable = null;\r
63 private JPanel jPanel2 = null;\r
64 private JScrollPane jScrollPane1 = null;\r
65 private JTextArea jTextArea = null;\r
66 private JPanel jPanel3 = null;\r
67 private JSplitPane jSplitPane = null;\r
68 private JPanel jPanel4 = null;\r
69 private JPanel jPanel5 = null;\r
70 private JLabel jLabel1 = null;\r
71 private JLabel jLabel2 = null;\r
72 private JScrollPane jScrollPane2 = null;\r
73 private JTable jTable1 = null;\r
74 private JScrollPane jScrollPane3 = null;\r
75 private JTable jTable2 = null;\r
76 private JScrollPane jScrollPane4 = null;\r
77 private JTable jTable3 = null;\r
78 private JPanel jPanel6 = null;\r
79 private JPanel jPanel7 = null;\r
80 private JScrollPane jScrollPane5 = null;\r
81 private JTextArea jTextArea1 = null;\r
82 private JLabel jLabel3 = null;\r
83 private JLabel jLabel4 = null;\r
84 private JButton jButton = null;\r
85 private JButton jButton1 = null;\r
86 private JLabel jLabel5 = null;\r
87 private JButton jButton2 = null;\r
88 private JButton jButton3 = null;\r
89 private PartialEditableTableModel model = null;\r
90 private LibraryTableModel model1 = null;\r
91 private LibraryTableModel model2 = null;\r
92 private LibraryTableModel model3 = null;\r
1800d80f 93 private DefaultTableModel optionsTableModel = null;\r
a13899c5 94 private FpdFileContents ffc = null;\r
95 private String moduleKey = null;\r
a13899c5 96 private HashMap<String, ArrayList<String>> classInstanceMap = null;\r
97 private ArrayList<String> classProduced = null;\r
a13899c5 98 private HashMap<String, ArrayList<String>> classConsumed = null;\r
6a09eb19 99 private JPanel jPanel8 = null;\r
100 private JLabel jLabel6 = null;\r
8f55ea73 101 private JTextField jTextFieldFvBinding = null;\r
6a09eb19 102 private JLabel jLabel7 = null;\r
8f55ea73 103 private JTextField jTextFieldFileGuid = null;\r
6a09eb19 104 private JLabel jLabel8 = null;\r
8f55ea73 105 private JTextField jTextFieldFfsKey = null;\r
6a09eb19 106 private JScrollPane jScrollPane6 = null;\r
107 private JTable jTable4 = null;\r
1800d80f 108 private JButton jButton4 = null;\r
109 private JButton jButton5 = null;\r
908b1c05 110 private JPanel jPanel9 = null;\r
111 private JPanel jPanel10 = null;\r
112 private JPanel jPanel11 = null;\r
113 private JPanel jPanel12 = null;\r
114 private JLabel jLabel9 = null;\r
115 private JComboBox jComboBox = null;\r
116 private JLabel jLabel10 = null;\r
117 private JTextField jTextField3 = null;\r
118 private JLabel jLabel11 = null;\r
119 private JTextField jTextField4 = null;\r
120 private JButton jButton6 = null;\r
121 private JComboBox jComboBox1 = null;\r
8f55ea73 122 private OpeningPlatformType docConsole = null;\r
123 private JLabel jLabel12 = null;\r
a13899c5 124 /**\r
125 * This is the default constructor\r
126 */\r
127 public FpdModuleSA() {\r
128 super();\r
129 initialize();\r
130 }\r
131 public FpdModuleSA(FpdFileContents ffc) {\r
132 this();\r
133 this.ffc = ffc;\r
134 }\r
135 \r
8f55ea73 136 public void setKey(String k, int i, OpeningPlatformType dc){\r
a13899c5 137 this.moduleKey = k;\r
8f55ea73 138 this.docConsole = dc;\r
908b1c05 139 jTabbedPane.setSelectedIndex(0);\r
055e7ae6 140 initPcdBuildDefinition(i);\r
a13899c5 141 }\r
142\r
143 /**\r
144 init will be called each time FpdModuleSA object is to be shown.\r
145 @param key Module information.\r
146 **/\r
055e7ae6 147 public void initPcdBuildDefinition(int i) {\r
a13899c5 148 //\r
149 // display pcd for key.\r
150 //\r
151 model.setRowCount(0);\r
055e7ae6 152 int pcdCount = ffc.getPcdDataCount(i);\r
a13899c5 153 if (pcdCount != 0) {\r
82961247 154 String[][] saa = new String[pcdCount][7];\r
055e7ae6 155 ffc.getPcdData(i, saa);\r
156 for (int j = 0; j < saa.length; ++j) {\r
157 model.addRow(saa[j]);\r
a13899c5 158 }\r
159 }\r
908b1c05 160 }\r
161 \r
162 public void initLibraries(String key) {\r
71baa24b 163 //\r
164 // display library classes that need to be resolved. also potential instances for them.\r
165 //\r
bf5abaff 166 resolveLibraryInstances(moduleKey);\r
a13899c5 167 //\r
168 // display lib instances already selected for key\r
169 //\r
170 model1.setRowCount(0);\r
171 int instanceCount = ffc.getLibraryInstancesCount(key);\r
172 if (instanceCount != 0) {\r
173 String[][] saa = new String[instanceCount][5];\r
174 ffc.getLibraryInstances(key, saa);\r
175 for (int i = 0; i < saa.length; ++i) {\r
71baa24b 176 ModuleIdentification mi = getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);\r
177 if (mi != null) {\r
178 saa[i][0] = mi.getName();\r
179 saa[i][2] = mi.getVersion();\r
180 saa[i][4] = mi.getPackage().getVersion();\r
181 //\r
182 // re-evaluate lib instance usage when adding a already-selected lib instance.\r
183 //\r
184 resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);\r
185 model1.addRow(saa[i]);\r
a13899c5 186 }\r
187 \r
71baa24b 188 \r
a13899c5 189 }\r
190 }\r
908b1c05 191 }\r
192 \r
193 public void initModuleSAOptions(String key) {\r
1800d80f 194 //\r
195 // display module SA options\r
196 //\r
197 String fvBinding = ffc.getFvBinding(key);\r
198 if (fvBinding != null) {\r
8f55ea73 199 jTextFieldFvBinding.setText(fvBinding);\r
1800d80f 200 }\r
201 String fileGuid = ffc.getFfsFileNameGuid(key);\r
202 if (fileGuid != null) {\r
8f55ea73 203 jTextFieldFileGuid.setText(fileGuid);\r
1800d80f 204 }\r
205 String ffsKey = ffc.getFfsFormatKey(key);\r
206 if (ffsKey != null) {\r
8f55ea73 207 jTextFieldFfsKey.setText(ffsKey);\r
1800d80f 208 }\r
bf5abaff 209 \r
210 optionsTableModel.setRowCount(0);\r
211 String[][] saa = new String[ffc.getModuleSAOptionsCount(key)][6];\r
212 ffc.getModuleSAOptions(key, saa);\r
213 for (int i = 0; i < saa.length; ++i) {\r
214 optionsTableModel.addRow(saa[i]);\r
215 }\r
a13899c5 216 }\r
217 \r
218 private void resolveLibraryInstances(String key) {\r
219 ModuleIdentification mi = getModuleId(key);\r
220 PackageIdentification[] depPkgList = null;\r
221 try{\r
222 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);\r
223 SurfaceAreaQuery.setDoc(m);\r
224 //\r
225 // Get dependency pkg list into which we will search lib instances.\r
226 //\r
227 depPkgList = SurfaceAreaQuery.getDependencePkg(null);\r
228 //\r
229 // Get the lib class consumed, produced by this module itself.\r
230 //\r
231 String[] classConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");\r
232 \r
233 if (this.classConsumed == null) {\r
234 this.classConsumed = new HashMap<String, ArrayList<String>>();\r
235 }\r
236 \r
237 for(int i = 0; i < classConsumed.length; ++i){\r
238 ArrayList<String> consumedBy = this.classConsumed.get(classConsumed[i]);\r
239 if (consumedBy == null) {\r
240 consumedBy = new ArrayList<String>();\r
241 }\r
242 consumedBy.add(key);\r
243 this.classConsumed.put(classConsumed[i], consumedBy);\r
244 }\r
245 \r
246 String[] classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");\r
247 if (this.classProduced == null) {\r
248 this.classProduced = new ArrayList<String>();\r
249 }\r
250 for(int i = 0; i < classProduced.length; ++i){\r
251 if (!this.classProduced.contains(classProduced[i])){\r
252 this.classProduced.add(classProduced[i]);\r
253 }\r
254 }\r
255 //\r
256 // Get classes unresolved\r
257 //\r
258// Iterator<String> lip = this.classProduced.listIterator();\r
259// while(lip.hasNext()){\r
260// String clsProduced = lip.next();\r
261// this.classConsumed.remove(clsProduced);\r
262//\r
263// }\r
264 //\r
265 // find potential instances in all dependency pkgs for classes still in classConsumed.\r
266 //\r
267 if (classInstanceMap == null){\r
268 classInstanceMap = new HashMap<String, ArrayList<String>>();\r
269 }\r
270 Iterator<String> lic = this.classConsumed.keySet().iterator();\r
271 while(lic.hasNext()){\r
272 String cls = lic.next();\r
273 if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {\r
274 continue;\r
275 }\r
276 ArrayList<String> instances = getInstancesForClass(cls, depPkgList);\r
277 if (instances.size() == 0){\r
278 JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " + \r
279 cls + ", Platform Build will Fail.");\r
280 }\r
281 classInstanceMap.put(cls, instances);\r
282 \r
283 }\r
284 \r
285 showClassToResolved();\r
286 }\r
287 catch(Exception e) {\r
288 e.printStackTrace();\r
289 }\r
290 }\r
291 \r
292 private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{\r
293 ArrayList<String> al = new ArrayList<String>();\r
294 \r
295 for (int i = 0; i < depPkgList.length; ++i) {\r
296 Set<ModuleIdentification> smi = GlobalData.getModules(depPkgList[i]);\r
297 Iterator ismi = smi.iterator();\r
298 while(ismi.hasNext()) {\r
299 ModuleIdentification mi = (ModuleIdentification)ismi.next();\r
300 \r
301 String[] clsProduced = getClassProduced(mi);\r
302 \r
303 boolean isPotential = false;\r
304 for (int j = 0; j < clsProduced.length; ++j) {\r
305 if (clsProduced[j] == null) {\r
306 continue;\r
307 }\r
308 if (clsProduced[j].equals(cls)){\r
309 isPotential = true;\r
310 }\r
311 if (classProduced.contains(clsProduced[j])) {\r
312 isPotential = false;\r
313 break;\r
314 }\r
315 }\r
316 if (isPotential) {\r
317 al.add(mi.getGuid() + " " + mi.getVersion() + " " + \r
318 depPkgList[i].getGuid() + " " + depPkgList[i].getVersion());\r
319 }\r
320 }\r
321 }\r
322 \r
323 return al;\r
324 }\r
325 \r
326 private void removeInstance(String key) {\r
327 ModuleIdentification mi = getModuleId(key); \r
328 //\r
329 // remove pcd information of instance from current ModuleSA\r
330 //\r
bf5abaff 331 ffc.removePcdData(key, mi);\r
a13899c5 332 //\r
333 // remove class produced by this instance and add back these produced class to be bound.\r
334 //\r
335 String[] clsProduced = getClassProduced(mi);\r
336 for (int i = 0; i < clsProduced.length; ++i) {\r
337 \r
338 classProduced.remove(clsProduced[i]);\r
339 }\r
340 //\r
341 // remove class consumed by this instance. we do not need to bound it now.\r
342 //\r
343 String[] clsConsumed = getClassConsumed(mi);\r
344 for (int i = 0; i < clsConsumed.length; ++i) {\r
345 ArrayList<String> al = classConsumed.get(clsConsumed[i]);\r
346 \r
347 if (al == null ) {\r
348 classConsumed.remove(clsConsumed[i]);\r
349 continue;\r
350 }\r
351 al.remove(key);\r
352 if (al.size() == 0) {\r
353 classConsumed.remove(clsConsumed[i]);\r
354 }\r
355 \r
356 }\r
357\r
358 showClassToResolved();\r
359 \r
360 }\r
361 \r
362 private ModuleIdentification getModuleId(String key){\r
363 //\r
bf5abaff 364 // Get ModuleGuid, ModuleVersion, PackageGuid, PackageVersion, Arch into string array.\r
a13899c5 365 //\r
366 String[] keyPart = key.split(" ");\r
367 Set<PackageIdentification> spi = GlobalData.getPackageList();\r
368 Iterator ispi = spi.iterator();\r
369 \r
370 while(ispi.hasNext()) {\r
371 PackageIdentification pi = (PackageIdentification)ispi.next();\r
bf5abaff 372 if ( !pi.getGuid().equals(keyPart[2])){ \r
373\r
a13899c5 374 continue;\r
375 }\r
bf5abaff 376 if (keyPart[3] != null && keyPart[3].length() > 0 && !keyPart[3].equals("null")){\r
377 if(!pi.getVersion().equals(keyPart[3])){\r
378 continue;\r
379 }\r
380 }\r
a13899c5 381 Set<ModuleIdentification> smi = GlobalData.getModules(pi);\r
382 Iterator ismi = smi.iterator();\r
383 while(ismi.hasNext()) {\r
384 ModuleIdentification mi = (ModuleIdentification)ismi.next();\r
71baa24b 385 if (mi.getGuid().equals(keyPart[0])){\r
bf5abaff 386 if (keyPart[1] != null && keyPart[1].length() > 0 && !keyPart[1].equals("null")){\r
387 if(!mi.getVersion().equals(keyPart[1])){\r
388 continue;\r
389 }\r
390 }\r
391\r
a13899c5 392 return mi;\r
393 }\r
394 }\r
395 }\r
396 return null;\r
397 }\r
398 \r
399 private String[] getClassProduced(ModuleIdentification mi){\r
400 \r
401 try{\r
402 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);\r
403 SurfaceAreaQuery.setDoc(m);\r
404 String[] clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");\r
405 return clsProduced;\r
406 \r
407 }catch (Exception e) {\r
408 e.printStackTrace();\r
409 }\r
410 return new String[0];\r
411 \r
412 }\r
413 \r
414 private String[] getClassConsumed(ModuleIdentification mi){\r
415 \r
416 String[] clsConsumed = null;\r
417 try{\r
418 Map<String, XmlObject> m = GlobalData.getNativeMsa(mi);\r
419 SurfaceAreaQuery.setDoc(m);\r
420 clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED");\r
421 \r
422 }catch (Exception e) {\r
423 e.printStackTrace();\r
424 }\r
425 return clsConsumed;\r
426 }\r
427 \r
428 private void showClassToResolved(){\r
429 model2.setRowCount(0);\r
430 if (classConsumed.size() == 0) {\r
431 return;\r
432 }\r
433 Iterator<String> li = classConsumed.keySet().iterator();\r
434 while(li.hasNext()){\r
435 \r
436 String[] s = {li.next()};\r
437 if (classConsumed.get(s[0]) == null) {\r
438 continue;\r
439 }\r
440 if (classConsumed.get(s[0]).size() == 0) {\r
441 continue;\r
442 }\r
443 if (!classProduced.contains(s[0])){\r
444 model2.addRow(s);\r
445 }\r
446 }\r
447 model3.setRowCount(0);\r
448 }\r
449 /**\r
450 * This method initializes this\r
451 * \r
452 * @return void\r
453 */\r
454 private void initialize() {\r
455 this.setSize(664, 515);\r
f3b0ed9a 456 this.centerWindow();\r
a13899c5 457 this.setModal(true);\r
458 this.setTitle("Module Settings");\r
459 this.setContentPane(getJContentPane());\r
460 }\r
461\r
462 /**\r
463 * This method initializes jContentPane\r
464 * \r
465 * @return javax.swing.JPanel\r
466 */\r
467 private JPanel getJContentPane() {\r
468 if (jContentPane == null) {\r
469 jContentPane = new JPanel();\r
470 jContentPane.setLayout(new BorderLayout());\r
471 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);\r
472 jContentPane.add(getJPanel3(), java.awt.BorderLayout.SOUTH);\r
473 }\r
474 return jContentPane;\r
475 }\r
476\r
477 /**\r
478 * This method initializes jTabbedPane \r
479 * \r
480 * @return javax.swing.JTabbedPane \r
481 */\r
482 private JTabbedPane getJTabbedPane() {\r
483 if (jTabbedPane == null) {\r
484 jTabbedPane = new JTabbedPane();\r
485 jTabbedPane.addTab("PCD Build Definition", null, getJPanel(), null);\r
6a09eb19 486 jTabbedPane.addTab("Module SA Options", null, getJPanel8(), null);\r
a13899c5 487 jTabbedPane.addTab("Libraries", null, getJPanel1(), null);\r
488 }\r
489 return jTabbedPane;\r
490 }\r
491\r
492 /**\r
493 * This method initializes jPanel \r
494 * \r
495 * @return javax.swing.JPanel \r
496 */\r
497 private JPanel getJPanel() {\r
498 if (jPanel == null) {\r
499 jLabel = new JLabel();\r
500 jLabel.setText("PcdData");\r
501 jPanel = new JPanel();\r
502 jPanel.setLayout(new BorderLayout());\r
503 jPanel.add(jLabel, java.awt.BorderLayout.NORTH);\r
504 jPanel.add(getJScrollPane(), java.awt.BorderLayout.CENTER);\r
505 jPanel.add(getJPanel2(), java.awt.BorderLayout.SOUTH);\r
506 jPanel.addComponentListener(new java.awt.event.ComponentAdapter() {\r
507 public void componentShown(java.awt.event.ComponentEvent e) {\r
055e7ae6 508// initPcdBuildDefinition(moduleKey);\r
a13899c5 509 }\r
510 });\r
511 \r
512 }\r
513 return jPanel;\r
514 }\r
515\r
516 /**\r
517 * This method initializes jPanel1 \r
518 * \r
519 * @return javax.swing.JPanel \r
520 */\r
521 private JPanel getJPanel1() {\r
522 if (jPanel1 == null) {\r
523 jPanel1 = new JPanel();\r
524 jPanel1.setLayout(new BorderLayout());\r
525 jPanel1.add(getJSplitPane(), java.awt.BorderLayout.NORTH);\r
526 jPanel1.add(getJPanel6(), java.awt.BorderLayout.SOUTH);\r
527 jPanel1.add(getJPanel7(), java.awt.BorderLayout.CENTER);\r
528 jPanel1.addComponentListener(new java.awt.event.ComponentAdapter() {\r
529 public void componentShown(java.awt.event.ComponentEvent e) {\r
908b1c05 530 initLibraries(moduleKey);\r
a13899c5 531 }\r
532 });\r
533 }\r
534 return jPanel1;\r
535 }\r
536\r
537 /**\r
538 * This method initializes jScrollPane \r
539 * \r
540 * @return javax.swing.JScrollPane \r
541 */\r
542 private JScrollPane getJScrollPane() {\r
543 if (jScrollPane == null) {\r
544 jScrollPane = new JScrollPane();\r
545 jScrollPane.setViewportView(getJTable());\r
546 }\r
547 return jScrollPane;\r
548 }\r
549\r
550 /**\r
551 * This method initializes jTable \r
552 * \r
553 * @return javax.swing.JTable \r
554 */\r
555 private JTable getJTable() {\r
556 if (jTable == null) {\r
557 model = new PartialEditableTableModel();\r
558 jTable = new JTable(model);\r
f3b0ed9a 559 jTable.setRowHeight(20);\r
71baa24b 560 jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
a13899c5 561 model.addColumn("CName");\r
562 model.addColumn("TokenSpaceGUID");\r
563 model.addColumn("ItemType");\r
564 model.addColumn("Token");\r
82961247 565 model.addColumn("MaxDatumSize");\r
a13899c5 566 model.addColumn("DataType");\r
567 model.addColumn("DefaultValue");\r
568 \r
569 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
570 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
571 public void valueChanged(ListSelectionEvent e) {\r
44053733 572 \r
a13899c5 573 if (e.getValueIsAdjusting()){\r
574 return;\r
575 }\r
576 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
577 if (lsm.isSelectionEmpty()) {\r
578 return;\r
579 }\r
580 else{\r
908b1c05 581 int selectedRow = lsm.getMinSelectionIndex();\r
582 String cName = jTable.getValueAt(selectedRow, 0)+"";\r
583 String[] pcdInfo = {"", ""};\r
584 getPcdInfo(cName, pcdInfo);\r
585 jTextArea.setText(pcdInfo[0]);\r
586 initComboBox(pcdInfo[1]);\r
587 jComboBox.setSelectedItem(pcdInfo[1]);\r
588 jTextField3.setEnabled(true);\r
589 jTextField3.setVisible(true);\r
590 jTextField3.setText(jTable.getValueAt(selectedRow, 4)+"");\r
591 jTextField4.setEnabled(true);\r
592 jTextField4.setText(jTable.getValueAt(selectedRow, 6)+"");\r
593 if (jTable.getValueAt(selectedRow, 5).equals("VOID*")) {\r
594 if (pcdInfo[1].equals("FEATURE_FLAG")) {\r
595 jTextField3.setVisible(false);\r
596 }\r
597 else if (pcdInfo[1].equals("FIXED_AT_BUILD")) {\r
598 try{\r
599 jTextField3.setEnabled(false);\r
600 jTextField3.setText(ffc.setMaxSizeForPointer(jTable.getValueAt(selectedRow, 6)+"")+"");\r
601 }\r
602 catch(Exception except){\r
603 JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage());\r
604 }\r
605 }\r
606 else{\r
607 jTextField3.setText(jTable.getValueAt(selectedRow, 4)+"");\r
608 }\r
609 }\r
610 else {\r
611 jTextField3.setEnabled(false);\r
612 }\r
a13899c5 613 \r
908b1c05 614 if (!jTable.getValueAt(selectedRow, 2).equals("DYNAMIC") && !jTable.getValueAt(selectedRow, 2).equals("DYNAMIC_EX")) {\r
615 jTextField4.setText(jTable.getValueAt(selectedRow, 6)+"");\r
616 if (jTable.getValueAt(selectedRow, 2).equals("FEATURE_FLAG")){\r
617 jTextField4.setVisible(false);\r
618 jComboBox1.setVisible(true);\r
619 jComboBox1.setSelectedItem(jTable.getValueAt(selectedRow, 6)+"");\r
620 }\r
621 else{\r
622 jTextField4.setVisible(true);\r
623 jTextField4.setEnabled(true);\r
624 jComboBox1.setVisible(false);\r
625 }\r
626 }\r
627 else{\r
628 jTextField4.setEnabled(false);\r
629 }\r
a13899c5 630 }\r
908b1c05 631 \r
632 \r
a13899c5 633 }\r
634 });\r
635 \r
636 jTable.getModel().addTableModelListener(new TableModelListener() {\r
637 public void tableChanged(TableModelEvent arg0) {\r
638 // TODO Auto-generated method stub\r
908b1c05 639// int row = arg0.getFirstRow();\r
640// TableModel m = (TableModel)arg0.getSource();\r
641 \r
a13899c5 642 if (arg0.getType() == TableModelEvent.UPDATE){\r
908b1c05 643 //update xml doc here.\r
a13899c5 644 \r
645 }\r
646 }\r
647 });\r
648 }\r
649 return jTable;\r
650 }\r
908b1c05 651 \r
652 private void initComboBox(String originalType) {\r
653 jComboBox.removeAllItems();\r
654 jComboBox.addItem(originalType);\r
655 if (originalType.equals("PATCHABLE_IN_MODULE")) {\r
656 jComboBox.addItem("FIXED_AT_BUILD");\r
657 }\r
658 if (originalType.equals("DYNAMIC")) {\r
659 jComboBox.addItem("FIXED_AT_BUILD");\r
660 jComboBox.addItem("PATCHABLE_IN_MODULE");\r
661 }\r
662 }\r
663 \r
664 private void getPcdInfo(String cName, String[] sa) {\r
665 String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];\r
666 ffc.getLibraryInstances(moduleKey, saa);\r
667 \r
668 try{\r
669 if (ffc.getPcdBuildDataInfo(getModuleId(moduleKey), cName, sa)) {\r
670 return;\r
671 }\r
672 for (int j = 0; j < saa.length; ++j) {\r
673 if (ffc.getPcdBuildDataInfo(getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),\r
674 cName, sa)) {\r
675 return;\r
676 }\r
677 }\r
678 }\r
679 catch(Exception e) {\r
680 JOptionPane.showMessageDialog(this, "Get PCD details fail: " + e.getMessage());\r
681 }\r
682 }\r
a13899c5 683\r
684 /**\r
685 * This method initializes jPanel2 \r
686 * \r
687 * @return javax.swing.JPanel \r
688 */\r
689 private JPanel getJPanel2() {\r
690 if (jPanel2 == null) {\r
691 jLabel5 = new JLabel();\r
692 jLabel5.setText("PCD Description");\r
693 jPanel2 = new JPanel();\r
908b1c05 694 jPanel2.setPreferredSize(new java.awt.Dimension(607,200));\r
a13899c5 695 jPanel2.add(jLabel5, null);\r
696 jPanel2.add(getJScrollPane1(), null);\r
908b1c05 697 jPanel2.add(getJPanel9(), null);\r
a13899c5 698 }\r
699 return jPanel2;\r
700 }\r
701\r
702 /**\r
703 * This method initializes jScrollPane1 \r
704 * \r
705 * @return javax.swing.JScrollPane \r
706 */\r
707 private JScrollPane getJScrollPane1() {\r
708 if (jScrollPane1 == null) {\r
709 jScrollPane1 = new JScrollPane();\r
710 jScrollPane1.setPreferredSize(new java.awt.Dimension(500,100));\r
711 jScrollPane1.setViewportView(getJTextArea());\r
712 }\r
713 return jScrollPane1;\r
714 }\r
715\r
716 /**\r
717 * This method initializes jTextArea \r
718 * \r
719 * @return javax.swing.JTextArea \r
720 */\r
721 private JTextArea getJTextArea() {\r
722 if (jTextArea == null) {\r
723 jTextArea = new JTextArea();\r
724 jTextArea.setEditable(false);\r
725 }\r
726 return jTextArea;\r
727 }\r
728\r
729 /**\r
730 * This method initializes jPanel3 \r
731 * \r
732 * @return javax.swing.JPanel \r
733 */\r
734 private JPanel getJPanel3() {\r
735 if (jPanel3 == null) {\r
736 FlowLayout flowLayout = new FlowLayout();\r
737 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);\r
738 jPanel3 = new JPanel();\r
739 jPanel3.setLayout(flowLayout);\r
740 jPanel3.add(getJButton2(), null);\r
741 jPanel3.add(getJButton3(), null);\r
742 }\r
743 return jPanel3;\r
744 }\r
745\r
746 /**\r
747 * This method initializes jSplitPane \r
748 * \r
749 * @return javax.swing.JSplitPane \r
750 */\r
751 private JSplitPane getJSplitPane() {\r
752 if (jSplitPane == null) {\r
753 jSplitPane = new JSplitPane();\r
754 jSplitPane.setDividerLocation(200);\r
755 jSplitPane.setLeftComponent(getJPanel4());\r
756 jSplitPane.setRightComponent(getJPanel5());\r
757 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));\r
758 }\r
759 return jSplitPane;\r
760 }\r
761\r
762 /**\r
763 * This method initializes jPanel4 \r
764 * \r
765 * @return javax.swing.JPanel \r
766 */\r
767 private JPanel getJPanel4() {\r
768 if (jPanel4 == null) {\r
769 jLabel1 = new JLabel();\r
bf5abaff 770 jLabel1.setText("Library Classes Uninstantiated");\r
a13899c5 771 jPanel4 = new JPanel();\r
772 jPanel4.add(jLabel1, null);\r
773 jPanel4.add(getJScrollPane3(), null);\r
774 }\r
775 return jPanel4;\r
776 }\r
777\r
778 /**\r
779 * This method initializes jPanel5 \r
780 * \r
781 * @return javax.swing.JPanel \r
782 */\r
783 private JPanel getJPanel5() {\r
784 if (jPanel5 == null) {\r
785 jLabel2 = new JLabel();\r
786 jLabel2.setText("Instances Available");\r
787 jPanel5 = new JPanel();\r
788 jPanel5.add(jLabel2, null);\r
789 jPanel5.add(getJScrollPane4(), null);\r
790 }\r
791 return jPanel5;\r
792 }\r
793\r
794 /**\r
795 * This method initializes jScrollPane2 \r
796 * \r
797 * @return javax.swing.JScrollPane \r
798 */\r
799 private JScrollPane getJScrollPane2() {\r
800 if (jScrollPane2 == null) {\r
801 jScrollPane2 = new JScrollPane();\r
802 jScrollPane2.setPreferredSize(new java.awt.Dimension(453,150));\r
803 jScrollPane2.setViewportView(getJTable1());\r
804 }\r
805 return jScrollPane2;\r
806 }\r
807\r
808 /**\r
809 * This method initializes jTable1 \r
810 * \r
811 * @return javax.swing.JTable \r
812 */\r
813 private JTable getJTable1() {\r
814 if (jTable1 == null) {\r
815 model1 = new LibraryTableModel();\r
816 model1.addColumn("Name");\r
817 model1.addColumn("ModuleGUID");\r
818 model1.addColumn("ModuleVersion");\r
819 model1.addColumn("PackageGUID");\r
820 model1.addColumn("PackageVersion");\r
821 jTable1 = new JTable(model1);\r
f3b0ed9a 822 jTable1.setRowHeight(20);\r
71baa24b 823 jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
a13899c5 824 jTable1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
a13899c5 825 \r
826 }\r
827 return jTable1;\r
828 }\r
829\r
830 /**\r
831 * This method initializes jScrollPane3 \r
832 * \r
833 * @return javax.swing.JScrollPane \r
834 */\r
835 private JScrollPane getJScrollPane3() {\r
836 if (jScrollPane3 == null) {\r
837 jScrollPane3 = new JScrollPane();\r
838 jScrollPane3.setPreferredSize(new java.awt.Dimension(200,170));\r
839 jScrollPane3.setViewportView(getJTable2());\r
840 }\r
841 return jScrollPane3;\r
842 }\r
843\r
844 /**\r
845 * This method initializes jTable2 \r
846 * \r
847 * @return javax.swing.JTable \r
848 */\r
849 private JTable getJTable2() {\r
850 if (jTable2 == null) {\r
851 model2 = new LibraryTableModel();\r
852 model2.addColumn("LibraryClass");\r
853 jTable2 = new JTable(model2);\r
f3b0ed9a 854 jTable2.setRowHeight(20);\r
855 jTable2.setShowGrid(false);\r
a13899c5 856 jTable2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
857 jTable2.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
858 public void valueChanged(ListSelectionEvent e) {\r
859 if (e.getValueIsAdjusting()){\r
860 return;\r
861 }\r
862 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
863 if (lsm.isSelectionEmpty()) {\r
864 return;\r
865 }\r
866 else{\r
867 int selectedRow2 = lsm.getMinSelectionIndex();\r
868 if (selectedRow2 < 0) {\r
869 return;\r
870 }\r
871 //\r
872 // display potential lib instances according to class selection\r
873 //\r
874 model3.setRowCount(0);\r
875 String cls = model2.getValueAt(selectedRow2, 0).toString();\r
876 ArrayList<String> al = classInstanceMap.get(cls);\r
877 ListIterator<String> li = al.listIterator();\r
878 while(li.hasNext()) {\r
879 String instance = li.next();\r
880 String[] s = {"", "", "", "", ""};\r
881 if (getModuleId(instance) != null) {\r
882 s[0] = getModuleId(instance).getName();\r
883 }\r
884 \r
885 String[] instancePart = instance.split(" ");\r
886 for (int i = 0; i < instancePart.length; ++i){\r
887 s[i+1] = instancePart[i];\r
888 }\r
889 model3.addRow(s);\r
890 }\r
891 \r
892 }\r
893 }\r
894 });\r
895 }\r
896 return jTable2;\r
897 }\r
898\r
899 /**\r
900 * This method initializes jScrollPane4 \r
901 * \r
902 * @return javax.swing.JScrollPane \r
903 */\r
904 private JScrollPane getJScrollPane4() {\r
905 if (jScrollPane4 == null) {\r
906 jScrollPane4 = new JScrollPane();\r
8f55ea73 907 jScrollPane4.setPreferredSize(new java.awt.Dimension(430,170));\r
a13899c5 908 jScrollPane4.setViewportView(getJTable3());\r
909 }\r
910 return jScrollPane4;\r
911 }\r
912\r
913 /**\r
914 * This method initializes jTable3 \r
915 * \r
916 * @return javax.swing.JTable \r
917 */\r
918 private JTable getJTable3() {\r
919 if (jTable3 == null) {\r
920 model3 = new LibraryTableModel();\r
921 model3.addColumn("Name");\r
922 model3.addColumn("ModuleGUID");\r
923 model3.addColumn("ModuleVersion");\r
924 model3.addColumn("PackageGUID");\r
925 model3.addColumn("PackageVersion");\r
926 jTable3 = new JTable(model3);\r
f3b0ed9a 927 jTable3.setRowHeight(20);\r
71baa24b 928 jTable3.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
a13899c5 929 jTable3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
908b1c05 930 \r
a13899c5 931 }\r
932 return jTable3;\r
933 }\r
934\r
935 /**\r
936 * This method initializes jPanel6 \r
937 * \r
938 * @return javax.swing.JPanel \r
939 */\r
940 private JPanel getJPanel6() {\r
941 if (jPanel6 == null) {\r
942 jPanel6 = new JPanel();\r
943 }\r
944 return jPanel6;\r
945 }\r
946\r
947 /**\r
948 * This method initializes jPanel7 \r
949 * \r
950 * @return javax.swing.JPanel \r
951 */\r
952 private JPanel getJPanel7() {\r
953 if (jPanel7 == null) {\r
954 jLabel4 = new JLabel();\r
955 jLabel4.setText("Instance Description");\r
956 jLabel3 = new JLabel();\r
957 jLabel3.setText("Selected Instances");\r
958 jPanel7 = new JPanel();\r
959 jPanel7.add(jLabel4, null);\r
960 jPanel7.add(getJScrollPane5(), null);\r
961 jPanel7.add(getJButton(), null);\r
962 jPanel7.add(getJButton1(), null);\r
963 jPanel7.add(jLabel3, null);\r
964 jPanel7.add(getJScrollPane2(), null);\r
965 }\r
966 return jPanel7;\r
967 }\r
968\r
969 /**\r
970 * This method initializes jScrollPane5 \r
971 * \r
972 * @return javax.swing.JScrollPane \r
973 */\r
974 private JScrollPane getJScrollPane5() {\r
975 if (jScrollPane5 == null) {\r
976 jScrollPane5 = new JScrollPane();\r
977 jScrollPane5.setPreferredSize(new java.awt.Dimension(300,50));\r
978 jScrollPane5.setViewportView(getJTextArea1());\r
979 }\r
980 return jScrollPane5;\r
981 }\r
982\r
983 /**\r
984 * This method initializes jTextArea1 \r
985 * \r
986 * @return javax.swing.JTextArea \r
987 */\r
988 private JTextArea getJTextArea1() {\r
989 if (jTextArea1 == null) {\r
990 jTextArea1 = new JTextArea();\r
991 jTextArea1.setEditable(false);\r
992 }\r
993 return jTextArea1;\r
994 }\r
995\r
996 /**\r
997 * This method initializes jButton \r
998 * \r
999 * @return javax.swing.JButton \r
1000 */\r
1001 private JButton getJButton() {\r
1002 if (jButton == null) {\r
1003 jButton = new JButton();\r
1004 jButton.setPreferredSize(new java.awt.Dimension(80,20));\r
1005 jButton.setText("Add");\r
1006 jButton.addActionListener(new java.awt.event.ActionListener() {\r
1007 public void actionPerformed(java.awt.event.ActionEvent e) {\r
1008 int row = jTable3.getSelectedRow();\r
1009 if (row < 0) {\r
1010 return;\r
1011 }\r
8f55ea73 1012 docConsole.setSaved(false);\r
a13899c5 1013 Object[] s = {model3.getValueAt(row, 0), model3.getValueAt(row, 1),\r
1014 model3.getValueAt(row, 2), model3.getValueAt(row, 3),\r
1015 model3.getValueAt(row, 4)};\r
1016 model1.addRow(s);\r
1017 String instanceValue = model3.getValueAt(row, 1) + " " + \r
1018 model3.getValueAt(row, 2) + " " +\r
1019 model3.getValueAt(row, 3) + " " +\r
1020 model3.getValueAt(row, 4);\r
908b1c05 1021 ffc.genLibraryInstance(model3.getValueAt(row, 1)+"", model3.getValueAt(row, 2)+"", model3.getValueAt(row, 3)+"", model3.getValueAt(row, 4)+"", moduleKey);\r
a13899c5 1022 //\r
1023 // Add pcd information of selected instance to current moduleSA\r
1024 //\r
82961247 1025 try{\r
bf5abaff 1026 ffc.addFrameworkModulesPcdBuildDefs(getModuleId(instanceValue), null, ffc.getModuleSA(moduleKey));\r
82961247 1027 }\r
1028 catch (Exception exception) {\r
1029 JOptionPane.showMessageDialog(frame, "PCD Insertion Fail. " + exception.getMessage());\r
1030 }\r
a13899c5 1031 resolveLibraryInstances(instanceValue);\r
1032 }\r
1033 });\r
1034 }\r
1035 return jButton;\r
1036 }\r
1037\r
1038 /**\r
1039 * This method initializes jButton1 \r
1040 * \r
1041 * @return javax.swing.JButton \r
1042 */\r
1043 private JButton getJButton1() {\r
1044 if (jButton1 == null) {\r
1045 jButton1 = new JButton();\r
1046 jButton1.setPreferredSize(new java.awt.Dimension(80,20));\r
1047 jButton1.setText("Delete");\r
1048 jButton1.addActionListener(new java.awt.event.ActionListener() {\r
1049 public void actionPerformed(java.awt.event.ActionEvent e) {\r
1050 int row = jTable1.getSelectedRow();\r
1051 if (row < 0) {\r
1052 return;\r
1053 }\r
8f55ea73 1054 docConsole.setSaved(false);\r
a13899c5 1055 removeInstance(model1.getValueAt(row, 1) + " " + \r
1056 model1.getValueAt(row, 2) + " " +\r
1057 model1.getValueAt(row, 3) + " " +\r
1058 model1.getValueAt(row, 4));\r
908b1c05 1059 ffc.removeLibraryInstance(moduleKey, row);\r
a13899c5 1060 model1.removeRow(row);\r
1061 \r
1062 }\r
1063 });\r
1064 }\r
1065 return jButton1;\r
1066 }\r
1067\r
1068 /**\r
1069 * This method initializes jButton2 \r
1070 * \r
1071 * @return javax.swing.JButton \r
1072 */\r
1073 private JButton getJButton2() {\r
1074 if (jButton2 == null) {\r
1075 jButton2 = new JButton();\r
1076 jButton2.setPreferredSize(new java.awt.Dimension(80,20));\r
1077 jButton2.setText("Ok");\r
1078 jButton2.addActionListener(this);\r
1079 }\r
1080 return jButton2;\r
1081 }\r
1082\r
1083 /**\r
1084 * This method initializes jButton3 \r
1085 * \r
1086 * @return javax.swing.JButton \r
1087 */\r
1088 private JButton getJButton3() {\r
1089 if (jButton3 == null) {\r
1090 jButton3 = new JButton();\r
1091 jButton3.setPreferredSize(new java.awt.Dimension(80,20));\r
1092 jButton3.setText("Cancel");\r
1093 jButton3.setVisible(false);\r
1094 }\r
1095 return jButton3;\r
1096 }\r
1097 public void actionPerformed(ActionEvent arg0) {\r
1098\r
1099 if (arg0.getSource() == jButton2) {\r
bf5abaff 1100 if (jTable4.isEditing()) {\r
1101 jTable4.getCellEditor().stopCellEditing();\r
1102 }\r
a13899c5 1103 this.setVisible(false);\r
1104 }\r
1105 }\r
6a09eb19 1106 /**\r
1107 * This method initializes jPanel8 \r
1108 * \r
1109 * @return javax.swing.JPanel \r
1110 */\r
1111 private JPanel getJPanel8() {\r
1112 if (jPanel8 == null) {\r
8f55ea73 1113 jLabel12 = new JLabel();\r
1114 jLabel12.setText("");\r
1115 jLabel12.setPreferredSize(new java.awt.Dimension(250,16));\r
1116 FlowLayout flowLayout4 = new FlowLayout();\r
1117 flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);\r
6a09eb19 1118 jLabel8 = new JLabel();\r
1119 jLabel8.setText("FFS Format Key");\r
8f55ea73 1120 jLabel8.setPreferredSize(new java.awt.Dimension(90,16));\r
6a09eb19 1121 jLabel7 = new JLabel();\r
1122 jLabel7.setText("FFS File GUID");\r
8f55ea73 1123 jLabel7.setPreferredSize(new java.awt.Dimension(90,16));\r
6a09eb19 1124 jLabel6 = new JLabel();\r
1125 jLabel6.setText("FV Binding");\r
8f55ea73 1126 jLabel6.setPreferredSize(new java.awt.Dimension(90,16));\r
6a09eb19 1127 jPanel8 = new JPanel();\r
8f55ea73 1128 jPanel8.setLayout(flowLayout4);\r
6a09eb19 1129 jPanel8.add(jLabel6, null);\r
8f55ea73 1130 jPanel8.add(getJTextFieldFvBinding(), null);\r
6a09eb19 1131 jPanel8.add(jLabel7, null);\r
8f55ea73 1132 jPanel8.add(getJTextFieldFileGuid(), null);\r
6a09eb19 1133 jPanel8.add(jLabel8, null);\r
8f55ea73 1134 jPanel8.add(getJTextFieldFfsKey(), null);\r
6a09eb19 1135 jPanel8.add(getJScrollPane6(), null);\r
8f55ea73 1136 jPanel8.add(jLabel12, null);\r
1800d80f 1137 jPanel8.add(getJButton4(), null);\r
1138 jPanel8.add(getJButton5(), null);\r
71baa24b 1139 jPanel8.addComponentListener(new java.awt.event.ComponentAdapter() {\r
1140 public void componentShown(java.awt.event.ComponentEvent e) {\r
908b1c05 1141 initModuleSAOptions(moduleKey);\r
71baa24b 1142 }\r
1143 });\r
6a09eb19 1144 }\r
1145 return jPanel8;\r
1146 }\r
1147 /**\r
1148 * This method initializes jTextField \r
1149 * \r
1150 * @return javax.swing.JTextField \r
1151 */\r
8f55ea73 1152 private JTextField getJTextFieldFvBinding() {\r
1153 if (jTextFieldFvBinding == null) {\r
1154 jTextFieldFvBinding = new JTextField();\r
1155 jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(150,20));\r
1156 jTextFieldFvBinding.addFocusListener(new java.awt.event.FocusAdapter() {\r
1157 public void focusLost(java.awt.event.FocusEvent e) {\r
1158 String originalFvBinding = ffc.getFvBinding(moduleKey);\r
1159 String newFvBinding = jTextFieldFvBinding.getText();\r
1160 if (newFvBinding.equals(originalFvBinding)) {\r
1161 return;\r
1162 }\r
1163 if (newFvBinding.length() == 0 && originalFvBinding == null) {\r
1164 return;\r
1165 }\r
1166 docConsole.setSaved(false);\r
1167 ffc.setFvBinding(moduleKey, newFvBinding);\r
1168 }\r
1169 });\r
bf5abaff 1170 \r
6a09eb19 1171 }\r
8f55ea73 1172 return jTextFieldFvBinding;\r
6a09eb19 1173 }\r
1174 /**\r
1175 * This method initializes jTextField1 \r
1176 * \r
1177 * @return javax.swing.JTextField \r
1178 */\r
8f55ea73 1179 private JTextField getJTextFieldFileGuid() {\r
1180 if (jTextFieldFileGuid == null) {\r
1181 jTextFieldFileGuid = new JTextField();\r
1182 jTextFieldFileGuid.setPreferredSize(new java.awt.Dimension(300,20));\r
1183 jTextFieldFileGuid.addFocusListener(new java.awt.event.FocusAdapter() {\r
1184 public void focusLost(java.awt.event.FocusEvent e) {\r
1185 String originalFileGuid = ffc.getFfsFileNameGuid(moduleKey);\r
1186 String newFileGuid = jTextFieldFileGuid.getText();\r
1187 if (newFileGuid.equals(originalFileGuid)) {\r
1188 return;\r
1189 }\r
1190 if (newFileGuid.length() == 0 && originalFileGuid == null) {\r
1191 return;\r
1192 }\r
1193 if (newFileGuid.length() > 0) {\r
1194 if (!DataValidation.isGuid(newFileGuid)) {\r
1195 JOptionPane.showMessageDialog(frame, "FFS File Guid is NOT GUID Type.");\r
1196 return;\r
1197 }\r
1198 }\r
1199 \r
1200 docConsole.setSaved(false);\r
1201 if (newFileGuid.length() == 0) {\r
1202 newFileGuid = null;\r
1203 }\r
1204 ffc.setFfsFileNameGuid(moduleKey, newFileGuid);\r
1205 }\r
1206 });\r
bf5abaff 1207 \r
6a09eb19 1208 }\r
8f55ea73 1209 return jTextFieldFileGuid;\r
6a09eb19 1210 }\r
1211 /**\r
8f55ea73 1212 * This method initializes jTextFieldFfsKey \r
6a09eb19 1213 * \r
1214 * @return javax.swing.JTextField \r
1215 */\r
8f55ea73 1216 private JTextField getJTextFieldFfsKey() {\r
1217 if (jTextFieldFfsKey == null) {\r
1218 jTextFieldFfsKey = new JTextField();\r
1219 jTextFieldFfsKey.setPreferredSize(new java.awt.Dimension(150,20));\r
1220 jTextFieldFfsKey.addFocusListener(new java.awt.event.FocusAdapter() {\r
1221 public void focusLost(java.awt.event.FocusEvent e) {\r
1222 String originalFfsKey = ffc.getFfsFormatKey(moduleKey);\r
1223 String newFfsKey = jTextFieldFfsKey.getText();\r
1224 if (newFfsKey.equals(originalFfsKey)) {\r
1225 return;\r
1226 }\r
1227 if (newFfsKey.length() == 0 && originalFfsKey == null) {\r
1228 return;\r
1229 }\r
1230 docConsole.setSaved(false);\r
1231 ffc.setFfsFormatKey(moduleKey, newFfsKey);\r
1232 }\r
1233 });\r
bf5abaff 1234 \r
6a09eb19 1235 }\r
8f55ea73 1236 return jTextFieldFfsKey;\r
6a09eb19 1237 }\r
1238 /**\r
1239 * This method initializes jScrollPane6 \r
1240 * \r
1241 * @return javax.swing.JScrollPane \r
1242 */\r
1243 private JScrollPane getJScrollPane6() {\r
1244 if (jScrollPane6 == null) {\r
1245 jScrollPane6 = new JScrollPane();\r
1246 jScrollPane6.setPreferredSize(new java.awt.Dimension(600,200));\r
1247 jScrollPane6.setViewportView(getJTable4());\r
1248 }\r
1249 return jScrollPane6;\r
1250 }\r
1251 /**\r
1252 * This method initializes jTable4 \r
1253 * \r
1254 * @return javax.swing.JTable \r
1255 */\r
1256 private JTable getJTable4() {\r
1257 if (jTable4 == null) {\r
1800d80f 1258 optionsTableModel = new DefaultTableModel();\r
1259 optionsTableModel.addColumn("BuildTargets");\r
1260 optionsTableModel.addColumn("ToolChainFamily");\r
1261 optionsTableModel.addColumn("TagName");\r
1262 optionsTableModel.addColumn("ToolCode");\r
1263 optionsTableModel.addColumn("SupportedArchs");\r
1264 optionsTableModel.addColumn("Contents");\r
1265 jTable4 = new JTable(optionsTableModel);\r
f3b0ed9a 1266 jTable4.setRowHeight(20);\r
1267 Vector<String> vArch = new Vector<String>();\r
1268 vArch.add("IA32");\r
1269 vArch.add("X64");\r
1270 vArch.add("IPF");\r
1271 vArch.add("EBC");\r
1272 vArch.add("ARM");\r
1273 vArch.add("PPC");\r
1274 jTable4.getColumnModel().getColumn(4).setCellEditor(new ListEditor(vArch));\r
1800d80f 1275 jTable4.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
71baa24b 1276 jTable4.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
1800d80f 1277 jTable4.getModel().addTableModelListener(new TableModelListener() {\r
1278 public void tableChanged(TableModelEvent arg0) {\r
1279 // TODO Auto-generated method stub\r
1280 int row = arg0.getFirstRow();\r
1281 TableModel m = (TableModel)arg0.getSource();\r
1282 \r
1283 if (arg0.getType() == TableModelEvent.UPDATE){\r
1284 //ToDo Data Validition check.\r
1285 String targets = m.getValueAt(row, 0) + "";\r
f3b0ed9a 1286 Vector<Object> targetName = null;\r
1287 if (targets.length() > 0) {\r
1288 targetName = new Vector<Object>();\r
1289 String[] sArray = targets.split(" ");\r
1290 for (int i = 0; i < sArray.length; ++i) {\r
1291 targetName.add(sArray[i]);\r
1292 }\r
1800d80f 1293 }\r
f3b0ed9a 1294 \r
1800d80f 1295 String toolChain = m.getValueAt(row, 1) + "";\r
1296 String tagName = m.getValueAt(row, 2) + "";\r
1297 String toolCode = m.getValueAt(row, 3) + "";\r
1298 String archs = m.getValueAt(row, 4) + "";\r
f3b0ed9a 1299 Vector<Object> supArch = null;\r
1300 if (archs.length() > 0) {\r
1301 supArch = new Vector<Object>();\r
1302 String[] sArray1 = archs.split(" ");\r
1303 for (int i = 0; i < sArray1.length; ++i) {\r
1304 supArch.add(sArray1[i]);\r
1305 }\r
1800d80f 1306 }\r
f3b0ed9a 1307 \r
1800d80f 1308 String contents = m.getValueAt(row, 5) + "";\r
8f55ea73 1309 docConsole.setSaved(false);\r
1800d80f 1310 ffc.updateModuleSAOptionsOpt(moduleKey, row, targetName, toolChain, tagName, toolCode, supArch, contents);\r
1311 }\r
1312 }\r
1313 });\r
6a09eb19 1314 }\r
1315 return jTable4;\r
1316 }\r
1800d80f 1317 /**\r
1318 * This method initializes jButton4 \r
1319 * \r
1320 * @return javax.swing.JButton \r
1321 */\r
1322 private JButton getJButton4() {\r
1323 if (jButton4 == null) {\r
1324 jButton4 = new JButton();\r
1325 jButton4.setPreferredSize(new java.awt.Dimension(80,20));\r
1326 jButton4.setText("New");\r
1327 jButton4.addActionListener(new java.awt.event.ActionListener() {\r
1328 public void actionPerformed(java.awt.event.ActionEvent e) {\r
bf5abaff 1329 String[] row = {"", "", "", "", "", ""};\r
1800d80f 1330 optionsTableModel.addRow(row);\r
1331 Vector<Object> v = new Vector<Object>();\r
bf5abaff 1332 Vector<Object> v1 = null;\r
8f55ea73 1333 docConsole.setSaved(false);\r
1800d80f 1334 ffc.genModuleSAOptionsOpt(moduleKey, v, "", "", "", v1, "");\r
1335 }\r
1336 });\r
1337 }\r
1338 return jButton4;\r
1339 }\r
1340 /**\r
1341 * This method initializes jButton5 \r
1342 * \r
1343 * @return javax.swing.JButton \r
1344 */\r
1345 private JButton getJButton5() {\r
1346 if (jButton5 == null) {\r
1347 jButton5 = new JButton();\r
1348 jButton5.setPreferredSize(new java.awt.Dimension(80,20));\r
1349 jButton5.setText("Delete");\r
1350 jButton5.addActionListener(new java.awt.event.ActionListener() {\r
1351 public void actionPerformed(java.awt.event.ActionEvent e) {\r
1352 if (jTable4.getSelectedRow() < 0) {\r
1353 return;\r
1354 }\r
8f55ea73 1355 docConsole.setSaved(false);\r
1800d80f 1356 ffc.removeModuleSAOptionsOpt(moduleKey, jTable4.getSelectedRow());\r
1357 optionsTableModel.removeRow(jTable4.getSelectedRow());\r
1358 }\r
1359 });\r
1360 }\r
1361 return jButton5;\r
1362 }\r
f3b0ed9a 1363 \r
1364 /**\r
1365 Start the window at the center of screen\r
1366 \r
1367 **/\r
1368 protected void centerWindow(int intWidth, int intHeight) {\r
1369 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r
1370 this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r
1371 }\r
1372\r
1373 /**\r
1374 Start the window at the center of screen\r
1375 \r
1376 **/\r
1377 protected void centerWindow() {\r
1378 centerWindow(this.getSize().width, this.getSize().height);\r
1379 }\r
908b1c05 1380/**\r
1381 * This method initializes jPanel9 \r
1382 * \r
1383 * @return javax.swing.JPanel \r
1384 */\r
1385private JPanel getJPanel9() {\r
1386 if (jPanel9 == null) {\r
1387 GridLayout gridLayout = new GridLayout();\r
1388 gridLayout.setRows(3);\r
1389 gridLayout.setColumns(2);\r
1390 jPanel9 = new JPanel();\r
1391 jPanel9.setLayout(gridLayout);\r
1392 jPanel9.setPreferredSize(new java.awt.Dimension(600,90));\r
1393 jPanel9.add(getJPanel12(), null);\r
1394 jPanel9.add(getJPanel10(), null);\r
1395 jPanel9.add(getJPanel11(), null);\r
1396 }\r
1397 return jPanel9;\r
1398}\r
1399/**\r
1400 * This method initializes jPanel10 \r
1401 * \r
1402 * @return javax.swing.JPanel \r
1403 */\r
1404private JPanel getJPanel10() {\r
1405 if (jPanel10 == null) {\r
1406 FlowLayout flowLayout2 = new FlowLayout();\r
1407 flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);\r
1408 jLabel10 = new JLabel();\r
1409 jLabel10.setText("Max Datum Size");\r
1410 jPanel10 = new JPanel();\r
1411 jPanel10.setLayout(flowLayout2);\r
1412 jPanel10.add(jLabel10, null);\r
1413 jPanel10.add(getJTextField3(), null);\r
1414 }\r
1415 return jPanel10;\r
1416}\r
1417/**\r
1418 * This method initializes jPanel11 \r
1419 * \r
1420 * @return javax.swing.JPanel \r
1421 */\r
1422private JPanel getJPanel11() {\r
1423 if (jPanel11 == null) {\r
1424 FlowLayout flowLayout3 = new FlowLayout();\r
1425 flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);\r
1426 jLabel11 = new JLabel();\r
1427 jLabel11.setText("Default Value");\r
1428 jLabel11.setPreferredSize(new java.awt.Dimension(91,16));\r
1429 jPanel11 = new JPanel();\r
1430 jPanel11.setLayout(flowLayout3);\r
1431 jPanel11.add(jLabel11, null);\r
1432 jPanel11.add(getJTextField4(), null);\r
1433 jPanel11.add(getJComboBox1(), null);\r
1434 }\r
1435 return jPanel11;\r
1436}\r
1437/**\r
1438 * This method initializes jPanel12 \r
1439 * \r
1440 * @return javax.swing.JPanel \r
1441 */\r
1442private JPanel getJPanel12() {\r
1443 if (jPanel12 == null) {\r
1444 FlowLayout flowLayout1 = new FlowLayout();\r
1445 flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);\r
1446 jLabel9 = new JLabel();\r
1447 jLabel9.setText("Item Type");\r
1448 jLabel9.setPreferredSize(new java.awt.Dimension(91,16));\r
1449 jPanel12 = new JPanel();\r
1450 jPanel12.setLayout(flowLayout1);\r
1451 jPanel12.add(jLabel9, null);\r
1452 jPanel12.add(getJComboBox(), null);\r
1453 jPanel12.add(getJButton6(), null);\r
1454 }\r
1455 return jPanel12;\r
1456}\r
1457/**\r
1458 * This method initializes jComboBox \r
1459 * \r
1460 * @return javax.swing.JComboBox \r
1461 */\r
1462private JComboBox getJComboBox() {\r
1463 if (jComboBox == null) {\r
1464 jComboBox = new JComboBox();\r
1465 jComboBox.setPreferredSize(new java.awt.Dimension(200,20));\r
1466 jComboBox.addItemListener(new java.awt.event.ItemListener() {\r
1467 public void itemStateChanged(java.awt.event.ItemEvent e) {\r
1468 int row = jTable.getSelectedRow();\r
1469 if (row < 0 || jTable.getValueAt(row, 2).equals(jComboBox.getSelectedItem())) {\r
1470 return;\r
1471 }\r
1472 if (jComboBox.getItemCount() == 3) {\r
1473 if (!jComboBox.getSelectedItem().equals("DYNAMIC")) {\r
1474 pcdDynamicToNonDynamic(jTable.getValueAt(row, 0)+"", jTable.getValueAt(row, 1)+"");\r
1475 }\r
1476 else{\r
1477 pcdNonDynamicToDynamic(jTable.getValueAt(row, 0)+"", jTable.getValueAt(row, 1)+"");\r
1478 }\r
1479 }\r
1480 }\r
1481 });\r
1482 }\r
1483 return jComboBox;\r
1484}\r
1485\r
1486private void pcdDynamicToNonDynamic(String cName, String tsGuid) {\r
1487 String[][] saa = new String[ffc.getDynamicPcdBuildDataCount()][5];\r
1488 ffc.getDynamicPcdBuildData(saa);\r
1489 String maxSize = "";\r
1490 String value = "";\r
1491 for (int i = 0; i < saa.length; ++i) {\r
1492 if (saa[i][0].equals(cName) && saa[i][2].equals(tsGuid)) {\r
1493 maxSize = saa[i][3];\r
1494 value = ffc.getDynamicPcdBuildDataValue(i);\r
1495 break;\r
1496 }\r
1497 }\r
1498 \r
1499 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
1500 for (int i = 0; i < al.size(); ++i) {\r
1501 String[] s = al.get(i).split(" ");\r
1502 String mKey = s[0] + s[1] + s[2] + s[3];\r
1503 ffc.updatePcdData(mKey, cName, tsGuid, jComboBox.getSelectedItem()+"", maxSize, value);\r
1504 s[4] = jComboBox.getSelectedItem()+"";\r
1505 al.set(i, s[0]+" "+s[1]+" "+s[2]+" "+s[3]+" "+s[4]);\r
1506 }\r
1507 \r
1508 ffc.removeDynamicPcdBuildData(cName, tsGuid);\r
1509}\r
1510\r
1511private void pcdNonDynamicToDynamic(String cName, String tsGuid) {\r
1512 ArrayList<String> al = ffc.getDynPcdMapValue(cName + " " + tsGuid);\r
1513 for (int i = 0; i < al.size(); ++i) {\r
1514 String[] s = al.get(i).split(" ");\r
bf5abaff 1515 String mKey = s[0] + " " + s[1]+ " " + s[2] + " " + s[3];\r
908b1c05 1516 ffc.updatePcdData(mKey, cName, tsGuid, jComboBox.getSelectedItem()+"", jTextField3.getText(), jTextField4.isVisible() ? jTextField4.getText() : jComboBox1.getSelectedItem()+"");\r
1517 s[4] = jComboBox.getSelectedItem()+"";\r
1518 al.set(i, s[0]+" "+s[1]+" "+s[2]+" "+s[3]+" "+s[4]);\r
1519 }\r
1520 try{\r
1521 ffc.addDynamicPcdBuildData(cName, jTable.getValueAt(jTable.getSelectedRow(), 3), tsGuid, "DYNAMIC", jTable.getValueAt(jTable.getSelectedRow(), 5)+"", jTextField4.isVisible() ? jTextField4.getText() : jComboBox1.getSelectedItem()+"");\r
1522 }\r
1523 catch(Exception e){\r
1524 JOptionPane.showMessageDialog(frame, "PCD value format: " + e.getMessage());\r
1525 }\r
1526}\r
1527/**\r
1528 * This method initializes jTextField3 \r
1529 * \r
1530 * @return javax.swing.JTextField \r
1531 */\r
1532private JTextField getJTextField3() {\r
1533 if (jTextField3 == null) {\r
1534 jTextField3 = new JTextField();\r
1535 jTextField3.setPreferredSize(new java.awt.Dimension(200,20));\r
1536 }\r
1537 return jTextField3;\r
1538}\r
1539/**\r
1540 * This method initializes jTextField4 \r
1541 * \r
1542 * @return javax.swing.JTextField \r
1543 */\r
1544private JTextField getJTextField4() {\r
1545 if (jTextField4 == null) {\r
1546 jTextField4 = new JTextField();\r
1547 jTextField4.setPreferredSize(new java.awt.Dimension(200,20));\r
1548 }\r
1549 return jTextField4;\r
1550}\r
1551/**\r
1552 * This method initializes jButton6 \r
1553 * \r
1554 * @return javax.swing.JButton \r
1555 */\r
1556private JButton getJButton6() {\r
1557 if (jButton6 == null) {\r
1558 jButton6 = new JButton();\r
1559 jButton6.setPreferredSize(new java.awt.Dimension(150,20));\r
1560 jButton6.setText("Update PCD Data");\r
1561 jButton6.addActionListener(new java.awt.event.ActionListener() {\r
1562 public void actionPerformed(java.awt.event.ActionEvent e) {\r
1563 int row = jTable.getSelectedRow();\r
1564 if (row < 0) {\r
1565 return;\r
1566 }\r
8f55ea73 1567 docConsole.setSaved(false);\r
908b1c05 1568 model.setValueAt(jComboBox.getSelectedItem(), row, 2);\r
1569 model.setValueAt(jTextField3.getText(), row, 4);\r
1570 model.setValueAt(jTextField4.isVisible()? jTextField4.getText():jComboBox1.getSelectedItem(), row, 6);\r
1571 ffc.updatePcdData(moduleKey, model.getValueAt(row, 0)+"", model.getValueAt(row, 1)+"", model.getValueAt(row, 2)+"", model.getValueAt(row, 4)+"", model.getValueAt(row, 6)+"");\r
1572 }\r
1573 });\r
1574 }\r
1575 return jButton6;\r
1576}\r
1577/**\r
1578 * This method initializes jComboBox1 \r
1579 * \r
1580 * @return javax.swing.JComboBox \r
1581 */\r
1582private JComboBox getJComboBox1() {\r
1583 if (jComboBox1 == null) {\r
1584 jComboBox1 = new JComboBox();\r
1585 jComboBox1.setPreferredSize(new java.awt.Dimension(100,20));\r
1586 jComboBox1.setVisible(false);\r
1587 jComboBox1.addItem("true");\r
1588 jComboBox1.addItem("false");\r
1589 }\r
1590 return jComboBox1;\r
1591}\r
f3b0ed9a 1592\r
a13899c5 1593\r
1594} // @jve:decl-index=0:visual-constraint="10,10"\r
1595\r
1596class PartialEditableTableModel extends DefaultTableModel {\r
44053733 1597 /**\r
1598 * \r
1599 */\r
1600 private static final long serialVersionUID = 1L;\r
1601\r
a13899c5 1602 public boolean isCellEditable(int row, int col) {\r
1603 switch (col){\r
1604 case 2:\r
82961247 1605 return false;\r
a13899c5 1606 default:\r
1607 return false; \r
1608 }\r
1609 \r
1610 }\r
1611}\r
1612\r
1613class LibraryTableModel extends DefaultTableModel {\r
44053733 1614 /**\r
1615 * \r
1616 */\r
1617 private static final long serialVersionUID = 1L;\r
1618\r
a13899c5 1619 public boolean isCellEditable(int row, int col) {\r
1620 return false;\r
1621 }\r
1622}\r