a880ae41f24e4c061de311c12c65ee2c3eabd493
[mirror_edk2.git] / Tools / Java / 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.JFileChooser;
20 import javax.swing.JFrame;
21 import javax.swing.JOptionPane;
22 import javax.swing.JTabbedPane;
23 import javax.swing.JButton;
24 import javax.swing.ListSelectionModel;
25
26 import org.tianocore.PlatformSurfaceAreaDocument;
27 import org.tianocore.frameworkwizard.common.DataValidation;
28 import org.tianocore.frameworkwizard.common.IDefaultTableModel;
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.global.WorkspaceProfile;
34
35 import java.awt.FlowLayout;
36 import java.awt.event.ActionEvent;
37 import java.awt.event.ComponentAdapter;
38 import java.awt.event.ComponentEvent;
39 import java.awt.event.ItemEvent;
40 import java.awt.event.ItemListener;
41 import java.awt.event.MouseAdapter;
42 import java.awt.event.MouseEvent;
43 import java.io.BufferedReader;
44 import java.io.File;
45 import java.io.FileReader;
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.TableModel;
67 import javax.swing.JComboBox;
68 import java.awt.Dimension;
69 import javax.swing.JSplitPane;
70
71 public class FpdFlash extends IInternalFrame {
72
73 /**
74 *
75 */
76 private static final long serialVersionUID = 1L;
77 private final int startIndexOfDynamicTab = 2;
78 static JFrame frame;
79 private JPanel jContentPane = null;
80 private JPanel jPanelContentEast = null;
81 private JPanel jPanelContentSouth = null;
82 private JPanel jPanelContentWest = null;
83 private JPanel jPanelContentNorth = null;
84 private JTabbedPane jTabbedPane = null;
85 private JPanel jPanelFvImages = null;
86 private JPanel jPanelFvImageS = null;
87 private JPanel jPanelFvImageN = null;
88 private JCheckBox jCheckBoxFvProperty = null;
89 private JLabel jLabelFvPropName = null;
90 private JTextField jTextFieldFvPropName = null;
91 private JLabel jLabelFvPropValue = null;
92 private JTextField jTextFieldFvPropValue = null;
93 private JButton jButtonFvPropAdd = null;
94 private JScrollPane jScrollPaneFvProp = null;
95 private JTable jTableFvProp = null;
96 private JPanel jPanelFvPropButtonGroup = null;
97 private JButton jButtonFvPropDel = null;
98 private DefaultTableModel fvPropertyTableModel = null;
99 private DefaultTableModel fvImageNameTableModel = null;
100 private ImageParaTableModel fvImageParaTableModel = null;
101 private DefaultTableModel fvOptionTableModel = null;
102 private JPanel jPanelFvImageC = null;
103 private JLabel jLabelFvParaType = null;
104 private JComboBox jComboBoxFvParaType = null;
105 private JLabel jLabelFvImageNames = null;
106 private JLabel jLabelFvParaName = null;
107 private JTextField jTextFieldFvParaName = null;
108 private JButton jButtonFvNameAdd = null;
109 private JScrollPane jScrollPaneFvImageNames = null;
110 private JTable jTableFvImageNames = null;
111 private JButton jButtonFvNameDel = null;
112 private JPanel jPanelFvImageOpts = null;
113 private JButton jButtonAddFvImage = null;
114 private JScrollPane jScrollPaneFvInfo = null;
115 private JTable jTableFvInfo = null;
116 private JButton jButtonDelFvImage = null;
117 private JPanel jPanelFvImagePara = null;
118 private OpeningPlatformType docConsole = null;
119 private FpdFileContents ffc = null;
120 private JPanel jPanelFdf = null;
121 private JCheckBox jCheckBoxFdf = null;
122 private JTextField jTextFieldFdf = null;
123 private JButton jButtonFdfBrowse = null;
124 private JLabel jLabelFvImageOptName = null;
125 private JTextField jTextFieldFvImageOptName = null;
126 private JLabel jLabelFvImageOptValue = null;
127 private JTextField jTextFieldFvImageOptValue = null;
128 private JPanel jPanelFvImageOptsButtonGroup = null;
129 private JButton jButtonFvImageOptAdd = null;
130 private JButton jButtonFvImageOptDel = null;
131 private JScrollPane jScrollPane = null;
132 private JTable jTableFvImageOpts = null;
133 private JButton jButtonUpdateFvImage = null;
134 private JPanel jPanelFdfN = null;
135 private JPanel jPanelFdfS = null;
136 private JSplitPane jSplitPaneFdfC = null;
137 private JPanel jPanelFdfCTop = null;
138 private JPanel jPanelFdfCBottom = null;
139 private JPanel jPanelFdfCTopN = null;
140 private JPanel jPanelFdfCTopS = null;
141 // private JPanel jPanelFdfCTopC = null;
142 private JPanel jPanelFdfCBottomN = null;
143 // private JPanel jPanelFdfCBottomC = null;
144 private JLabel jLabelFvInFdf = null;
145 private JLabel jLabelFvAdditional = null;
146 private JScrollPane jScrollPaneFvInFdf = null;
147 private JTable jTableFvInFdf = null;
148 private IDefaultTableModel fvInFdfTableModel = null; // @jve:decl-index=0:visual-constraint=""
149 private JButton jButtonFvInFdfOptions = null;
150 private JScrollPane jScrollPaneFvAdditional = null;
151 private JTable jTableFvAdditional = null;
152 private DefaultTableModel fvAdditionalTableModel = null; // @jve:decl-index=0:visual-constraint=""
153 private JButton jButtonAddFv = null;
154 private JButton jButtonDelFv = null;
155 private JButton jButtonAddFvOptions = null;
156 private int tabIndexForFv = -1;
157 private int selectedRowInFvAdditionalTable = -1;
158 private String oldFvName = null;
159 private Vector<String> vBlockSize = new Vector<String>();
160 private String determinedFvBlockSize = null;
161 private final String defaultBlkSize = "0x10000";
162 private String erasePolarity = "";
163 boolean memModified = false;
164 private FvOptsTableModel fvInFdfOptTableModel = null;
165 private FvOptsTableModel fvAdditionalOptTableModel = null;
166 private boolean sizeFromOptionDlg = false;
167 private boolean fileFromOptionDlg = false;
168 private JLabel jLabelOptions = null;
169 private JPanel jPanelBgFvName = null;
170 private JPanel jPanelBgFvImage = null;
171 private JPanel jPanelW = null;
172 private JPanel jPanelFvImageParaN = null;
173 private JPanel jPanelFvImageParaS = null;
174 // private JPanel jPanelFvImageParaC = null;
175 private JPanel jPanelFvImageOptsN = null;
176 private JPanel jPanelFvImageOptsS = null;
177 // private JPanel jPanelFvImageOptsC = null;
178 private JPanel jPanelFvImageParaE = null;
179 private JPanel jPanelFvImageOptsE = null;
180 private JPanel jPanelFvImageSN = null;
181 private JPanel jPanelFvImageSE = null;
182 private JPanel jPanelFvImageSS = null;
183
184 public FpdFlash() {
185 super();
186 // TODO Auto-generated constructor stub
187
188 initialize();
189 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));
190 this.setVisible(true);
191 }
192
193 public FpdFlash(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd){
194 this();
195 ffc = new FpdFileContents(fpd);
196 init(ffc);
197 }
198
199 public FpdFlash(OpeningPlatformType opt) {
200 this(opt.getXmlFpd());
201 docConsole = opt;
202 if (memModified) {
203 docConsole.setSaved(false);
204 JOptionPane.showMessageDialog(frame, "Platform Synced with FDF file.");
205 memModified = false;
206 }
207 }
208
209 /**
210 * This method initializes jPanel
211 *
212 * @return javax.swing.JPanel
213 */
214 private JPanel getJPanelContentEast() {
215 if (jPanelContentEast == null) {
216 FlowLayout flowLayout7 = new FlowLayout();
217 flowLayout7.setVgap(50);
218 jPanelContentEast = new JPanel();
219 jPanelContentEast.setLayout(flowLayout7);
220 }
221 return jPanelContentEast;
222 }
223
224 /**
225 * This method initializes jPanel1
226 *
227 * @return javax.swing.JPanel
228 */
229 private JPanel getJPanelContentSouth() {
230 if (jPanelContentSouth == null) {
231 FlowLayout flowLayout = new FlowLayout();
232 flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
233 flowLayout.setHgap(15);
234 jPanelContentSouth = new JPanel();
235 jPanelContentSouth.setLayout(flowLayout);
236 jPanelContentSouth.setComponentOrientation(java.awt.ComponentOrientation.LEFT_TO_RIGHT);
237 }
238 return jPanelContentSouth;
239 }
240
241 /**
242 * This method initializes jPanel2
243 *
244 * @return javax.swing.JPanel
245 */
246 private JPanel getJPanelContentWest() {
247 if (jPanelContentWest == null) {
248 jPanelContentWest = new JPanel();
249 }
250 return jPanelContentWest;
251 }
252
253 /**
254 * This method initializes jPanel3
255 *
256 * @return javax.swing.JPanel
257 */
258 private JPanel getJPanelContentNorth() {
259 if (jPanelContentNorth == null) {
260 jPanelContentNorth = new JPanel();
261 }
262 return jPanelContentNorth;
263 }
264
265 /**
266 * This method initializes jTabbedPane
267 *
268 * @return javax.swing.JTabbedPane
269 */
270 private JTabbedPane getJTabbedPane() {
271 if (jTabbedPane == null) {
272 jTabbedPane = new JTabbedPane();
273 jTabbedPane.addTab("General", null, getJPanelFdf(), null);
274 jTabbedPane.addTab("Advanced", null, getJPanelFvImages(), null);
275
276 }
277 return jTabbedPane;
278 }
279
280 /**
281 * This method initializes jPanelFvImages
282 *
283 * @return javax.swing.JPanel
284 */
285 private JPanel getJPanelFvImages() {
286 if (jPanelFvImages == null) {
287 jPanelFvImages = new JPanel();
288 jPanelFvImages.setLayout(new BorderLayout());
289 jPanelFvImages.add(getJPanelFvImageN(), java.awt.BorderLayout.NORTH);
290 jPanelFvImages.add(getJPanelFvImageS(), java.awt.BorderLayout.SOUTH);
291 jPanelFvImages.add(getJPanelFvImageC(), java.awt.BorderLayout.CENTER);
292 jPanelFvImages.add(getJPanelW(), java.awt.BorderLayout.EAST);
293 jPanelFvImages.addComponentListener(new java.awt.event.ComponentAdapter() {
294 public void componentShown(java.awt.event.ComponentEvent e) {
295 // fvImageParaTableModel.setRowCount(0);
296 // fvPropertyTableModel.setRowCount(0);
297
298
299 }
300 });
301
302 }
303 return jPanelFvImages;
304 }
305
306 /**
307 * This method initializes jPanelFvImageN
308 *
309 * @return javax.swing.JPanel
310 */
311 private JPanel getJPanelFvImageS() {
312 if (jPanelFvImageS == null) {
313 jLabelFvPropValue = new JLabel();
314 jLabelFvPropValue.setText("Value");
315 jLabelFvPropValue.setEnabled(false);
316 jLabelFvPropValue.setPreferredSize(new java.awt.Dimension(38,20));
317 jLabelFvPropName = new JLabel();
318 jLabelFvPropName.setText("Name");
319 jLabelFvPropName.setEnabled(false);
320 jLabelFvPropName.setPreferredSize(new java.awt.Dimension(38,20));
321 jPanelFvImageS = new JPanel();
322 jPanelFvImageS.setPreferredSize(new java.awt.Dimension(576,130));
323 jPanelFvImageS.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
324 jPanelFvImageS.setLayout(new BorderLayout());
325 jPanelFvImageS.add(getJPanelFvImageSN(), java.awt.BorderLayout.NORTH);
326 jPanelFvImageS.add(getJPanelFvImageSE(), java.awt.BorderLayout.EAST);
327 jPanelFvImageS.add(getJPanelFvImageSS(), java.awt.BorderLayout.SOUTH);
328 jPanelFvImageS.add(getJScrollPaneFvProp(), java.awt.BorderLayout.CENTER);
329
330 }
331 return jPanelFvImageS;
332 }
333
334 /**
335 * This method initializes jPanelFvImageS
336 *
337 * @return javax.swing.JPanel
338 */
339 private JPanel getJPanelFvImageN() {
340 if (jPanelFvImageN == null) {
341 GridLayout gridLayout2 = new GridLayout();
342 gridLayout2.setRows(1);
343 jPanelFvImageN = new JPanel();
344 jPanelFvImageN.setPreferredSize(new java.awt.Dimension(480,150));
345 jPanelFvImageN.setLayout(gridLayout2);
346 jPanelFvImageN.add(getJScrollPaneFvInfo(), null);
347 }
348 return jPanelFvImageN;
349 }
350
351
352 /**
353 * This method initializes jCheckBox1
354 *
355 * @return javax.swing.JCheckBox
356 */
357 private JCheckBox getJCheckBoxFvProperty() {
358 if (jCheckBoxFvProperty == null) {
359 jCheckBoxFvProperty = new JCheckBox();
360 jCheckBoxFvProperty.setText("Global FV Variables");
361 jCheckBoxFvProperty.addItemListener(new ItemListener(){
362
363 public void itemStateChanged(ItemEvent arg0) {
364 // TODO Auto-generated method stub
365 boolean seleted = jCheckBoxFvProperty.isSelected();
366
367 jLabelFvPropName.setEnabled(seleted);
368 jTextFieldFvPropName.setEnabled(seleted);
369 jLabelFvPropValue.setEnabled(seleted);
370 jTextFieldFvPropValue.setEnabled(seleted);
371 jTableFvProp.setEnabled(seleted);
372 jButtonFvPropAdd.setEnabled(seleted);
373 jButtonFvPropDel.setEnabled(seleted);
374
375
376 }
377
378 });
379 }
380 return jCheckBoxFvProperty;
381 }
382
383
384 /**
385 * This method initializes jTextField
386 *
387 * @return javax.swing.JTextField
388 */
389 private JTextField getJTextFieldFvPropName() {
390 if (jTextFieldFvPropName == null) {
391 jTextFieldFvPropName = new JTextField();
392 jTextFieldFvPropName.setPreferredSize(new java.awt.Dimension(100,20));
393 jTextFieldFvPropName.setEnabled(false);
394 }
395 return jTextFieldFvPropName;
396 }
397
398
399 /**
400 * This method initializes jTextField1
401 *
402 * @return javax.swing.JTextField
403 */
404 private JTextField getJTextFieldFvPropValue() {
405 if (jTextFieldFvPropValue == null) {
406 jTextFieldFvPropValue = new JTextField();
407 jTextFieldFvPropValue.setPreferredSize(new java.awt.Dimension(100,20));
408 jTextFieldFvPropValue.setEnabled(false);
409 }
410 return jTextFieldFvPropValue;
411 }
412
413
414 /**
415 * This method initializes jButton
416 *
417 * @return javax.swing.JButton
418 */
419 private JButton getJButtonFvPropAdd() {
420 if (jButtonFvPropAdd == null) {
421 jButtonFvPropAdd = new JButton();
422 jButtonFvPropAdd.setPreferredSize(new java.awt.Dimension(80,20));
423 jButtonFvPropAdd.setEnabled(false);
424 jButtonFvPropAdd.setText("Add");
425 jButtonFvPropAdd.addActionListener(new AbstractAction() {
426 /**
427 *
428 */
429 private static final long serialVersionUID = 1L;
430
431 public void actionPerformed(ActionEvent e) {
432 if (jTextFieldFvPropName.getText().length() > 0 && jTextFieldFvPropValue.getText().length() > 0){
433 String[] row = {jTextFieldFvPropName.getText(), jTextFieldFvPropValue.getText()};
434 fvPropertyTableModel.addRow(row);
435 docConsole.setSaved(false);
436 ffc.genFvImagesNameValue(row[0], row[1]);
437 }
438 }
439 });
440 }
441 return jButtonFvPropAdd;
442 }
443
444
445 /**
446 * This method initializes jScrollPane1
447 *
448 * @return javax.swing.JScrollPane
449 */
450 private JScrollPane getJScrollPaneFvProp() {
451 if (jScrollPaneFvProp == null) {
452 jScrollPaneFvProp = new JScrollPane();
453 jScrollPaneFvProp.setPreferredSize(new java.awt.Dimension(350,100));
454 jScrollPaneFvProp.setViewportView(getJTableFvProp());
455 }
456 return jScrollPaneFvProp;
457 }
458
459
460 /**
461 * This method initializes jTable
462 *
463 * @return javax.swing.JTable
464 */
465 private JTable getJTableFvProp() {
466 if (jTableFvProp == null) {
467 fvPropertyTableModel = new DefaultTableModel();
468 jTableFvProp = new JTable(fvPropertyTableModel);
469 fvPropertyTableModel.addColumn("Name");
470 fvPropertyTableModel.addColumn("Value");
471 jTableFvProp.setRowHeight(20);
472 jTableFvProp.setEnabled(false);
473
474 jTableFvProp.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
475 jTableFvProp.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
476 public void valueChanged(ListSelectionEvent e) {
477 if (e.getValueIsAdjusting()){
478 return;
479 }
480 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
481 if (lsm.isSelectionEmpty()) {
482 return;
483 }
484 else{
485 // selectedRow = lsm.getMinSelectionIndex();
486 }
487 }
488 });
489
490 jTableFvProp.getModel().addTableModelListener(new TableModelListener(){
491 public void tableChanged(TableModelEvent arg0) {
492 // TODO Auto-generated method stub
493 int row = arg0.getFirstRow();
494 TableModel m = (TableModel)arg0.getSource();
495 if (arg0.getType() == TableModelEvent.UPDATE){
496
497 String name = m.getValueAt(row, 0) + "";
498 String value = m.getValueAt(row, 1) + "";
499 docConsole.setSaved(false);
500 ffc.updateFvImagesNameValue(row, name, value);
501 }
502 }
503 });
504 }
505 return jTableFvProp;
506 }
507
508
509 /**
510 * This method initializes jPanel4
511 *
512 * @return javax.swing.JPanel
513 */
514 private JPanel getJPanelFvPropButtonGroup() {
515 if (jPanelFvPropButtonGroup == null) {
516 jPanelFvPropButtonGroup = new JPanel();
517 jPanelFvPropButtonGroup.setPreferredSize(new java.awt.Dimension(80,55));
518
519 jPanelFvPropButtonGroup.add(getJButtonFvPropAdd(), null);
520 jPanelFvPropButtonGroup.add(getJButtonFvPropDel(), null);
521 }
522 return jPanelFvPropButtonGroup;
523 }
524
525
526 /**
527 * This method initializes jButton1
528 *
529 * @return javax.swing.JButton
530 */
531 private JButton getJButtonFvPropDel() {
532 if (jButtonFvPropDel == null) {
533 jButtonFvPropDel = new JButton();
534 jButtonFvPropDel.setPreferredSize(new java.awt.Dimension(80,20));
535 jButtonFvPropDel.setEnabled(false);
536 jButtonFvPropDel.setText("Delete");
537 jButtonFvPropDel.addActionListener(new AbstractAction() {
538 /**
539 *
540 */
541 private static final long serialVersionUID = 1L;
542
543 public void actionPerformed(ActionEvent e) {
544 if (jTableFvProp.getSelectedRow() >= 0){
545 fvPropertyTableModel.removeRow(jTableFvProp.getSelectedRow());
546 docConsole.setSaved(false);
547 ffc.removeFvImagesNameValue(jTableFvProp.getSelectedRow());
548 }
549 }
550 });
551 }
552 return jButtonFvPropDel;
553 }
554
555
556 /**
557 * This method initializes jPanelFvImageC
558 *
559 * @return javax.swing.JPanel
560 */
561 private JPanel getJPanelFvImageC() {
562 if (jPanelFvImageC == null) {
563 GridLayout gridLayout = new GridLayout();
564 gridLayout.setRows(2);
565 jLabelFvParaName = new JLabel();
566 jLabelFvParaName.setPreferredSize(new Dimension(38, 20));
567 jLabelFvParaName.setText("Name");
568 jLabelFvImageNames = new JLabel();
569 jLabelFvImageNames.setText("FV Image Names");
570 jLabelFvImageNames.setPreferredSize(new java.awt.Dimension(150,20));
571 jLabelFvParaType = new JLabel();
572 jLabelFvParaType.setText("Type");
573 jLabelFvParaType.setPreferredSize(new java.awt.Dimension(70,20));
574 jPanelFvImageC = new JPanel();
575 jPanelFvImageC.setLayout(gridLayout);
576 jPanelFvImageC.add(getJPanelFvImagePara(), null);
577 jPanelFvImageC.add(getJPanelFvImageOpts(), null);
578
579
580 }
581 return jPanelFvImageC;
582 }
583
584
585 /**
586 * This method initializes jComboBox
587 *
588 * @return javax.swing.JComboBox
589 */
590 private JComboBox getJComboBoxFvParaType() {
591 if (jComboBoxFvParaType == null) {
592 jComboBoxFvParaType = new JComboBox();
593 jComboBoxFvParaType.addItem("Attributes");
594 jComboBoxFvParaType.addItem("Components");
595 jComboBoxFvParaType.setSelectedIndex(0);
596 jComboBoxFvParaType.setPreferredSize(new java.awt.Dimension(180,20));
597 jComboBoxFvParaType.addItemListener(new ItemListener() {
598
599 public void itemStateChanged(ItemEvent arg0) {
600 // TODO disable attribute settings when ValidImageNames selected.
601 int selectedRow = jTableFvInfo.getSelectedRow();
602 if (selectedRow < 0) {
603 return;
604 }
605 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";
606 String oldType = jTableFvInfo.getValueAt(selectedRow, 1)+"";
607 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, oldType);
608 if (fvImagePos < 0) {
609 return;
610 }
611
612 String type = jComboBoxFvParaType.getSelectedItem()+"";
613 ffc.updateFvImagesFvImageType(fvImagePos, type);
614 jTableFvInfo.setValueAt(type, selectedRow, 1);
615 docConsole.setSaved(false);
616 }
617
618 });
619 }
620 return jComboBoxFvParaType;
621 }
622
623
624 /**
625 * This method initializes jTextField2
626 *
627 * @return javax.swing.JTextField
628 */
629 private JTextField getJTextFieldFvParaName() {
630 if (jTextFieldFvParaName == null) {
631 jTextFieldFvParaName = new JTextField();
632 jTextFieldFvParaName.setPreferredSize(new java.awt.Dimension(140,20));
633 }
634 return jTextFieldFvParaName;
635 }
636
637
638 /**
639 * This method initializes jButton2
640 *
641 * @return javax.swing.JButton
642 */
643 private JButton getJButtonFvNameAdd() {
644 if (jButtonFvNameAdd == null) {
645 jButtonFvNameAdd = new JButton();
646 jButtonFvNameAdd.setPreferredSize(new Dimension(80, 20));
647 jButtonFvNameAdd.setEnabled(true);
648 jButtonFvNameAdd.setText("Add");
649 jButtonFvNameAdd.addActionListener(new AbstractAction() {
650 /**
651 *
652 */
653 private static final long serialVersionUID = 1L;
654
655 public void actionPerformed(java.awt.event.ActionEvent e) {
656 if (jTextFieldFvParaName.getText().length() > 0){
657 String[] row = {jTextFieldFvParaName.getText()};
658 int selectedRow = jTableFvInfo.getSelectedRow();
659 if (selectedRow < 0) {
660 return;
661 }
662
663 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";
664 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";
665 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);
666
667 if (fvImagePos < 0) {
668 // new FvImage.
669 ffc.genFvImagesFvImage(row, jComboBoxFvParaType.getSelectedItem()+"", null);
670 }
671 else {
672 //append Fv name.
673 ffc.addFvImageNamesInFvImage(fvImagePos, row);
674 }
675 docConsole.setSaved(false);
676 fvImageNameTableModel.addRow(row);
677 fvNameList += " ";
678 fvNameList += row[0];
679 jTableFvInfo.setValueAt(fvNameList.trim(), selectedRow, 0);
680 jTableFvImageNames.changeSelection(jTableFvImageNames.getRowCount() - 1, 0, false, false);
681 }
682 }
683 });
684 }
685 return jButtonFvNameAdd;
686 }
687
688
689 /**
690 * This method initializes jScrollPane2
691 *
692 * @return javax.swing.JScrollPane
693 */
694 private JScrollPane getJScrollPaneFvImageNames() {
695 if (jScrollPaneFvImageNames == null) {
696 jScrollPaneFvImageNames = new JScrollPane();
697 jScrollPaneFvImageNames.setPreferredSize(new java.awt.Dimension(350,80));
698 jScrollPaneFvImageNames.setViewportView(getJTableFvImageNames());
699 }
700 return jScrollPaneFvImageNames;
701 }
702
703
704 /**
705 * This method initializes jTable1
706 *
707 * @return javax.swing.JTable
708 */
709 private JTable getJTableFvImageNames() {
710 if (jTableFvImageNames == null) {
711 fvImageNameTableModel = new IDefaultTableModel();
712 jTableFvImageNames = new JTable(fvImageNameTableModel);
713 jTableFvImageNames.setRowHeight(20);
714 fvImageNameTableModel.addColumn("FV Image Name");
715
716 }
717 return jTableFvImageNames;
718 }
719
720
721 /**
722 * This method initializes jButton3
723 *
724 * @return javax.swing.JButton
725 */
726 private JButton getJButtonFvNameDel() {
727 if (jButtonFvNameDel == null) {
728 jButtonFvNameDel = new JButton();
729 jButtonFvNameDel.setPreferredSize(new Dimension(80, 20));
730 jButtonFvNameDel.setEnabled(true);
731 jButtonFvNameDel.setText("Delete");
732 jButtonFvNameDel.addActionListener(new AbstractAction() {
733 /**
734 *
735 */
736 private static final long serialVersionUID = 1L;
737
738 public void actionPerformed(java.awt.event.ActionEvent e) {
739 if (jTableFvImageNames.getSelectedRow() >= 0){
740 int selectedRow = jTableFvInfo.getSelectedRow();
741 if (selectedRow < 0) {
742 return;
743 }
744
745 String selectedFvName = jTableFvImageNames.getValueAt(jTableFvImageNames.getSelectedRow(), 0)+"";
746 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";
747 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";
748 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);
749
750 if (fvImagePos < 0) {
751 return;
752 }
753 else {
754 //delete Fv name.
755 ffc.updateFvImageNamesInFvImage(fvImagePos, selectedFvName, null);
756 }
757 docConsole.setSaved(false);
758 String newList = removeFvNameFromList(fvNameList, selectedFvName);
759 jTableFvInfo.setValueAt(newList, selectedRow, 0);
760 fvImageNameTableModel.removeRow(jTableFvImageNames.getSelectedRow());
761 }
762 }
763 });
764 }
765 return jButtonFvNameDel;
766 }
767
768 private String removeFvNameFromList (String list, String name) {
769 String[] nameArray = list.split(" ");
770 int occursAt = -1;
771 for (int i = 0; i < nameArray.length; ++i) {
772 if (nameArray[i].equals(name)) {
773 occursAt = i;
774 break;
775 }
776 }
777
778 if (occursAt == -1) {
779 return list;
780 }
781
782 String newList = " ";
783 for (int j = 0; j < nameArray.length; ++j) {
784 if (j != occursAt) {
785 newList += nameArray[j];
786 newList += " ";
787 }
788 }
789
790 return newList.trim();
791 }
792
793
794 private JPanel getJPanelFvImageOpts() {
795
796
797 if (jPanelFvImageOpts == null) {
798 //ToDo add ButtonGroup for RadioButtons
799 jLabelOptions = new JLabel();
800 jLabelOptions.setText("Attribute");
801 jLabelFvImageOptValue = new JLabel();
802 jLabelFvImageOptValue.setEnabled(true);
803 jLabelFvImageOptValue.setText("Value");
804 jLabelFvImageOptValue.setPreferredSize(new Dimension(38, 20));
805 jLabelFvImageOptName = new JLabel();
806 jLabelFvImageOptName.setEnabled(true);
807 jLabelFvImageOptName.setText("Name");
808 jLabelFvImageOptName.setPreferredSize(new Dimension(38, 20));
809 jPanelFvImageOpts = new JPanel();
810 jPanelFvImageOpts.setLayout(new BorderLayout());
811 jPanelFvImageOpts.setPreferredSize(new java.awt.Dimension(450,130));
812
813
814 jPanelFvImageOpts.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
815
816 jPanelFvImageOpts.add(getJPanelFvImageOptsN(), java.awt.BorderLayout.NORTH);
817 jPanelFvImageOpts.add(getJPanelFvImageOptsS(), java.awt.BorderLayout.SOUTH);
818 jPanelFvImageOpts.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
819
820 jPanelFvImageOpts.add(getJPanelFvImageOptsE(), java.awt.BorderLayout.EAST);
821 }
822 return jPanelFvImageOpts;
823 }
824
825
826 /**
827 * This method initializes jButton4
828 *
829 * @return javax.swing.JButton
830 */
831 private JButton getJButtonAddFvImage() {
832 if (jButtonAddFvImage == null) {
833 jButtonAddFvImage = new JButton();
834 jButtonAddFvImage.setPreferredSize(new java.awt.Dimension(150,20));
835 jButtonAddFvImage.setText("New FV Attributes");
836 jButtonAddFvImage.addActionListener(new AbstractAction() {
837 /**
838 *
839 */
840 private static final long serialVersionUID = 1L;
841
842 public void actionPerformed(java.awt.event.ActionEvent e) {
843
844 // String imageName = " ";
845 // for (int i = 0; i < jTableFvImageNames.getRowCount(); ++i){
846 // imageName += (String)jTableFvImageNames.getValueAt(i, 0);
847 // imageName += " ";
848 // }
849 // imageName = imageName.trim();
850
851 // LinkedHashMap<String, String> m = null;
852 // m = new LinkedHashMap<String, String>();
853 // getOptionNameValue(m);
854 // ffc.genFvImagesFvImage(imageName.split(" "), jComboBoxFvParaType.getSelectedItem()+"", m);
855 // docConsole.setSaved(false);
856 fvImageNameTableModel.setRowCount(0);
857 fvOptionTableModel.setRowCount(0);
858 Object[] row = {"", jComboBoxFvParaType.getSelectedItem()};
859 fvImageParaTableModel.addRow(row);
860 jTableFvInfo.changeSelection(jTableFvInfo.getRowCount() - 1, 0, false, false);
861 }
862 });
863 }
864 return jButtonAddFvImage;
865 }
866
867
868 /**
869 * This method initializes jScrollPane3
870 *
871 * @return javax.swing.JScrollPane
872 */
873 private JScrollPane getJScrollPaneFvInfo() {
874 if (jScrollPaneFvInfo == null) {
875 jScrollPaneFvInfo = new JScrollPane();
876 jScrollPaneFvInfo.setPreferredSize(new java.awt.Dimension(480,150));
877 jScrollPaneFvInfo.setViewportView(getJTableFvInfo());
878 }
879 return jScrollPaneFvInfo;
880 }
881
882
883 /**
884 * This method initializes jTable2
885 *
886 * @return javax.swing.JTable
887 */
888 private JTable getJTableFvInfo() {
889 if (jTableFvInfo == null) {
890 fvImageParaTableModel = new ImageParaTableModel();
891 jTableFvInfo = new JTable(fvImageParaTableModel);
892 fvImageParaTableModel.addColumn("FvImageNames");
893 fvImageParaTableModel.addColumn("Type");
894
895 jTableFvInfo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
896 jTableFvInfo.setRowHeight(20);
897 jTableFvInfo.getSelectionModel().addListSelectionListener(new ListSelectionListener(){
898 public void valueChanged(ListSelectionEvent e) {
899 if (e.getValueIsAdjusting()){
900 return;
901 }
902 ListSelectionModel lsm = (ListSelectionModel)e.getSource();
903 if (lsm.isSelectionEmpty()) {
904 return;
905 }
906 else{
907 int selectedRow = lsm.getMinSelectionIndex();
908 String fvNameList = fvImageParaTableModel.getValueAt(selectedRow, 0)+"";
909 String type = fvImageParaTableModel.getValueAt(selectedRow, 1)+"";
910 jComboBoxFvParaType.setSelectedItem(type);
911 String[] fvNames = fvNameList.split(" ");
912 fvImageNameTableModel.setRowCount(0);
913 fvOptionTableModel.setRowCount(0);
914 for (int i = 0; i < fvNames.length; ++i) {
915 String[] row = { fvNames[i] };
916 if (row[0].length() > 0) {
917 fvImageNameTableModel.addRow(row);
918 }
919 }
920
921 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);
922 if (fvImagePos < 0) {
923 return;
924 }
925 LinkedHashMap<String, String> optionMap = new LinkedHashMap<String, String>();
926 ffc.getFvImagesFvImageOptions(fvImagePos, optionMap);
927 if (optionMap.size() > 0){
928 Set<String> key = optionMap.keySet();
929 Iterator<String> i = key.iterator();
930 while (i.hasNext()) {
931 String k = (String)i.next();
932 String[] row = {k, optionMap.get(k)};
933 fvOptionTableModel.addRow(row);
934 }
935 }
936 }
937 }
938 });
939
940
941 }
942 return jTableFvInfo;
943 }
944
945
946 /**
947 * This method initializes jButton6
948 *
949 * @return javax.swing.JButton
950 */
951 private JButton getJButtonDelFvImage() {
952 if (jButtonDelFvImage == null) {
953 jButtonDelFvImage = new JButton();
954 jButtonDelFvImage.setPreferredSize(new java.awt.Dimension(150,20));
955 jButtonDelFvImage.setText("Delete FV Attributes");
956 jButtonDelFvImage.addActionListener(new AbstractAction() {
957 /**
958 *
959 */
960 private static final long serialVersionUID = 1L;
961
962 public void actionPerformed(ActionEvent arg0) {
963 // TODO Auto-generated method stub
964 if (jTableFvInfo.getSelectedRow() >= 0 ) {
965 String fvNameList = fvImageParaTableModel.getValueAt(jTableFvInfo.getSelectedRow(), 0)+"";
966 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, jComboBoxFvParaType.getSelectedItem()+"");
967
968 ffc.removeFvImagesFvImage(fvImagePos);
969 fvImageParaTableModel.removeRow(jTableFvInfo.getSelectedRow());
970 docConsole.setSaved(false);
971
972 fvImageNameTableModel.setRowCount(0);
973 fvOptionTableModel.setRowCount(0);
974 }
975 }
976
977 });
978 }
979 return jButtonDelFvImage;
980 }
981
982
983 /**
984 * This method initializes jPanel6
985 *
986 * @return javax.swing.JPanel
987 */
988 private JPanel getJPanelFvImagePara() {
989 if (jPanelFvImagePara == null) {
990 StarLabel starLabel = new StarLabel();
991 starLabel.setVisible(false);
992 jPanelFvImagePara = new JPanel();
993 jPanelFvImagePara.setLayout(new BorderLayout());
994 jPanelFvImagePara.setPreferredSize(new java.awt.Dimension(450,140));
995 jPanelFvImagePara.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
996
997 jPanelFvImagePara.add(getJPanelFvImageParaN(), java.awt.BorderLayout.NORTH);
998 jPanelFvImagePara.add(getJPanelFvImageParaS(), java.awt.BorderLayout.SOUTH);
999 jPanelFvImagePara.add(getJScrollPaneFvImageNames(), java.awt.BorderLayout.CENTER);
1000
1001 jPanelFvImagePara.add(getJPanelFvImageParaE(), java.awt.BorderLayout.EAST);
1002 //
1003 //
1004 //
1005 }
1006 return jPanelFvImagePara;
1007 }
1008
1009 /**
1010 * This method initializes jPanel7
1011 *
1012 * @return javax.swing.JPanel
1013 */
1014 private JPanel getJPanelFdf() {
1015 if (jPanelFdf == null) {
1016 jPanelFdf = new JPanel();
1017 jPanelFdf.setLayout(new BorderLayout());
1018
1019 jPanelFdf.add(getJPanelFdfN(), java.awt.BorderLayout.NORTH);
1020 jPanelFdf.add(getJPanelFdfS(), java.awt.BorderLayout.SOUTH);
1021 jPanelFdf.add(getJSplitPaneFdfC(), java.awt.BorderLayout.CENTER);
1022 jPanelFdf.addComponentListener(new ComponentAdapter(){
1023 public void componentShown(ComponentEvent e) {
1024 // if (ffc.getFlashDefinitionFile() != null) {
1025 // jTextFieldFdf.setText(ffc.getFlashDefinitionFile());
1026 // initFvInFdfTable(System.getenv("WORKSPACE") + File.separator + jTextFieldFdf.getText());
1027 //
1028 // }
1029 }
1030 public void componentHidden(ComponentEvent e) {
1031 if (jCheckBoxFdf.isSelected()) {
1032 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());
1033 }
1034 }
1035 });
1036 }
1037 return jPanelFdf;
1038 }
1039
1040 /**
1041 * This method initializes jCheckBox
1042 *
1043 * @return javax.swing.JCheckBox
1044 */
1045 private JCheckBox getJCheckBoxFdf() {
1046 if (jCheckBoxFdf == null) {
1047 jCheckBoxFdf = new JCheckBox();
1048 jCheckBoxFdf.setText("Flash Definition File");
1049 jCheckBoxFdf.addItemListener(new ItemListener() {
1050
1051 public void itemStateChanged(ItemEvent arg0) {
1052 // TODO Auto-generated method stub
1053 if (jCheckBoxFdf.isSelected()){
1054 jTextFieldFdf.setEnabled(true);
1055 jButtonFdfBrowse.setEnabled(true);
1056 }
1057 else {
1058 getFvInFdfTableModel().setRowCount(0);
1059 jTextFieldFdf.setEnabled(false);
1060 jTextFieldFdf.setText("");
1061 jButtonFdfBrowse.setEnabled(false);
1062 ffc.genFlashDefinitionFile("");
1063 docConsole.setSaved(false);
1064 int selectedBackup = selectedRowInFvAdditionalTable;
1065 selectedRowInFvAdditionalTable = -1;
1066 initFvAdditionalTable();
1067 selectedRowInFvAdditionalTable = selectedBackup;
1068 }
1069 }
1070 });
1071 }
1072 return jCheckBoxFdf;
1073 }
1074
1075 /**
1076 * This method initializes jTextField3
1077 *
1078 * @return javax.swing.JTextField
1079 */
1080 private JTextField getJTextFieldFdf() {
1081 if (jTextFieldFdf == null) {
1082 jTextFieldFdf = new JTextField();
1083 jTextFieldFdf.setEnabled(false);
1084 jTextFieldFdf.setEditable(false);
1085 jTextFieldFdf.setPreferredSize(new Dimension(300, 20));
1086 jTextFieldFdf.addFocusListener(new java.awt.event.FocusAdapter() {
1087 public void focusLost(java.awt.event.FocusEvent e) {
1088 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());
1089 }
1090 });
1091 }
1092 return jTextFieldFdf;
1093 }
1094
1095 /**
1096 * This method initializes jButton5
1097 *
1098 * @return javax.swing.JButton
1099 */
1100 private JButton getJButtonFdfBrowse() {
1101 if (jButtonFdfBrowse == null) {
1102 jButtonFdfBrowse = new JButton();
1103 jButtonFdfBrowse.setEnabled(false);
1104 jButtonFdfBrowse.setText("Browse");
1105 jButtonFdfBrowse.setPreferredSize(new Dimension(78, 20));
1106 jButtonFdfBrowse.addActionListener(new AbstractAction(){
1107 /**
1108 *
1109 */
1110 private static final long serialVersionUID = 1L;
1111
1112 public void actionPerformed(ActionEvent e) {
1113 // TODO Auto-generated method stub
1114 String wsDir = System.getenv("WORKSPACE");
1115 JFileChooser chooser = new JFileChooser(wsDir);
1116 chooser.setMultiSelectionEnabled(false);
1117 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
1118 int retval = chooser.showOpenDialog(frame);
1119 if (retval == JFileChooser.APPROVE_OPTION) {
1120
1121 File theFile = chooser.getSelectedFile();
1122 String filePath = theFile.getPath();
1123 if (!filePath.startsWith(wsDir)) {
1124 JOptionPane.showMessageDialog(frame, "You can only select files in current WORKSPACE.");
1125 return;
1126 }
1127 jTextFieldFdf.setText(filePath.substring(wsDir.length() + 1).replace('\\', '/'));
1128 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());
1129 docConsole.setSaved(false);
1130 initFvInFdfTable(filePath);
1131 }
1132 }
1133
1134 });
1135 }
1136 return jButtonFdfBrowse;
1137 }
1138
1139 private void initFvAttributes () {
1140 if (ffc.getFvImagesFvImageCount("Attributes") == 0 && ffc.getFvImagesFvImageCount("Components") == 0) {
1141 return;
1142 }
1143 String[][] saa = new String[ffc.getFvImagesFvImageCount("Attributes")][2];
1144 ffc.getFvImagesFvImages(saa, "Attributes");
1145
1146 int i = 0;
1147 while (i < saa.length) {
1148 fvImageParaTableModel.addRow(saa[i]);
1149 ++i;
1150 }
1151
1152 saa = new String[ffc.getFvImagesFvImageCount("Components")][2];
1153 ffc.getFvImagesFvImages(saa, "Components");
1154 i = 0;
1155 while (i < saa.length) {
1156 fvImageParaTableModel.addRow(saa[i]);
1157 ++i;
1158 }
1159
1160 saa = new String[ffc.getFvImagesNameValueCount()][2];
1161 ffc.getFvImagesNameValues(saa);
1162 for (int m = 0; m < saa.length; ++m) {
1163 fvPropertyTableModel.addRow(saa[m]);
1164 }
1165 }
1166
1167 private void initFvAdditionalTable() {
1168 Vector<String> vFvNames = new Vector<String>();
1169 ffc.getFvImagesFvImageFvImageNames(vFvNames);
1170 for (int i = 0; i < vFvNames.size(); ++i) {
1171 String fvName = vFvNames.get(i);
1172 if (fvNameExists(fvName)) {
1173 continue;
1174 }
1175 fvAdditionalTableModel.addRow(getBasicFvInfo(fvName));
1176 addTabForFv(new FvInfoFromFdf(fvName, "", ""));
1177 }
1178 }
1179
1180 private void initFvInFdfTable(String fdfPath){
1181 Vector<FvInfoFromFdf> vFvInfo = new Vector<FvInfoFromFdf>();
1182 getFvInfoFromFdf(fdfPath, vFvInfo);
1183 getFlashInfoFromFdf (fdfPath);
1184 if (!erasePolarity.equals("1") && !erasePolarity.equals("0")) {
1185 JOptionPane.showMessageDialog(frame, "FDF file does NOT contain valid Erase Polarity.");
1186 }
1187 else {
1188 ffc.setTypedFvImageNameValue("Attributes", "EFI_ERASE_POLARITY", erasePolarity);
1189 }
1190
1191 // BugBug: assume all blocks have same size;
1192
1193 String blkSize = defaultBlkSize;
1194 if (vBlockSize.size() > 0) {
1195 blkSize = vBlockSize.get(0);
1196 if (!DataValidation.isInt(blkSize) && !DataValidation.isHexDoubleWordDataType(blkSize)) {
1197 JOptionPane.showMessageDialog(frame, "FDF file does NOT contain valid FV block size. Default size 0x10000 will be used.");
1198 blkSize = defaultBlkSize;
1199 }
1200 }
1201 determinedFvBlockSize = blkSize;
1202
1203 getFvInFdfTableModel().setRowCount(0);
1204 Vector<String> vExistingFvNameInFpd = new Vector<String>();
1205 ffc.getFvImagesFvImageFvImageNames(vExistingFvNameInFpd);
1206 for (int j = 0; j < vFvInfo.size(); ++j) {
1207 FvInfoFromFdf fvInfo = vFvInfo.get(j);
1208 String[] row = {fvInfo.getFvName(), fvInfo.getSize(), fvInfo.getEfiFileName()};
1209
1210 if (row[0].length() > 0 && !vExistingFvNameInFpd.contains(row[0])) {
1211 ffc.addFvImageFvImageNames(new String[]{row[0]});
1212 }
1213
1214 // if FV addtional table contains the same FV from fdf file, remove that row.
1215 for (int k = 0; k < jTableFvAdditional.getRowCount(); ++k) {
1216 if (fvAdditionalTableModel.getValueAt(k, 0).equals(row[0])) {
1217 fvAdditionalTableModel.removeRow(k);
1218 }
1219 }
1220 getFvInFdfTableModel().addRow(row);
1221 try {
1222 int blockSize = Integer.decode(blkSize);
1223 int fvSize = Integer.decode(row[1]);
1224 int numBlocks = fvSize/blockSize;
1225 HashMap<String, String> mOptions = new HashMap<String, String>();
1226 // if no options for this FV before, generate a new options entry for this FV.
1227 if (ffc.getFvImagesFvImageWithName(row[0], "Options") == null) {
1228
1229 mOptions.put("EFI_BLOCK_SIZE", blkSize);
1230 mOptions.put("EFI_NUM_BLOCKS", numBlocks+"");
1231 mOptions.put("EFI_FILE_NAME", row[2]);
1232 ffc.genFvImagesFvImage(new String[]{row[0]}, "Options", mOptions);
1233 memModified = true;
1234 }
1235 else {
1236 ffc.getFvImagesFvImageOptions(row[0], mOptions);
1237 if (mOptions.get("EFI_BLOCK_SIZE") == null || !mOptions.get("EFI_BLOCK_SIZE").equalsIgnoreCase(blkSize)) {
1238 ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_BLOCK_SIZE", blkSize, null);
1239 memModified = true;
1240 }
1241 if (mOptions.get("EFI_NUM_BLOCKS") == null || Integer.decode(mOptions.get("EFI_NUM_BLOCKS")) != numBlocks) {
1242 ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_NUM_BLOCKS", numBlocks + "", null);
1243 memModified = true;
1244 }
1245 if (mOptions.get("EFI_FILE_NAME") == null || !mOptions.get("EFI_FILE_NAME").equals(row[2])) {
1246 ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_FILE_NAME", row[2], null);
1247 memModified = true;
1248 }
1249
1250 }
1251 }
1252 catch (NumberFormatException e){
1253 JOptionPane.showMessageDialog(frame, e.getMessage());
1254 }
1255 }
1256
1257 for (int k = 0; k < vFvInfo.size(); ++k) {
1258 FvInfoFromFdf fvInfo = vFvInfo.get(k);
1259 addTabForFv(fvInfo);
1260 }
1261
1262 }
1263
1264 private void addTabForFv (FvInfoFromFdf fvInfo) {
1265 String fvName = fvInfo.getFvName();
1266 String outputFile = fvInfo.getEfiFileName();
1267 int index = jTabbedPane.indexOfTab(fvName);
1268 if (index >= startIndexOfDynamicTab) {
1269 return;
1270 }
1271 jTabbedPane.addTab(fvName, null, new ModuleOrderPane(fvName, outputFile), null);
1272 }
1273 /**
1274 * This method initializes jTextField4
1275 *
1276 * @return javax.swing.JTextField
1277 */
1278 private JTextField getJTextFieldFvImageOptName() {
1279 if (jTextFieldFvImageOptName == null) {
1280 jTextFieldFvImageOptName = new JTextField();
1281 jTextFieldFvImageOptName.setEnabled(true);
1282 jTextFieldFvImageOptName.setPreferredSize(new Dimension(100, 20));
1283 }
1284 return jTextFieldFvImageOptName;
1285 }
1286
1287 /**
1288 * This method initializes jTextField5
1289 *
1290 * @return javax.swing.JTextField
1291 */
1292 private JTextField getJTextFieldFvImageOptValue() {
1293 if (jTextFieldFvImageOptValue == null) {
1294 jTextFieldFvImageOptValue = new JTextField();
1295 jTextFieldFvImageOptValue.setEnabled(true);
1296 jTextFieldFvImageOptValue.setPreferredSize(new Dimension(100, 20));
1297 }
1298 return jTextFieldFvImageOptValue;
1299 }
1300
1301 /**
1302 * This method initializes jPanel8
1303 *
1304 * @return javax.swing.JPanel
1305 */
1306 private JPanel getJPanelFvImageOptsButtonGroup() {
1307 if (jPanelFvImageOptsButtonGroup == null) {
1308 jPanelFvImageOptsButtonGroup = new JPanel();
1309 jPanelFvImageOptsButtonGroup.setPreferredSize(new Dimension(80, 55));
1310 jPanelFvImageOptsButtonGroup.add(getJButtonFvImageOptAdd(), null);
1311 jPanelFvImageOptsButtonGroup.add(getJButtonFvImageOptDel(), null);
1312 }
1313 return jPanelFvImageOptsButtonGroup;
1314 }
1315
1316 /**
1317 * This method initializes jButton7
1318 *
1319 * @return javax.swing.JButton
1320 */
1321 private JButton getJButtonFvImageOptAdd() {
1322 if (jButtonFvImageOptAdd == null) {
1323 jButtonFvImageOptAdd = new JButton();
1324 jButtonFvImageOptAdd.setEnabled(true);
1325 jButtonFvImageOptAdd.setText("Add");
1326 jButtonFvImageOptAdd.setPreferredSize(new Dimension(80, 20));
1327 jButtonFvImageOptAdd.addActionListener(new AbstractAction() {
1328 /**
1329 *
1330 */
1331 private static final long serialVersionUID = 1L;
1332
1333 public void actionPerformed(ActionEvent e) {
1334 if (jTextFieldFvImageOptName.getText().length() > 0 && jTextFieldFvImageOptValue.getText().length() > 0){
1335 int selectedRow = jTableFvInfo.getSelectedRow();
1336 if (selectedRow < 0) {
1337 return;
1338 }
1339
1340 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";
1341 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";
1342 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);
1343 String[] row = {jTextFieldFvImageOptName.getText(), jTextFieldFvImageOptValue.getText()};
1344
1345 if (fvImagePos < 0) {
1346 return;
1347 }
1348 else {
1349 //append options to FvImage.
1350 ffc.setFvImagesFvImageNameValue(fvImagePos, row[0], row[1]);
1351 }
1352 docConsole.setSaved(false);
1353 fvOptionTableModel.addRow(row);
1354 jTableFvImageOpts.changeSelection(jTableFvImageOpts.getRowCount() - 1, 0, false, false);
1355 }
1356 }
1357 });
1358 }
1359 return jButtonFvImageOptAdd;
1360 }
1361
1362 /**
1363 * This method initializes jButton8
1364 *
1365 * @return javax.swing.JButton
1366 */
1367 private JButton getJButtonFvImageOptDel() {
1368 if (jButtonFvImageOptDel == null) {
1369 jButtonFvImageOptDel = new JButton();
1370 jButtonFvImageOptDel.setEnabled(true);
1371 jButtonFvImageOptDel.setText("Delete");
1372 jButtonFvImageOptDel.setPreferredSize(new Dimension(80, 20));
1373 jButtonFvImageOptDel.addActionListener(new AbstractAction() {
1374 /**
1375 *
1376 */
1377 private static final long serialVersionUID = 1L;
1378
1379 public void actionPerformed(ActionEvent e) {
1380 if (jTableFvImageOpts.getSelectedRow() >= 0){
1381 int selectedRow = jTableFvInfo.getSelectedRow();
1382 if (selectedRow < 0) {
1383 return;
1384 }
1385
1386 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";
1387 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";
1388 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);
1389 if (fvImagePos < 0) {
1390 return;
1391 }
1392
1393 String optName = fvOptionTableModel.getValueAt(jTableFvImageOpts.getSelectedRow(), 0)+"";
1394 ffc.removeFvImageNameValue(fvImagePos, optName);
1395 docConsole.setSaved(false);
1396 fvOptionTableModel.removeRow(jTableFvImageOpts.getSelectedRow());
1397 }
1398 }
1399 });
1400 }
1401 return jButtonFvImageOptDel;
1402 }
1403
1404 /**
1405 * This method initializes jScrollPane
1406 *
1407 * @return javax.swing.JScrollPane
1408 */
1409 private JScrollPane getJScrollPane() {
1410 if (jScrollPane == null) {
1411 jScrollPane = new JScrollPane();
1412 jScrollPane.setPreferredSize(new java.awt.Dimension(350,100));
1413 jScrollPane.setViewportView(getJTableFvImageOpts());
1414 }
1415 return jScrollPane;
1416 }
1417
1418 /**
1419 * This method initializes jTable3
1420 *
1421 * @return javax.swing.JTable
1422 */
1423 private JTable getJTableFvImageOpts() {
1424 if (jTableFvImageOpts == null) {
1425 fvOptionTableModel = new IDefaultTableModel();
1426 fvOptionTableModel.addColumn("Name");
1427 fvOptionTableModel.addColumn("Value");
1428 jTableFvImageOpts = new JTable(fvOptionTableModel);
1429
1430 jTableFvImageOpts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
1431 jTableFvImageOpts.setRowHeight(20);
1432
1433 }
1434 return jTableFvImageOpts;
1435 }
1436
1437 /**
1438 * This method initializes jButton9
1439 *
1440 * @return javax.swing.JButton
1441 */
1442 private JButton getJButtonUpdateFvImage() {
1443 if (jButtonUpdateFvImage == null) {
1444 jButtonUpdateFvImage = new JButton();
1445 jButtonUpdateFvImage.setPreferredSize(new java.awt.Dimension(150,20));
1446 jButtonUpdateFvImage.setActionCommand("Update");
1447 jButtonUpdateFvImage.setText("Update FV Attributes");
1448 jButtonUpdateFvImage.setVisible(false);
1449 jButtonUpdateFvImage.addActionListener(new java.awt.event.ActionListener() {
1450 public void actionPerformed(java.awt.event.ActionEvent e) {
1451 int row = jTableFvInfo.getSelectedRow();
1452 if (jTableFvInfo.isEditing()) {
1453 jTableFvInfo.getCellEditor().stopCellEditing();
1454 }
1455 if (jTableFvImageOpts.isEditing()) {
1456 jTableFvImageOpts.getCellEditor().stopCellEditing();
1457 }
1458
1459 //ToDo Check data validity before update
1460 String name = fvImageParaTableModel.getValueAt(row, 0) + "";
1461 String type = fvImageParaTableModel.getValueAt(row, 1) + "";
1462
1463 LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();
1464 getOptionNameValue(lhm);
1465
1466 docConsole.setSaved(false);
1467 ffc.updateFvImagesFvImage(row, name.split(" "), type, lhm);
1468
1469 }
1470 });
1471 }
1472 return jButtonUpdateFvImage;
1473 }
1474
1475 /**
1476 * This method initializes jPanelFdfN
1477 *
1478 * @return javax.swing.JPanel
1479 */
1480 private JPanel getJPanelFdfN() {
1481 if (jPanelFdfN == null) {
1482 jPanelFdfN = new JPanel();
1483 jPanelFdfN.add(getJCheckBoxFdf(), null);
1484 jPanelFdfN.add(getJTextFieldFdf(), null);
1485 jPanelFdfN.add(getJButtonFdfBrowse(), null);
1486 }
1487 return jPanelFdfN;
1488 }
1489
1490 /**
1491 * This method initializes jPanelFdfS
1492 *
1493 * @return javax.swing.JPanel
1494 */
1495 private JPanel getJPanelFdfS() {
1496 if (jPanelFdfS == null) {
1497 FlowLayout flowLayout4 = new FlowLayout();
1498 flowLayout4.setAlignment(java.awt.FlowLayout.RIGHT);
1499 jPanelFdfS = new JPanel();
1500 jPanelFdfS.setLayout(flowLayout4);
1501 jPanelFdfS.add(getJButtonAddFv(), null);
1502 jPanelFdfS.add(getJButtonDelFv(), null);
1503 jPanelFdfS.add(getJButtonAddFvOptions(), null);
1504 }
1505 return jPanelFdfS;
1506 }
1507
1508 /**
1509 * This method initializes jSplitPaneFdfC
1510 *
1511 * @return javax.swing.JSplitPane
1512 */
1513 private JSplitPane getJSplitPaneFdfC() {
1514 if (jSplitPaneFdfC == null) {
1515 jSplitPaneFdfC = new JSplitPane();
1516 jSplitPaneFdfC.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
1517 jSplitPaneFdfC.setDividerSize(5);
1518 jSplitPaneFdfC.setTopComponent(getJPanelFdfCTop());
1519 jSplitPaneFdfC.setBottomComponent(getJPanelFdfCBottom());
1520 jSplitPaneFdfC.setDividerLocation(280);
1521 }
1522 return jSplitPaneFdfC;
1523 }
1524
1525 /**
1526 * This method initializes jPanelFdfCTop
1527 *
1528 * @return javax.swing.JPanel
1529 */
1530 private JPanel getJPanelFdfCTop() {
1531 if (jPanelFdfCTop == null) {
1532 jPanelFdfCTop = new JPanel();
1533 jPanelFdfCTop.setLayout(new BorderLayout());
1534 jPanelFdfCTop.add(getJPanelFdfCTopN(), java.awt.BorderLayout.NORTH);
1535 jPanelFdfCTop.add(getJPanelFdfCTopS(), java.awt.BorderLayout.SOUTH);
1536 jPanelFdfCTop.add(getJScrollPaneFvInFdf(), java.awt.BorderLayout.CENTER);
1537 }
1538 return jPanelFdfCTop;
1539 }
1540
1541 /**
1542 * This method initializes jPanelFdfCBottom
1543 *
1544 * @return javax.swing.JPanel
1545 */
1546 private JPanel getJPanelFdfCBottom() {
1547 if (jPanelFdfCBottom == null) {
1548 jPanelFdfCBottom = new JPanel();
1549 jPanelFdfCBottom.setLayout(new BorderLayout());
1550 jPanelFdfCBottom.add(getJPanelFdfCBottomN(), java.awt.BorderLayout.NORTH);
1551 jPanelFdfCBottom.add(getJScrollPaneFvAdditional(), java.awt.BorderLayout.CENTER);
1552 }
1553 return jPanelFdfCBottom;
1554 }
1555
1556 /**
1557 * This method initializes jPanelFdfCTopN
1558 *
1559 * @return javax.swing.JPanel
1560 */
1561 private JPanel getJPanelFdfCTopN() {
1562 if (jPanelFdfCTopN == null) {
1563 jLabelFvInFdf = new JLabel();
1564 jLabelFvInFdf.setText("FVs in Flash Definition File");
1565 jPanelFdfCTopN = new JPanel();
1566 jPanelFdfCTopN.add(jLabelFvInFdf, null);
1567 }
1568 return jPanelFdfCTopN;
1569 }
1570
1571 /**
1572 * This method initializes jPanelFdfCTopS
1573 *
1574 * @return javax.swing.JPanel
1575 */
1576 private JPanel getJPanelFdfCTopS() {
1577 if (jPanelFdfCTopS == null) {
1578 FlowLayout flowLayout1 = new FlowLayout();
1579 flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
1580 jPanelFdfCTopS = new JPanel();
1581 jPanelFdfCTopS.setLayout(flowLayout1);
1582 jPanelFdfCTopS.add(getJButtonFvInFdfOptions(), null);
1583 }
1584 return jPanelFdfCTopS;
1585 }
1586
1587 /**
1588 * This method initializes jPanelFdfCTopC
1589 *
1590 * @return javax.swing.JPanel
1591 */
1592 // private JPanel getJPanelFdfCTopC() {
1593 // if (jPanelFdfCTopC == null) {
1594 // jPanelFdfCTopC = new JPanel();
1595 // jPanelFdfCTopC.add(getJScrollPaneFvInFdf(), null);
1596 // }
1597 // return jPanelFdfCTopC;
1598 // }
1599
1600 /**
1601 * This method initializes jPanelFdfCBottomN
1602 *
1603 * @return javax.swing.JPanel
1604 */
1605 private JPanel getJPanelFdfCBottomN() {
1606 if (jPanelFdfCBottomN == null) {
1607 jLabelFvAdditional = new JLabel();
1608 jLabelFvAdditional.setText("Additional FVs");
1609 jPanelFdfCBottomN = new JPanel();
1610 jPanelFdfCBottomN.add(jLabelFvAdditional, null);
1611 }
1612 return jPanelFdfCBottomN;
1613 }
1614
1615 /**
1616 * This method initializes jPanelFdfCBottomC
1617 *
1618 * @return javax.swing.JPanel
1619 */
1620 // private JPanel getJPanelFdfCBottomC() {
1621 // if (jPanelFdfCBottomC == null) {
1622 // jPanelFdfCBottomC = new JPanel();
1623 // jPanelFdfCBottomC.add(getJScrollPaneFvAdditional(), null);
1624 // }
1625 // return jPanelFdfCBottomC;
1626 // }
1627
1628 /**
1629 * This method initializes jScrollPaneFvInFdf
1630 *
1631 * @return javax.swing.JScrollPane
1632 */
1633 private JScrollPane getJScrollPaneFvInFdf() {
1634 if (jScrollPaneFvInFdf == null) {
1635 jScrollPaneFvInFdf = new JScrollPane();
1636 jScrollPaneFvInFdf.setPreferredSize(new java.awt.Dimension(653,200));
1637 jScrollPaneFvInFdf.setViewportView(getJTableFvInFdf());
1638 }
1639 return jScrollPaneFvInFdf;
1640 }
1641
1642 /**
1643 * This method initializes jTableFvInFdf
1644 *
1645 * @return javax.swing.JTable
1646 */
1647 private JTable getJTableFvInFdf() {
1648 if (jTableFvInFdf == null) {
1649 jTableFvInFdf = new JTable();
1650 jTableFvInFdf.setRowHeight(20);
1651 jTableFvInFdf.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
1652 jTableFvInFdf.setModel(getFvInFdfTableModel());
1653 }
1654 return jTableFvInFdf;
1655 }
1656
1657 /**
1658 * This method initializes fvInFdfTableModel
1659 *
1660 * @return org.tianocore.frameworkwizard.platform.ui.NonEditableTableModel
1661 */
1662 private IDefaultTableModel getFvInFdfTableModel() {
1663 if (fvInFdfTableModel == null) {
1664 fvInFdfTableModel = new IDefaultTableModel();
1665 fvInFdfTableModel.addColumn("FV Name");
1666 fvInFdfTableModel.addColumn("Size");
1667 fvInFdfTableModel.addColumn("Corresponding File Name");
1668 }
1669 return fvInFdfTableModel;
1670 }
1671
1672 /**
1673 * This method initializes jButtonFvInFdfOptions
1674 *
1675 * @return javax.swing.JButton
1676 */
1677 private JButton getJButtonFvInFdfOptions() {
1678 if (jButtonFvInFdfOptions == null) {
1679 jButtonFvInFdfOptions = new JButton();
1680 jButtonFvInFdfOptions.setPreferredSize(new java.awt.Dimension(80,20));
1681 jButtonFvInFdfOptions.setEnabled(true);
1682 jButtonFvInFdfOptions.setText("Options");
1683 jButtonFvInFdfOptions.addActionListener(new java.awt.event.ActionListener() {
1684 public void actionPerformed(java.awt.event.ActionEvent e) {
1685 int selectedRow = jTableFvInFdf.getSelectedRow();
1686 if (selectedRow < 0) {
1687 return;
1688 }
1689 String fvName = jTableFvInFdf.getValueAt(selectedRow, 0)+"";
1690 if (fvName.length() == 0) {
1691 return;
1692 }
1693 DefaultTableModel dtm = getFvInFdfOptTableModel();
1694 new FpdFvOptions(fvName, dtm, ffc, docConsole);
1695 }
1696 });
1697 }
1698 return jButtonFvInFdfOptions;
1699 }
1700
1701 private DefaultTableModel getFvInFdfOptTableModel() {
1702 if (fvInFdfOptTableModel == null) {
1703 fvInFdfOptTableModel = new FvOptsTableModel();
1704 fvInFdfOptTableModel.addColumn("Name");
1705 fvInFdfOptTableModel.addColumn("Value");
1706 Vector<Object> v = new Vector<Object>();
1707 v.add("EFI_BLOCK_SIZE");
1708 v.add("EFI_NUM_BLOCKS");
1709 v.add("EFI_FILE_NAME");
1710 fvInFdfOptTableModel.setVKeyWords(v);
1711 fvInFdfOptTableModel.setVNonEditableName(v);
1712 }
1713 return fvInFdfOptTableModel;
1714 }
1715
1716 private DefaultTableModel getFvAdditionalOptTableModel() {
1717 if (fvAdditionalOptTableModel == null) {
1718 fvAdditionalOptTableModel = new FvOptsTableModel();
1719 fvAdditionalOptTableModel.addColumn("Name");
1720 fvAdditionalOptTableModel.addColumn("Value");
1721 Vector<Object> v = new Vector<Object>();
1722 v.add("EFI_BLOCK_SIZE");
1723 v.add("EFI_NUM_BLOCKS");
1724 v.add("EFI_FILE_NAME");
1725 fvAdditionalOptTableModel.setVNonEditableName(v);
1726 }
1727 return fvAdditionalOptTableModel;
1728 }
1729
1730 /**
1731 * This method initializes jScrollPaneFvAdditional
1732 *
1733 * @return javax.swing.JScrollPane
1734 */
1735 private JScrollPane getJScrollPaneFvAdditional() {
1736 if (jScrollPaneFvAdditional == null) {
1737 jScrollPaneFvAdditional = new JScrollPane();
1738 jScrollPaneFvAdditional.setPreferredSize(new java.awt.Dimension(653,200));
1739 jScrollPaneFvAdditional.setViewportView(getJTableFvAdditional());
1740 }
1741 return jScrollPaneFvAdditional;
1742 }
1743
1744 /**
1745 * This method initializes jTableFvAdditional
1746 *
1747 * @return javax.swing.JTable
1748 */
1749 private JTable getJTableFvAdditional() {
1750 if (jTableFvAdditional == null) {
1751 jTableFvAdditional = new JTable();
1752 jTableFvAdditional.setRowHeight(20);
1753 jTableFvAdditional.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
1754 jTableFvAdditional.setModel(getFvAdditionalTableModel());
1755
1756 jTableFvAdditional.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
1757 public void valueChanged(ListSelectionEvent e) {
1758 if (e.getValueIsAdjusting()) {
1759 return;
1760 }
1761 ListSelectionModel lsm = (ListSelectionModel) e.getSource();
1762 if (lsm.isSelectionEmpty()) {
1763 return;
1764 } else {
1765 selectedRowInFvAdditionalTable = lsm.getMinSelectionIndex();
1766 oldFvName = jTableFvAdditional.getValueAt(selectedRowInFvAdditionalTable, 0)+"";
1767 }
1768 }
1769 });
1770
1771 jTableFvAdditional.getModel().addTableModelListener(new TableModelListener() {
1772 public void tableChanged(TableModelEvent arg0) {
1773 // TODO Auto-generated method stub
1774 int row = arg0.getFirstRow();
1775 int col = arg0.getColumn();
1776 TableModel m = (TableModel) arg0.getSource();
1777
1778 if (arg0.getType() == TableModelEvent.UPDATE) {
1779 if (col == 0) {
1780 String newFvName = m.getValueAt(row, 0) + "";
1781 if (newFvName.equals(oldFvName)) {
1782 return;
1783 }
1784 if (fvNameExists(newFvName)) {
1785 JOptionPane.showMessageDialog(frame, "This FV already exists. Please choose another FV name.");
1786 m.setValueAt(oldFvName, row, 0);
1787 return;
1788 }
1789
1790 tabIndexForFv = jTabbedPane.indexOfTab(oldFvName);
1791 if (tabIndexForFv >= startIndexOfDynamicTab) {
1792 jTabbedPane.setTitleAt(tabIndexForFv, newFvName);
1793 // change FvName in UserExtensions
1794 ffc.updateBuildOptionsUserExtensions(oldFvName, newFvName);
1795 // change FvBinding in ModuleSA
1796 ffc.appendFvBindingFor(oldFvName, newFvName);
1797 ffc.removeFvBindingAll(oldFvName);
1798 // change FvImageNames in Flash
1799 ffc.updateFvImageNameAll(oldFvName, newFvName);
1800
1801 } else {
1802 jTabbedPane.addTab(newFvName, new ModuleOrderPane(newFvName, ""));
1803 // Add FvImageNames in Flash
1804 String[] fvNames = {newFvName};
1805 ffc.addFvImageFvImageNames(fvNames);
1806 }
1807 docConsole.setSaved(false);
1808 oldFvName = newFvName;
1809 }
1810
1811 if (col == 1 && !sizeFromOptionDlg) {
1812 String fvSize = m.getValueAt(row, col) + "";
1813 if (!DataValidation.isInt(fvSize) && !DataValidation.isHexDoubleWordDataType(fvSize)) {
1814 JOptionPane.showMessageDialog(frame, "FV size should be Integer or Hex format.");
1815 return;
1816 }
1817 HashMap<String, String> mFvOpts = new HashMap<String, String>();
1818 ffc.getFvImagesFvImageOptions(oldFvName, mFvOpts);
1819 String blkSize = mFvOpts.get("EFI_BLOCK_SIZE");
1820 if (blkSize == null) {
1821 if (determinedFvBlockSize != null) {
1822 blkSize = determinedFvBlockSize;
1823 }
1824 else {
1825 blkSize = defaultBlkSize;
1826 }
1827 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", blkSize, null);
1828 int fs = Integer.decode(fvSize);
1829 int bs = Integer.decode(blkSize);
1830 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"", null);
1831 docConsole.setSaved(false);
1832 }
1833 else {
1834 if (!DataValidation.isInt(blkSize) && !DataValidation.isHexDoubleWordDataType(blkSize)) {
1835 int retVal = JOptionPane.showConfirmDialog(frame, "Confirm", "FPD file contains error block size format. Would you like to replace it with a default value?", JOptionPane.YES_NO_OPTION);
1836 if (retVal == JOptionPane.YES_OPTION) {
1837 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", defaultBlkSize, null);
1838 int fs = Integer.decode(fvSize);
1839 int bs = Integer.decode(defaultBlkSize);
1840 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"", null);
1841 docConsole.setSaved(false);
1842 return;
1843 }
1844 else {
1845 return;
1846 }
1847
1848 }
1849 int fs = Integer.decode(fvSize);
1850 int bs = Integer.decode(blkSize);
1851 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"", null);
1852 docConsole.setSaved(false);
1853 }
1854 }
1855
1856 if (col == 2 && !fileFromOptionDlg) {
1857 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_FILE_NAME", m.getValueAt(row, col)+"", null);
1858 docConsole.setSaved(false);
1859 }
1860
1861 }
1862 }
1863 });
1864 }
1865 return jTableFvAdditional;
1866 }
1867
1868 private boolean fvNameExistsInFvInFdfTable (String fvName) {
1869 for (int i = 0; i < jTableFvInFdf.getRowCount(); ++i) {
1870 if (fvInFdfTableModel.getValueAt(i, 0).equals(fvName)) {
1871 return true;
1872 }
1873 }
1874 return false;
1875 }
1876
1877 private boolean fvNameExists (String fvName) {
1878 if (fvNameExistsInFvInFdfTable(fvName)) {
1879 return true;
1880 }
1881
1882 for (int j = 0; j < jTableFvAdditional.getRowCount(); ++j) {
1883 if (fvAdditionalTableModel.getValueAt(j, 0).equals(fvName) && j != selectedRowInFvAdditionalTable) {
1884 return true;
1885 }
1886 }
1887 return false;
1888 }
1889
1890 /**
1891 * This method initializes fvAdditionalTableModel
1892 *
1893 * @return javax.swing.table.DefaultTableModel
1894 */
1895 private DefaultTableModel getFvAdditionalTableModel() {
1896 if (fvAdditionalTableModel == null) {
1897 fvAdditionalTableModel = new DefaultTableModel();
1898 fvAdditionalTableModel.addColumn("FV Name");
1899 fvAdditionalTableModel.addColumn("Size");
1900 fvAdditionalTableModel.addColumn("Corresponding File Name");
1901 }
1902 return fvAdditionalTableModel;
1903 }
1904
1905 /**
1906 * This method initializes jButtonAddFv
1907 *
1908 * @return javax.swing.JButton
1909 */
1910 private JButton getJButtonAddFv() {
1911 if (jButtonAddFv == null) {
1912 jButtonAddFv = new JButton();
1913 jButtonAddFv.setPreferredSize(new java.awt.Dimension(80,20));
1914 jButtonAddFv.setEnabled(true);
1915 jButtonAddFv.setText("New");
1916 jButtonAddFv.addActionListener(new java.awt.event.ActionListener() {
1917 public void actionPerformed(java.awt.event.ActionEvent e) {
1918 if (jTableFvAdditional.isEditing()) {
1919 jTableFvAdditional.getCellEditor().stopCellEditing();
1920 }
1921 String[] row = {"", "", ""};
1922 fvAdditionalTableModel.addRow(row);
1923 }
1924 });
1925 }
1926 return jButtonAddFv;
1927 }
1928
1929 /**
1930 * This method initializes jButtonDelFv
1931 *
1932 * @return javax.swing.JButton
1933 */
1934 private JButton getJButtonDelFv() {
1935 if (jButtonDelFv == null) {
1936 jButtonDelFv = new JButton();
1937 jButtonDelFv.setPreferredSize(new java.awt.Dimension(80,20));
1938 jButtonDelFv.setEnabled(true);
1939 jButtonDelFv.setText("Delete");
1940 jButtonDelFv.addActionListener(new java.awt.event.ActionListener() {
1941 public void actionPerformed(java.awt.event.ActionEvent e) {
1942 //delete row in FvAdditional table.
1943 int selectedRow = jTableFvAdditional.getSelectedRow();
1944 if (selectedRow < 0) {
1945 return;
1946 }
1947 String fvName = fvAdditionalTableModel.getValueAt(selectedRow, 0) + "";
1948 fvAdditionalTableModel.removeRow(selectedRow);
1949 //
1950 //delete tab with selected FV name.
1951 //
1952 jTabbedPane.removeTabAt(jTabbedPane.indexOfTab(fvName));
1953 //delete FV Name from FvImages element.
1954 ffc.updateFvImageNameAll(fvName, null);
1955 //delete FvBinding from ModuleSA.
1956 ffc.removeFvBindingAll(fvName);
1957 docConsole.setSaved(false);
1958 }
1959 });
1960 }
1961 return jButtonDelFv;
1962 }
1963
1964 /**
1965 * This method initializes jButtonAddFvOptions
1966 *
1967 * @return javax.swing.JButton
1968 */
1969 private JButton getJButtonAddFvOptions() {
1970 if (jButtonAddFvOptions == null) {
1971 jButtonAddFvOptions = new JButton();
1972 jButtonAddFvOptions.setPreferredSize(new java.awt.Dimension(80,20));
1973 jButtonAddFvOptions.setEnabled(true);
1974 jButtonAddFvOptions.setText("Options");
1975 jButtonAddFvOptions.addActionListener(new java.awt.event.ActionListener() {
1976 public void actionPerformed(java.awt.event.ActionEvent e) {
1977 int selectedRow = jTableFvAdditional.getSelectedRow();
1978 if (selectedRow < 0) {
1979 return;
1980 }
1981 String fvName = jTableFvAdditional.getValueAt(selectedRow, 0)+"";
1982 String oldFvSize = jTableFvAdditional.getValueAt(selectedRow, 1)+"";
1983 String oldFileName = jTableFvAdditional.getValueAt(selectedRow, 2)+"";
1984 if (fvName.length() == 0) {
1985 return;
1986 }
1987 DefaultTableModel dtm = getFvAdditionalOptTableModel();
1988 new FpdFvOptions(fvName, dtm, ffc, docConsole);
1989
1990 String[] updatedFvInfo = getBasicFvInfo (fvName);
1991 if (!oldFvSize.equalsIgnoreCase(updatedFvInfo[1])) {
1992 sizeFromOptionDlg = true;
1993 jTableFvAdditional.setValueAt(updatedFvInfo[1], selectedRow, 1);
1994 sizeFromOptionDlg = false;
1995 }
1996 if (!oldFileName.equals(updatedFvInfo[2])) {
1997 fileFromOptionDlg = true;
1998 jTableFvAdditional.setValueAt(updatedFvInfo[2], selectedRow, 2);
1999 fileFromOptionDlg = false;
2000 }
2001 }
2002 });
2003 }
2004 return jButtonAddFvOptions;
2005 }
2006
2007 private String[] getBasicFvInfo (String fvName) {
2008 HashMap<String, String> mFvOpts = new HashMap<String, String>();
2009 ffc.getFvImagesFvImageOptions(fvName, mFvOpts);
2010 String bSize = "";
2011 String numBlks = "";
2012 String fvSize = "";
2013 String fvFile = "";
2014 if (mFvOpts.get("EFI_FILE_NAME") != null) {
2015 fvFile = mFvOpts.get("EFI_FILE_NAME");
2016 }
2017 if (mFvOpts.get("EFI_BLOCK_SIZE") != null && mFvOpts.get("EFI_NUM_BLOCKS") != null) {
2018 bSize = mFvOpts.get("EFI_BLOCK_SIZE");
2019 numBlks = mFvOpts.get("EFI_NUM_BLOCKS");
2020 boolean blockSizeWellFormat = true;
2021 boolean numOfBlockWellFormat = true;
2022 if (!DataValidation.isHexDoubleWordDataType(bSize) && !DataValidation.isInt(bSize)) {
2023 blockSizeWellFormat = false;
2024 JOptionPane.showMessageDialog(frame, fvName + " block size bad format.");
2025 }
2026 if (!DataValidation.isHexDoubleWordDataType(numBlks) && !DataValidation.isInt(numBlks)) {
2027 numOfBlockWellFormat = false;
2028 JOptionPane.showMessageDialog(frame, fvName + " number of blocks bad format.");
2029 }
2030 if (blockSizeWellFormat && numOfBlockWellFormat) {
2031 int size = Integer.decode(bSize);
2032 int num = Integer.decode(numBlks);
2033 fvSize = "0x" + Integer.toHexString(size*num);
2034 }
2035 }
2036
2037 return new String[]{fvName, fvSize, fvFile};
2038
2039 }
2040
2041 /**
2042 * This method initializes jPanelBgFvName
2043 *
2044 * @return javax.swing.JPanel
2045 */
2046 private JPanel getJPanelBgFvName() {
2047 if (jPanelBgFvName == null) {
2048 jPanelBgFvName = new JPanel();
2049 jPanelBgFvName.setPreferredSize(new java.awt.Dimension(80,55));
2050 jPanelBgFvName.add(getJButtonFvNameAdd(), null);
2051 jPanelBgFvName.add(getJButtonFvNameDel(), null);
2052 }
2053 return jPanelBgFvName;
2054 }
2055
2056 /**
2057 * This method initializes jPanelBgFvImage
2058 *
2059 * @return javax.swing.JPanel
2060 */
2061 private JPanel getJPanelBgFvImage() {
2062 if (jPanelBgFvImage == null) {
2063 jPanelBgFvImage = new JPanel();
2064 jPanelBgFvImage.setPreferredSize(new java.awt.Dimension(150,100));
2065 jPanelBgFvImage.add(getJButtonAddFvImage(), null);
2066 jPanelBgFvImage.add(getJButtonDelFvImage(), null);
2067 jPanelBgFvImage.add(getJButtonUpdateFvImage(), null);
2068 }
2069 return jPanelBgFvImage;
2070 }
2071
2072 /**
2073 * This method initializes jPanelW
2074 *
2075 * @return javax.swing.JPanel
2076 */
2077 private JPanel getJPanelW() {
2078 if (jPanelW == null) {
2079 jPanelW = new JPanel();
2080 jPanelW.add(getJPanelBgFvImage(), null);
2081 }
2082 return jPanelW;
2083 }
2084
2085 /**
2086 * This method initializes jPanelFvImageParaN
2087 *
2088 * @return javax.swing.JPanel
2089 */
2090 private JPanel getJPanelFvImageParaN() {
2091 if (jPanelFvImageParaN == null) {
2092 FlowLayout flowLayout3 = new FlowLayout();
2093 flowLayout3.setAlignment(java.awt.FlowLayout.CENTER);
2094 jPanelFvImageParaN = new JPanel();
2095 jPanelFvImageParaN.setLayout(flowLayout3);
2096 jPanelFvImageParaN.add(new StarLabel(), null);
2097 jPanelFvImageParaN.add(jLabelFvImageNames, null);
2098 jPanelFvImageParaN.add(jLabelFvParaName, null);
2099 jPanelFvImageParaN.add(getJTextFieldFvParaName(), null);
2100 }
2101 return jPanelFvImageParaN;
2102 }
2103
2104 /**
2105 * This method initializes jPanelFvImageParaS
2106 *
2107 * @return javax.swing.JPanel
2108 */
2109 private JPanel getJPanelFvImageParaS() {
2110 if (jPanelFvImageParaS == null) {
2111 FlowLayout flowLayout6 = new FlowLayout();
2112 flowLayout6.setAlignment(java.awt.FlowLayout.CENTER);
2113 jPanelFvImageParaS = new JPanel();
2114 jPanelFvImageParaS.setLayout(flowLayout6);
2115 jPanelFvImageParaS.add(jLabelFvParaType, null);
2116 jPanelFvImageParaS.add(getJComboBoxFvParaType(), null);
2117 }
2118 return jPanelFvImageParaS;
2119 }
2120
2121 /**
2122 * This method initializes jPanelFvImageParaC
2123 *
2124 * @return javax.swing.JPanel
2125 */
2126 // private JPanel getJPanelFvImageParaC() {
2127 // if (jPanelFvImageParaC == null) {
2128 // jPanelFvImageParaC = new JPanel();
2129 // jPanelFvImageParaC.add(getJScrollPaneFvImageNames(), null);
2130 // }
2131 // return jPanelFvImageParaC;
2132 // }
2133
2134 /**
2135 * This method initializes jPanelFvImageOptsN
2136 *
2137 * @return javax.swing.JPanel
2138 */
2139 private JPanel getJPanelFvImageOptsN() {
2140 if (jPanelFvImageOptsN == null) {
2141 jPanelFvImageOptsN = new JPanel();
2142 jPanelFvImageOptsN.add(jLabelOptions, null);
2143 jPanelFvImageOptsN.add(jLabelFvImageOptName, null);
2144 jPanelFvImageOptsN.add(getJTextFieldFvImageOptName(), null);
2145 jPanelFvImageOptsN.add(jLabelFvImageOptValue, null);
2146 jPanelFvImageOptsN.add(getJTextFieldFvImageOptValue(), null);
2147 }
2148 return jPanelFvImageOptsN;
2149 }
2150
2151 /**
2152 * This method initializes jPanelFvImageOptsS
2153 *
2154 * @return javax.swing.JPanel
2155 */
2156 private JPanel getJPanelFvImageOptsS() {
2157 if (jPanelFvImageOptsS == null) {
2158 jPanelFvImageOptsS = new JPanel();
2159 }
2160 return jPanelFvImageOptsS;
2161 }
2162
2163 /**
2164 * This method initializes jPanelFvImageOptsC
2165 *
2166 * @return javax.swing.JPanel
2167 */
2168 // private JPanel getJPanelFvImageOptsC() {
2169 // if (jPanelFvImageOptsC == null) {
2170 // jPanelFvImageOptsC = new JPanel();
2171 // jPanelFvImageOptsC.add(getJScrollPane(), null);
2172 // }
2173 // return jPanelFvImageOptsC;
2174 // }
2175
2176 /**
2177 * This method initializes jPanelFvImageParaE
2178 *
2179 * @return javax.swing.JPanel
2180 */
2181 private JPanel getJPanelFvImageParaE() {
2182 if (jPanelFvImageParaE == null) {
2183 jPanelFvImageParaE = new JPanel();
2184 jPanelFvImageParaE.add(getJPanelBgFvName(), null);
2185 }
2186 return jPanelFvImageParaE;
2187 }
2188
2189 /**
2190 * This method initializes jPanelFvImageOptsE
2191 *
2192 * @return javax.swing.JPanel
2193 */
2194 private JPanel getJPanelFvImageOptsE() {
2195 if (jPanelFvImageOptsE == null) {
2196 jPanelFvImageOptsE = new JPanel();
2197 jPanelFvImageOptsE.add(getJPanelFvImageOptsButtonGroup(), null);
2198 }
2199 return jPanelFvImageOptsE;
2200 }
2201
2202 /**
2203 * This method initializes jPanelFvImageSN
2204 *
2205 * @return javax.swing.JPanel
2206 */
2207 private JPanel getJPanelFvImageSN() {
2208 if (jPanelFvImageSN == null) {
2209 jPanelFvImageSN = new JPanel();
2210 jPanelFvImageSN.add(getJCheckBoxFvProperty(), null);
2211 jPanelFvImageSN.add(jLabelFvPropName, null);
2212 jPanelFvImageSN.add(getJTextFieldFvPropName(), null);
2213 jPanelFvImageSN.add(jLabelFvPropValue, null);
2214 jPanelFvImageSN.add(getJTextFieldFvPropValue(), null);
2215 }
2216 return jPanelFvImageSN;
2217 }
2218
2219 /**
2220 * This method initializes jPanelFvImageSE
2221 *
2222 * @return javax.swing.JPanel
2223 */
2224 private JPanel getJPanelFvImageSE() {
2225 if (jPanelFvImageSE == null) {
2226 jPanelFvImageSE = new JPanel();
2227 jPanelFvImageSE.add(getJPanelFvPropButtonGroup(), null);
2228 }
2229 return jPanelFvImageSE;
2230 }
2231
2232 /**
2233 * This method initializes jPanelFvImageSS
2234 *
2235 * @return javax.swing.JPanel
2236 */
2237 private JPanel getJPanelFvImageSS() {
2238 if (jPanelFvImageSS == null) {
2239 jPanelFvImageSS = new JPanel();
2240 }
2241 return jPanelFvImageSS;
2242 }
2243
2244 /**
2245 * @param args
2246 */
2247 public static void main(String[] args) {
2248 // TODO Auto-generated method stub
2249 new FpdFlash().setVisible(true);
2250 }
2251
2252 /**
2253 * This method initializes this
2254 *
2255 * @return void
2256 */
2257 private void initialize() {
2258 this.setSize(660, 650);
2259 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
2260 this.setContentPane(getJContentPane());
2261 this.setTitle("FPD Flash Definitions");
2262 this.addInternalFrameListener(new InternalFrameAdapter(){
2263 public void internalFrameDeactivated(InternalFrameEvent e){
2264 if (jTableFvProp.isEditing()) {
2265 jTableFvProp.getCellEditor().stopCellEditing();
2266 }
2267 if (jTableFvImageNames.isEditing()) {
2268 jTableFvImageNames.getCellEditor().stopCellEditing();
2269 }
2270 if (jTableFvInfo.isEditing()) {
2271 jTableFvInfo.getCellEditor().stopCellEditing();
2272 }
2273 if (jTableFvAdditional.isEditing()) {
2274 jTableFvAdditional.getCellEditor().stopCellEditing();
2275 }
2276 }
2277 });
2278 }
2279
2280 private void init(FpdFileContents ffc) {
2281 initFvAttributes();
2282
2283 jTextFieldFdf.setText("");
2284 String fdfFile = ffc.getFlashDefinitionFile();
2285 if (fdfFile != null && fdfFile.length() > 0) {
2286 jCheckBoxFdf.setSelected(true);
2287 jTextFieldFdf.setText(fdfFile);
2288 String fdfPath = System.getenv("WORKSPACE") + File.separator + fdfFile;
2289 initFvInFdfTable(fdfPath);
2290 }
2291
2292 initFvAdditionalTable();
2293 }
2294
2295 private void getOptionNameValue(Map<String, String> m){
2296 for (int i = 0; i < jTableFvImageOpts.getRowCount(); ++i) {
2297 m.put(fvOptionTableModel.getValueAt(i, 0)+"", fvOptionTableModel.getValueAt(i, 1)+"");
2298 }
2299 }
2300 /**
2301 * This method initializes jContentPane
2302 *
2303 * @return javax.swing.JPanel
2304 */
2305 private JPanel getJContentPane() {
2306 if (jContentPane == null) {
2307 jContentPane = new JPanel();
2308 jContentPane.setLayout(new BorderLayout());
2309 jContentPane.add(getJPanelContentEast(), java.awt.BorderLayout.EAST);
2310 jContentPane.add(getJPanelContentSouth(), java.awt.BorderLayout.SOUTH);
2311 jContentPane.add(getJPanelContentWest(), java.awt.BorderLayout.WEST);
2312 jContentPane.add(getJPanelContentNorth(), java.awt.BorderLayout.NORTH);
2313 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);
2314 }
2315 return jContentPane;
2316 }
2317
2318 private void getFlashInfoFromFdf (String fdfPath) {
2319 File fdf = new File(fdfPath);
2320 if (!fdf.exists()) {
2321 return;
2322 }
2323 int lines = 0;
2324
2325 try {
2326 FileReader reader = new FileReader(fdf);
2327 BufferedReader in = new BufferedReader(reader);
2328 String str;
2329
2330 while ((str = in.readLine()) != null) {
2331 ++lines;
2332 str = str.trim();
2333 //
2334 // skip empty line, comment (start with //)
2335 //
2336 if (str.length() == 0 || str.startsWith("//")) {
2337 continue;
2338 }
2339 //
2340 // ErasePolarity
2341 //
2342 if (str.startsWith("ErasePolarity")) {
2343 erasePolarity = str.substring(str.indexOf("=") + 1, str.lastIndexOf(",")).trim();
2344 }
2345 //
2346 // dig into Block section.
2347 //
2348 if (str.startsWith("Block") && str.endsWith("}")) {
2349 String[] blockSec = str.split(",");
2350 String nv = blockSec[1].trim();
2351 String[] sizeSec = nv.split("=");
2352 vBlockSize.add(sizeSec[1].trim());
2353 }
2354
2355 }
2356
2357 reader.close();
2358 in.close();
2359 }
2360 catch (Exception e) {
2361
2362 }
2363 }
2364
2365 private void getFvInfoFromFdf(String fdfPath, Vector<FvInfoFromFdf> vFvInfo) {
2366 File fdf = new File(fdfPath);
2367 if (!fdf.exists()) {
2368 return;
2369 }
2370 int lines = 0;
2371
2372 try {
2373 FileReader reader = new FileReader(fdf);
2374 BufferedReader in = new BufferedReader(reader);
2375 String str;
2376
2377 while ((str = in.readLine()) != null) {
2378 ++lines;
2379 str = str.trim();
2380 //
2381 // skip empty line, comment (start with //)
2382 //
2383 if (str.length() == 0 || str.startsWith("//")) {
2384 continue;
2385 }
2386 //
2387 // dig into Region {} section, create FvInfoFromFdf object for it.
2388 //
2389 if (str.startsWith("Region") && str.endsWith("{")) {
2390 FvInfoFromFdf fvInfo = new FvInfoFromFdf();
2391 boolean nameFound = false;
2392 boolean sizeFound = false;
2393 while ((str = in.readLine()) != null) {
2394 ++lines;
2395 str = str.trim();
2396 //
2397 // skip empty line, comment (start with //)
2398 //
2399 if (str.length() == 0 || str.startsWith("//")) {
2400 continue;
2401 }
2402
2403 if (str.startsWith("Name")) {
2404 int firstQuote = str.indexOf("\"");
2405 int lastQuote = str.lastIndexOf("\"");
2406 fvInfo.setFvName(str.substring(firstQuote + 1, lastQuote));
2407 nameFound = true;
2408 }
2409
2410 if (str.startsWith("Size")) {
2411 int equalIndex = str.indexOf("=");
2412 int commaIndex = str.indexOf(",");
2413 fvInfo.setSize(str.substring(equalIndex + 1, commaIndex).trim());
2414 sizeFound = true;
2415 }
2416
2417 if (nameFound && sizeFound) {
2418 break;
2419 }
2420 }
2421
2422 vFvInfo.add(fvInfo);
2423 }
2424 //
2425 // dig into File {} section, supply file name information to existing FvInfoFromFdf object.
2426 //
2427 if (str.startsWith("File")) {
2428 boolean fileNameFound = false;
2429 boolean fvFound = false;
2430 String fileName = "";
2431 String fvName = "";
2432 while ((str = in.readLine()) != null) {
2433 ++lines;
2434 str = str.trim();
2435 //
2436 // skip empty line, comment (start with //)
2437 //
2438 if (str.length() == 0 || str.startsWith("//")) {
2439 continue;
2440 }
2441
2442 if (str.startsWith("Name")) {
2443 int firstQuote = str.indexOf("\"");
2444 int lastQuote = str.lastIndexOf("\"");
2445 fileName = str.substring(firstQuote + 1, lastQuote);
2446 fileNameFound = true;
2447 }
2448
2449 if (str.startsWith("Region")) {
2450 int firstQuote = str.indexOf("\"");
2451 int lastQuote = str.lastIndexOf("\"");
2452 fvName = str.substring(firstQuote + 1, lastQuote);
2453 fvFound = true;
2454 }
2455
2456 if (fileNameFound && fvFound) {
2457 break;
2458 }
2459 }
2460
2461 for (int i = 0; i <vFvInfo.size(); ++i) {
2462 if (vFvInfo.get(i).getFvName().equals(fvName)) {
2463 vFvInfo.get(i).setEfiFileName(fileName);
2464 }
2465 }
2466 }
2467
2468 }
2469
2470 reader.close();
2471 in.close();
2472 }
2473 catch (Exception e) {
2474
2475 }
2476
2477 }
2478
2479 // class ModuleSAInfo {
2480 // private int rowNumber = -1;
2481 // private String moduleGuid = null;
2482 // private String moduleVersion = null;
2483 // private String packageGuid = null;
2484 // private String packageVersion = null;
2485 // private String arch = null;
2486 //
2487 // public ModuleSAInfo (String mg, String mv, String pg, String pv, String a) {
2488 // moduleGuid = mg;
2489 // moduleVersion = mv;
2490 // packageGuid = pg;
2491 // packageVersion = pv;
2492 // arch = a;
2493 // }
2494 //
2495 // /**
2496 // * @return Returns the arch.
2497 // */
2498 // public String getArch() {
2499 // return arch;
2500 // }
2501 //
2502 // /**
2503 // * @param arch The arch to set.
2504 // */
2505 // public void setArch(String arch) {
2506 // this.arch = arch;
2507 // }
2508 //
2509 // /**
2510 // * @return Returns the moduleGuid.
2511 // */
2512 // public String getModuleGuid() {
2513 // return moduleGuid;
2514 // }
2515 //
2516 // /**
2517 // * @param moduleGuid The moduleGuid to set.
2518 // */
2519 // public void setModuleGuid(String moduleGuid) {
2520 // this.moduleGuid = moduleGuid;
2521 // }
2522 //
2523 // /**
2524 // * @return Returns the moduleVersion.
2525 // */
2526 // public String getModuleVersion() {
2527 // return moduleVersion;
2528 // }
2529 //
2530 // /**
2531 // * @param moduleVersion The moduleVersion to set.
2532 // */
2533 // public void setModuleVersion(String moduleVersion) {
2534 // this.moduleVersion = moduleVersion;
2535 // }
2536 //
2537 // /**
2538 // * @return Returns the packageGuid.
2539 // */
2540 // public String getPackageGuid() {
2541 // return packageGuid;
2542 // }
2543 //
2544 // /**
2545 // * @param packageGuid The packageGuid to set.
2546 // */
2547 // public void setPackageGuid(String packageGuid) {
2548 // this.packageGuid = packageGuid;
2549 // }
2550 //
2551 // /**
2552 // * @return Returns the packageVersion.
2553 // */
2554 // public String getPackageVersion() {
2555 // return packageVersion;
2556 // }
2557 //
2558 // /**
2559 // * @param packageVersion The packageVersion to set.
2560 // */
2561 // public void setPackageVersion(String packageVersion) {
2562 // this.packageVersion = packageVersion;
2563 // }
2564 //
2565 // /**
2566 // * @return Returns the rowNumber.
2567 // */
2568 // public int getRowNumber() {
2569 // return rowNumber;
2570 // }
2571 //
2572 // /**
2573 // * @param rowNumber The rowNumber to set.
2574 // */
2575 // public void setRowNumber(int rowNumber) {
2576 // this.rowNumber = rowNumber;
2577 // }
2578 // }
2579
2580 private class ModuleOrderPane extends JPanel {
2581
2582 /**
2583 *
2584 */
2585 private static final long serialVersionUID = 1L;
2586 private JPanel jPanelModOrderN = null;
2587 private JPanel jPanelModOrderS = null;
2588 private JPanel jPanelModOrderC = null;
2589 private JScrollPane jScrollPaneModInFv = null;
2590 private JTable jTableModInFv = null;
2591 private JPanel jPanelController = null;
2592 private JScrollPane jScrollPaneFpdModules = null;
2593 private JTable jTableFpdModules = null;
2594 private JButton jButtonUp = null;
2595 private JButton jButtonInsert = null;
2596 private JButton jButtonRemove = null;
2597 private JButton jButtonDown = null;
2598 private JButton jButtonOk = null;
2599 private JButton jButtonCancel = null;
2600 private IDefaultTableModel modInFvTableModel = null;
2601 private IDefaultTableModel fpdModTableModel = null;
2602 // private ArrayList<ModuleSAInfo> listTableModInFvModuleSAInfo = null;
2603 // private ArrayList<ModuleSAInfo> listTableFpdModulesModuleSAInfo = null;
2604 private String title = null;
2605 private String outputFileName = null;
2606
2607 public ModuleOrderPane(String tabTitle, String file) {
2608 super(new BorderLayout());
2609 title = tabTitle;
2610 outputFileName = file;
2611 // listTableModInFvModuleSAInfo = new ArrayList<ModuleSAInfo>();
2612 // listTableFpdModulesModuleSAInfo = new ArrayList<ModuleSAInfo>();
2613 add(getJPanelModOrderN(), java.awt.BorderLayout.NORTH);
2614 add(getJPanelModOrderS(), java.awt.BorderLayout.SOUTH);
2615 add(getJPanelModOrderC(), java.awt.BorderLayout.CENTER);
2616 showModulesInFv(title);
2617 showAllModulesInPlatform();
2618 }
2619
2620 private void showModulesInFv(String fvName) {
2621 int size = ffc.getUserExtsIncModCount(fvName);
2622
2623 if (size != -1) {
2624 String[][] saa = new String[size][5];
2625 ffc.getUserExtsIncMods(fvName, saa);
2626
2627 for (int i = 0; i < size; ++i) {
2628 String moduleKey = saa[i][0] + " " + saa[i][1] + " " + saa[i][2] + " " + saa[i][3];
2629 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
2630 String name = "N/A";
2631 if (mi != null) {
2632 name = mi.getName();
2633 }
2634
2635 String[] row = { name, saa[i][0] , saa[i][1], saa[i][2] , saa[i][3], saa[i][4] };
2636 modInFvTableModel.addRow(row);
2637 }
2638 }
2639 //
2640 // From ModuleSAs, get module guids with FvBinding = fvName.
2641 //
2642 Vector<String[]> vModuleSA = new Vector<String[]>();
2643 ffc.getFrameworkModuleSAByFvBinding(fvName, vModuleSA);
2644 //
2645 // If BuildOptions->UserExtensions already contain these module info,
2646 // no need to add them into table again.
2647 //
2648 Iterator<String[]> iter = vModuleSA.iterator();
2649 while (iter.hasNext()){
2650 String[] sa = iter.next();
2651 if (!moduleInfoInTable (sa, modInFvTableModel)) {
2652 String moduleKey = sa[0] + " " + sa[1] + " " + sa[2] + " " + sa[3];
2653 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
2654 String name = "N/A";
2655 if (mi != null) {
2656 name = mi.getName();
2657 }
2658 String[] row = { name, sa[0] , sa[1], sa[2] , sa[3], sa[4] };
2659 modInFvTableModel.addRow(row);
2660 }
2661 }
2662
2663 }
2664
2665 private void showAllModulesInPlatform() {
2666 int size = ffc.getFrameworkModulesCount();
2667 String[][] saa = new String[size][5];
2668 ffc.getFrameworkModulesInfo(saa);
2669
2670 for (int i = 0; i < size; ++i) {
2671 if (moduleInfoInTable(saa[i], modInFvTableModel) || moduleInfoInTable(saa[i], fpdModTableModel)) {
2672 continue;
2673 }
2674 String moduleKey = saa[i][0] + " " + saa[i][1] + " " + saa[i][2] + " " + saa[i][3];
2675 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);
2676 String name = "N/A";
2677 if (mi != null) {
2678 name = mi.getName();
2679 }
2680 String[] row = { name, saa[i][0] , saa[i][1], saa[i][2] , saa[i][3], saa[i][4] };
2681 fpdModTableModel.addRow(row);
2682 }
2683
2684 TableSorter sorter = (TableSorter)jTableFpdModules.getModel();
2685 sorter.setSortState(0, TableSorter.ASCENDING);
2686 }
2687
2688
2689 private boolean moduleInfoInTable (String[] moduleInfo, DefaultTableModel model) {
2690 boolean matched = false;
2691 int size = model.getDataVector().size();
2692 for (int i = 0; i < size; ++i) {
2693 Vector rowData = (Vector)model.getDataVector().elementAt(i);
2694 for (int j = 1; j < rowData.size(); ++j) {
2695 if (rowData.elementAt(j) == null && moduleInfo[j-1] == null) {
2696 matched = true;
2697 }
2698 else if (rowData.elementAt(j).equals("null") && moduleInfo[j-1] == null) {
2699 matched = true;
2700 }
2701 else if (rowData.elementAt(j) == null && moduleInfo[j-1].equals("null")) {
2702 matched = true;
2703 }
2704 else if (rowData.elementAt(j) != null && rowData.elementAt(j).toString().equalsIgnoreCase(moduleInfo[j-1])) {
2705 matched = true;
2706 }
2707 else {
2708 matched = false;
2709 break;
2710 }
2711 }
2712
2713 if (matched) {
2714 return true;
2715 }
2716
2717 }
2718 return false;
2719 }
2720
2721
2722
2723 /**
2724 * This method initializes jPanelModOrderN
2725 *
2726 * @return javax.swing.JPanel
2727 */
2728 private JPanel getJPanelModOrderN() {
2729 if (jPanelModOrderN == null) {
2730 jPanelModOrderN = new JPanel();
2731 }
2732 return jPanelModOrderN;
2733 }
2734
2735 /**
2736 * This method initializes jPanelModOrderS
2737 *
2738 * @return javax.swing.JPanel
2739 */
2740 private JPanel getJPanelModOrderS() {
2741 if (jPanelModOrderS == null) {
2742 FlowLayout flowLayout6 = new FlowLayout();
2743 flowLayout6.setAlignment(java.awt.FlowLayout.RIGHT);
2744 jPanelModOrderS = new JPanel();
2745 jPanelModOrderS.setLayout(flowLayout6);
2746 jPanelModOrderS.add(getJButtonOk(), null);
2747 jPanelModOrderS.add(getJButtonCancel(), null);
2748 }
2749 return jPanelModOrderS;
2750 }
2751
2752 /**
2753 * This method initializes jPanelModOrderC
2754 *
2755 * @return javax.swing.JPanel
2756 */
2757 private JPanel getJPanelModOrderC() {
2758 if (jPanelModOrderC == null) {
2759 jPanelModOrderC = new JPanel();
2760 jPanelModOrderC.add(getJScrollPaneModInFv(), null);
2761 jPanelModOrderC.add(getJPanelController(), null);
2762 jPanelModOrderC.add(getJScrollPaneFpdModules(), null);
2763 }
2764 return jPanelModOrderC;
2765 }
2766
2767 /**
2768 * This method initializes jScrollPaneModInFv
2769 *
2770 * @return javax.swing.JScrollPane
2771 */
2772 private JScrollPane getJScrollPaneModInFv() {
2773 if (jScrollPaneModInFv == null) {
2774 jScrollPaneModInFv = new JScrollPane();
2775 jScrollPaneModInFv.setPreferredSize(new java.awt.Dimension(200,500));
2776 jScrollPaneModInFv.setViewportView(getJTableModInFv());
2777 }
2778 return jScrollPaneModInFv;
2779 }
2780
2781 /**
2782 * This method initializes jTableModInFv
2783 *
2784 * @return javax.swing.JTable
2785 */
2786 private JTable getJTableModInFv() {
2787 if (jTableModInFv == null) {
2788 modInFvTableModel = new IDefaultTableModel();
2789
2790 jTableModInFv = new JTable(modInFvTableModel){
2791 /**
2792 *
2793 */
2794 private static final long serialVersionUID = 4903583933542581721L;
2795
2796 public String getToolTipText(MouseEvent e) {
2797 String tip = null;
2798 java.awt.Point p = e.getPoint();
2799 int rowIndex = rowAtPoint(p);
2800 // int colIndex = columnAtPoint(p);
2801 // int realColumnIndex = convertColumnIndexToModel(colIndex);
2802
2803 TableModel model = getModel();
2804 String mg = (String) model.getValueAt(rowIndex, 1);
2805 String mv = (String) model.getValueAt(rowIndex, 2);
2806 String pg = (String) model.getValueAt(rowIndex, 3);
2807 String pv = (String) model.getValueAt(rowIndex, 4);
2808 String arch = (String) model.getValueAt(rowIndex, 5);
2809 ModuleIdentification mi = WorkspaceProfile.getModuleId(mg + " " + mv + " " + pg + " " + pv);
2810 if (mi != null) {
2811 tip = "Path: " + mi.getPath() + "; Arch: " + arch + ";";
2812 }
2813 else {
2814 tip = "No Module Path Information.";
2815 }
2816
2817 return tip;
2818 }