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