a8d70e2ca39acb49b2ad096560402688e8d6272f
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFlash.java
1 /** @file
2 Java class FpdFlash is GUI for Flash element operation in SPD file.
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13 package org.tianocore.frameworkwizard.platform.ui;
14
15 import java.awt.BorderLayout;
16 import javax.swing.JPanel;
17
18 import javax.swing.AbstractAction;
19 import javax.swing.DefaultCellEditor;
20 import javax.swing.JFileChooser;
21 import javax.swing.JFrame;
22 import javax.swing.JOptionPane;
23 import javax.swing.JTabbedPane;
24 import javax.swing.JButton;
25 import javax.swing.ListSelectionModel;
26
27 import org.tianocore.PlatformSurfaceAreaDocument;
28 import org.tianocore.frameworkwizard.common.GlobalData;
29 import org.tianocore.frameworkwizard.common.Identifications.OpeningPlatformType;
30 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
31 import org.tianocore.frameworkwizard.common.ui.StarLabel;
32 import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;
33 import org.tianocore.frameworkwizard.platform.ui.FpdFrameworkModules;
34 import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;
35
36 import java.awt.FlowLayout;
37 import java.awt.event.ActionEvent;
38 import java.awt.event.ComponentAdapter;
39 import java.awt.event.ComponentEvent;
40 import java.awt.event.ItemEvent;
41 import java.awt.event.ItemListener;
42 import java.io.BufferedReader;
43 import java.io.File;
44 import java.io.FileReader;
45 import java.util.ArrayList;
46 import java.util.HashMap;
47 import java.util.Iterator;
48 import java.util.LinkedHashMap;
49 import java.util.Map;
50 import java.util.Set;
51 import java.util.Vector;
52
53 import javax.swing.JCheckBox;
54 import javax.swing.JTextField;
55 import java.awt.GridLayout;
56 import javax.swing.JLabel;
57 import javax.swing.JScrollPane;
58 import javax.swing.JTable;
59 import javax.swing.event.InternalFrameAdapter;
60 import javax.swing.event.InternalFrameEvent;
61 import javax.swing.event.ListSelectionEvent;
62 import javax.swing.event.ListSelectionListener;
63 import javax.swing.event.TableModelEvent;
64 import javax.swing.event.TableModelListener;
65 import javax.swing.table.DefaultTableModel;
66 import javax.swing.table.TableColumn;
67 import javax.swing.table.TableModel;
68 import javax.swing.JComboBox;
69 import java.awt.Dimension;
70 import javax.swing.JSplitPane;
71
72 public class FpdFlash extends IInternalFrame {
73
74 /**
75 *
76 */
77 private static final long serialVersionUID = 1L;
78 private final int startIndexOfDynamicTab = 2;
79 static JFrame frame;
80 private JPanel jContentPane = null;
81 private JPanel jPanelContentEast = null;
82 private JPanel jPanelContentSouth = null;
83 private JPanel jPanelContentWest = null;
84 private JPanel jPanelContentNorth = null;
85 private JTabbedPane jTabbedPane = null;
86 private JPanel jPanelFvImages = null;
87 private JPanel jPanelFvImageN = null;
88 private JPanel jPanelFvImageS = null;
89 private JCheckBox jCheckBoxFvProperty = null;
90 private JLabel jLabelFvPropName = null;
91 private JTextField jTextFieldFvPropName = null;
92 private JLabel jLabelFvPropValue = null;
93 private JTextField jTextFieldFvPropValue = null;
94 private JButton jButtonFvPropAdd = null;
95 private JScrollPane jScrollPaneFvProp = null;
96 private JTable jTableFvProp = null;
97 private JPanel jPanelFvPropButtonGroup = null;
98 private JButton jButtonFvPropDel = null;
99 private DefaultTableModel fvPropertyTableModel = null;
100 private DefaultTableModel fvImageNameTableModel = null;
101 private ImageParaTableModel fvImageParaTableModel = null;
102 private DefaultTableModel fvOptionTableModel = null;
103 private JPanel jPanelFvImageC = null;
104 private JCheckBox jCheckBoxFvImagePara = null;
105 private JLabel jLabelFvParaType = null;
106 private JComboBox jComboBoxFvParaType = null;
107 private JLabel jLabelFvImageNames = null;
108 private JLabel jLabelFvParaName = null;
109 private JTextField jTextFieldFvParaName = null;
110 private JButton jButtonFvParaAdd = null;
111 private JScrollPane jScrollPaneFvImageNames = null;
112 private JTable jTableFvImageNames = null;
113 private JButton jButtonFvParaDel = null;
114 private JPanel jPanelFvImageOpts = null;
115 private JButton jButtonAddFvImage = null;
116 private JScrollPane jScrollPaneFvInfo = null;
117 private JTable jTableFvInfo = null;
118 private JButton jButtonDelFvImage = null;
119 private JCheckBox jCheckBoxFvImageOpts = null;
120 private JPanel jPanelFvImagePara = null;
121 private OpeningPlatformType docConsole = null;
122 private FpdFileContents ffc = null;
123 private JPanel jPanelFdf = null;
124 private JCheckBox jCheckBoxFdf = null;
125 private JTextField jTextFieldFdf = null;
126 private JButton jButtonFdfBrowse = null;
127 private JLabel jLabelFvImageOptName = null;
128 private JTextField jTextFieldFvImageOptName = null;
129 private JLabel jLabelFvImageOptValue = null;
130 private JTextField jTextFieldFvImageOptValue = null;
131 private JPanel jPanelFvImageOptsButtonGroup = null;
132 private JButton jButtonFvImageOptAdd = null;
133 private JButton jButtonFvImageOptDel = null;
134 private JScrollPane jScrollPane = null;
135 private JTable jTableFvImageOpts = null;
136 private JButton jButtonUpdateFvImage = null;
137 private JPanel jPanelFdfN = null;
138 private JPanel jPanelFdfS = null;
139 private JSplitPane jSplitPaneFdfC = null;
140 private JPanel jPanelFdfCTop = null;
141 private JPanel jPanelFdfCBottom = null;
142 private JPanel jPanelFdfCTopN = null;
143 private JPanel jPanelFdfCTopS = null;
144 private JPanel jPanelFdfCTopC = null;
145 private JPanel jPanelFdfCBottomN = null;
146 private JPanel jPanelFdfCBottomC = null;
147 private JLabel jLabelFvInFdf = null;
148 private JLabel jLabelFvAdditional = null;
149 private JScrollPane jScrollPaneFvInFdf = null;
150 private JTable jTableFvInFdf = null;
151 private NonEditableTableModel fvInFdfTableModel = null; // @jve:decl-index=0:visual-constraint=""
152 private JButton jButtonFvInFdfOptions = null;
153 private JScrollPane jScrollPaneFvAdditional = null;
154 private JTable jTableFvAdditional = null;
155 private DefaultTableModel fvAddtionalTableModel = null; // @jve:decl-index=0:visual-constraint=""
156 private JButton jButtonAddFv = null;
157 private JButton jButtonDelFv = null;
158 private JButton jButtonAddFvOptions = null;
159 private int tabIndexForFv = -1;
160 private int selectedRowInFvAdditionalTable = -1;
161 private String oldFvName = null;
162
163
164 public FpdFlash() {
165 super();
166 // TODO Auto-generated constructor stub
167
168 initialize();
169 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
170 this.setVisible(true);
171 }
172
173 public FpdFlash(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){
174 this();
175 ffc = new FpdFileContents(fpd);
176 init(ffc);
177 }
178
179 public FpdFlash(OpeningPlatformType opt) {
180 this(opt.getXmlFpd());
181 docConsole = opt;
182 }
183
184 /**
185 * This method initializes jPanel
186 *
187 * @return javax.swing.JPanel
188 */
189 private JPanel getJPanelContentEast() {
190 if (jPanelContentEast == null) {
191 jPanelContentEast = new JPanel();
192 }
193 return jPanelContentEast;
194 }
195
196 /**
197 * This method initializes jPanel1
198 *
199 * @return javax.swing.JPanel
200 */
201 private JPanel getJPanelContentSouth() {
202 if (jPanelContentSouth == null) {
203 FlowLayout flowLayout = new FlowLayout();
204 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
205 flowLayout.setHgap(15);
206 jPanelContentSouth = new JPanel();
207 jPanelContentSouth.setLayout(flowLayout);
208 jPanelContentSouth.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
209 }
210 return jPanelContentSouth;
211 }
212
213 /**
214 * This method initializes jPanel2
215 *
216 * @return javax.swing.JPanel
217 */
218 private JPanel getJPanelContentWest() {
219 if (jPanelContentWest == null) {
220 jPanelContentWest = new JPanel();
221 }
222 return jPanelContentWest;
223 }
224
225 /**
226 * This method initializes jPanel3
227 *
228 * @return javax.swing.JPanel
229 */
230 private JPanel getJPanelContentNorth() {
231 if (jPanelContentNorth == null) {
232 jPanelContentNorth = new JPanel();
233 }
234 return jPanelContentNorth;
235 }
236
237 /**
238 * This method initializes jTabbedPane
239 *
240 * @return javax.swing.JTabbedPane
241 */
242 private JTabbedPane getJTabbedPane() {
243 if (jTabbedPane == null) {
244 jTabbedPane = new JTabbedPane();
245 jTabbedPane.addTab("General", null, getJPanelFdf(), null);
246 jTabbedPane.addTab("Advanced", null, getJPanelFvImages(), null);
247
248 }
249 return jTabbedPane;
250 }
251
252 /**
253 * This method initializes jPanelFvImages
254 *
255 * @return javax.swing.JPanel
256 */
257 private JPanel getJPanelFvImages() {
258 if (jPanelFvImages == null) {
259 jPanelFvImages = new JPanel();
260 jPanelFvImages.setLayout(new BorderLayout());
261 jPanelFvImages.add(getJPanelFvImageN(), java.awt.BorderLayout.NORTH);
262 // jPanelFvImages.add(getJPanelFvImageW(), java.awt.BorderLayout.WEST);
263 jPanelFvImages.add(getJPanelFvImageS(), java.awt.BorderLayout.SOUTH);
264 jPanelFvImages.add(getJPanelFvImageC(), java.awt.BorderLayout.CENTER);
265 jPanelFvImages.addComponentListener(new java.awt.event.ComponentAdapter() {
266 public void componentShown(java.awt.event.ComponentEvent e) {
267 fvImageParaTableModel.setRowCount(0);
268 fvPropertyTableModel.setRowCount(0);
269
270 if (ffc.getFvImagesFvImageCount() == 0) {
271 return;
272 }
273 String[][] saa = new String[ffc.getFvImagesFvImageCount()][2];
274 ffc.getFvImagesFvImages(saa);
275
276 int i = 0;
277 while (i < saa.length) {
278 fvImageParaTableModel.addRow(saa[i]);
279 ++i;
280 }
281
282 saa = new String[ffc.getFvImagesNameValueCount()][2];
283 ffc.getFvImagesNameValues(saa);
284 for (int m = 0; m < saa.length; ++m) {
285 fvPropertyTableModel.addRow(saa[m]);
286 }
287 }
288 });
289
290 }
291 return jPanelFvImages;
292 }
293
294 /**
295 * This method initializes jPanelFvImageN
296 *
297 * @return javax.swing.JPanel
298 */
299 private JPanel getJPanelFvImageN() {
300 if (jPanelFvImageN == null) {
301 jLabelFvPropValue = new JLabel();
302 jLabelFvPropValue.setText("Value");
303 jLabelFvPropValue.setEnabled(false);
304 jLabelFvPropValue.setPreferredSize(new java.awt.Dimension(38,20));
305 jLabelFvPropName = new JLabel();
306 jLabelFvPropName.setText("Name");
307 jLabelFvPropName.setEnabled(false);
308 jLabelFvPropName.setPreferredSize(new java.awt.Dimension(38,20));
309 FlowLayout flowLayout2 = new FlowLayout();
310 flowLayout2.setAlignment(java.awt.FlowLayout.LEFT);
311 flowLayout2.setHgap(15);
312 jPanelFvImageN = new JPanel();
313 jPanelFvImageN.setPreferredSize(new java.awt.Dimension(576,100));
314 jPanelFvImageN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
315 jPanelFvImageN.setLayout(flowLayout2);
316 jPanelFvImageN.add(getJCheckBoxFvProperty(), null);
317 jPanelFvImageN.add(jLabelFvPropName, null);
318 jPanelFvImageN.add(getJTextFieldFvPropName(), null);
319 jPanelFvImageN.add(jLabelFvPropValue, null);
320 jPanelFvImageN.add(getJTextFieldFvPropValue(), null);
321 jPanelFvImageN.add(getJScrollPaneFvProp(), null);
322 jPanelFvImageN.add(getJPanelFvPropButtonGroup(), null);
323 }
324 return jPanelFvImageN;
325 }
326
327 /**
328 * This method initializes jPanelFvImageS
329 *
330 * @return javax.swing.JPanel
331 */
332 private JPanel getJPanelFvImageS() {
333 if (jPanelFvImageS == null) {
334 GridLayout gridLayout2 = new GridLayout();
335 gridLayout2.setRows(1);
336 jPanelFvImageS = new JPanel();
337 jPanelFvImageS.setPreferredSize(new java.awt.Dimension(480,190));
338 jPanelFvImageS.setLayout(gridLayout2);
339 jPanelFvImageS.add(getJScrollPaneFvInfo(), null);
340 }
341 return jPanelFvImageS;
342 }
343
344
345 /**
346 * This method initializes jCheckBox1
347 *
348 * @return javax.swing.JCheckBox
349 */
350 private JCheckBox getJCheckBoxFvProperty() {
351 if (jCheckBoxFvProperty == null) {
352 jCheckBoxFvProperty = new JCheckBox();
353 jCheckBoxFvProperty.setText("Global FV Variables");
354 jCheckBoxFvProperty.addItemListener(new ItemListener(){
355
356 public void itemStateChanged(ItemEvent arg0) {
357 // TODO Auto-generated method stub
358 boolean seleted = jCheckBoxFvProperty.isSelected();
359
360 jLabelFvPropName.setEnabled(seleted);
361 jTextFieldFvPropName.setEnabled(seleted);
362 jLabelFvPropValue.setEnabled(seleted);
363 jTextFieldFvPropValue.setEnabled(seleted);
364 jTableFvProp.setEnabled(seleted);
365 jButtonFvPropAdd.setEnabled(seleted);
366 jButtonFvPropDel.setEnabled(seleted);
367
368
369 }
370
371 });
372 }
373 return jCheckBoxFvProperty;
374 }
375
376
377 /**
378 * This method initializes jTextField
379 *
380 * @return javax.swing.JTextField
381 */
382 private JTextField getJTextFieldFvPropName() {
383 if (jTextFieldFvPropName == null) {
384 jTextFieldFvPropName = new JTextField();
385 jTextFieldFvPropName.setPreferredSize(new java.awt.Dimension(100,20));
386 jTextFieldFvPropName.setEnabled(false);
387 }
388 return jTextFieldFvPropName;
389 }
390
391
392 /**
393 * This method initializes jTextField1
394 *
395 * @return javax.swing.JTextField
396 */
397 private JTextField getJTextFieldFvPropValue() {
398 if (jTextFieldFvPropValue == null) {
399 jTextFieldFvPropValue = new JTextField();
400 jTextFieldFvPropValue.setPreferredSize(new java.awt.Dimension(100,20));
401 jTextFieldFvPropValue.setEnabled(false);
402 }
403 return jTextFieldFvPropValue;
404 }
405
406
407 /**
408 * This method initializes jButton
409 *
410 * @return javax.swing.JButton
411 */
412 private JButton getJButtonFvPropAdd() {
413 if (jButtonFvPropAdd == null) {
414 jButtonFvPropAdd = new JButton();
415 jButtonFvPropAdd.setPreferredSize(new java.awt.Dimension(80,20));
416 jButtonFvPropAdd.setEnabled(false);
417 jButtonFvPropAdd.setText("Add");
418 jButtonFvPropAdd.addActionListener(new AbstractAction() {
419 /**
420 *
421 */
422 private static final long serialVersionUID = 1L;
423
424 public void actionPerformed(ActionEvent e) {
425 if (jTextFieldFvPropName.getText().length() > 0 && jTextFieldFvPropValue.getText().length() > 0){
426 String[] row = {jTextFieldFvPropName.getText(), jTextFieldFvPropValue.getText()};
427 fvPropertyTableModel.addRow(row);
428 docConsole.setSaved(false);
429 ffc.genFvImagesNameValue(row[0], row[1]);
430 }
431 }
432 });
433 }
434 return jButtonFvPropAdd;
435 }
436
437
438 /**
439 * This method initializes jScrollPane1
440 *
441 * @return javax.swing.JScrollPane
442 */
443 private JScrollPane getJScrollPaneFvProp() {
444 if (jScrollPaneFvProp == null) {
445 jScrollPaneFvProp = new JScrollPane();
446 jScrollPaneFvProp.setPreferredSize(new java.awt.Dimension(350,55));
447 jScrollPaneFvProp.setViewportView(getJTableFvProp());
448 }
449 return jScrollPaneFvProp;
450 }
451
452
453 /**
454 * This method initializes jTable
455 *
456 * @return javax.swing.JTable
457 */
458 private JTable getJTableFvProp() {
459 if (jTableFvProp == null) {
460 fvPropertyTableModel = new DefaultTableModel();
461 jTableFvProp = new JTable(fvPropertyTableModel);
462 fvPropertyTableModel.addColumn("Name");
463 fvPropertyTableModel.addColumn("Value");
464 jTableFvProp.setRowHeight(20);
465 jTableFvProp.setEnabled(false);
466
467 jTableFvProp.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
468 jTableFvProp.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
469 public void valueChanged(ListSelectionEvent e) {
470 if (e.getValueIsAdjusting()){
471 return;
472 }
473 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
474 if (lsm.isSelectionEmpty()) {
475 return;
476 }
477 else{
478 // selectedRow = lsm.getMinSelectionIndex();
479 }
480 }
481 });
482
483 jTableFvProp.getModel().addTableModelListener(new TableModelListener(){
484 public void tableChanged(TableModelEvent arg0) {
485 // TODO Auto-generated method stub
486 int row = arg0.getFirstRow();
487 TableModel m = (TableModel)arg0.getSource();
488 if (arg0.getType() == TableModelEvent.UPDATE){
489
490 String name = m.getValueAt(row, 0) + "";
491 String value = m.getValueAt(row, 1) + "";
492 docConsole.setSaved(false);
493 ffc.updateFvImagesNameValue(row, name, value);
494 }
495 }
496 });
497 }
498 return jTableFvProp;
499 }
500
501
502 /**
503 * This method initializes jPanel4
504 *
505 * @return javax.swing.JPanel
506 */
507 private JPanel getJPanelFvPropButtonGroup() {
508 if (jPanelFvPropButtonGroup == null) {
509 jPanelFvPropButtonGroup = new JPanel();
510 jPanelFvPropButtonGroup.setPreferredSize(new java.awt.Dimension(80,55));
511
512 jPanelFvPropButtonGroup.add(getJButtonFvPropAdd(), null);
513 jPanelFvPropButtonGroup.add(getJButtonFvPropDel(), null);
514 }
515 return jPanelFvPropButtonGroup;
516 }
517
518
519 /**
520 * This method initializes jButton1
521 *
522 * @return javax.swing.JButton
523 */
524 private JButton getJButtonFvPropDel() {
525 if (jButtonFvPropDel == null) {
526 jButtonFvPropDel = new JButton();
527 jButtonFvPropDel.setPreferredSize(new java.awt.Dimension(80,20));
528 jButtonFvPropDel.setEnabled(false);
529 jButtonFvPropDel.setText("Delete");
530 jButtonFvPropDel.addActionListener(new AbstractAction() {
531 /**
532 *
533 */
534 private static final long serialVersionUID = 1L;
535
536 public void actionPerformed(ActionEvent e) {
537 if (jTableFvProp.getSelectedRow() >= 0){
538 fvPropertyTableModel.removeRow(jTableFvProp.getSelectedRow());
539 docConsole.setSaved(false);
540 ffc.removeFvImagesNameValue(jTableFvProp.getSelectedRow());
541 }
542 }
543 });
544 }
545 return jButtonFvPropDel;
546 }
547
548
549 /**
550 * This method initializes jPanelFvImageC
551 *
552 * @return javax.swing.JPanel
553 */
554 private JPanel getJPanelFvImageC() {
555 if (jPanelFvImageC == null) {
556 jLabelFvParaName = new JLabel();
557 jLabelFvParaName.setPreferredSize(new Dimension(38, 20));
558 jLabelFvParaName.setEnabled(false);
559 jLabelFvParaName.setText("Name");
560 jLabelFvImageNames = new JLabel();
561 jLabelFvImageNames.setText("FV Image Names");
562 jLabelFvImageNames.setEnabled(false);
563 jLabelFvImageNames.setPreferredSize(new java.awt.Dimension(150,20));
564 jLabelFvParaType = new JLabel();
565 jLabelFvParaType.setText("Type");
566 jLabelFvParaType.setEnabled(false);
567 jLabelFvParaType.setPreferredSize(new java.awt.Dimension(70,20));
568 FlowLayout flowLayout3 = new FlowLayout();
569 flowLayout3.setAlignment(java.awt.FlowLayout.LEFT);
570 flowLayout3.setHgap(5);
571 jPanelFvImageC = new JPanel();
572 jPanelFvImageC.setLayout(flowLayout3);
573 jPanelFvImageC.add(getJPanelFvImagePara(), null);
574
575 jPanelFvImageC.add(getJPanelFvImageOpts(), null);
576
577 }
578 return jPanelFvImageC;
579 }
580
581
582 /**
583 * This method initializes jCheckBox2
584 *
585 * @return javax.swing.JCheckBox
586 */
587 private JCheckBox getJCheckBoxFvImagePara() {
588 if (jCheckBoxFvImagePara == null) {
589 jCheckBoxFvImagePara = new JCheckBox();
590 jCheckBoxFvImagePara.setText("FV Image Parameters");
591 jCheckBoxFvImagePara.setPreferredSize(new java.awt.Dimension(200,20));
592 jCheckBoxFvImagePara.addItemListener(new ItemListener(){
593
594 public void itemStateChanged(ItemEvent arg0) {
595 // TODO Auto-generated method stub
596 boolean seleted = jCheckBoxFvImagePara.isSelected();
597
598 jLabelFvParaType.setEnabled(seleted);
599 jLabelFvImageNames.setEnabled(seleted);
600 jLabelFvParaName.setEnabled(seleted);
601 jComboBoxFvParaType.setEnabled(seleted);
602 jTextFieldFvParaName.setEnabled(seleted);
603
604 jTableFvImageNames.setEnabled(seleted);
605 jButtonFvParaAdd.setEnabled(seleted);
606 jButtonFvParaDel.setEnabled(seleted);
607
608
609 }
610
611 });
612 }
613 return jCheckBoxFvImagePara;
614 }
615
616
617 /**
618 * This method initializes jComboBox
619 *
620 * @return javax.swing.JComboBox
621 */
622 private JComboBox getJComboBoxFvParaType() {
623 if (jComboBoxFvParaType == null) {
624 jComboBoxFvParaType = new JComboBox();
625 jComboBoxFvParaType.addItem("ImageName");
626 jComboBoxFvParaType.addItem("Attributes");
627 jComboBoxFvParaType.addItem("Options");
628 jComboBoxFvParaType.addItem("Components");
629 jComboBoxFvParaType.setPreferredSize(new java.awt.Dimension(180,20));
630 jComboBoxFvParaType.setEnabled(false);
631 jComboBoxFvParaType.addItemListener(new ItemListener() {
632
633 public void itemStateChanged(ItemEvent arg0) {
634 // TODO disable attribute settings when ValidImageNames selected.
635
636 }
637
638 });
639 }
640 return jComboBoxFvParaType;
641 }
642
643
644 /**
645 * This method initializes jTextField2
646 *
647 * @return javax.swing.JTextField
648 */
649 private JTextField getJTextFieldFvParaName() {
650 if (jTextFieldFvParaName == null) {
651 jTextFieldFvParaName = new JTextField();
652 jTextFieldFvParaName.setPreferredSize(new java.awt.Dimension(140,20));
653 jTextFieldFvParaName.setEnabled(false);
654 }
655 return jTextFieldFvParaName;
656 }
657
658
659 /**
660 * This method initializes jButton2
661 *
662 * @return javax.swing.JButton
663 */
664 private JButton getJButtonFvParaAdd() {
665 if (jButtonFvParaAdd == null) {
666 jButtonFvParaAdd = new JButton();
667 jButtonFvParaAdd.setPreferredSize(new Dimension(80, 20));
668 jButtonFvParaAdd.setEnabled(false);
669 jButtonFvParaAdd.setText("Add");
670 jButtonFvParaAdd.addActionListener(new AbstractAction() {
671 /**
672 *
673 */
674 private static final long serialVersionUID = 1L;
675
676 public void actionPerformed(java.awt.event.ActionEvent e) {
677 if (jTextFieldFvParaName.getText().length() > 0){
678 String[] row = {jTextFieldFvParaName.getText()};
679 fvImageNameTableModel.addRow(row);
680 }
681 }
682 });
683 }
684 return jButtonFvParaAdd;
685 }
686
687
688 /**
689 * This method initializes jScrollPane2
690 *
691 * @return javax.swing.JScrollPane
692 */
693 private JScrollPane getJScrollPaneFvImageNames() {
694 if (jScrollPaneFvImageNames == null) {
695 jScrollPaneFvImageNames = new JScrollPane();
696 jScrollPaneFvImageNames.setPreferredSize(new java.awt.Dimension(350,50));
697 jScrollPaneFvImageNames.setViewportView(getJTableFvImageNames());
698 }
699 return jScrollPaneFvImageNames;
700 }
701
702
703 /**
704 * This method initializes jTable1
705 *
706 * @return javax.swing.JTable
707 */
708 private JTable getJTableFvImageNames() {
709 if (jTableFvImageNames == null) {
710 fvImageNameTableModel = new DefaultTableModel();
711 jTableFvImageNames = new JTable(fvImageNameTableModel);
712 jTableFvImageNames.setEnabled(false);
713 fvImageNameTableModel.addColumn("FV Image Name");
714 }
715 return jTableFvImageNames;
716 }
717
718
719 /**
720 * This method initializes jButton3
721 *
722 * @return javax.swing.JButton
723 */
724 private JButton getJButtonFvParaDel() {
725 if (jButtonFvParaDel == null) {
726 jButtonFvParaDel = new JButton();
727 jButtonFvParaDel.setPreferredSize(new Dimension(80, 20));
728 jButtonFvParaDel.setEnabled(false);
729 jButtonFvParaDel.setText("Delete");
730 jButtonFvParaDel.addActionListener(new AbstractAction() {
731 /**
732 *
733 */
734 private static final long serialVersionUID = 1L;
735
736 public void actionPerformed(java.awt.event.ActionEvent e) {
737 if (jTableFvImageNames.getSelectedRow() >= 0){
738
739 fvImageNameTableModel.removeRow(jTableFvImageNames.getSelectedRow());
740 }
741 }
742 });
743 }
744 return jButtonFvParaDel;
745 }
746
747
748
749
750 private JPanel getJPanelFvImageOpts() {
751
752
753 if (jPanelFvImageOpts == null) {
754 //ToDo add ButtonGroup for RadioButtons
755 jLabelFvImageOptValue = new JLabel();
756 jLabelFvImageOptValue.setEnabled(true);
757 jLabelFvImageOptValue.setText("Value");
758 jLabelFvImageOptValue.setPreferredSize(new Dimension(38, 20));
759 jLabelFvImageOptName = new JLabel();
760 jLabelFvImageOptName.setEnabled(true);
761 jLabelFvImageOptName.setText("Name");
762 jLabelFvImageOptName.setPreferredSize(new Dimension(38, 20));
763 jPanelFvImageOpts = new JPanel();
764 jPanelFvImageOpts.setPreferredSize(new java.awt.Dimension(480,150));
765
766 jPanelFvImageOpts.setLayout(new FlowLayout());
767
768 jPanelFvImageOpts.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
769 jPanelFvImageOpts.add(getJCheckBoxFvImageOpts(), null);
770 jPanelFvImageOpts.add(jLabelFvImageOptName, null);
771 jPanelFvImageOpts.add(getJTextFieldFvImageOptName(), null);
772 jPanelFvImageOpts.add(jLabelFvImageOptValue, null);
773 jPanelFvImageOpts.add(getJTextFieldFvImageOptValue(), null);
774 jPanelFvImageOpts.add(getJScrollPane(), null);
775 jPanelFvImageOpts.add(getJPanelFvImageOptsButtonGroup(), null);
776 jPanelFvImageOpts.add(getJButtonAddFvImage(), null);
777 jPanelFvImageOpts.add(getJButtonDelFvImage(), null);
778 jPanelFvImageOpts.add(getJButtonUpdateFvImage(), null);
779
780
781
782
783
784 }
785 return jPanelFvImageOpts;
786 }
787
788
789 /**
790 * This method initializes jButton4
791 *
792 * @return javax.swing.JButton
793 */
794 private JButton getJButtonAddFvImage() {
795 if (jButtonAddFvImage == null) {
796 jButtonAddFvImage = new JButton();
797 jButtonAddFvImage.setPreferredSize(new java.awt.Dimension(120,20));
798 // jButton4.setEnabled(false);
799 jButtonAddFvImage.setText("Add FV Image");
800 jButtonAddFvImage.addActionListener(new AbstractAction() {
801 /**
802 *
803 */
804 private static final long serialVersionUID = 1L;
805
806 public void actionPerformed(java.awt.event.ActionEvent e) {
807 if (jTableFvInfo.isEditing()) {
808 jTableFvInfo.getCellEditor().stopCellEditing();
809 }
810 if (jTableFvImageOpts.isEditing()) {
811 jTableFvImageOpts.getCellEditor().stopCellEditing();
812 }
813 if (jTableFvImageNames.getRowCount()== 0){
814 return;
815 }
816 String imageName = " ";
817 for (int i = 0; i < jTableFvImageNames.getRowCount(); ++i){
818 imageName += (String)jTableFvImageNames.getValueAt(i, 0);
819 imageName += " ";
820 }
821 imageName = imageName.trim();
822
823 if (!jCheckBoxFvImageOpts.isSelected() && jComboBoxFvParaType.getSelectedIndex() != 0){
824 return;
825
826 }
827
828 LinkedHashMap<String, String> m = null;
829 if (jCheckBoxFvImageOpts.isSelected()) {
830 m = new LinkedHashMap<String, String>();
831 getOptionNameValue(m);
832 }
833 ffc.genFvImagesFvImage(imageName.split(" "), jComboBoxFvParaType.getSelectedItem()+"", m);
834 docConsole.setSaved(false);
835 Object[] row = {imageName, jComboBoxFvParaType.getSelectedItem()};
836 fvImageParaTableModel.addRow(row);
837 }
838 });
839 }
840 return jButtonAddFvImage;
841 }
842
843
844 /**
845 * This method initializes jScrollPane3
846 *
847 * @return javax.swing.JScrollPane
848 */
849 private JScrollPane getJScrollPaneFvInfo() {
850 if (jScrollPaneFvInfo == null) {
851 jScrollPaneFvInfo = new JScrollPane();
852 jScrollPaneFvInfo.setPreferredSize(new java.awt.Dimension(480,150));
853 jScrollPaneFvInfo.setViewportView(getJTableFvInfo());
854 }
855 return jScrollPaneFvInfo;
856 }
857
858
859 /**
860 * This method initializes jTable2
861 *
862 * @return javax.swing.JTable
863 */
864 private JTable getJTableFvInfo() {
865 if (jTableFvInfo == null) {
866 fvImageParaTableModel = new ImageParaTableModel();
867 jTableFvInfo = new JTable(fvImageParaTableModel);
868 fvImageParaTableModel.addColumn("FvImageNames");
869 fvImageParaTableModel.addColumn("Type");
870
871
872 TableColumn typeCol = jTableFvInfo.getColumnModel().getColumn(1);
873 JComboBox cb = new JComboBox();
874 cb.addItem("ImageName");
875 cb.addItem("Attributes");
876 cb.addItem("Options");
877 cb.addItem("Components");
878 typeCol.setCellEditor(new DefaultCellEditor(cb));
879
880 jTableFvInfo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
881 jTableFvInfo.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
882 public void valueChanged(ListSelectionEvent e) {
883 if (e.getValueIsAdjusting()){
884 return;
885 }
886 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
887 if (lsm.isSelectionEmpty()) {
888 return;
889 }
890 else{
891 int selectedRow = lsm.getMinSelectionIndex();
892 if (fvImageParaTableModel.getValueAt(selectedRow, 1).equals("ImageName")) {
893 String[] fvNames = fvImageParaTableModel.getValueAt(selectedRow, 0).toString().split(" ");
894 for (int i = 0; i < fvNames.length; ++i) {
895 String[] row = {fvNames[i]};
896 fvImageNameTableModel.addRow(row);
897 }
898 return;
899 }
900 LinkedHashMap<String, String> optionMap = new LinkedHashMap<String, String>();
901 ffc.getFvImagesFvImageOptions(selectedRow, optionMap);
902 if (optionMap.size() > 0){
903 fvOptionTableModel.setRowCount(0);
904 Set<String> key = optionMap.keySet();
905 Iterator<String> i = key.iterator();
906 while (i.hasNext()) {
907
908 String k = (String)i.next();
909 String[] row = {k, optionMap.get(k)};
910
911 fvOptionTableModel.addRow(row);
912 }
913 }
914
915 }
916 }
917 });
918
919
920 }
921 return jTableFvInfo;
922 }
923
924
925 /**
926 * This method initializes jButton6
927 *
928 * @return javax.swing.JButton
929 */
930 private JButton getJButtonDelFvImage() {
931 if (jButtonDelFvImage == null) {
932 jButtonDelFvImage = new JButton();
933 jButtonDelFvImage.setPreferredSize(new java.awt.Dimension(120,20));
934 // jButton6.setEnabled(false);
935 jButtonDelFvImage.setText("Delete Row");
936 jButtonDelFvImage.addActionListener(new AbstractAction() {
937 /**
938 *
939 */
940 private static final long serialVersionUID = 1L;
941
942 public void actionPerformed(ActionEvent arg0) {
943 // TODO Auto-generated method stub
944 if (jTableFvInfo.getSelectedRow() >= 0 ) {
945 ffc.removeFvImagesFvImage(jTableFvInfo.getSelectedRow());
946 fvImageParaTableModel.removeRow(jTableFvInfo.getSelectedRow());
947 docConsole.setSaved(false);
948 }
949 }
950
951 });
952 }
953 return jButtonDelFvImage;
954 }
955
956
957 /**
958 * This method initializes jCheckBox3
959 *
960 * @return javax.swing.JCheckBox
961 */
962 private JCheckBox getJCheckBoxFvImageOpts() {
963 if (jCheckBoxFvImageOpts == null) {
964 jCheckBoxFvImageOpts = new JCheckBox();
965 jCheckBoxFvImageOpts.setText("FV Image Options");
966 jCheckBoxFvImageOpts.addItemListener(new ItemListener(){
967
968 public void itemStateChanged(ItemEvent arg0) {
969 // TODO Auto-generated method stub
970 // boolean selected = jCheckBox3.isSelected();
971
972 if (!jCheckBoxFvImagePara.isSelected() || jComboBoxFvParaType.getSelectedIndex() == 0) {
973 return;
974 }
975
976 }
977
978 });
979 }
980 return jCheckBoxFvImageOpts;
981 }
982
983
984 /**
985 * This method initializes jPanel6
986 *
987 * @return javax.swing.JPanel
988 */
989 private JPanel getJPanelFvImagePara() {
990 if (jPanelFvImagePara == null) {
991 StarLabel starLabel = new StarLabel();
992 starLabel.setVisible(false);
993 jPanelFvImagePara = new JPanel();
994 jPanelFvImagePara.setPreferredSize(new java.awt.Dimension(480,120));
995 jPanelFvImagePara.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
996 jPanelFvImagePara.add(getJCheckBoxFvImagePara(), null);
997 jPanelFvImagePara.add(jLabelFvParaType, null);
998 jPanelFvImagePara.add(getJComboBoxFvParaType(), null);
999 jPanelFvImagePara.add(new StarLabel(), null);
1000 jPanelFvImagePara.add(jLabelFvImageNames, null);
1001 jPanelFvImagePara.add(jLabelFvParaName, null);
1002 jPanelFvImagePara.add(getJTextFieldFvParaName(), null);
1003 jPanelFvImagePara.add(getJButtonFvParaAdd(), null);
1004 jPanelFvImagePara.add(getJScrollPaneFvImageNames(), null);
1005 jPanelFvImagePara.add(getJButtonFvParaDel(), null);
1006 }
1007 return jPanelFvImagePara;
1008 }
1009
1010 /**
1011 * This method initializes jPanel7
1012 *
1013 * @return javax.swing.JPanel
1014 */
1015 private JPanel getJPanelFdf() {
1016 if (jPanelFdf == null) {
1017 jPanelFdf = new JPanel();
1018 jPanelFdf.setLayout(new BorderLayout());
1019
1020 jPanelFdf.add(getJPanelFdfN(), java.awt.BorderLayout.NORTH);
1021 jPanelFdf.add(getJPanelFdfS(), java.awt.BorderLayout.SOUTH);
1022 jPanelFdf.add(getJSplitPaneFdfC(), java.awt.BorderLayout.CENTER);
1023 jPanelFdf.addComponentListener(new ComponentAdapter(){
1024 public void componentShown(ComponentEvent e) {
1025 // if (ffc.getFlashDefinitionFile() != null) {
1026 // jTextFieldFdf.setText(ffc.getFlashDefinitionFile());
1027 // initFvInFdfTable(System.getenv("WORKSPACE") + File.separator + jTextFieldFdf.getText());
1028 //
1029 // }
1030 }
1031 public void componentHidden(ComponentEvent e) {
1032 if (jCheckBoxFdf.isSelected()) {
1033 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());
1034 }
1035 }
1036 });
1037 }
1038 return jPanelFdf;
1039 }
1040
1041 /**
1042 * This method initializes jCheckBox
1043 *
1044 * @return javax.swing.JCheckBox
1045 */
1046 private JCheckBox getJCheckBoxFdf() {
1047 if (jCheckBoxFdf == null) {
1048 jCheckBoxFdf = new JCheckBox();
1049 jCheckBoxFdf.setText("Flash Definition File");
1050 jCheckBoxFdf.addItemListener(new ItemListener() {
1051
1052 public void itemStateChanged(ItemEvent arg0) {
1053 // TODO Auto-generated method stub
1054 if (jCheckBoxFdf.isSelected()){
1055 jTextFieldFdf.setEnabled(true);
1056 jButtonFdfBrowse.setEnabled(true);
1057 }
1058 else {
1059
1060 jTextFieldFdf.setEnabled(false);
1061 jButtonFdfBrowse.setEnabled(false);
1062 }
1063 }
1064 });
1065 }
1066 return jCheckBoxFdf;
1067 }
1068
1069 /**
1070 * This method initializes jTextField3
1071 *
1072 * @return javax.swing.JTextField
1073 */
1074 private JTextField getJTextFieldFdf() {
1075 if (jTextFieldFdf == null) {
1076 jTextFieldFdf = new JTextField();
1077 jTextFieldFdf.setEnabled(false);
1078 jTextFieldFdf.setEditable(false);
1079 jTextFieldFdf.setPreferredSize(new Dimension(300, 20));
1080 jTextFieldFdf.addFocusListener(new java.awt.event.FocusAdapter() {
1081 public void focusLost(java.awt.event.FocusEvent e) {
1082 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());
1083 }
1084 });
1085 }
1086 return jTextFieldFdf;
1087 }
1088
1089 /**
1090 * This method initializes jButton5
1091 *
1092 * @return javax.swing.JButton
1093 */
1094 private JButton getJButtonFdfBrowse() {
1095 if (jButtonFdfBrowse == null) {
1096 jButtonFdfBrowse = new JButton();
1097 jButtonFdfBrowse.setEnabled(false);
1098 jButtonFdfBrowse.setText("Browse");
1099 jButtonFdfBrowse.setPreferredSize(new Dimension(78, 20));
1100 jButtonFdfBrowse.addActionListener(new AbstractAction(){
1101 /**
1102 *
1103 */
1104 private static final long serialVersionUID = 1L;
1105
1106 public void actionPerformed(ActionEvent e) {
1107 // TODO Auto-generated method stub
1108 String wsDir = System.getenv("WORKSPACE");
1109 JFileChooser chooser = new JFileChooser(wsDir);
1110 chooser.setMultiSelectionEnabled(false);
1111 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
1112 int retval = chooser.showOpenDialog(frame);
1113 if (retval == JFileChooser.APPROVE_OPTION) {
1114
1115 File theFile = chooser.getSelectedFile();
1116 String filePath = theFile.getPath();
1117 if (!filePath.startsWith(wsDir)) {
1118 JOptionPane.showMessageDialog(frame, "You can only select files in current WORKSPACE.");
1119 return;
1120 }
1121 jTextFieldFdf.setText(filePath.substring(wsDir.length() + 1).replace('\\', '/'));
1122 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());
1123 docConsole.setSaved(false);
1124 initFvInFdfTable(filePath);
1125 }
1126 }
1127
1128 });
1129 }
1130 return jButtonFdfBrowse;
1131 }
1132
1133 private void initFvAdditionalTable() {
1134
1135 }
1136
1137 private void initFvInFdfTable(String fdfPath){
1138 Vector<FvInfoFromFdf> vFvInfo = new Vector<FvInfoFromFdf>();
1139 getFvInfoFromFdf(fdfPath, vFvInfo);
1140 getFvInFdfTableModel().setRowCount(0);
1141 for (int j = 0; j < vFvInfo.size(); ++j) {
1142 FvInfoFromFdf fvInfo = vFvInfo.get(j);
1143 String[] row = {fvInfo.getFvName(), fvInfo.getSize(), fvInfo.getEfiFileName()};
1144 getFvInFdfTableModel().addRow(row);
1145 }
1146
1147 for (int k = 0; k < vFvInfo.size(); ++k) {
1148 FvInfoFromFdf fvInfo = vFvInfo.get(k);
1149 addTabForFv(fvInfo);
1150 }
1151 }
1152
1153 private void addTabForFv (FvInfoFromFdf fvInfo) {
1154 String fvName = fvInfo.getFvName();
1155 String outputFile = fvInfo.getEfiFileName();
1156 int index = jTabbedPane.indexOfTab(fvName);
1157 if (index >= startIndexOfDynamicTab) {
1158 return;
1159 }
1160 jTabbedPane.addTab(fvName, null, new ModuleOrderPane(fvName, outputFile), null);
1161 }
1162 /**
1163 * This method initializes jTextField4
1164 *
1165 * @return javax.swing.JTextField
1166 */
1167 private JTextField getJTextFieldFvImageOptName() {
1168 if (jTextFieldFvImageOptName == null) {
1169 jTextFieldFvImageOptName = new JTextField();
1170 jTextFieldFvImageOptName.setEnabled(true);
1171 jTextFieldFvImageOptName.setPreferredSize(new Dimension(100, 20));
1172 }
1173 return jTextFieldFvImageOptName;
1174 }
1175
1176 /**
1177 * This method initializes jTextField5
1178 *
1179 * @return javax.swing.JTextField
1180 */
1181 private JTextField getJTextFieldFvImageOptValue() {
1182 if (jTextFieldFvImageOptValue == null) {
1183 jTextFieldFvImageOptValue = new JTextField();
1184 jTextFieldFvImageOptValue.setEnabled(true);
1185 jTextFieldFvImageOptValue.setPreferredSize(new Dimension(100, 20));
1186 }
1187 return jTextFieldFvImageOptValue;
1188 }
1189
1190 /**
1191 * This method initializes jPanel8
1192 *
1193 * @return javax.swing.JPanel
1194 */
1195 private JPanel getJPanelFvImageOptsButtonGroup() {
1196 if (jPanelFvImageOptsButtonGroup == null) {
1197 jPanelFvImageOptsButtonGroup = new JPanel();
1198 jPanelFvImageOptsButtonGroup.setPreferredSize(new Dimension(80, 55));
1199 jPanelFvImageOptsButtonGroup.add(getJButtonFvImageOptAdd(), null);
1200 jPanelFvImageOptsButtonGroup.add(getJButtonFvImageOptDel(), null);
1201 }
1202 return jPanelFvImageOptsButtonGroup;
1203 }
1204
1205 /**
1206 * This method initializes jButton7
1207 *
1208 * @return javax.swing.JButton
1209 */
1210 private JButton getJButtonFvImageOptAdd() {
1211 if (jButtonFvImageOptAdd == null) {
1212 jButtonFvImageOptAdd = new JButton();
1213 jButtonFvImageOptAdd.setEnabled(true);
1214 jButtonFvImageOptAdd.setText("Add");
1215 jButtonFvImageOptAdd.setPreferredSize(new Dimension(80, 20));
1216 jButtonFvImageOptAdd.addActionListener(new AbstractAction() {
1217 /**
1218 *
1219 */
1220 private static final long serialVersionUID = 1L;
1221
1222 public void actionPerformed(ActionEvent e) {
1223 if (jTextFieldFvImageOptName.getText().length() > 0 && jTextFieldFvImageOptValue.getText().length() > 0){
1224 String[] row = {jTextFieldFvImageOptName.getText(), jTextFieldFvImageOptValue.getText()};
1225 fvOptionTableModel.addRow(row);
1226 }
1227 }
1228 });
1229 }
1230 return jButtonFvImageOptAdd;
1231 }
1232
1233 /**
1234 * This method initializes jButton8
1235 *
1236 * @return javax.swing.JButton
1237 */
1238 private JButton getJButtonFvImageOptDel() {
1239 if (jButtonFvImageOptDel == null) {
1240 jButtonFvImageOptDel = new JButton();
1241 jButtonFvImageOptDel.setEnabled(true);
1242 jButtonFvImageOptDel.setText("Delete");
1243 jButtonFvImageOptDel.setPreferredSize(new Dimension(80, 20));
1244 jButtonFvImageOptDel.addActionListener(new AbstractAction() {
1245 /**
1246 *
1247 */
1248 private static final long serialVersionUID = 1L;
1249
1250 public void actionPerformed(ActionEvent e) {
1251 if (jTableFvImageOpts.getSelectedRow() >= 0){
1252 fvOptionTableModel.removeRow(jTableFvProp.getSelectedRow());
1253 }
1254 }
1255 });
1256 }
1257 return jButtonFvImageOptDel;
1258 }
1259
1260 /**
1261 * This method initializes jScrollPane
1262 *
1263 * @return javax.swing.JScrollPane
1264 */
1265 private JScrollPane getJScrollPane() {
1266 if (jScrollPane == null) {
1267 jScrollPane = new JScrollPane();
1268 jScrollPane.setPreferredSize(new java.awt.Dimension(350,80));
1269 jScrollPane.setViewportView(getJTableFvImageOpts());
1270 }
1271 return jScrollPane;
1272 }
1273
1274 /**
1275 * This method initializes jTable3
1276 *
1277 * @return javax.swing.JTable
1278 */
1279 private JTable getJTableFvImageOpts() {
1280 if (jTableFvImageOpts == null) {
1281 fvOptionTableModel = new DefaultTableModel();
1282 fvOptionTableModel.addColumn("Name");
1283 fvOptionTableModel.addColumn("Value");
1284 jTableFvImageOpts = new JTable(fvOptionTableModel);
1285
1286 jTableFvImageOpts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1287 jTableFvImageOpts.setRowHeight(20);
1288
1289 }
1290 return jTableFvImageOpts;
1291 }
1292
1293 /**
1294 * This method initializes jButton9
1295 *
1296 * @return javax.swing.JButton
1297 */
1298 private JButton getJButtonUpdateFvImage() {
1299 if (jButtonUpdateFvImage == null) {
1300 jButtonUpdateFvImage = new JButton();
1301 jButtonUpdateFvImage.setPreferredSize(new Dimension(120, 20));
1302 jButtonUpdateFvImage.setActionCommand("Update");
1303 jButtonUpdateFvImage.setText("Update FV");
1304 jButtonUpdateFvImage.addActionListener(new java.awt.event.ActionListener() {
1305 public void actionPerformed(java.awt.event.ActionEvent e) {
1306 int row = jTableFvInfo.getSelectedRow();
1307 if (jTableFvInfo.isEditing()) {
1308 jTableFvInfo.getCellEditor().stopCellEditing();
1309 }
1310 if (jTableFvImageOpts.isEditing()) {
1311 jTableFvImageOpts.getCellEditor().stopCellEditing();
1312 }
1313
1314 //ToDo Check data validity before update
1315 String name = fvImageParaTableModel.getValueAt(row, 0) + "";
1316 String type = fvImageParaTableModel.getValueAt(row, 1) + "";
1317
1318 LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();
1319 getOptionNameValue(lhm);
1320
1321 docConsole.setSaved(false);
1322 ffc.updateFvImagesFvImage(row, name.split(" "), type, lhm);
1323
1324 }
1325 });
1326 }
1327 return jButtonUpdateFvImage;
1328 }
1329
1330 // private JButton getJButtonTest() {
1331 // if (jButtonTest == null) {
1332 // jButtonTest = new JButton();
1333 // jButtonTest.addActionListener(new java.awt.event.ActionListener() {
1334 // public void actionPerformed(java.awt.event.ActionEvent e) {
1335 // docConsole.setSaved(false);
1336 // String[][] includeModules = {{"1", "a"}, {"2", "b"}};
1337 // ffc.genBuildOptionsUserExtensions("FV_RECOVERY", "FvRecovery.inf", null, includeModules);
1338 // int i = ffc.getUserExtsIncModCount("FV_RECOVERY");
1339 // String[][] saa = new String[i][2];
1340 // ffc.getUserExtsIncMods("FV_RECOVERY", saa);
1341 // jTextFieldFdf.setText(saa[0][0] + saa[0][1] + saa[1][0] + saa[1][1]);
1342 //
1343 // }
1344 // });
1345 // }
1346 // return jButtonTest;
1347 // }
1348
1349 /**
1350 * This method initializes jPanelFdfN
1351 *
1352 * @return javax.swing.JPanel
1353 */
1354 private JPanel getJPanelFdfN() {
1355 if (jPanelFdfN == null) {
1356 jPanelFdfN = new JPanel();
1357 jPanelFdfN.add(getJCheckBoxFdf(), null);
1358 jPanelFdfN.add(getJTextFieldFdf(), null);
1359 jPanelFdfN.add(getJButtonFdfBrowse(), null);
1360 }
1361 return jPanelFdfN;
1362 }
1363
1364 /**
1365 * This method initializes jPanelFdfS
1366 *
1367 * @return javax.swing.JPanel
1368 */
1369 private JPanel getJPanelFdfS() {
1370 if (jPanelFdfS == null) {
1371 FlowLayout flowLayout4 = new FlowLayout();
1372 flowLayout4.setAlignment(java.awt.FlowLayout.RIGHT);
1373 jPanelFdfS = new JPanel();
1374 jPanelFdfS.setLayout(flowLayout4);
1375 jPanelFdfS.add(getJButtonAddFv(), null);
1376 jPanelFdfS.add(getJButtonDelFv(), null);
1377 jPanelFdfS.add(getJButtonAddFvOptions(), null);
1378 }
1379 return jPanelFdfS;
1380 }
1381
1382 /**
1383 * This method initializes jSplitPaneFdfC
1384 *
1385 * @return javax.swing.JSplitPane
1386 */
1387 private JSplitPane getJSplitPaneFdfC() {
1388 if (jSplitPaneFdfC == null) {
1389 jSplitPaneFdfC = new JSplitPane();
1390 jSplitPaneFdfC.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
1391 jSplitPaneFdfC.setDividerSize(5);
1392 jSplitPaneFdfC.setTopComponent(getJPanelFdfCTop());
1393 jSplitPaneFdfC.setBottomComponent(getJPanelFdfCBottom());
1394 jSplitPaneFdfC.setDividerLocation(280);
1395 }
1396 return jSplitPaneFdfC;
1397 }
1398
1399 /**
1400 * This method initializes jPanelFdfCTop
1401 *
1402 * @return javax.swing.JPanel
1403 */
1404 private JPanel getJPanelFdfCTop() {
1405 if (jPanelFdfCTop == null) {
1406 jPanelFdfCTop = new JPanel();
1407 jPanelFdfCTop.setLayout(new BorderLayout());
1408 jPanelFdfCTop.add(getJPanelFdfCTopN(), java.awt.BorderLayout.NORTH);
1409 jPanelFdfCTop.add(getJPanelFdfCTopS(), java.awt.BorderLayout.SOUTH);
1410 jPanelFdfCTop.add(getJPanelFdfCTopC(), java.awt.BorderLayout.CENTER);
1411 }
1412 return jPanelFdfCTop;
1413 }
1414
1415 /**
1416 * This method initializes jPanelFdfCBottom
1417 *
1418 * @return javax.swing.JPanel
1419 */
1420 private JPanel getJPanelFdfCBottom() {
1421 if (jPanelFdfCBottom == null) {
1422 jPanelFdfCBottom = new JPanel();
1423 jPanelFdfCBottom.setLayout(new BorderLayout());
1424 jPanelFdfCBottom.add(getJPanelFdfCBottomN(), java.awt.BorderLayout.NORTH);
1425 jPanelFdfCBottom.add(getJPanelFdfCBottomC(), java.awt.BorderLayout.CENTER);
1426 }
1427 return jPanelFdfCBottom;
1428 }
1429
1430 /**
1431 * This method initializes jPanelFdfCTopN
1432 *
1433 * @return javax.swing.JPanel
1434 */
1435 private JPanel getJPanelFdfCTopN() {
1436 if (jPanelFdfCTopN == null) {
1437 jLabelFvInFdf = new JLabel();
1438 jLabelFvInFdf.setText("FVs in Flash Definition File");
1439 jPanelFdfCTopN = new JPanel();
1440 jPanelFdfCTopN.add(jLabelFvInFdf, null);
1441 }
1442 return jPanelFdfCTopN;
1443 }
1444
1445 /**
1446 * This method initializes jPanelFdfCTopS
1447 *
1448 * @return javax.swing.JPanel
1449 */
1450 private JPanel getJPanelFdfCTopS() {
1451 if (jPanelFdfCTopS == null) {
1452 FlowLayout flowLayout1 = new FlowLayout();
1453 flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
1454 jPanelFdfCTopS = new JPanel();
1455 jPanelFdfCTopS.setLayout(flowLayout1);
1456 jPanelFdfCTopS.add(getJButtonFvInFdfOptions(), null);
1457 }
1458 return jPanelFdfCTopS;
1459 }
1460
1461 /**
1462 * This method initializes jPanelFdfCTopC
1463 *
1464 * @return javax.swing.JPanel
1465 */
1466 private JPanel getJPanelFdfCTopC() {
1467 if (jPanelFdfCTopC == null) {
1468 jPanelFdfCTopC = new JPanel();
1469 jPanelFdfCTopC.add(getJScrollPaneFvInFdf(), null);
1470 }
1471 return jPanelFdfCTopC;
1472 }
1473
1474 /**
1475 * This method initializes jPanelFdfCBottomN
1476 *
1477 * @return javax.swing.JPanel
1478 */
1479 private JPanel getJPanelFdfCBottomN() {
1480 if (jPanelFdfCBottomN == null) {
1481 jLabelFvAdditional = new JLabel();
1482 jLabelFvAdditional.setText("Additional FVs");
1483 jPanelFdfCBottomN = new JPanel();
1484 jPanelFdfCBottomN.add(jLabelFvAdditional, null);
1485 }
1486 return jPanelFdfCBottomN;
1487 }
1488
1489 /**
1490 * This method initializes jPanelFdfCBottomC
1491 *
1492 * @return javax.swing.JPanel
1493 */
1494 private JPanel getJPanelFdfCBottomC() {
1495 if (jPanelFdfCBottomC == null) {
1496 jPanelFdfCBottomC = new JPanel();
1497 jPanelFdfCBottomC.add(getJScrollPaneFvAdditional(), null);
1498 }
1499 return jPanelFdfCBottomC;
1500 }
1501
1502 /**
1503 * This method initializes jScrollPaneFvInFdf
1504 *
1505 * @return javax.swing.JScrollPane
1506 */
1507 private JScrollPane getJScrollPaneFvInFdf() {
1508 if (jScrollPaneFvInFdf == null) {
1509 jScrollPaneFvInFdf = new JScrollPane();
1510 jScrollPaneFvInFdf.setPreferredSize(new java.awt.Dimension(653,200));
1511 jScrollPaneFvInFdf.setViewportView(getJTableFvInFdf());
1512 }
1513 return jScrollPaneFvInFdf;
1514 }
1515
1516 /**
1517 * This method initializes jTableFvInFdf
1518 *
1519 * @return javax.swing.JTable
1520 */
1521 private JTable getJTableFvInFdf() {
1522 if (jTableFvInFdf == null) {
1523 jTableFvInFdf = new JTable();
1524 jTableFvInFdf.setRowHeight(20);
1525 jTableFvInFdf.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
1526 jTableFvInFdf.setModel(getFvInFdfTableModel());
1527 }
1528 return jTableFvInFdf;
1529 }
1530
1531 /**
1532 * This method initializes fvInFdfTableModel
1533 *
1534 * @return org.tianocore.frameworkwizard.platform.ui.NonEditableTableModel
1535 */
1536 private NonEditableTableModel getFvInFdfTableModel() {
1537 if (fvInFdfTableModel == null) {
1538 fvInFdfTableModel = new NonEditableTableModel();
1539 fvInFdfTableModel.addColumn("FV Name");
1540 fvInFdfTableModel.addColumn("Size");
1541 fvInFdfTableModel.addColumn("Corresponding File Name");
1542 }
1543 return fvInFdfTableModel;
1544 }
1545
1546 /**
1547 * This method initializes jButtonFvInFdfOptions
1548 *
1549 * @return javax.swing.JButton
1550 */
1551 private JButton getJButtonFvInFdfOptions() {
1552 if (jButtonFvInFdfOptions == null) {
1553 jButtonFvInFdfOptions = new JButton();
1554 jButtonFvInFdfOptions.setPreferredSize(new java.awt.Dimension(80,20));
1555 jButtonFvInFdfOptions.setEnabled(false);
1556 jButtonFvInFdfOptions.setText("Options");
1557 jButtonFvInFdfOptions.addActionListener(new java.awt.event.ActionListener() {
1558 public void actionPerformed(java.awt.event.ActionEvent e) {
1559 int selectedRow = jTableFvInFdf.getSelectedRow();
1560 if (selectedRow < 0) {
1561 return;
1562 }
1563 }
1564 });
1565 }
1566 return jButtonFvInFdfOptions;
1567 }
1568
1569 /**
1570 * This method initializes jScrollPaneFvAdditional
1571 *
1572 * @return javax.swing.JScrollPane
1573 */
1574 private JScrollPane getJScrollPaneFvAdditional() {
1575 if (jScrollPaneFvAdditional == null) {
1576 jScrollPaneFvAdditional = new JScrollPane();
1577 jScrollPaneFvAdditional.setPreferredSize(new java.awt.Dimension(653,200));
1578 jScrollPaneFvAdditional.setViewportView(getJTableFvAdditional());
1579 }
1580 return jScrollPaneFvAdditional;
1581 }
1582
1583 /**
1584 * This method initializes jTableFvAdditional
1585 *
1586 * @return javax.swing.JTable
1587 */
1588 private JTable getJTableFvAdditional() {
1589 if (jTableFvAdditional == null) {
1590 jTableFvAdditional = new JTable();
1591 jTableFvAdditional.setRowHeight(20);
1592 jTableFvAdditional.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
1593 jTableFvAdditional.setModel(getFvAddtionalTableModel());
1594
1595 jTableFvAdditional.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
1596 public void valueChanged(ListSelectionEvent e) {
1597 if (e.getValueIsAdjusting()) {
1598 return;
1599 }
1600 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1601 if (lsm.isSelectionEmpty()) {
1602 return;
1603 } else {
1604 selectedRowInFvAdditionalTable = lsm.getMinSelectionIndex();
1605 oldFvName = jTableFvAdditional.getValueAt(selectedRowInFvAdditionalTable, 0)+"";
1606 }
1607 }
1608 });
1609
1610 jTableFvAdditional.getModel().addTableModelListener(new TableModelListener() {
1611 public void tableChanged(TableModelEvent arg0) {
1612 // TODO Auto-generated method stub
1613 int row = arg0.getFirstRow();
1614 int col = arg0.getColumn();
1615 TableModel m = (TableModel) arg0.getSource();
1616 if (arg0.getType() == TableModelEvent.UPDATE) {
1617 if (col == 0) {
1618 String newFvName = m.getValueAt(row, 0) + "";
1619 if (newFvName.equals(oldFvName)) {
1620 return;
1621 }
1622 if (fvNameExists(newFvName)) {
1623 JOptionPane.showMessageDialog(frame, "This FV already exists. Please choose another FV name.");
1624 m.setValueAt(oldFvName, row, 0);
1625 return;
1626 }
1627
1628 tabIndexForFv = jTabbedPane.indexOfTab(oldFvName);
1629 if (tabIndexForFv >= startIndexOfDynamicTab) {
1630 jTabbedPane.setTitleAt(tabIndexForFv, newFvName);
1631 // change FvName in UserExtensions
1632 ffc.updateBuildOptionsUserExtensions(oldFvName, newFvName);
1633 // change FvBinding in ModuleSA
1634 ffc.appendFvBindingFor(oldFvName, newFvName);
1635 ffc.removeFvBindingAll(oldFvName);
1636 // change FvImageNames in Flash
1637 ffc.updateFvImageNameAll(oldFvName, newFvName);
1638
1639 } else {
1640 jTabbedPane.addTab(newFvName, new ModuleOrderPane(newFvName, ""));
1641 // Add FvImageNames in Flash
1642 String[] fvNames = {newFvName};
1643 ffc.AddFvImageFvImageNames(fvNames);
1644 }
1645
1646 oldFvName = newFvName;
1647 }
1648 docConsole.setSaved(false);
1649 }
1650 }
1651 });
1652 }
1653 return jTableFvAdditional;
1654 }
1655
1656 private boolean fvNameExists (String fvName) {
1657 for (int i = 0; i < jTableFvInFdf.getRowCount(); ++i) {
1658 if (fvInFdfTableModel.getValueAt(i, 0).equals(fvName)) {
1659 return true;
1660 }
1661 }
1662 for (int j = 0; j < jTableFvAdditional.getRowCount(); ++j) {
1663 if (fvAddtionalTableModel.getValueAt(j, 0).equals(fvName) && j != selectedRowInFvAdditionalTable) {
1664 return true;
1665 }
1666 }
1667 return false;
1668 }
1669
1670 /**
1671 * This method initializes fvAddtionalTableModel
1672 *
1673 * @return javax.swing.table.DefaultTableModel
1674 */
1675 private DefaultTableModel getFvAddtionalTableModel() {
1676 if (fvAddtionalTableModel == null) {
1677 fvAddtionalTableModel = new DefaultTableModel();
1678 fvAddtionalTableModel.addColumn("FV Name");
1679 fvAddtionalTableModel.addColumn("Size");
1680 fvAddtionalTableModel.addColumn("Corresponding File Name");
1681 }
1682 return fvAddtionalTableModel;
1683 }
1684
1685 /**
1686 * This method initializes jButtonAddFv
1687 *
1688 * @return javax.swing.JButton
1689 */
1690 private JButton getJButtonAddFv() {
1691 if (jButtonAddFv == null) {
1692 jButtonAddFv = new JButton();
1693 jButtonAddFv.setPreferredSize(new java.awt.Dimension(80,20));
1694 jButtonAddFv.setEnabled(true);
1695 jButtonAddFv.setText("New");
1696 jButtonAddFv.addActionListener(new java.awt.event.ActionListener() {
1697 public void actionPerformed(java.awt.event.ActionEvent e) {
1698 if (jTableFvAdditional.isEditing()) {
1699 jTableFvAdditional.getCellEditor().stopCellEditing();
1700 }
1701 String[] row = {"", "", ""};
1702 fvAddtionalTableModel.addRow(row);
1703 }
1704 });
1705 }
1706 return jButtonAddFv;
1707 }
1708
1709 /**
1710 * This method initializes jButtonDelFv
1711 *
1712 * @return javax.swing.JButton
1713 */
1714 private JButton getJButtonDelFv() {
1715 if (jButtonDelFv == null) {
1716 jButtonDelFv = new JButton();
1717 jButtonDelFv.setPreferredSize(new java.awt.Dimension(80,20));
1718 jButtonDelFv.setEnabled(false);
1719 jButtonDelFv.setText("Delete");
1720 jButtonDelFv.addActionListener(new java.awt.event.ActionListener() {
1721 public void actionPerformed(java.awt.event.ActionEvent e) {
1722 System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
1723 }
1724 });
1725 }
1726 return jButtonDelFv;
1727 }
1728
1729 /**
1730 * This method initializes jButtonAddFvOptions
1731 *
1732 * @return javax.swing.JButton
1733 */
1734 private JButton getJButtonAddFvOptions() {
1735 if (jButtonAddFvOptions == null) {
1736 jButtonAddFvOptions = new JButton();
1737 jButtonAddFvOptions.setPreferredSize(new java.awt.Dimension(80,20));
1738 jButtonAddFvOptions.setEnabled(false);
1739 jButtonAddFvOptions.setText("Options");
1740 jButtonAddFvOptions.addActionListener(new java.awt.event.ActionListener() {
1741 public void actionPerformed(java.awt.event.ActionEvent e) {
1742 System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
1743 }
1744 });
1745 }
1746 return jButtonAddFvOptions;
1747 }
1748
1749 /**
1750 * @param args
1751 */
1752 public static void main(String[] args) {
1753 // TODO Auto-generated method stub
1754 new FpdFlash().setVisible(true);
1755 }
1756
1757 /**
1758 * This method initializes this
1759 *
1760 * @return void
1761 */
1762 private void initialize() {
1763 this.setSize(518, 650);
1764 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
1765 this.setContentPane(getJContentPane());
1766 this.setTitle("FPD Flash Definitions");
1767 this.addInternalFrameListener(new InternalFrameAdapter(){
1768 public void internalFrameDeactivated(InternalFrameEvent e){
1769 if (jTableFvProp.isEditing()) {
1770 jTableFvProp.getCellEditor().stopCellEditing();
1771 }
1772 if (jTableFvImageNames.isEditing()) {
1773 jTableFvImageNames.getCellEditor().stopCellEditing();
1774 }
1775 if (jTableFvInfo.isEditing()) {
1776 jTableFvInfo.getCellEditor().stopCellEditing();
1777 }
1778 }
1779 });
1780 }
1781
1782 private void init(FpdFileContents ffc) {
1783
1784 jTextFieldFdf.setText("");
1785 String fdfFile = ffc.getFlashDefinitionFile();
1786 if (fdfFile != null) {
1787 jTextFieldFdf.setText(fdfFile);
1788 }
1789
1790 String fdfPath = System.getenv("WORKSPACE") + File.separator + fdfFile;
1791 initFvInFdfTable(fdfPath);
1792 initFvAdditionalTable();
1793 }
1794
1795 private void getOptionNameValue(Map<String, String> m){
1796 for (int i = 0; i < jTableFvImageOpts.getRowCount(); ++i) {
1797 m.put(fvOptionTableModel.getValueAt(i, 0)+"", fvOptionTableModel.getValueAt(i, 1)+"");
1798 }
1799 }
1800 /**
1801 * This method initializes jContentPane
1802 *
1803 * @return javax.swing.JPanel
1804 */
1805 private JPanel getJContentPane() {
1806 if (jContentPane == null) {
1807 jContentPane = new JPanel();
1808 jContentPane.setLayout(new BorderLayout());
1809 jContentPane.add(getJPanelContentEast(), java.awt.BorderLayout.EAST);
1810 jContentPane.add(getJPanelContentSouth(), java.awt.BorderLayout.SOUTH);
1811 jContentPane.add(getJPanelContentWest(), java.awt.BorderLayout.WEST);
1812 jContentPane.add(getJPanelContentNorth(), java.awt.BorderLayout.NORTH);
1813 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
1814 }
1815 return jContentPane;
1816 }
1817
1818 private void getFvInfoFromFdf(String fdfPath, Vector<FvInfoFromFdf> vFvInfo) {
1819 File fdf = new File(fdfPath);
1820 if (!fdf.exists()) {
1821 return;
1822 }
1823 int lines = 0;
1824
1825 try {
1826 FileReader reader = new FileReader(fdf);
1827 BufferedReader in = new BufferedReader(reader);
1828 String str;
1829
1830 while ((str = in.readLine()) != null) {
1831 ++lines;
1832 str = str.trim();
1833 //
1834 // skip empty line, comment (start with //)
1835 //
1836 if (str.length() == 0 || str.startsWith("//")) {
1837 continue;
1838 }
1839 //
1840 // dig into Region {} section, create FvInfoFromFdf object for it.
1841 //
1842 if (str.startsWith("Region") && str.endsWith("{")) {
1843 FvInfoFromFdf fvInfo = new FvInfoFromFdf();
1844 boolean nameFound = false;
1845 boolean sizeFound = false;
1846 while ((str = in.readLine()) != null) {
1847 ++lines;
1848 str = str.trim();
1849 //
1850 // skip empty line, comment (start with //)
1851 //
1852 if (str.length() == 0 || str.startsWith("//")) {
1853 continue;
1854 }
1855
1856 if (str.startsWith("Name")) {
1857 int firstQuote = str.indexOf("\"");
1858 int lastQuote = str.lastIndexOf("\"");
1859 fvInfo.setFvName(str.substring(firstQuote + 1, lastQuote));
1860 nameFound = true;
1861 }
1862
1863 if (str.startsWith("Size")) {
1864 int equalIndex = str.indexOf("=");
1865 int commaIndex = str.indexOf(",");
1866 fvInfo.setSize(str.substring(equalIndex + 1, commaIndex).trim());
1867 sizeFound = true;
1868 }
1869
1870 if (nameFound && sizeFound) {
1871 break;
1872 }
1873 }
1874
1875 vFvInfo.add(fvInfo);
1876 }
1877 //
1878 // dig into File {} section, supply file name information to existing FvInfoFromFdf object.
1879 //
1880 if (str.startsWith("File")) {
1881 boolean fileNameFound = false;
1882 boolean fvFound = false;
1883 String fileName = "";
1884 String fvName = "";
1885 while ((str = in.readLine()) != null) {
1886 ++lines;
1887 str = str.trim();
1888 //
1889 // skip empty line, comment (start with //)
1890 //
1891 if (str.length() == 0 || str.startsWith("//")) {
1892 continue;
1893 }
1894
1895 if (str.startsWith("Name")) {
1896 int firstQuote = str.indexOf("\"");
1897 int lastQuote = str.lastIndexOf("\"");
1898 fileName = str.substring(firstQuote + 1, lastQuote);
1899 fileNameFound = true;
1900 }
1901
1902 if (str.startsWith("Region")) {
1903 int firstQuote = str.indexOf("\"");
1904 int lastQuote = str.lastIndexOf("\"");
1905 fvName = str.substring(firstQuote + 1, lastQuote);
1906 fvFound = true;
1907 }
1908
1909 if (fileNameFound && fvFound) {
1910 break;
1911 }
1912 }
1913
1914 for (int i = 0; i <vFvInfo.size(); ++i) {
1915 if (vFvInfo.get(i).getFvName().equals(fvName)) {
1916 vFvInfo.get(i).setEfiFileName(fileName);
1917 }
1918 }
1919 }
1920
1921 }
1922
1923 reader.close();
1924 in.close();
1925 }
1926 catch (Exception e) {
1927
1928 }
1929
1930 }
1931
1932 private class ModuleOrderPane extends JPanel {
1933
1934 /**
1935 *
1936 */
1937 private static final long serialVersionUID = 1L;
1938 private JPanel jPanelModOrderN = null;
1939 private JPanel jPanelModOrderS = null;
1940 private JPanel jPanelModOrderC = null;
1941 private JScrollPane jScrollPaneModInFv = null;
1942 private JTable jTableModInFv = null;
1943 private JPanel jPanelController = null;
1944 private JScrollPane jScrollPaneFpdModules = null;
1945 private JTable jTableFpdModules = null;
1946 private JButton jButtonUp = null;
1947 private JButton jButtonInsert = null;
1948 private JButton jButtonRemove = null;
1949 private JButton jButtonDown = null;
1950 private JButton jButtonOk = null;
1951 private JButton jButtonCancel = null;
1952 private NonEditableTableModel modInFvTableModel = null;
1953 private NonEditableTableModel fpdModTableModel = null;
1954 private HashMap<String, ModuleIdentification> mGuidToModuleId = null;
1955 private ArrayList<String> listModGuidInFv = null;
1956 private String title = null;
1957 private String outputFileName = null;
1958
1959 public ModuleOrderPane(String tabTitle, String file) {
1960 super(new BorderLayout());
1961 title = tabTitle;
1962 outputFileName = file;
1963 mGuidToModuleId = new HashMap<String, ModuleIdentification>();
1964 listModGuidInFv = new ArrayList<String>();
1965 add(getJPanelModOrderN(), java.awt.BorderLayout.NORTH);
1966 add(getJPanelModOrderS(), java.awt.BorderLayout.SOUTH);
1967 add(getJPanelModOrderC(), java.awt.BorderLayout.CENTER);
1968 showModulesInFv(title);
1969 showAllModulesInPlatform();
1970 }
1971
1972 private void showModulesInFv(String fvName) {
1973 int size = ffc.getUserExtsIncModCount(fvName);
1974
1975 if (size != -1) {
1976 String[][] saa = new String[size][2];
1977 ffc.getUserExtsIncMods(fvName, saa);
1978
1979 for (int i = 0; i < size; ++i) {
1980 listModGuidInFv.add(saa[i][0].toLowerCase());
1981 String name = getModuleName(saa[i][0]);
1982 String[] row = { name };
1983 modInFvTableModel.addRow(row);
1984 }
1985 }
1986 //
1987 // From ModuleSAs, get module guids with FvBinding = fvName.
1988 //
1989 Vector<String> vGuid = new Vector<String>();
1990 ffc.getFrameworkModuleGuid(fvName, vGuid);
1991 //
1992 // If BuildOptions->UserExtensions already contain these module info,
1993 // no need to add them into table again.
1994 //
1995 Iterator<String> iter = vGuid.iterator();
1996 while (iter.hasNext()){
1997 String guid = iter.next();
1998 // String moduleName = getModuleName(guid);
1999 // if (existedInTable(moduleName, modInFvTableModel)) {
2000 // vGuid.remove(guid);
2001 // }
2002 if (!listModGuidInFv.contains(guid.toLowerCase())) {
2003 String[] row = {getModuleName(guid)};
2004 modInFvTableModel.addRow(row);
2005 }
2006 }
2007
2008 }
2009
2010 private void showAllModulesInPlatform() {
2011 int size = ffc.getFrameworkModulesCount();
2012 String[][] saa = new String[size][5];
2013 ffc.getFrameworkModulesInfo(saa);
2014
2015 for (int i = 0; i < size; ++i) {
2016 String name = getModuleName(saa[i][0]);
2017 if (existedInTable(name, modInFvTableModel) || existedInTable(name, fpdModTableModel)) {
2018 continue;
2019 }
2020 String[] row = {name};
2021 fpdModTableModel.addRow(row);
2022 }
2023
2024 TableSorter sorter = (TableSorter)jTableFpdModules.getModel();
2025 sorter.setSortState(0, TableSorter.ASCENDING);
2026 }
2027
2028 private String getModuleName (String guid) {
2029
2030 for (int i = 0; i < GlobalData.vModuleList.size(); ++i) {
2031 ModuleIdentification mi = GlobalData.vModuleList.get(i);
2032 String mg = mi.getGuid();
2033 if (mg == null) {
2034 continue;
2035 }
2036 if (mg.equalsIgnoreCase(guid)) {
2037 mGuidToModuleId.put(guid.toLowerCase(), mi);
2038 return mi.getName();
2039 }
2040 }
2041
2042 return "";
2043 }
2044
2045 private boolean existedInTable (String name, DefaultTableModel model) {
2046 int size = model.getDataVector().size();
2047 for (int i = 0; i < size; ++i) {
2048 if (((Vector)model.getDataVector().elementAt(i)).contains(name)) {
2049 return true;
2050 }
2051 }
2052 return false;
2053 }
2054
2055
2056
2057 /**
2058 * This method initializes jPanelModOrderN
2059 *
2060 * @return javax.swing.JPanel
2061 */
2062 private JPanel getJPanelModOrderN() {
2063 if (jPanelModOrderN == null) {
2064 jPanelModOrderN = new JPanel();
2065 }
2066 return jPanelModOrderN;
2067 }
2068
2069 /**
2070 * This method initializes jPanelModOrderS
2071 *
2072 * @return javax.swing.JPanel
2073 */
2074 private JPanel getJPanelModOrderS() {
2075 if (jPanelModOrderS == null) {
2076 FlowLayout flowLayout6 = new FlowLayout();
2077 flowLayout6.setAlignment(java.awt.FlowLayout.RIGHT);
2078 jPanelModOrderS = new JPanel();
2079 jPanelModOrderS.setLayout(flowLayout6);
2080 jPanelModOrderS.add(getJButtonOk(), null);
2081 jPanelModOrderS.add(getJButtonCancel(), null);
2082 }
2083 return jPanelModOrderS;
2084 }
2085
2086 /**
2087 * This method initializes jPanelModOrderC
2088 *
2089 * @return javax.swing.JPanel
2090 */
2091 private JPanel getJPanelModOrderC() {
2092 if (jPanelModOrderC == null) {
2093 jPanelModOrderC = new JPanel();
2094 jPanelModOrderC.add(getJScrollPaneModInFv(), null);
2095 jPanelModOrderC.add(getJPanelController(), null);
2096 jPanelModOrderC.add(getJScrollPaneFpdModules(), null);
2097 }
2098 return jPanelModOrderC;
2099 }
2100
2101 /**
2102 * This method initializes jScrollPaneModInFv
2103 *
2104 * @return javax.swing.JScrollPane
2105 */
2106 private JScrollPane getJScrollPaneModInFv() {
2107 if (jScrollPaneModInFv == null) {
2108 jScrollPaneModInFv = new JScrollPane();
2109 jScrollPaneModInFv.setPreferredSize(new java.awt.Dimension(200,500));
2110 jScrollPaneModInFv.setViewportView(getJTableModInFv());
2111 }
2112 return jScrollPaneModInFv;
2113 }
2114
2115 /**
2116 * This method initializes jTableModInFv
2117 *
2118 * @return javax.swing.JTable
2119 */
2120 private JTable getJTableModInFv() {
2121 if (jTableModInFv == null) {
2122 modInFvTableModel = new NonEditableTableModel();
2123 modInFvTableModel.addColumn("Module Orders in FV");
2124 jTableModInFv = new JTable(modInFvTableModel);
2125 jTableModInFv.setRowHeight(20);
2126 jTableModInFv.setShowGrid(false);
2127
2128 }
2129 return jTableModInFv;
2130 }
2131
2132 /**
2133 * This method initializes jPanelController
2134 *
2135 * @return javax.swing.JPanel
2136 */
2137 private JPanel getJPanelController() {
2138 if (jPanelController == null) {
2139 FlowLayout flowLayout5 = new FlowLayout();
2140 flowLayout5.setVgap(50);
2141 flowLayout5.setHgap(50);
2142 jPanelController = new JPanel();
2143 jPanelController.setLayout(flowLayout5);
2144 jPanelController.setPreferredSize(new java.awt.Dimension(150,500));
2145 jPanelController.add(getJButtonUp(), null);
2146 jPanelController.add(getJButtonInsert(), null);
2147 jPanelController.add(getJButtonRemove(), null);
2148 jPanelController.add(getJButtonDown(), null);
2149 }
2150 return jPanelController;
2151 }
2152
2153 /**
2154 * This method initializes jScrollPaneFpdModules
2155 *
2156 * @return javax.swing.JScrollPane
2157 */
2158 private JScrollPane getJScrollPaneFpdModules() {
2159 if (jScrollPaneFpdModules == null) {
2160 jScrollPaneFpdModules = new JScrollPane();
2161 jScrollPaneFpdModules.setPreferredSize(new java.awt.Dimension(200,500));
2162 jScrollPaneFpdModules.setViewportView(getJTableFpdModules());
2163 }
2164 return jScrollPaneFpdModules;
2165 }
2166
2167 /**
2168 * This method initializes jTableFpdModules
2169 *
2170 * @return javax.swing.JTable
2171 */
2172 private JTable getJTableFpdModules() {
2173 if (jTableFpdModules == null) {
2174 fpdModTableModel = new NonEditableTableModel();
2175 TableSorter sorter = new TableSorter(fpdModTableModel);
2176 jTableFpdModules = new JTable(sorter);
2177 jTableFpdModules.setRowHeight(20);
2178 jTableFpdModules.setShowGrid(false);
2179 fpdModTableModel.addColumn("Modules in Platform");
2180
2181 }
2182 return jTableFpdModules;
2183 }
2184
2185 /**
2186 * This method initializes jButtonUp
2187 *
2188 * @return javax.swing.JButton
2189 */
2190 private JButton getJButtonUp() {
2191 if (jButtonUp == null) {
2192 jButtonUp = new JButton();
2193 jButtonUp.setPreferredSize(new java.awt.Dimension(60,20));
2194 jButtonUp.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 14));
2195 jButtonUp.setText("^");
2196 jButtonUp.addActionListener(new java.awt.event.ActionListener() {
2197 public void actionPerformed(java.awt.event.ActionEvent e) {
2198 int selectedRow = jTableModInFv.getSelectedRow();
2199 if (selectedRow <= 0) {
2200 return;
2201 }
2202 modInFvTableModel.moveRow(selectedRow, selectedRow, selectedRow - 1);
2203 jTableModInFv.changeSelection(selectedRow - 1, 0, false, false);
2204 }
2205 });
2206 }
2207 return jButtonUp;
2208 }
2209
2210 /**
2211 * This method initializes jButtonInsert
2212 *
2213 * @return javax.swing.JButton
2214 */
2215 private JButton getJButtonInsert() {
2216 if (jButtonInsert == null) {
2217 jButtonInsert = new JButton();
2218 jButtonInsert.setText("<<");
2219 jButtonInsert.setPreferredSize(new java.awt.Dimension(60,20));
2220 jButtonInsert.addActionListener(new java.awt.event.ActionListener() {
2221 public void actionPerformed(java.awt.event.ActionEvent e) {
2222 int selectedRowRight = jTableFpdModules.getSelectedRow();
2223 if (selectedRowRight < 0) {
2224 return;
2225 }
2226
2227 int rowInModel = ((TableSorter)jTableFpdModules.getModel()).getModelRowIndex(selectedRowRight);
2228
2229 String[] row = {jTableFpdModules.getValueAt(selectedRowRight, 0)+""};
2230 int selectedRowLeft = jTableModInFv.getSelectedRow();
2231 if (selectedRowLeft < 0) {
2232 modInFvTableModel.addRow(row);
2233 jTableModInFv.changeSelection(jTableModInFv.getRowCount() - 1, 0, false, false);
2234 }
2235 else {
2236 modInFvTableModel.insertRow(selectedRowLeft, row);
2237 jTableModInFv.changeSelection(selectedRowLeft, 0, false, false);
2238 }
2239 fpdModTableModel.removeRow(rowInModel);
2240 }
2241 });
2242 }
2243 return jButtonInsert;
2244 }
2245
2246 /**
2247 * This method initializes jButtonRemove
2248 *
2249 * @return javax.swing.JButton
2250 */
2251 private JButton getJButtonRemove() {
2252 if (jButtonRemove == null) {
2253 jButtonRemove = new JButton();
2254 jButtonRemove.setPreferredSize(new java.awt.Dimension(60,20));
2255 jButtonRemove.setText(">>");
2256 jButtonRemove.addActionListener(new java.awt.event.ActionListener() {
2257 public void actionPerformed(java.awt.event.ActionEvent e) {
2258 int selectedRowLeft = jTableModInFv.getSelectedRow();
2259 if (selectedRowLeft < 0) {
2260 return;
2261 }
2262
2263 String[] row = {jTableModInFv.getValueAt(selectedRowLeft, 0)+""};
2264 fpdModTableModel.addRow(row);
2265 int viewIndex = ((TableSorter) jTableFpdModules.getModel()).getViewIndexArray()[jTableFpdModules
2266 .getRowCount() - 1];
2267 jTableFpdModules.changeSelection(viewIndex, 0, false, false);
2268 modInFvTableModel.removeRow(selectedRowLeft);
2269 }
2270 });
2271 }
2272 return jButtonRemove;
2273 }
2274
2275 /**
2276 * This method initializes jButtonDown
2277 *
2278 * @return javax.swing.JButton
2279 */
2280 private JButton getJButtonDown() {
2281 if (jButtonDown == null) {
2282 jButtonDown = new JButton();
2283 jButtonDown.setPreferredSize(new java.awt.Dimension(60,20));
2284 jButtonDown.setFont(new java.awt.Font("Dialog", java.awt.Font.BOLD, 10));
2285 jButtonDown.setText("v");
2286 jButtonDown.addActionListener(new java.awt.event.ActionListener() {
2287 public void actionPerformed(java.awt.event.ActionEvent e) {
2288 int selectedRow = jTableModInFv.getSelectedRow();
2289 if (selectedRow >= jTableModInFv.getRowCount() - 1) {
2290 return;
2291 }
2292 modInFvTableModel.moveRow(selectedRow, selectedRow, selectedRow + 1);
2293 jTableModInFv.changeSelection(selectedRow + 1, 0, false, false);
2294 }
2295 });
2296 }
2297 return jButtonDown;
2298 }
2299
2300 /**
2301 * This method initializes jButtonOk
2302 *
2303 * @return javax.swing.JButton
2304 */
2305 private JButton getJButtonOk() {
2306 if (jButtonOk == null) {
2307 jButtonOk = new JButton();
2308 jButtonOk.setPreferredSize(new java.awt.Dimension(80,20));
2309 jButtonOk.setText("Ok");
2310 jButtonOk.addActionListener(new java.awt.event.ActionListener() {
2311 public void actionPerformed(java.awt.event.ActionEvent e) {
2312 // need reset FvBindings in ModuleSA.
2313 ffc.removeFvBindingAll(title);
2314 //
2315 // collect module order information to store them into <BuildOptions> -> <UserExtensions>.
2316 // also update the FvBinding info in <ModuleSA>.
2317 //
2318 Vector<String[]> vModInFv = new Vector<String[]>();
2319 for (int i = 0; i < jTableModInFv.getRowCount(); ++i) {
2320 String moduleName = jTableModInFv.getValueAt(i, 0)+"";
2321 if (moduleName.length() == 0) {
2322 continue;
2323 }
2324 ModuleIdentification mi = null;
2325 Set<String> key = mGuidToModuleId.keySet();
2326 Iterator<String> iter = key.iterator();
2327 while (iter.hasNext()) {
2328 String guid = iter.next();
2329 mi = mGuidToModuleId.get(guid);
2330 if (mi.getName().equals(moduleName)) {
2331 String[] sa = {guid, WorkspaceProfile.getModuleBaseName(mi)};
2332 vModInFv.add(sa);
2333 ffc.updateFvBindingInModuleSA (mi, title);
2334 break;
2335 }
2336 }
2337
2338 }
2339 ffc.removeBuildOptionsUserExtensions(title);
2340 ffc.genBuildOptionsUserExtensions(title, outputFileName, vModInFv);
2341
2342 docConsole.setSaved(false);
2343 jTabbedPane.setSelectedIndex(0);
2344 }
2345 });
2346 }
2347 return jButtonOk;
2348 }
2349
2350 /**
2351 * This method initializes jButtonCancel
2352 *
2353 * @return javax.swing.JButton
2354 */
2355 private JButton getJButtonCancel() {
2356 if (jButtonCancel == null) {
2357 jButtonCancel = new JButton();
2358 jButtonCancel.setPreferredSize(new java.awt.Dimension(80,20));
2359 jButtonCancel.setText("Cancel");
2360 jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
2361 public void actionPerformed(java.awt.event.ActionEvent e) {
2362 jTabbedPane.setSelectedIndex(0);
2363 }
2364 });
2365 }
2366 return jButtonCancel;
2367 }
2368 }
2369
2370 } // @jve:decl-index=0:visual-constraint="10,10"
2371
2372 class ImageParaTableModel extends DefaultTableModel {
2373
2374 private static final long serialVersionUID = 1L;
2375
2376 public boolean isCellEditable(int row, int col) {
2377 if (getValueAt(row, 1).equals("ImageName") && col >=1) {
2378 return false;
2379 }
2380 return true;
2381 }
2382 }
2383
2384 class FvInfoFromFdf {
2385 private String fvName;
2386 private String size;
2387 private String efiFileName;
2388
2389 public FvInfoFromFdf () {
2390 fvName = "";
2391 size = "";
2392 efiFileName = "";
2393 }
2394 public FvInfoFromFdf (String f, String s, String e) {
2395 this();
2396 fvName = f;
2397 size = s;
2398 efiFileName = e;
2399 }
2400 public String getEfiFileName() {
2401 return efiFileName;
2402 }
2403 public void setEfiFileName(String efiFileName) {
2404 this.efiFileName = efiFileName;
2405 }
2406 public String getFvName() {
2407 return fvName;
2408 }
2409 public void setFvName(String fvName) {
2410 this.fvName = fvName;
2411 }
2412 public String getSize() {
2413 return size;
2414 }
2415 public void setSize(String size) {
2416 this.size = size;
2417 }
2418
2419 }