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