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