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