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