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