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