add multi-source pcd check before adding/deleting lib instance for ModuleSA in platform.
[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 jPanelToolchainC = null;
127 private JPanel jPanelLibraryCenterN = null;
128 private JPanel jPanelLibraryCenterC = null; // @jve:decl-index=0:visual-constraint="20,224"
129 /**
130 * This is the default constructor
131 */
132 public FpdModuleSA() {
133 super();
134 initialize();
135 }
136 public FpdModuleSA(FpdFileContents ffc) {
137 this();
138 this.ffc = ffc;
139 }
140
141 public void setKey(String k, int i, OpeningPlatformType dc){
142 this.moduleKey = k;
143 moduleSaNum = i;
144 this.docConsole = dc;
145 classProduced = null;
146 classConsumed = null;
147 jTabbedPane.setSelectedIndex(0);
148 initPcdBuildDefinition(i);
149 }
150
151 /**
152 init will be called each time FpdModuleSA object is to be shown.
153 @param key Module information.
154 **/
155 public void initPcdBuildDefinition(int i) {
156 //
157 // display pcd for key.
158 //
159 model.setRowCount(0);
160 jTextAreaPcdHelp.setText("");
161 jComboBoxItemType.setSelectedIndex(-1);
162 jTextFieldMaxDatumSize.setText("");
163 jTextFieldPcdDefault.setText("");
164 int pcdCount = ffc.getPcdDataCount(i);
165 if (pcdCount != 0) {
166 String[][] saa = new String[pcdCount][7];
167 ffc.getPcdData(i, saa);
168 for (int j = 0; j < saa.length; ++j) {
169 model.addRow(saa[j]);
170 }
171 }
172 }
173
174 public void initLibraries(String key) {
175 //
176 // display library classes that need to be resolved. also potential instances for them.
177 //
178 resolveLibraryInstances(moduleKey);
179 //
180 // display lib instances already selected for key
181 //
182 selectedInstancesTableModel.setRowCount(0);
183 int instanceCount = ffc.getLibraryInstancesCount(key);
184 if (instanceCount != 0) {
185 String[][] saa = new String[instanceCount][5];
186 ffc.getLibraryInstances(key, saa);
187 for (int i = 0; i < saa.length; ++i) {
188 ModuleIdentification mi = WorkspaceProfile.getModuleId(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
189 if (mi != null) {
190 saa[i][0] = mi.getName();
191 saa[i][2] = mi.getVersion();
192 saa[i][4] = mi.getPackageId().getVersion();
193 //
194 // re-evaluate lib instance usage when adding a already-selected lib instance.
195 //
196 resolveLibraryInstances(saa[i][1] + " " + saa[i][2] + " " + saa[i][3] + " " + saa[i][4]);
197 selectedInstancesTableModel.addRow(saa[i]);
198 }
199 }
200 }
201 showClassToResolved();
202 }
203
204 public void initFvInfo (String key) {
205 //
206 // display module SA options
207 //
208 jTextFieldFvBinding.setText("");
209 String fvBinding = ffc.getFvBinding(key);
210 if (fvBinding != null) {
211 jTextFieldFvBinding.setText(fvBinding);
212 }
213 jTextFieldFileGuid.setText("");
214 String fileGuid = ffc.getFfsFileNameGuid(key);
215 if (fileGuid != null) {
216 jTextFieldFileGuid.setText(fileGuid);
217 }
218 jTextFieldFfsKey.setText("");
219 String ffsKey = ffc.getFfsFormatKey(key);
220 if (ffsKey != null) {
221 jTextFieldFfsKey.setText(ffsKey);
222 }
223 }
224
225 public void initToolChainOptions(String key) {
226
227 optionsTableModel.setRowCount(0);
228 String[][] saa = new String[ffc.getModuleSAOptionsCount(key)][6];
229 ffc.getModuleSAOptions(key, saa);
230 for (int i = 0; i < saa.length; ++i) {
231 optionsTableModel.addRow(saa[i]);
232 }
233 }
234
235 private void resolveLibraryInstances(String key) {
236 ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
237 PackageIdentification[] depPkgList = null;
238 try{
239 //
240 // Get dependency pkg list into which we will search lib instances.
241 //
242 depPkgList = SurfaceAreaQuery.getDependencePkg(null, mi);
243 //
244 // Get the lib class consumed, produced by this module itself.
245 //
246 Vector<String> vClassConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
247
248 if (this.classConsumed == null) {
249 this.classConsumed = new HashMap<String, ArrayList<String>>();
250 }
251
252 for(int i = 0; i < vClassConsumed.size(); ++i){
253 ArrayList<String> consumedBy = this.classConsumed.get(vClassConsumed.get(i));
254 if (consumedBy == null) {
255 consumedBy = new ArrayList<String>();
256 }
257 consumedBy.add(key);
258 this.classConsumed.put(vClassConsumed.get(i), consumedBy);
259 }
260
261 Vector<String> vClassProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
262 if (this.classProduced == null) {
263 this.classProduced = new ArrayList<String>();
264 }
265 for(int i = 0; i < vClassProduced.size(); ++i){
266 if (!this.classProduced.contains(vClassProduced.get(i))){
267 this.classProduced.add(vClassProduced.get(i));
268 }
269 }
270
271 //
272 // find potential instances in all dependency pkgs for classes still in classConsumed.
273 //
274 if (classInstanceMap == null){
275 classInstanceMap = new HashMap<String, ArrayList<String>>();
276 }
277 Iterator<String> lic = this.classConsumed.keySet().iterator();
278 while(lic.hasNext()){
279 String cls = lic.next();
280 if (this.classProduced.contains(cls) || classInstanceMap.containsKey(cls)) {
281 continue;
282 }
283 ArrayList<String> instances = getInstancesForClass(cls, depPkgList);
284 if (instances.size() == 0){
285 JOptionPane.showMessageDialog(frame, "No Applicable Instance for Library Class " +
286 cls + ", Platform Build will Fail.");
287 }
288 classInstanceMap.put(cls, instances);
289
290 }
291
292 // showClassToResolved();
293 }
294 catch(Exception e) {
295 e.printStackTrace();
296 }
297 }
298
299 private ArrayList<String> getInstancesForClass(String cls, PackageIdentification[] depPkgList) throws Exception{
300 ArrayList<String> al = new ArrayList<String>();
301
302 // for (int i = 0; i < depPkgList.length; ++i) {
303 Iterator ismi = GlobalData.vModuleList.iterator();
304 while(ismi.hasNext()) {
305 ModuleIdentification mi = (ModuleIdentification)ismi.next();
306 // if (!mi.getPackageId().getGuid().equalsIgnoreCase(depPkgList[i].getGuid())) {
307 // continue;
308 // }
309 String[] clsProduced = getClassProduced(mi);
310
311 boolean isPotential = false;
312 for (int j = 0; j < clsProduced.length; ++j) {
313 if (clsProduced[j] == null) {
314 continue;
315 }
316 if (clsProduced[j].equals(cls)){
317 isPotential = true;
318 }
319 if (classProduced.contains(clsProduced[j])) {
320 isPotential = false;
321 break;
322 }
323 }
324 if (isPotential) {
325 al.add(mi.getGuid() + " " + mi.getVersion() + " " +
326 mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion());
327 }
328 }
329 // }
330
331 return al;
332 }
333
334 private void removeInstance(String key) {
335 ModuleIdentification mi = WorkspaceProfile.getModuleId(key);
336 //
337 // remove pcd information of instance from current ModuleSA
338 //
339 ffc.removePcdData(moduleKey, mi);
340 //
341 // remove class produced by this instance and add back these produced class to be bound.
342 //
343 String[] clsProduced = getClassProduced(mi);
344 for (int i = 0; i < clsProduced.length; ++i) {
345
346 classProduced.remove(clsProduced[i]);
347 }
348 //
349 // remove class consumed by this instance. we do not need to bound it now.
350 //
351 String[] clsConsumed = getClassConsumed(mi);
352 for (int i = 0; i < clsConsumed.length; ++i) {
353 ArrayList<String> al = classConsumed.get(clsConsumed[i]);
354
355 if (al == null ) {
356 classConsumed.remove(clsConsumed[i]);
357 continue;
358 }
359 al.remove(key);
360 if (al.size() == 0) {
361 classConsumed.remove(clsConsumed[i]);
362 }
363
364 }
365
366 showClassToResolved();
367
368 }
369
370
371 private String[] getClassProduced(ModuleIdentification mi){
372
373 try{
374 Vector<String> clsProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);
375 String[] sClassProduced = new String[clsProduced.size()];
376 for (int i = 0; i < clsProduced.size(); ++i) {
377 sClassProduced[i] = clsProduced.get(i);
378 }
379 return sClassProduced;
380
381 }catch (Exception e) {
382 e.printStackTrace();
383 }
384 return new String[0];
385
386 }
387
388 private String[] getClassConsumed(ModuleIdentification mi){
389
390 try{
391 Vector<String> clsConsumed = SurfaceAreaQuery.getLibraryClasses("ALWAYS_CONSUMED", mi);
392 String[] sClassConsumed = new String[clsConsumed.size()];
393 for (int i = 0; i < clsConsumed.size(); ++i) {
394 sClassConsumed[i] = clsConsumed.get(i);
395 }
396 return sClassConsumed;
397 }catch (Exception e) {
398 e.printStackTrace();
399 }
400 return new String[0];
401 }
402
403 private void showClassToResolved(){
404 libClassTableModel.setRowCount(0);
405 if (classConsumed.size() == 0) {
406 return;
407 }
408 Iterator<String> li = classConsumed.keySet().iterator();
409 while(li.hasNext()){
410
411 String[] s = {li.next()};
412 // if (classConsumed.get(s[0]) == null) {
413 // continue;
414 // }
415 // if (classConsumed.get(s[0]).size() == 0) {
416 // continue;
417 // }
418 if (!classProduced.contains(s[0])){
419 libClassTableModel.addRow(s);
420 }
421 }
422 libInstanceTableModel.setRowCount(0);
423 }
424
425 private void addLibInstance (ModuleIdentification libMi) throws Exception{
426
427 //
428 // Add pcd information of selected instance to current moduleSA
429 //
430 ffc.addFrameworkModulesPcdBuildDefs(libMi, null, ffc.getModuleSA(moduleKey));
431
432 ffc.genLibraryInstance(libMi, moduleKey);
433 }
434 /**
435 * This method initializes this
436 *
437 * @return void
438 */
439 private void initialize() {
440 this.setSize(877, 555);
441 this.setResizable(false);
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(" PCD Data");
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 IDefaultTableModel();
546 jTablePcd = new JTable(model);
547 jTablePcd.setRowHeight(20);
548 jTablePcd.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
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 = model.getValueAt(selectedRow, 0)+"";
571 String tsGuid = model.getValueAt(selectedRow, 1)+"";
572 String itemType = model.getValueAt(selectedRow, 2)+"";
573 //
574 // array for pcd related information: helpText, itemType, moduleType.
575 //
576 String[] pcdInfo = {"", "", ""};
577 getPcdInfo(cName, tsGuid, pcdInfo);
578 jTextAreaPcdHelp.setText(pcdInfo[0]);
579 initComboBox(pcdInfo[1], pcdInfo[2]);
580 jComboBoxItemType.setSelectedItem(itemType);
581 jTextFieldMaxDatumSize.setEnabled(true);
582 jTextFieldMaxDatumSize.setVisible(true);
583 jTextFieldMaxDatumSize.setText(jTablePcd.getValueAt(selectedRow, 4)+"");
584 jTextFieldPcdDefault.setEnabled(true);
585 jTextFieldPcdDefault.setText(jTablePcd.getValueAt(selectedRow, 6)+"");
586 if (model.getValueAt(selectedRow, 5).equals("VOID*")) {
587 if (pcdInfo[1].equals("FEATURE_FLAG")) {
588 jTextFieldMaxDatumSize.setVisible(false);
589 }
590 else if (pcdInfo[1].equals("FIXED_AT_BUILD")) {
591 try{
592 jTextFieldMaxDatumSize.setEnabled(false);
593 jTextFieldMaxDatumSize.setText(ffc.setMaxSizeForPointer(jTablePcd.getValueAt(selectedRow, 6)+"")+"");
594 }
595 catch(Exception except){
596 JOptionPane.showMessageDialog(frame, "Unacceptable PCD Value: " + except.getMessage());
597 }
598 }
599 else{
600 jTextFieldMaxDatumSize.setText(jTablePcd.getValueAt(selectedRow, 4)+"");
601 }
602 }
603 else {
604 jTextFieldMaxDatumSize.setEnabled(false);
605 }
606
607 if (!model.getValueAt(selectedRow, 2).equals("DYNAMIC") && !model.getValueAt(selectedRow, 2).equals("DYNAMIC_EX")) {
608 jTextFieldPcdDefault.setText(model.getValueAt(selectedRow, 6)+"");
609 if (model.getValueAt(selectedRow, 2).equals("FEATURE_FLAG")){
610 jTextFieldPcdDefault.setVisible(false);
611 jComboBoxFeatureFlagValue.setVisible(true);
612 jComboBoxFeatureFlagValue.setSelectedItem(model.getValueAt(selectedRow, 6)+"");
613 }
614 else{
615 jTextFieldPcdDefault.setVisible(true);
616 jTextFieldPcdDefault.setEnabled(true);
617 jComboBoxFeatureFlagValue.setVisible(false);
618 }
619 }
620 else{
621 jTextFieldPcdDefault.setEnabled(false);
622 }
623 }
624
625
626 }
627 });
628
629 }
630 return jTablePcd;
631 }
632
633 private void initComboBox(String originalType, String mType) {
634 jComboBoxItemType.removeAllItems();
635 jComboBoxItemType.addItem(originalType);
636 if (originalType.equals("PATCHABLE_IN_MODULE") && mType.equalsIgnoreCase("false")) {
637 jComboBoxItemType.addItem("FIXED_AT_BUILD");
638 }
639 if (originalType.equals("DYNAMIC")) {
640 jComboBoxItemType.addItem("FIXED_AT_BUILD");
641 jComboBoxItemType.addItem("PATCHABLE_IN_MODULE");
642 }
643 }
644
645 private void getPcdInfo(String cName, String tsGuid, String[] sa) {
646 String[][] saa = new String[ffc.getLibraryInstancesCount(moduleKey)][5];
647 ffc.getLibraryInstances(moduleKey, saa);
648
649 try{
650 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(moduleKey), cName, tsGuid, sa)) {
651 return;
652 }
653 for (int j = 0; j < saa.length; ++j) {
654 if (ffc.getPcdBuildDataInfo(WorkspaceProfile.getModuleId(saa[j][1] + " " + saa[j][2] + " " + saa[j][3] + " " + saa[j][4]),
655 cName, tsGuid, sa)) {
656 return;
657 }
658 }
659 }
660 catch(Exception e) {
661 JOptionPane.showMessageDialog(this, "Get PCD details fail: " + e.getMessage());
662 }
663 }
664
665 /**
666 * This method initializes jPanelPcdSouth
667 *
668 * @return javax.swing.JPanel
669 */
670 private JPanel getJPanelPcdSouth() {
671 if (jPanelPcdSouth == null) {
672 jLabelPcdHelp = new JLabel();
673 jLabelPcdHelp.setText("PCD Description");
674 jPanelPcdSouth = new JPanel();
675 jPanelPcdSouth.setPreferredSize(new java.awt.Dimension(607,200));
676 jPanelPcdSouth.add(jLabelPcdHelp, null);
677 jPanelPcdSouth.add(getJScrollPanePcdHelp(), null);
678 jPanelPcdSouth.add(getJPanelPcdFields(), null);
679 }
680 return jPanelPcdSouth;
681 }
682
683 /**
684 * This method initializes jScrollPanePcdHelp
685 *
686 * @return javax.swing.JScrollPane
687 */
688 private JScrollPane getJScrollPanePcdHelp() {
689 if (jScrollPanePcdHelp == null) {
690 jScrollPanePcdHelp = new JScrollPane();
691 jScrollPanePcdHelp.setPreferredSize(new java.awt.Dimension(500,100));
692 jScrollPanePcdHelp.setViewportView(getJTextAreaPcdHelp());
693 }
694 return jScrollPanePcdHelp;
695 }
696
697 /**
698 * This method initializes jTextAreaPcdHelp
699 *
700 * @return javax.swing.JTextArea
701 */
702 private JTextArea getJTextAreaPcdHelp() {
703 if (jTextAreaPcdHelp == null) {
704 jTextAreaPcdHelp = new JTextArea();
705 jTextAreaPcdHelp.setEditable(false);
706 }
707 return jTextAreaPcdHelp;
708 }
709
710 /**
711 * This method initializes jPanelContentPaneSouth
712 *
713 * @return javax.swing.JPanel
714 */
715 private JPanel getJPanelContentPaneSouth() {
716 if (jPanelContentPaneSouth == null) {
717 FlowLayout flowLayout = new FlowLayout();
718 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
719 jPanelContentPaneSouth = new JPanel();
720 jPanelContentPaneSouth.setLayout(flowLayout);
721 jPanelContentPaneSouth.add(getJButtonOk(), null);
722 jPanelContentPaneSouth.add(getJButtonCancel(), null);
723 }
724 return jPanelContentPaneSouth;
725 }
726
727 /**
728 * This method initializes jSplitPane
729 *
730 * @return javax.swing.JSplitPane
731 */
732 private JSplitPane getJSplitPane() {
733 if (jSplitPane == null) {
734 jSplitPane = new JSplitPane();
735 jSplitPane.setDividerLocation(200);
736 jSplitPane.setLeftComponent(getJPanelLibraryLeft());
737 jSplitPane.setRightComponent(getJPanelLibraryRight());
738 jSplitPane.setPreferredSize(new java.awt.Dimension(202,200));
739 }
740 return jSplitPane;
741 }
742
743 /**
744 * This method initializes jPanelLibraryLeft
745 *
746 * @return javax.swing.JPanel
747 */
748 private JPanel getJPanelLibraryLeft() {
749 if (jPanelLibraryLeft == null) {
750 jLabelLibClass = new JLabel();
751 jLabelLibClass.setText("Library Classes Uninstantiated");
752 jPanelLibraryLeft = new JPanel();
753 jPanelLibraryLeft.add(jLabelLibClass, null);
754 jPanelLibraryLeft.add(getJScrollPaneLibClass(), null);
755 }
756 return jPanelLibraryLeft;
757 }
758
759 /**
760 * This method initializes jPanelLibraryRight
761 *
762 * @return javax.swing.JPanel
763 */
764 private JPanel getJPanelLibraryRight() {
765 if (jPanelLibraryRight == null) {
766 jLabelQualifiedInstance = new JLabel();
767 jLabelQualifiedInstance.setText("Instances Available");
768 jPanelLibraryRight = new JPanel();
769 jPanelLibraryRight.add(jLabelQualifiedInstance, null);
770 jPanelLibraryRight.add(getJScrollPaneQualifiedInstance(), null);
771 }
772 return jPanelLibraryRight;
773 }
774
775 /**
776 * This method initializes jScrollPaneSelectedInstances
777 *
778 * @return javax.swing.JScrollPane
779 */
780 private JScrollPane getJScrollPaneSelectedInstances() {
781 if (jScrollPaneSelectedInstances == null) {
782 jScrollPaneSelectedInstances = new JScrollPane();
783 jScrollPaneSelectedInstances.setPreferredSize(new java.awt.Dimension(600,150));
784 jScrollPaneSelectedInstances.setViewportView(getJTableSelectedInstances());
785 }
786 return jScrollPaneSelectedInstances;
787 }
788
789 /**
790 * This method initializes jTableSelectedInstances
791 *
792 * @return javax.swing.JTable
793 */
794 private JTable getJTableSelectedInstances() {
795 if (jTableSelectedInstances == null) {
796 selectedInstancesTableModel = new IDefaultTableModel();
797 selectedInstancesTableModel.addColumn("Name");
798 selectedInstancesTableModel.addColumn("ModuleGUID");
799 selectedInstancesTableModel.addColumn("ModuleVersion");
800 selectedInstancesTableModel.addColumn("PackageGUID");
801 selectedInstancesTableModel.addColumn("PackageVersion");
802 jTableSelectedInstances = new JTable(selectedInstancesTableModel);
803 jTableSelectedInstances.setRowHeight(20);
804 jTableSelectedInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
805 jTableSelectedInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
806
807 }
808 return jTableSelectedInstances;
809 }
810
811 /**
812 * This method initializes jScrollPaneLibClass
813 *
814 * @return javax.swing.JScrollPane
815 */
816 private JScrollPane getJScrollPaneLibClass() {
817 if (jScrollPaneLibClass == null) {
818 jScrollPaneLibClass = new JScrollPane();
819 jScrollPaneLibClass.setPreferredSize(new java.awt.Dimension(200,170));
820 jScrollPaneLibClass.setViewportView(getJTableLibClass());
821 }
822 return jScrollPaneLibClass;
823 }
824
825 /**
826 * This method initializes jTableLibClass
827 *
828 * @return javax.swing.JTable
829 */
830 private JTable getJTableLibClass() {
831 if (jTableLibClass == null) {
832 libClassTableModel = new IDefaultTableModel();
833 libClassTableModel.addColumn("LibraryClass");
834 jTableLibClass = new JTable(libClassTableModel);
835 jTableLibClass.setRowHeight(20);
836 jTableLibClass.setShowGrid(false);
837 jTableLibClass.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
838 jTableLibClass.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
839 public void valueChanged(ListSelectionEvent e) {
840 if (e.getValueIsAdjusting()){
841 return;
842 }
843 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
844 if (lsm.isSelectionEmpty()) {
845 return;
846 }
847 else{
848 int selectedRow2 = lsm.getMinSelectionIndex();
849 if (selectedRow2 < 0) {
850 return;
851 }
852 //
853 // display potential lib instances according to class selection
854 //
855 libInstanceTableModel.setRowCount(0);
856 String cls = libClassTableModel.getValueAt(selectedRow2, 0).toString();
857 ArrayList<String> al = classInstanceMap.get(cls);
858 ListIterator<String> li = al.listIterator();
859 while(li.hasNext()) {
860 String instance = li.next();
861 String[] s = {"", "", "", "", ""};
862 if (WorkspaceProfile.getModuleId(instance) != null) {
863 s[0] = WorkspaceProfile.getModuleId(instance).getName();
864 }
865
866 String[] instancePart = instance.split(" ");
867 for (int i = 0; i < instancePart.length; ++i){
868 s[i+1] = instancePart[i];
869 }
870 libInstanceTableModel.addRow(s);
871 }
872
873 }
874 }
875 });
876 }
877 return jTableLibClass;
878 }
879
880 /**
881 * This method initializes jScrollPaneQualifiedInstance
882 *
883 * @return javax.swing.JScrollPane
884 */
885 private JScrollPane getJScrollPaneQualifiedInstance() {
886 if (jScrollPaneQualifiedInstance == null) {
887 jScrollPaneQualifiedInstance = new JScrollPane();
888 jScrollPaneQualifiedInstance.setPreferredSize(new java.awt.Dimension(600,170));
889 jScrollPaneQualifiedInstance.setViewportView(getJTableLibInstances());
890 }
891 return jScrollPaneQualifiedInstance;
892 }
893
894 /**
895 * This method initializes jTableLibInstances
896 *
897 * @return javax.swing.JTable
898 */
899 private JTable getJTableLibInstances() {
900 if (jTableLibInstances == null) {
901 libInstanceTableModel = new IDefaultTableModel();
902 libInstanceTableModel.addColumn("Name");
903 libInstanceTableModel.addColumn("ModuleGUID");
904 libInstanceTableModel.addColumn("ModuleVersion");
905 libInstanceTableModel.addColumn("PackageGUID");
906 libInstanceTableModel.addColumn("PackageVersion");
907 jTableLibInstances = new JTable(libInstanceTableModel);
908 jTableLibInstances.setRowHeight(20);
909 jTableLibInstances.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
910 jTableLibInstances.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
911
912 }
913 return jTableLibInstances;
914 }
915
916 /**
917 * This method initializes jPanelLibrarySouth
918 *
919 * @return javax.swing.JPanel
920 */
921 private JPanel getJPanelLibrarySouth() {
922 if (jPanelLibrarySouth == null) {
923 jPanelLibrarySouth = new JPanel();
924 }
925 return jPanelLibrarySouth;
926 }
927
928 /**
929 * This method initializes jPanelLibraryCenter
930 *
931 * @return javax.swing.JPanel
932 */
933 private JPanel getJPanelLibraryCenter() {
934 if (jPanelLibraryCenter == null) {
935 jLabelInstanceHelp = new JLabel();
936 jLabelInstanceHelp.setText("Instance Description");
937 jLabelSelectedInstances = new JLabel();
938 jLabelSelectedInstances.setText("Selected Instances");
939 jPanelLibraryCenter = new JPanel();
940 jPanelLibraryCenter.setLayout(new BorderLayout());
941
942 jPanelLibraryCenter.add(getJPanelLibraryCenterC(), java.awt.BorderLayout.CENTER);
943 jPanelLibraryCenter.add(getJPanelLibraryCenterN(), java.awt.BorderLayout.NORTH);
944
945 }
946 return jPanelLibraryCenter;
947 }
948
949 /**
950 * This method initializes jScrollPaneInstanceHelp
951 *
952 * @return javax.swing.JScrollPane
953 */
954 private JScrollPane getJScrollPaneInstanceHelp() {
955 if (jScrollPaneInstanceHelp == null) {
956 jScrollPaneInstanceHelp = new JScrollPane();
957 jScrollPaneInstanceHelp.setPreferredSize(new java.awt.Dimension(400,50));
958 jScrollPaneInstanceHelp.setViewportView(getJTextAreaInstanceHelp());
959 }
960 return jScrollPaneInstanceHelp;
961 }
962
963 /**
964 * This method initializes jTextAreaInstanceHelp
965 *
966 * @return javax.swing.JTextArea
967 */
968 private JTextArea getJTextAreaInstanceHelp() {
969 if (jTextAreaInstanceHelp == null) {
970 jTextAreaInstanceHelp = new JTextArea();
971 jTextAreaInstanceHelp.setEditable(false);
972 }
973 return jTextAreaInstanceHelp;
974 }
975
976 /**
977 * This method initializes jButtonAdd
978 *
979 * @return javax.swing.JButton
980 */
981 private JButton getJButtonAdd() {
982 if (jButtonAdd == null) {
983 jButtonAdd = new JButton();
984 jButtonAdd.setPreferredSize(new java.awt.Dimension(80,20));
985 jButtonAdd.setText("Add");
986 jButtonAdd.addActionListener(new java.awt.event.ActionListener() {
987 public void actionPerformed(java.awt.event.ActionEvent e) {
988 int row = jTableLibInstances.getSelectedRow();
989 if (row < 0) {
990 return;
991 }
992
993 String instanceValue = libInstanceTableModel.getValueAt(row, 1) + " " +
994 libInstanceTableModel.getValueAt(row, 2) + " " +
995 libInstanceTableModel.getValueAt(row, 3) + " " +
996 libInstanceTableModel.getValueAt(row, 4);
997 ModuleIdentification libMi = WorkspaceProfile.getModuleId(instanceValue);
998 try {
999 addLibInstance (libMi);
1000 }
1001 catch (Exception exception) {
1002 JOptionPane.showMessageDialog(frame, "Adding Instance" + libMi.getName() + ": "+ exception.getMessage());
1003 return;
1004 }
1005 docConsole.setSaved(false);
1006 Object[] s = {libInstanceTableModel.getValueAt(row, 0), libInstanceTableModel.getValueAt(row, 1),
1007 libInstanceTableModel.getValueAt(row, 2), libInstanceTableModel.getValueAt(row, 3),
1008 libInstanceTableModel.getValueAt(row, 4)};
1009 selectedInstancesTableModel.addRow(s);
1010 resolveLibraryInstances(instanceValue);
1011 showClassToResolved();
1012 }
1013 });
1014 }
1015 return jButtonAdd;
1016 }
1017
1018 /**
1019 * This method initializes jButton1
1020 *
1021 * @return javax.swing.JButton
1022 */
1023 private JButton getJButtonDeleteInstance() {
1024 if (jButtonDeleteInstance == null) {
1025 jButtonDeleteInstance = new JButton();
1026 jButtonDeleteInstance.setPreferredSize(new java.awt.Dimension(80,20));
1027 jButtonDeleteInstance.setText("Delete");
1028 jButtonDeleteInstance.addActionListener(new java.awt.event.ActionListener() {
1029 public void actionPerformed(java.awt.event.ActionEvent e) {
1030 int row = jTableSelectedInstances.getSelectedRow();
1031 if (row < 0) {
1032 return;
1033 }
1034 docConsole.setSaved(false);
1035 removeInstance(selectedInstancesTableModel.getValueAt(row, 1) + " " +
1036 selectedInstancesTableModel.getValueAt(row, 2) + " " +
1037 selectedInstancesTableModel.getValueAt(row, 3) + " " +
1038 selectedInstancesTableModel.getValueAt(row, 4));
1039 ffc.removeLibraryInstance(moduleKey, row);
1040 selectedInstancesTableModel.removeRow(row);
1041
1042 }
1043 });
1044 }
1045 return jButtonDeleteInstance;
1046 }
1047
1048 /**
1049 * This method initializes jButton2
1050 *
1051 * @return javax.swing.JButton
1052 */
1053 private JButton getJButtonOk() {
1054 if (jButtonOk == null) {
1055 jButtonOk = new JButton();
1056 jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
1057 jButtonOk.setText("Ok");
1058 jButtonOk.addActionListener(this);
1059 }
1060 return jButtonOk;
1061 }
1062
1063 /**
1064 * This method initializes jButton3
1065 *
1066 * @return javax.swing.JButton
1067 */
1068 private JButton getJButtonCancel() {
1069 if (jButtonCancel == null) {
1070 jButtonCancel = new JButton();
1071 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
1072 jButtonCancel.setText("Cancel");
1073 jButtonCancel.setVisible(false);
1074 }
1075 return jButtonCancel;
1076 }
1077 public void actionPerformed(ActionEvent arg0) {
1078
1079 if (arg0.getSource() == jButtonOk) {
1080 if (jTableModuleSaOptions.isEditing()) {
1081 jTableModuleSaOptions.getCellEditor().stopCellEditing();
1082 }
1083 this.setVisible(false);
1084 }
1085 }
1086 /**
1087 * This method initializes jPanelModuleSaOpts
1088 *
1089 * @return javax.swing.JPanel
1090 */
1091 private JPanel getJPanelModuleSaOpts() {
1092 if (jPanelModuleSaOpts == null) {
1093 FlowLayout flowLayout4 = new FlowLayout();
1094 flowLayout4.setAlignment(java.awt.FlowLayout.LEFT);
1095 jLabelFfsFormatKey = new JLabel();
1096 jLabelFfsFormatKey.setText("FFS Format Key");
1097 jLabelFfsFormatKey.setPreferredSize(new java.awt.Dimension(90,16));
1098 jLabelFfsFileGuid = new JLabel();
1099 jLabelFfsFileGuid.setText("FFS File GUID");
1100 jLabelFfsFileGuid.setPreferredSize(new java.awt.Dimension(90,16));
1101 jLabelFfsFileGuid.setVisible(false);
1102 jLabelFvBinding = new JLabel();
1103 jLabelFvBinding.setText("FV Binding");
1104 jLabelFvBinding.setPreferredSize(new java.awt.Dimension(90,16));
1105 jPanelModuleSaOpts = new JPanel();
1106 jPanelModuleSaOpts.setLayout(flowLayout4);
1107 jPanelModuleSaOpts.add(jLabelFvBinding, null);
1108 jPanelModuleSaOpts.add(getJTextFieldFvBinding(), null);
1109 jPanelModuleSaOpts.add(jLabelFfsFileGuid, null);
1110 jPanelModuleSaOpts.add(getJTextFieldFileGuid(), null);
1111 jPanelModuleSaOpts.add(jLabelFfsFormatKey, null);
1112 jPanelModuleSaOpts.add(getJTextFieldFfsKey(), null);
1113 jPanelModuleSaOpts.addComponentListener(new java.awt.event.ComponentAdapter() {
1114 public void componentShown(java.awt.event.ComponentEvent e) {
1115 initFvInfo(moduleKey);
1116 }
1117 });
1118 }
1119 return jPanelModuleSaOpts;
1120 }
1121 /**
1122 * This method initializes jTextField
1123 *
1124 * @return javax.swing.JTextField
1125 */
1126 private JTextField getJTextFieldFvBinding() {
1127 if (jTextFieldFvBinding == null) {
1128 jTextFieldFvBinding = new JTextField();
1129 jTextFieldFvBinding.setPreferredSize(new java.awt.Dimension(150,20));
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(getJPanelToolchainC(), 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 * This method initializes jPanelToolchainC
1630 *
1631 * @return javax.swing.JPanel
1632 */
1633 private JPanel getJPanelToolchainC() {
1634 if (jPanelToolchainC == null) {
1635 jPanelToolchainC = new JPanel();
1636 jPanelToolchainC.add(getJScrollPaneModuleSaOptions(), null);
1637 }
1638 return jPanelToolchainC;
1639 }
1640 /**
1641 * This method initializes jPanelLibraryCenterN
1642 *
1643 * @return javax.swing.JPanel
1644 */
1645 private JPanel getJPanelLibraryCenterN() {
1646 if (jPanelLibraryCenterN == null) {
1647 FlowLayout flowLayout5 = new FlowLayout();
1648 flowLayout5.setAlignment(java.awt.FlowLayout.CENTER);
1649 flowLayout5.setHgap(10);
1650 jPanelLibraryCenterN = new JPanel();
1651 jPanelLibraryCenterN.setLayout(flowLayout5);
1652 jPanelLibraryCenterN.add(jLabelInstanceHelp, null);
1653 jPanelLibraryCenterN.add(getJScrollPaneInstanceHelp(), null);
1654 jPanelLibraryCenterN.add(getJButtonAdd(), null);
1655 jPanelLibraryCenterN.add(getJButtonDeleteInstance(), null);
1656 }
1657 return jPanelLibraryCenterN;
1658 }
1659 /**
1660 * This method initializes jPanelLibraryCenterC
1661 *
1662 * @return javax.swing.JPanel
1663 */
1664 private JPanel getJPanelLibraryCenterC() {
1665 if (jPanelLibraryCenterC == null) {
1666 jPanelLibraryCenterC = new JPanel();
1667 jPanelLibraryCenterC.add(jLabelSelectedInstances, null);
1668 jPanelLibraryCenterC.add(getJScrollPaneSelectedInstances(), null);
1669 }
1670 return jPanelLibraryCenterC;
1671 }
1672
1673
1674 } // @jve:decl-index=0:visual-constraint="10,10"