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