Fix EDKT337,Double click on modules in "Framework Modules" of Platforms should be...
[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
ed850fbf 28import org.tianocore.frameworkwizard.common.IDefaultTableModel;\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
61919f8c 33import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r
a13899c5 34\r
35import java.awt.FlowLayout;\r
36import java.awt.event.ActionEvent;\r
2b70a636 37import java.awt.event.ComponentAdapter;\r
38import java.awt.event.ComponentEvent;\r
a13899c5 39import java.awt.event.ItemEvent;\r
40import java.awt.event.ItemListener;\r
17bd391e 41import java.awt.event.MouseAdapter;\r
42import java.awt.event.MouseEvent;\r
3658f95e 43import java.io.BufferedReader;\r
a13899c5 44import java.io.File;\r
3658f95e 45import java.io.FileReader;\r
2b70a636 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
54aa8673 108 private JButton jButtonFvNameAdd = null;\r
4da2e625 109 private JScrollPane jScrollPaneFvImageNames = null;\r
110 private JTable jTableFvImageNames = null;\r
54aa8673 111 private JButton jButtonFvNameDel = null;\r
4da2e625 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
ed850fbf 148 private IDefaultTableModel fvInFdfTableModel = null; // @jve:decl-index=0:visual-constraint=""\r
3658f95e 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
54aa8673 590 jComboBoxFvParaType.setSelectedIndex(0);\r
4da2e625 591 jComboBoxFvParaType.setPreferredSize(new java.awt.Dimension(180,20));\r
4da2e625 592 jComboBoxFvParaType.addItemListener(new ItemListener() {\r
a13899c5 593\r
594 public void itemStateChanged(ItemEvent arg0) {\r
595 // TODO disable attribute settings when ValidImageNames selected.\r
72426064 596 int selectedRow = jTableFvInfo.getSelectedRow();\r
597 if (selectedRow < 0) {\r
598 return;\r
599 }\r
600 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";\r
601 String oldType = jTableFvInfo.getValueAt(selectedRow, 1)+"";\r
602 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, oldType);\r
603 if (fvImagePos < 0) {\r
604 return;\r
605 }\r
a13899c5 606 \r
72426064 607 String type = jComboBoxFvParaType.getSelectedItem()+"";\r
608 ffc.updateFvImagesFvImageType(fvImagePos, type);\r
609 jTableFvInfo.setValueAt(type, selectedRow, 1);\r
610 docConsole.setSaved(false);\r
a13899c5 611 }\r
612 \r
613 });\r
614 }\r
4da2e625 615 return jComboBoxFvParaType;\r
a13899c5 616 }\r
617\r
618\r
619 /**\r
620 * This method initializes jTextField2 \r
621 * \r
622 * @return javax.swing.JTextField \r
623 */\r
4da2e625 624 private JTextField getJTextFieldFvParaName() {\r
625 if (jTextFieldFvParaName == null) {\r
626 jTextFieldFvParaName = new JTextField();\r
627 jTextFieldFvParaName.setPreferredSize(new java.awt.Dimension(140,20));\r
a13899c5 628 }\r
4da2e625 629 return jTextFieldFvParaName;\r
a13899c5 630 }\r
631\r
632\r
633 /**\r
634 * This method initializes jButton2 \r
635 * \r
636 * @return javax.swing.JButton \r
637 */\r
54aa8673 638 private JButton getJButtonFvNameAdd() {\r
639 if (jButtonFvNameAdd == null) {\r
640 jButtonFvNameAdd = new JButton();\r
641 jButtonFvNameAdd.setPreferredSize(new Dimension(80, 20));\r
642 jButtonFvNameAdd.setEnabled(true);\r
643 jButtonFvNameAdd.setText("Add");\r
644 jButtonFvNameAdd.addActionListener(new AbstractAction() {\r
44053733 645 /**\r
646 * \r
647 */\r
648 private static final long serialVersionUID = 1L;\r
649\r
a13899c5 650 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 651 if (jTextFieldFvParaName.getText().length() > 0){\r
652 String[] row = {jTextFieldFvParaName.getText()}; \r
54aa8673 653 int selectedRow = jTableFvInfo.getSelectedRow();\r
654 if (selectedRow < 0) {\r
72426064 655 return;\r
656 }\r
657 \r
54aa8673 658 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";\r
659 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";\r
72426064 660 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);\r
661 \r
662 if (fvImagePos < 0) {\r
663 // new FvImage.\r
54aa8673 664 ffc.genFvImagesFvImage(row, jComboBoxFvParaType.getSelectedItem()+"", null); \r
72426064 665 }\r
666 else {\r
54aa8673 667 //append Fv name.\r
668 ffc.addFvImageNamesInFvImage(fvImagePos, row); \r
72426064 669 }\r
54aa8673 670 docConsole.setSaved(false);\r
671 fvImageNameTableModel.addRow(row);\r
672 fvNameList += " ";\r
673 fvNameList += row[0];\r
674 jTableFvInfo.setValueAt(fvNameList.trim(), selectedRow, 0);\r
675 jTableFvImageNames.changeSelection(jTableFvImageNames.getRowCount() - 1, 0, false, false);\r
a13899c5 676 }\r
677 }\r
678 });\r
679 }\r
54aa8673 680 return jButtonFvNameAdd;\r
a13899c5 681 }\r
682\r
683\r
684 /**\r
685 * This method initializes jScrollPane2 \r
686 * \r
687 * @return javax.swing.JScrollPane \r
688 */\r
4da2e625 689 private JScrollPane getJScrollPaneFvImageNames() {\r
690 if (jScrollPaneFvImageNames == null) {\r
691 jScrollPaneFvImageNames = new JScrollPane();\r
72426064 692 jScrollPaneFvImageNames.setPreferredSize(new java.awt.Dimension(350,80));\r
4da2e625 693 jScrollPaneFvImageNames.setViewportView(getJTableFvImageNames());\r
a13899c5 694 }\r
4da2e625 695 return jScrollPaneFvImageNames;\r
a13899c5 696 }\r
697\r
698\r
699 /**\r
700 * This method initializes jTable1 \r
701 * \r
702 * @return javax.swing.JTable \r
703 */\r
4da2e625 704 private JTable getJTableFvImageNames() {\r
705 if (jTableFvImageNames == null) {\r
ed850fbf 706 fvImageNameTableModel = new IDefaultTableModel();\r
4da2e625 707 jTableFvImageNames = new JTable(fvImageNameTableModel);\r
72426064 708 jTableFvImageNames.setRowHeight(20);\r
a13899c5 709 fvImageNameTableModel.addColumn("FV Image Name");\r
72426064 710 \r
a13899c5 711 }\r
4da2e625 712 return jTableFvImageNames;\r
a13899c5 713 }\r
714\r
715\r
716 /**\r
717 * This method initializes jButton3 \r
718 * \r
719 * @return javax.swing.JButton \r
720 */\r
54aa8673 721 private JButton getJButtonFvNameDel() {\r
722 if (jButtonFvNameDel == null) {\r
723 jButtonFvNameDel = new JButton();\r
724 jButtonFvNameDel.setPreferredSize(new Dimension(80, 20));\r
725 jButtonFvNameDel.setEnabled(true);\r
726 jButtonFvNameDel.setText("Delete");\r
727 jButtonFvNameDel.addActionListener(new AbstractAction() {\r
44053733 728 /**\r
729 * \r
730 */\r
731 private static final long serialVersionUID = 1L;\r
732\r
a13899c5 733 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 734 if (jTableFvImageNames.getSelectedRow() >= 0){\r
54aa8673 735 int selectedRow = jTableFvInfo.getSelectedRow();\r
736 if (selectedRow < 0) {\r
737 return;\r
738 }\r
739 \r
740 String selectedFvName = jTableFvImageNames.getValueAt(jTableFvImageNames.getSelectedRow(), 0)+"";\r
741 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";\r
742 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";\r
743 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);\r
744 \r
745 if (fvImagePos < 0) {\r
746 return; \r
747 }\r
748 else {\r
749 //delete Fv name.\r
750 ffc.updateFvImageNamesInFvImage(fvImagePos, selectedFvName, null);\r
751 }\r
752 docConsole.setSaved(false);\r
753 String newList = removeFvNameFromList(fvNameList, selectedFvName);\r
754 jTableFvInfo.setValueAt(newList, selectedRow, 0); \r
4da2e625 755 fvImageNameTableModel.removeRow(jTableFvImageNames.getSelectedRow());\r
a13899c5 756 }\r
757 }\r
758 });\r
759 }\r
54aa8673 760 return jButtonFvNameDel;\r
761 }\r
762\r
763 private String removeFvNameFromList (String list, String name) {\r
764 String[] nameArray = list.split(" ");\r
765 int occursAt = -1;\r
766 for (int i = 0; i < nameArray.length; ++i) {\r
767 if (nameArray[i].equals(name)) {\r
768 occursAt = i;\r
769 break;\r
770 }\r
771 }\r
772 \r
773 if (occursAt == -1) {\r
774 return list;\r
775 }\r
776 \r
777 String newList = " ";\r
778 for (int j = 0; j < nameArray.length; ++j) {\r
779 if (j != occursAt) {\r
780 newList += nameArray[j];\r
781 newList += " ";\r
782 }\r
783 }\r
784 \r
785 return newList.trim();\r
786 }\r
a13899c5 787\r
788 \r
4da2e625 789 private JPanel getJPanelFvImageOpts() {\r
a13899c5 790 \r
791\r
4da2e625 792 if (jPanelFvImageOpts == null) {\r
a13899c5 793 //ToDo add ButtonGroup for RadioButtons\r
72426064 794 FlowLayout flowLayout5 = new FlowLayout();\r
795 flowLayout5.setAlignment(java.awt.FlowLayout.LEFT);\r
796 jLabelOptions = new JLabel();\r
797 jLabelOptions.setText("Attribute");\r
4da2e625 798 jLabelFvImageOptValue = new JLabel();\r
799 jLabelFvImageOptValue.setEnabled(true);\r
800 jLabelFvImageOptValue.setText("Value");\r
801 jLabelFvImageOptValue.setPreferredSize(new Dimension(38, 20));\r
802 jLabelFvImageOptName = new JLabel();\r
803 jLabelFvImageOptName.setEnabled(true);\r
804 jLabelFvImageOptName.setText("Name");\r
805 jLabelFvImageOptName.setPreferredSize(new Dimension(38, 20));\r
806 jPanelFvImageOpts = new JPanel();\r
72426064 807 jPanelFvImageOpts.setLayout(flowLayout5);\r
808 jPanelFvImageOpts.setPreferredSize(new java.awt.Dimension(450,130));\r
a13899c5 809 \r
a13899c5 810 \r
4da2e625 811 jPanelFvImageOpts.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));\r
72426064 812 jPanelFvImageOpts.add(jLabelOptions, null);\r
4da2e625 813 jPanelFvImageOpts.add(jLabelFvImageOptName, null);\r
814 jPanelFvImageOpts.add(getJTextFieldFvImageOptName(), null);\r
815 jPanelFvImageOpts.add(jLabelFvImageOptValue, null);\r
816 jPanelFvImageOpts.add(getJTextFieldFvImageOptValue(), null);\r
817 jPanelFvImageOpts.add(getJScrollPane(), null);\r
818 jPanelFvImageOpts.add(getJPanelFvImageOptsButtonGroup(), null);\r
a13899c5 819 \r
820 \r
821 \r
822\r
823 \r
824 }\r
4da2e625 825 return jPanelFvImageOpts;\r
a13899c5 826 }\r
827\r
828\r
829 /**\r
830 * This method initializes jButton4 \r
831 * \r
832 * @return javax.swing.JButton \r
833 */\r
4da2e625 834 private JButton getJButtonAddFvImage() {\r
835 if (jButtonAddFvImage == null) {\r
836 jButtonAddFvImage = new JButton();\r
72426064 837 jButtonAddFvImage.setPreferredSize(new java.awt.Dimension(150,20));\r
838 jButtonAddFvImage.setText("New FV Attributes");\r
4da2e625 839 jButtonAddFvImage.addActionListener(new AbstractAction() {\r
44053733 840 /**\r
841 * \r
842 */\r
843 private static final long serialVersionUID = 1L;\r
844\r
a13899c5 845 public void actionPerformed(java.awt.event.ActionEvent e) {\r
a13899c5 846 \r
54aa8673 847// String imageName = " ";\r
848// for (int i = 0; i < jTableFvImageNames.getRowCount(); ++i){\r
849// imageName += (String)jTableFvImageNames.getValueAt(i, 0);\r
850// imageName += " ";\r
72426064 851// }\r
54aa8673 852// imageName = imageName.trim();\r
853 \r
854// LinkedHashMap<String, String> m = null;\r
855// m = new LinkedHashMap<String, String>();\r
856// getOptionNameValue(m);\r
857// ffc.genFvImagesFvImage(imageName.split(" "), jComboBoxFvParaType.getSelectedItem()+"", m);\r
858// docConsole.setSaved(false);\r
859 fvImageNameTableModel.setRowCount(0);\r
860 fvOptionTableModel.setRowCount(0);\r
861 Object[] row = {"", jComboBoxFvParaType.getSelectedItem()};\r
862 fvImageParaTableModel.addRow(row);\r
863 jTableFvInfo.changeSelection(jTableFvInfo.getRowCount() - 1, 0, false, false);\r
a13899c5 864 }\r
865 });\r
866 }\r
4da2e625 867 return jButtonAddFvImage;\r
a13899c5 868 }\r
869\r
870\r
871 /**\r
872 * This method initializes jScrollPane3 \r
873 * \r
874 * @return javax.swing.JScrollPane \r
875 */\r
4da2e625 876 private JScrollPane getJScrollPaneFvInfo() {\r
877 if (jScrollPaneFvInfo == null) {\r
878 jScrollPaneFvInfo = new JScrollPane();\r
879 jScrollPaneFvInfo.setPreferredSize(new java.awt.Dimension(480,150));\r
880 jScrollPaneFvInfo.setViewportView(getJTableFvInfo());\r
a13899c5 881 }\r
4da2e625 882 return jScrollPaneFvInfo;\r
a13899c5 883 }\r
884\r
885\r
886 /**\r
887 * This method initializes jTable2 \r
888 * \r
889 * @return javax.swing.JTable \r
890 */\r
4da2e625 891 private JTable getJTableFvInfo() {\r
892 if (jTableFvInfo == null) {\r
a13899c5 893 fvImageParaTableModel = new ImageParaTableModel();\r
4da2e625 894 jTableFvInfo = new JTable(fvImageParaTableModel);\r
a13899c5 895 fvImageParaTableModel.addColumn("FvImageNames");\r
896 fvImageParaTableModel.addColumn("Type");\r
ae0d4fd2 897 \r
4da2e625 898 jTableFvInfo.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
72426064 899 jTableFvInfo.setRowHeight(20);\r
4da2e625 900 jTableFvInfo.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
a13899c5 901 public void valueChanged(ListSelectionEvent e) {\r
902 if (e.getValueIsAdjusting()){\r
903 return;\r
904 }\r
905 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
906 if (lsm.isSelectionEmpty()) {\r
907 return;\r
908 }\r
909 else{\r
ae0d4fd2 910 int selectedRow = lsm.getMinSelectionIndex();\r
72426064 911 String fvNameList = fvImageParaTableModel.getValueAt(selectedRow, 0)+"";\r
912 String type = fvImageParaTableModel.getValueAt(selectedRow, 1)+"";\r
913 jComboBoxFvParaType.setSelectedItem(type);\r
914 String[] fvNames = fvNameList.split(" ");\r
915 fvImageNameTableModel.setRowCount(0);\r
54aa8673 916 fvOptionTableModel.setRowCount(0);\r
72426064 917 for (int i = 0; i < fvNames.length; ++i) {\r
918 String[] row = { fvNames[i] };\r
54aa8673 919 if (row[0].length() > 0) {\r
920 fvImageNameTableModel.addRow(row);\r
921 }\r
72426064 922 }\r
923 \r
924 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);\r
925 if (fvImagePos < 0) {\r
61919f8c 926 return;\r
927 }\r
ae0d4fd2 928 LinkedHashMap<String, String> optionMap = new LinkedHashMap<String, String>();\r
72426064 929 ffc.getFvImagesFvImageOptions(fvImagePos, optionMap);\r
ae0d4fd2 930 if (optionMap.size() > 0){\r
ae0d4fd2 931 Set<String> key = optionMap.keySet();\r
932 Iterator<String> i = key.iterator();\r
933 while (i.hasNext()) {\r
ae0d4fd2 934 String k = (String)i.next();\r
935 String[] row = {k, optionMap.get(k)};\r
ae0d4fd2 936 fvOptionTableModel.addRow(row);\r
937 }\r
a13899c5 938 }\r
a13899c5 939 }\r
940 }\r
941 });\r
ae0d4fd2 942 \r
943 \r
a13899c5 944 }\r
4da2e625 945 return jTableFvInfo;\r
a13899c5 946 }\r
947\r
948\r
949 /**\r
950 * This method initializes jButton6 \r
951 * \r
952 * @return javax.swing.JButton \r
953 */\r
4da2e625 954 private JButton getJButtonDelFvImage() {\r
955 if (jButtonDelFvImage == null) {\r
956 jButtonDelFvImage = new JButton();\r
72426064 957 jButtonDelFvImage.setPreferredSize(new java.awt.Dimension(150,20));\r
958 jButtonDelFvImage.setText("Delete FV Attributes");\r
4da2e625 959 jButtonDelFvImage.addActionListener(new AbstractAction() {\r
44053733 960 /**\r
961 * \r
962 */\r
963 private static final long serialVersionUID = 1L;\r
a13899c5 964\r
965 public void actionPerformed(ActionEvent arg0) {\r
966 // TODO Auto-generated method stub\r
4da2e625 967 if (jTableFvInfo.getSelectedRow() >= 0 ) {\r
54aa8673 968 String fvNameList = fvImageParaTableModel.getValueAt(jTableFvInfo.getSelectedRow(), 0)+"";\r
969 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, jComboBoxFvParaType.getSelectedItem()+"");\r
970 \r
971 ffc.removeFvImagesFvImage(fvImagePos);\r
4da2e625 972 fvImageParaTableModel.removeRow(jTableFvInfo.getSelectedRow());\r
d6d24759 973 docConsole.setSaved(false);\r
54aa8673 974 \r
975 fvImageNameTableModel.setRowCount(0);\r
976 fvOptionTableModel.setRowCount(0);\r
a13899c5 977 }\r
978 }\r
979 \r
980 });\r
981 }\r
4da2e625 982 return jButtonDelFvImage;\r
a13899c5 983 }\r
984\r
985\r
a13899c5 986 /**\r
987 * This method initializes jPanel6 \r
988 * \r
989 * @return javax.swing.JPanel \r
990 */\r
4da2e625 991 private JPanel getJPanelFvImagePara() {\r
992 if (jPanelFvImagePara == null) {\r
72426064 993 FlowLayout flowLayout6 = new FlowLayout();\r
994 flowLayout6.setAlignment(java.awt.FlowLayout.LEFT);\r
a13899c5 995 StarLabel starLabel = new StarLabel();\r
996 starLabel.setVisible(false);\r
4da2e625 997 jPanelFvImagePara = new JPanel();\r
72426064 998 jPanelFvImagePara.setLayout(flowLayout6);\r
999 jPanelFvImagePara.setPreferredSize(new java.awt.Dimension(450,140));\r
4da2e625 1000 jPanelFvImagePara.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));\r
4da2e625 1001 jPanelFvImagePara.add(new StarLabel(), null);\r
1002 jPanelFvImagePara.add(jLabelFvImageNames, null);\r
1003 jPanelFvImagePara.add(jLabelFvParaName, null);\r
1004 jPanelFvImagePara.add(getJTextFieldFvParaName(), null);\r
4da2e625 1005 jPanelFvImagePara.add(getJScrollPaneFvImageNames(), null);\r
72426064 1006 jPanelFvImagePara.add(getJPanelBgFvName(), null);\r
1007 jPanelFvImagePara.add(jLabelFvParaType, null);\r
1008 jPanelFvImagePara.add(getJComboBoxFvParaType(), null);\r
a13899c5 1009 }\r
4da2e625 1010 return jPanelFvImagePara;\r
a13899c5 1011 }\r
1012\r
1013 /**\r
1014 * This method initializes jPanel7 \r
1015 * \r
1016 * @return javax.swing.JPanel \r
1017 */\r
4da2e625 1018 private JPanel getJPanelFdf() {\r
1019 if (jPanelFdf == null) {\r
4da2e625 1020 jPanelFdf = new JPanel();\r
3658f95e 1021 jPanelFdf.setLayout(new BorderLayout());\r
1022\r
1023 jPanelFdf.add(getJPanelFdfN(), java.awt.BorderLayout.NORTH);\r
1024 jPanelFdf.add(getJPanelFdfS(), java.awt.BorderLayout.SOUTH);\r
1025 jPanelFdf.add(getJSplitPaneFdfC(), java.awt.BorderLayout.CENTER);\r
2b70a636 1026 jPanelFdf.addComponentListener(new ComponentAdapter(){\r
1027 public void componentShown(ComponentEvent e) {\r
3658f95e 1028// if (ffc.getFlashDefinitionFile() != null) {\r
1029// jTextFieldFdf.setText(ffc.getFlashDefinitionFile());\r
2b70a636 1030// initFvInFdfTable(System.getenv("WORKSPACE") + File.separator + jTextFieldFdf.getText());\r
1031// \r
3658f95e 1032// }\r
2b70a636 1033 }\r
1034 public void componentHidden(ComponentEvent e) {\r
1035 if (jCheckBoxFdf.isSelected()) {\r
1036 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());\r
1037 }\r
1038 }\r
1039 });\r
a13899c5 1040 }\r
4da2e625 1041 return jPanelFdf;\r
a13899c5 1042 }\r
1043\r
1044 /**\r
1045 * This method initializes jCheckBox \r
1046 * \r
1047 * @return javax.swing.JCheckBox \r
1048 */\r
4da2e625 1049 private JCheckBox getJCheckBoxFdf() {\r
1050 if (jCheckBoxFdf == null) {\r
1051 jCheckBoxFdf = new JCheckBox();\r
1052 jCheckBoxFdf.setText("Flash Definition File");\r
1053 jCheckBoxFdf.addItemListener(new ItemListener() {\r
a13899c5 1054\r
1055 public void itemStateChanged(ItemEvent arg0) {\r
1056 // TODO Auto-generated method stub\r
4da2e625 1057 if (jCheckBoxFdf.isSelected()){\r
1058 jTextFieldFdf.setEnabled(true);\r
1059 jButtonFdfBrowse.setEnabled(true);\r
a13899c5 1060 }\r
1061 else {\r
1062 \r
4da2e625 1063 jTextFieldFdf.setEnabled(false);\r
1064 jButtonFdfBrowse.setEnabled(false);\r
a13899c5 1065 }\r
1066 }\r
1067 });\r
1068 }\r
4da2e625 1069 return jCheckBoxFdf;\r
a13899c5 1070 }\r
1071\r
1072 /**\r
1073 * This method initializes jTextField3 \r
1074 * \r
1075 * @return javax.swing.JTextField \r
1076 */\r
4da2e625 1077 private JTextField getJTextFieldFdf() {\r
1078 if (jTextFieldFdf == null) {\r
1079 jTextFieldFdf = new JTextField();\r
1080 jTextFieldFdf.setEnabled(false);\r
2b70a636 1081 jTextFieldFdf.setEditable(false);\r
4da2e625 1082 jTextFieldFdf.setPreferredSize(new Dimension(300, 20));\r
1083 jTextFieldFdf.addFocusListener(new java.awt.event.FocusAdapter() {\r
908b1c05 1084 public void focusLost(java.awt.event.FocusEvent e) {\r
4da2e625 1085 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());\r
908b1c05 1086 }\r
1087 });\r
a13899c5 1088 }\r
4da2e625 1089 return jTextFieldFdf;\r
a13899c5 1090 }\r
1091\r
1092 /**\r
1093 * This method initializes jButton5 \r
1094 * \r
1095 * @return javax.swing.JButton \r
1096 */\r
4da2e625 1097 private JButton getJButtonFdfBrowse() {\r
1098 if (jButtonFdfBrowse == null) {\r
1099 jButtonFdfBrowse = new JButton();\r
1100 jButtonFdfBrowse.setEnabled(false);\r
1101 jButtonFdfBrowse.setText("Browse");\r
1102 jButtonFdfBrowse.setPreferredSize(new Dimension(78, 20));\r
1103 jButtonFdfBrowse.addActionListener(new AbstractAction(){\r
44053733 1104 /**\r
1105 * \r
1106 */\r
1107 private static final long serialVersionUID = 1L;\r
1108\r
a13899c5 1109 public void actionPerformed(ActionEvent e) {\r
1110 // TODO Auto-generated method stub\r
908b1c05 1111 String wsDir = System.getenv("WORKSPACE");\r
1112 JFileChooser chooser = new JFileChooser(wsDir);\r
a13899c5 1113 chooser.setMultiSelectionEnabled(false);\r
1114 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
1115 int retval = chooser.showOpenDialog(frame);\r
1116 if (retval == JFileChooser.APPROVE_OPTION) {\r
1117\r
1118 File theFile = chooser.getSelectedFile();\r
908b1c05 1119 String filePath = theFile.getPath();\r
1120 if (!filePath.startsWith(wsDir)) {\r
1121 JOptionPane.showMessageDialog(frame, "You can only select files in current WORKSPACE.");\r
1122 return;\r
1123 }\r
4da2e625 1124 jTextFieldFdf.setText(filePath.substring(wsDir.length() + 1).replace('\\', '/'));\r
3658f95e 1125 ffc.genFlashDefinitionFile(jTextFieldFdf.getText());\r
1126 docConsole.setSaved(false);\r
2b70a636 1127 initFvInFdfTable(filePath);\r
a13899c5 1128 }\r
1129 }\r
1130 \r
1131 });\r
1132 }\r
4da2e625 1133 return jButtonFdfBrowse;\r
a13899c5 1134 }\r
eb8ea829 1135 \r
72426064 1136 private void initFvAttributes () {\r
1137 if (ffc.getFvImagesFvImageCount("Attributes") == 0 && ffc.getFvImagesFvImageCount("Components") == 0) {\r
1138 return;\r
1139 }\r
1140 String[][] saa = new String[ffc.getFvImagesFvImageCount("Attributes")][2];\r
1141 ffc.getFvImagesFvImages(saa, "Attributes");\r
1142 \r
1143 int i = 0;\r
1144 while (i < saa.length) {\r
1145 fvImageParaTableModel.addRow(saa[i]);\r
1146 ++i;\r
1147 }\r
1148 \r
1149 saa = new String[ffc.getFvImagesFvImageCount("Components")][2];\r
1150 ffc.getFvImagesFvImages(saa, "Components");\r
1151 i = 0;\r
1152 while (i < saa.length) {\r
1153 fvImageParaTableModel.addRow(saa[i]);\r
1154 ++i;\r
1155 }\r
1156 \r
1157 saa = new String[ffc.getFvImagesNameValueCount()][2];\r
1158 ffc.getFvImagesNameValues(saa);\r
1159 for (int m = 0; m < saa.length; ++m) {\r
1160 fvPropertyTableModel.addRow(saa[m]);\r
1161 }\r
1162 }\r
1163 \r
eb8ea829 1164 private void initFvAdditionalTable() {\r
98c20797 1165 Vector<String> vFvNames = new Vector<String>();\r
1166 ffc.getFvImagesFvImageFvImageNames(vFvNames);\r
1167 for (int i = 0; i < vFvNames.size(); ++i) {\r
1168 String fvName = vFvNames.get(i);\r
1169 if (fvNameExists(fvName)) {\r
1170 continue;\r
1171 }\r
72426064 1172 fvAdditionalTableModel.addRow(getBasicFvInfo(fvName));\r
98c20797 1173 addTabForFv(new FvInfoFromFdf(fvName, "", ""));\r
1174 }\r
eb8ea829 1175 }\r
a13899c5 1176\r
2b70a636 1177 private void initFvInFdfTable(String fdfPath){\r
1178 Vector<FvInfoFromFdf> vFvInfo = new Vector<FvInfoFromFdf>();\r
1179 getFvInfoFromFdf(fdfPath, vFvInfo);\r
701d95b3 1180 getFlashInfoFromFdf (fdfPath);\r
1181 if (!erasePolarity.equals("1") && !erasePolarity.equals("0")) {\r
1182 JOptionPane.showMessageDialog(frame, "FDF file does NOT contain valid Erase Polarity.");\r
1183 }\r
1184 else {\r
54aa8673 1185 ffc.setTypedFvImageNameValue("Attributes", "EFI_ERASE_POLARITY", erasePolarity);\r
701d95b3 1186 }\r
1187 \r
98c20797 1188 // BugBug: assume all blocks have same size;\r
701d95b3 1189 \r
72426064 1190 String blkSize = defaultBlkSize;\r
701d95b3 1191 if (vBlockSize.size() > 0) {\r
1192 blkSize = vBlockSize.get(0);\r
1193 if (!DataValidation.isInt(blkSize) && !DataValidation.isHexDoubleWordDataType(blkSize)) {\r
1194 JOptionPane.showMessageDialog(frame, "FDF file does NOT contain valid FV block size. Default size 0x10000 will be used.");\r
72426064 1195 blkSize = defaultBlkSize;\r
701d95b3 1196 }\r
1197 }\r
1198 determinedFvBlockSize = blkSize;\r
98c20797 1199 \r
2b70a636 1200 getFvInFdfTableModel().setRowCount(0);\r
1201 for (int j = 0; j < vFvInfo.size(); ++j) {\r
1202 FvInfoFromFdf fvInfo = vFvInfo.get(j);\r
1203 String[] row = {fvInfo.getFvName(), fvInfo.getSize(), fvInfo.getEfiFileName()};\r
701d95b3 1204 // if FV addtional table contains the same FV from fdf file, remove that row.\r
1205 for (int k = 0; k < jTableFvAdditional.getRowCount(); ++k) {\r
1206 if (fvAdditionalTableModel.getValueAt(k, 0).equals(row[0])) {\r
1207 fvAdditionalTableModel.removeRow(k);\r
1208 }\r
1209 }\r
2b70a636 1210 getFvInFdfTableModel().addRow(row);\r
98c20797 1211 try {\r
1212 int blockSize = Integer.decode(blkSize);\r
1213 int fvSize = Integer.decode(row[1]);\r
1214 int numBlocks = fvSize/blockSize;\r
701d95b3 1215 HashMap<String, String> mOptions = new HashMap<String, String>();\r
98c20797 1216 // if no options for this FV before, generate a new options entry for this FV.\r
1217 if (ffc.getFvImagesFvImageWithName(row[0], "Options") == null) {\r
701d95b3 1218 \r
98c20797 1219 mOptions.put("EFI_BLOCK_SIZE", blkSize);\r
1220 mOptions.put("EFI_NUM_BLOCKS", numBlocks+"");\r
1221 mOptions.put("EFI_FILE_NAME", row[2]);\r
1222 ffc.genFvImagesFvImage(new String[]{row[0]}, "Options", mOptions);\r
1223 memModified = true;\r
1224 }\r
1225 else {\r
701d95b3 1226 ffc.getFvImagesFvImageOptions(row[0], mOptions);\r
1227 if (mOptions.get("EFI_BLOCK_SIZE") == null || !mOptions.get("EFI_BLOCK_SIZE").equalsIgnoreCase(blkSize)) {\r
1228 ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_BLOCK_SIZE", blkSize);\r
1229 memModified = true;\r
1230 }\r
1231 if (mOptions.get("EFI_NUM_BLOCKS") == null || Integer.decode(mOptions.get("EFI_NUM_BLOCKS")) != numBlocks) {\r
1232 ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_NUM_BLOCKS", numBlocks + "");\r
1233 memModified = true;\r
1234 }\r
1235 if (mOptions.get("EFI_FILE_NAME") == null || !mOptions.get("EFI_FILE_NAME").equals(row[2])) {\r
1236 ffc.setTypedNamedFvImageNameValue(row[0], "Options", "EFI_FILE_NAME", row[2]);\r
1237 memModified = true;\r
1238 }\r
1239 \r
98c20797 1240 }\r
1241 }\r
1242 catch (NumberFormatException e){\r
1243 JOptionPane.showMessageDialog(frame, e.getMessage());\r
1244 }\r
2b70a636 1245 }\r
1246\r
1247 for (int k = 0; k < vFvInfo.size(); ++k) {\r
1248 FvInfoFromFdf fvInfo = vFvInfo.get(k);\r
1249 addTabForFv(fvInfo);\r
1250 }\r
98c20797 1251 \r
2b70a636 1252 }\r
1253 \r
1254 private void addTabForFv (FvInfoFromFdf fvInfo) {\r
1255 String fvName = fvInfo.getFvName();\r
1256 String outputFile = fvInfo.getEfiFileName();\r
eb8ea829 1257 int index = jTabbedPane.indexOfTab(fvName);\r
1258 if (index >= startIndexOfDynamicTab) {\r
1259 return;\r
2b70a636 1260 }\r
1261 jTabbedPane.addTab(fvName, null, new ModuleOrderPane(fvName, outputFile), null);\r
1262 }\r
44053733 1263 /**\r
ae0d4fd2 1264 * This method initializes jTextField4 \r
44053733 1265 * \r
ae0d4fd2 1266 * @return javax.swing.JTextField \r
44053733 1267 */\r
4da2e625 1268 private JTextField getJTextFieldFvImageOptName() {\r
1269 if (jTextFieldFvImageOptName == null) {\r
1270 jTextFieldFvImageOptName = new JTextField();\r
1271 jTextFieldFvImageOptName.setEnabled(true);\r
1272 jTextFieldFvImageOptName.setPreferredSize(new Dimension(100, 20));\r
44053733 1273 }\r
4da2e625 1274 return jTextFieldFvImageOptName;\r
ae0d4fd2 1275 }\r
1276\r
1277 /**\r
1278 * This method initializes jTextField5 \r
1279 * \r
1280 * @return javax.swing.JTextField \r
1281 */\r
4da2e625 1282 private JTextField getJTextFieldFvImageOptValue() {\r
1283 if (jTextFieldFvImageOptValue == null) {\r
1284 jTextFieldFvImageOptValue = new JTextField();\r
1285 jTextFieldFvImageOptValue.setEnabled(true);\r
1286 jTextFieldFvImageOptValue.setPreferredSize(new Dimension(100, 20));\r
ae0d4fd2 1287 }\r
4da2e625 1288 return jTextFieldFvImageOptValue;\r
ae0d4fd2 1289 }\r
1290\r
1291 /**\r
1292 * This method initializes jPanel8 \r
1293 * \r
1294 * @return javax.swing.JPanel \r
1295 */\r
4da2e625 1296 private JPanel getJPanelFvImageOptsButtonGroup() {\r
1297 if (jPanelFvImageOptsButtonGroup == null) {\r
1298 jPanelFvImageOptsButtonGroup = new JPanel();\r
1299 jPanelFvImageOptsButtonGroup.setPreferredSize(new Dimension(80, 55));\r
1300 jPanelFvImageOptsButtonGroup.add(getJButtonFvImageOptAdd(), null);\r
1301 jPanelFvImageOptsButtonGroup.add(getJButtonFvImageOptDel(), null);\r
ae0d4fd2 1302 }\r
4da2e625 1303 return jPanelFvImageOptsButtonGroup;\r
ae0d4fd2 1304 }\r
1305\r
1306 /**\r
1307 * This method initializes jButton7 \r
1308 * \r
1309 * @return javax.swing.JButton \r
1310 */\r
4da2e625 1311 private JButton getJButtonFvImageOptAdd() {\r
1312 if (jButtonFvImageOptAdd == null) {\r
1313 jButtonFvImageOptAdd = new JButton();\r
1314 jButtonFvImageOptAdd.setEnabled(true);\r
1315 jButtonFvImageOptAdd.setText("Add");\r
1316 jButtonFvImageOptAdd.setPreferredSize(new Dimension(80, 20));\r
1317 jButtonFvImageOptAdd.addActionListener(new AbstractAction() {\r
ae0d4fd2 1318 /**\r
1319 * \r
1320 */\r
1321 private static final long serialVersionUID = 1L;\r
1322\r
1323 public void actionPerformed(ActionEvent e) {\r
4da2e625 1324 if (jTextFieldFvImageOptName.getText().length() > 0 && jTextFieldFvImageOptValue.getText().length() > 0){\r
54aa8673 1325 int selectedRow = jTableFvInfo.getSelectedRow();\r
1326 if (selectedRow < 0) {\r
1327 return;\r
1328 }\r
1329 \r
1330 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";\r
1331 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";\r
1332 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);\r
1333 String[] row = {jTextFieldFvImageOptName.getText(), jTextFieldFvImageOptValue.getText()};\r
1334 \r
1335 if (fvImagePos < 0) {\r
1336 return;\r
1337 }\r
1338 else {\r
1339 //append options to FvImage.\r
1340 ffc.setFvImagesFvImageNameValue(fvImagePos, row[0], row[1]);\r
1341 }\r
1342 docConsole.setSaved(false);\r
ae0d4fd2 1343 fvOptionTableModel.addRow(row);\r
54aa8673 1344 jTableFvImageOpts.changeSelection(jTableFvImageOpts.getRowCount() - 1, 0, false, false);\r
ae0d4fd2 1345 }\r
1346 }\r
1347 });\r
1348 }\r
4da2e625 1349 return jButtonFvImageOptAdd;\r
ae0d4fd2 1350 }\r
1351\r
1352 /**\r
1353 * This method initializes jButton8 \r
1354 * \r
1355 * @return javax.swing.JButton \r
1356 */\r
4da2e625 1357 private JButton getJButtonFvImageOptDel() {\r
1358 if (jButtonFvImageOptDel == null) {\r
1359 jButtonFvImageOptDel = new JButton();\r
1360 jButtonFvImageOptDel.setEnabled(true);\r
1361 jButtonFvImageOptDel.setText("Delete");\r
1362 jButtonFvImageOptDel.setPreferredSize(new Dimension(80, 20));\r
1363 jButtonFvImageOptDel.addActionListener(new AbstractAction() {\r
ae0d4fd2 1364 /**\r
1365 * \r
1366 */\r
1367 private static final long serialVersionUID = 1L;\r
1368\r
1369 public void actionPerformed(ActionEvent e) {\r
4da2e625 1370 if (jTableFvImageOpts.getSelectedRow() >= 0){\r
54aa8673 1371 int selectedRow = jTableFvInfo.getSelectedRow();\r
1372 if (selectedRow < 0) {\r
1373 return;\r
1374 }\r
1375 \r
1376 String fvNameList = jTableFvInfo.getValueAt(selectedRow, 0)+"";\r
1377 String type = jTableFvInfo.getValueAt(selectedRow, 1)+"";\r
1378 int fvImagePos = ffc.getFvImagePosInFvImages(fvNameList, type);\r
1379 if (fvImagePos < 0) {\r
1380 return;\r
1381 }\r
1382 \r
1383 String optName = fvOptionTableModel.getValueAt(jTableFvImageOpts.getSelectedRow(), 0)+"";\r
1384 ffc.removeFvImageNameValue(fvImagePos, optName);\r
1385 docConsole.setSaved(false);\r
1386 fvOptionTableModel.removeRow(jTableFvImageOpts.getSelectedRow());\r
ae0d4fd2 1387 }\r
1388 }\r
1389 });\r
1390 }\r
4da2e625 1391 return jButtonFvImageOptDel;\r
ae0d4fd2 1392 }\r
1393\r
1394 /**\r
1395 * This method initializes jScrollPane \r
1396 * \r
1397 * @return javax.swing.JScrollPane \r
1398 */\r
1399 private JScrollPane getJScrollPane() {\r
1400 if (jScrollPane == null) {\r
1401 jScrollPane = new JScrollPane();\r
72426064 1402 jScrollPane.setPreferredSize(new java.awt.Dimension(350,100));\r
4da2e625 1403 jScrollPane.setViewportView(getJTableFvImageOpts());\r
ae0d4fd2 1404 }\r
1405 return jScrollPane;\r
1406 }\r
1407\r
1408 /**\r
1409 * This method initializes jTable3 \r
1410 * \r
1411 * @return javax.swing.JTable \r
1412 */\r
4da2e625 1413 private JTable getJTableFvImageOpts() {\r
1414 if (jTableFvImageOpts == null) {\r
ed850fbf 1415 fvOptionTableModel = new IDefaultTableModel();\r
ae0d4fd2 1416 fvOptionTableModel.addColumn("Name");\r
1417 fvOptionTableModel.addColumn("Value");\r
4da2e625 1418 jTableFvImageOpts = new JTable(fvOptionTableModel);\r
ae0d4fd2 1419\r
4da2e625 1420 jTableFvImageOpts.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
1421 jTableFvImageOpts.setRowHeight(20);\r
ae0d4fd2 1422 \r
1423 }\r
4da2e625 1424 return jTableFvImageOpts;\r
ae0d4fd2 1425 }\r
1426\r
1427 /**\r
1428 * This method initializes jButton9 \r
1429 * \r
1430 * @return javax.swing.JButton \r
1431 */\r
4da2e625 1432 private JButton getJButtonUpdateFvImage() {\r
1433 if (jButtonUpdateFvImage == null) {\r
1434 jButtonUpdateFvImage = new JButton();\r
72426064 1435 jButtonUpdateFvImage.setPreferredSize(new java.awt.Dimension(150,20));\r
4da2e625 1436 jButtonUpdateFvImage.setActionCommand("Update");\r
72426064 1437 jButtonUpdateFvImage.setText("Update FV Attributes");\r
1438 jButtonUpdateFvImage.setVisible(false);\r
4da2e625 1439 jButtonUpdateFvImage.addActionListener(new java.awt.event.ActionListener() {\r
ae0d4fd2 1440 public void actionPerformed(java.awt.event.ActionEvent e) {\r
4da2e625 1441 int row = jTableFvInfo.getSelectedRow();\r
1442 if (jTableFvInfo.isEditing()) {\r
1443 jTableFvInfo.getCellEditor().stopCellEditing();\r
ae0d4fd2 1444 }\r
4da2e625 1445 if (jTableFvImageOpts.isEditing()) {\r
1446 jTableFvImageOpts.getCellEditor().stopCellEditing();\r
ae0d4fd2 1447 }\r
1448 \r
1449 //ToDo Check data validity before update\r
1450 String name = fvImageParaTableModel.getValueAt(row, 0) + "";\r
1451 String type = fvImageParaTableModel.getValueAt(row, 1) + "";\r
1452 \r
1453 LinkedHashMap<String, String> lhm = new LinkedHashMap<String, String>();\r
1454 getOptionNameValue(lhm);\r
1455 \r
d6d24759 1456 docConsole.setSaved(false);\r
ae0d4fd2 1457 ffc.updateFvImagesFvImage(row, name.split(" "), type, lhm);\r
1458 \r
1459 }\r
1460 });\r
1461 }\r
4da2e625 1462 return jButtonUpdateFvImage;\r
44053733 1463 }\r
1464\r
3658f95e 1465 /**\r
1466 * This method initializes jPanelFdfN \r
1467 * \r
1468 * @return javax.swing.JPanel \r
1469 */\r
1470 private JPanel getJPanelFdfN() {\r
1471 if (jPanelFdfN == null) {\r
1472 jPanelFdfN = new JPanel();\r
1473 jPanelFdfN.add(getJCheckBoxFdf(), null);\r
1474 jPanelFdfN.add(getJTextFieldFdf(), null);\r
1475 jPanelFdfN.add(getJButtonFdfBrowse(), null);\r
1476 }\r
1477 return jPanelFdfN;\r
1478 }\r
1479\r
1480 /**\r
1481 * This method initializes jPanelFdfS \r
1482 * \r
1483 * @return javax.swing.JPanel \r
1484 */\r
1485 private JPanel getJPanelFdfS() {\r
1486 if (jPanelFdfS == null) {\r
1487 FlowLayout flowLayout4 = new FlowLayout();\r
1488 flowLayout4.setAlignment(java.awt.FlowLayout.RIGHT);\r
1489 jPanelFdfS = new JPanel();\r
1490 jPanelFdfS.setLayout(flowLayout4);\r
1491 jPanelFdfS.add(getJButtonAddFv(), null);\r
1492 jPanelFdfS.add(getJButtonDelFv(), null);\r
1493 jPanelFdfS.add(getJButtonAddFvOptions(), null);\r
1494 }\r
1495 return jPanelFdfS;\r
1496 }\r
1497\r
1498 /**\r
1499 * This method initializes jSplitPaneFdfC \r
1500 * \r
1501 * @return javax.swing.JSplitPane \r
1502 */\r
1503 private JSplitPane getJSplitPaneFdfC() {\r
1504 if (jSplitPaneFdfC == null) {\r
1505 jSplitPaneFdfC = new JSplitPane();\r
1506 jSplitPaneFdfC.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);\r
1507 jSplitPaneFdfC.setDividerSize(5);\r
1508 jSplitPaneFdfC.setTopComponent(getJPanelFdfCTop());\r
1509 jSplitPaneFdfC.setBottomComponent(getJPanelFdfCBottom());\r
1510 jSplitPaneFdfC.setDividerLocation(280);\r
1511 }\r
1512 return jSplitPaneFdfC;\r
1513 }\r
1514\r
1515 /**\r
1516 * This method initializes jPanelFdfCTop \r
1517 * \r
1518 * @return javax.swing.JPanel \r
1519 */\r
1520 private JPanel getJPanelFdfCTop() {\r
1521 if (jPanelFdfCTop == null) {\r
1522 jPanelFdfCTop = new JPanel();\r
1523 jPanelFdfCTop.setLayout(new BorderLayout());\r
1524 jPanelFdfCTop.add(getJPanelFdfCTopN(), java.awt.BorderLayout.NORTH);\r
1525 jPanelFdfCTop.add(getJPanelFdfCTopS(), java.awt.BorderLayout.SOUTH);\r
1526 jPanelFdfCTop.add(getJPanelFdfCTopC(), java.awt.BorderLayout.CENTER);\r
1527 }\r
1528 return jPanelFdfCTop;\r
1529 }\r
1530\r
1531 /**\r
1532 * This method initializes jPanelFdfCBottom \r
1533 * \r
1534 * @return javax.swing.JPanel \r
1535 */\r
1536 private JPanel getJPanelFdfCBottom() {\r
1537 if (jPanelFdfCBottom == null) {\r
1538 jPanelFdfCBottom = new JPanel();\r
1539 jPanelFdfCBottom.setLayout(new BorderLayout());\r
1540 jPanelFdfCBottom.add(getJPanelFdfCBottomN(), java.awt.BorderLayout.NORTH);\r
1541 jPanelFdfCBottom.add(getJPanelFdfCBottomC(), java.awt.BorderLayout.CENTER);\r
1542 }\r
1543 return jPanelFdfCBottom;\r
1544 }\r
1545\r
1546 /**\r
1547 * This method initializes jPanelFdfCTopN \r
1548 * \r
1549 * @return javax.swing.JPanel \r
1550 */\r
1551 private JPanel getJPanelFdfCTopN() {\r
1552 if (jPanelFdfCTopN == null) {\r
1553 jLabelFvInFdf = new JLabel();\r
1554 jLabelFvInFdf.setText("FVs in Flash Definition File");\r
1555 jPanelFdfCTopN = new JPanel();\r
1556 jPanelFdfCTopN.add(jLabelFvInFdf, null);\r
1557 }\r
1558 return jPanelFdfCTopN;\r
1559 }\r
1560\r
1561 /**\r
1562 * This method initializes jPanelFdfCTopS \r
1563 * \r
1564 * @return javax.swing.JPanel \r
1565 */\r
1566 private JPanel getJPanelFdfCTopS() {\r
1567 if (jPanelFdfCTopS == null) {\r
1568 FlowLayout flowLayout1 = new FlowLayout();\r
1569 flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);\r
1570 jPanelFdfCTopS = new JPanel();\r
1571 jPanelFdfCTopS.setLayout(flowLayout1);\r
1572 jPanelFdfCTopS.add(getJButtonFvInFdfOptions(), null);\r
1573 }\r
1574 return jPanelFdfCTopS;\r
1575 }\r
1576\r
1577 /**\r
1578 * This method initializes jPanelFdfCTopC \r
1579 * \r
1580 * @return javax.swing.JPanel \r
1581 */\r
1582 private JPanel getJPanelFdfCTopC() {\r
1583 if (jPanelFdfCTopC == null) {\r
1584 jPanelFdfCTopC = new JPanel();\r
1585 jPanelFdfCTopC.add(getJScrollPaneFvInFdf(), null);\r
1586 }\r
1587 return jPanelFdfCTopC;\r
1588 }\r
1589\r
1590 /**\r
1591 * This method initializes jPanelFdfCBottomN \r
1592 * \r
1593 * @return javax.swing.JPanel \r
1594 */\r
1595 private JPanel getJPanelFdfCBottomN() {\r
1596 if (jPanelFdfCBottomN == null) {\r
1597 jLabelFvAdditional = new JLabel();\r
1598 jLabelFvAdditional.setText("Additional FVs");\r
1599 jPanelFdfCBottomN = new JPanel();\r
1600 jPanelFdfCBottomN.add(jLabelFvAdditional, null);\r
1601 }\r
1602 return jPanelFdfCBottomN;\r
1603 }\r
1604\r
1605 /**\r
1606 * This method initializes jPanelFdfCBottomC \r
1607 * \r
1608 * @return javax.swing.JPanel \r
1609 */\r
1610 private JPanel getJPanelFdfCBottomC() {\r
1611 if (jPanelFdfCBottomC == null) {\r
1612 jPanelFdfCBottomC = new JPanel();\r
1613 jPanelFdfCBottomC.add(getJScrollPaneFvAdditional(), null);\r
1614 }\r
1615 return jPanelFdfCBottomC;\r
1616 }\r
1617\r
1618 /**\r
1619 * This method initializes jScrollPaneFvInFdf \r
1620 * \r
1621 * @return javax.swing.JScrollPane \r
1622 */\r
1623 private JScrollPane getJScrollPaneFvInFdf() {\r
1624 if (jScrollPaneFvInFdf == null) {\r
1625 jScrollPaneFvInFdf = new JScrollPane();\r
1626 jScrollPaneFvInFdf.setPreferredSize(new java.awt.Dimension(653,200));\r
1627 jScrollPaneFvInFdf.setViewportView(getJTableFvInFdf());\r
1628 }\r
1629 return jScrollPaneFvInFdf;\r
1630 }\r
1631\r
1632 /**\r
1633 * This method initializes jTableFvInFdf \r
1634 * \r
1635 * @return javax.swing.JTable \r
1636 */\r
1637 private JTable getJTableFvInFdf() {\r
1638 if (jTableFvInFdf == null) {\r
1639 jTableFvInFdf = new JTable();\r
1640 jTableFvInFdf.setRowHeight(20);\r
1641 jTableFvInFdf.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);\r
1642 jTableFvInFdf.setModel(getFvInFdfTableModel());\r
1643 }\r
1644 return jTableFvInFdf;\r
1645 }\r
1646\r
1647 /**\r
1648 * This method initializes fvInFdfTableModel \r
1649 * \r
1650 * @return org.tianocore.frameworkwizard.platform.ui.NonEditableTableModel \r
1651 */\r
ed850fbf 1652 private IDefaultTableModel getFvInFdfTableModel() {\r
3658f95e 1653 if (fvInFdfTableModel == null) {\r
ed850fbf 1654 fvInFdfTableModel = new IDefaultTableModel();\r
3658f95e 1655 fvInFdfTableModel.addColumn("FV Name");\r
1656 fvInFdfTableModel.addColumn("Size");\r
1657 fvInFdfTableModel.addColumn("Corresponding File Name");\r
1658 }\r
1659 return fvInFdfTableModel;\r
1660 }\r
1661\r
1662 /**\r
1663 * This method initializes jButtonFvInFdfOptions \r
1664 * \r
1665 * @return javax.swing.JButton \r
1666 */\r
1667 private JButton getJButtonFvInFdfOptions() {\r
1668 if (jButtonFvInFdfOptions == null) {\r
1669 jButtonFvInFdfOptions = new JButton();\r
1670 jButtonFvInFdfOptions.setPreferredSize(new java.awt.Dimension(80,20));\r
b411fc1f 1671 jButtonFvInFdfOptions.setEnabled(true);\r
3658f95e 1672 jButtonFvInFdfOptions.setText("Options");\r
1673 jButtonFvInFdfOptions.addActionListener(new java.awt.event.ActionListener() {\r
1674 public void actionPerformed(java.awt.event.ActionEvent e) {\r
1675 int selectedRow = jTableFvInFdf.getSelectedRow();\r
61919f8c 1676 if (selectedRow < 0) {\r
3658f95e 1677 return;\r
1678 }\r
b411fc1f 1679 String fvName = jTableFvInFdf.getValueAt(selectedRow, 0)+"";\r
72426064 1680 if (fvName.length() == 0) {\r
1681 return;\r
1682 }\r
b411fc1f 1683 DefaultTableModel dtm = getFvInFdfOptTableModel();\r
1684 new FpdFvOptions(fvName, dtm, ffc, docConsole);\r
3658f95e 1685 }\r
1686 });\r
1687 }\r
1688 return jButtonFvInFdfOptions;\r
1689 }\r
b411fc1f 1690 \r
1691 private DefaultTableModel getFvInFdfOptTableModel() {\r
1692 if (fvInFdfOptTableModel == null) {\r
1693 fvInFdfOptTableModel = new FvOptsTableModel();\r
1694 fvInFdfOptTableModel.addColumn("Name");\r
1695 fvInFdfOptTableModel.addColumn("Value");\r
1696 Vector<Object> v = new Vector<Object>();\r
1697 v.add("EFI_BLOCK_SIZE");\r
1698 v.add("EFI_NUM_BLOCKS");\r
1699 v.add("EFI_FILE_NAME");\r
1700 fvInFdfOptTableModel.setVKeyWords(v);\r
1701 fvInFdfOptTableModel.setVNonEditableName(v);\r
1702 }\r
1703 return fvInFdfOptTableModel;\r
1704 }\r
72426064 1705 \r
1706 private DefaultTableModel getFvAdditionalOptTableModel() {\r
1707 if (fvAdditionalOptTableModel == null) {\r
1708 fvAdditionalOptTableModel = new FvOptsTableModel();\r
1709 fvAdditionalOptTableModel.addColumn("Name");\r
1710 fvAdditionalOptTableModel.addColumn("Value");\r
1711 Vector<Object> v = new Vector<Object>();\r
1712 v.add("EFI_BLOCK_SIZE");\r
1713 v.add("EFI_NUM_BLOCKS");\r
1714 v.add("EFI_FILE_NAME");\r
1715 fvAdditionalOptTableModel.setVNonEditableName(v);\r
1716 }\r
1717 return fvAdditionalOptTableModel;\r
1718 }\r
3658f95e 1719\r
1720 /**\r
1721 * This method initializes jScrollPaneFvAdditional \r
1722 * \r
1723 * @return javax.swing.JScrollPane \r
1724 */\r
1725 private JScrollPane getJScrollPaneFvAdditional() {\r
1726 if (jScrollPaneFvAdditional == null) {\r
1727 jScrollPaneFvAdditional = new JScrollPane();\r
1728 jScrollPaneFvAdditional.setPreferredSize(new java.awt.Dimension(653,200));\r
1729 jScrollPaneFvAdditional.setViewportView(getJTableFvAdditional());\r
1730 }\r
1731 return jScrollPaneFvAdditional;\r
1732 }\r
1733\r
1734 /**\r
1735 * This method initializes jTableFvAdditional \r
1736 * \r
1737 * @return javax.swing.JTable \r
1738 */\r
1739 private JTable getJTableFvAdditional() {\r
1740 if (jTableFvAdditional == null) {\r
1741 jTableFvAdditional = new JTable();\r
1742 jTableFvAdditional.setRowHeight(20);\r
1743 jTableFvAdditional.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);\r
98c20797 1744 jTableFvAdditional.setModel(getFvAdditionalTableModel());\r
eb8ea829 1745 \r
1746 jTableFvAdditional.getSelectionModel().addListSelectionListener(new ListSelectionListener() {\r
1747 public void valueChanged(ListSelectionEvent e) {\r
1748 if (e.getValueIsAdjusting()) {\r
1749 return;\r
1750 }\r
1751 ListSelectionModel lsm = (ListSelectionModel) e.getSource();\r
1752 if (lsm.isSelectionEmpty()) {\r
1753 return;\r
1754 } else {\r
1755 selectedRowInFvAdditionalTable = lsm.getMinSelectionIndex();\r
1756 oldFvName = jTableFvAdditional.getValueAt(selectedRowInFvAdditionalTable, 0)+"";\r
1757 }\r
1758 }\r
1759 });\r
1760 \r
1761 jTableFvAdditional.getModel().addTableModelListener(new TableModelListener() {\r
1762 public void tableChanged(TableModelEvent arg0) {\r
1763 // TODO Auto-generated method stub\r
1764 int row = arg0.getFirstRow();\r
1765 int col = arg0.getColumn();\r
1766 TableModel m = (TableModel) arg0.getSource();\r
701d95b3 1767 \r
eb8ea829 1768 if (arg0.getType() == TableModelEvent.UPDATE) {\r
1769 if (col == 0) {\r
1770 String newFvName = m.getValueAt(row, 0) + "";\r
1771 if (newFvName.equals(oldFvName)) {\r
1772 return;\r
1773 }\r
1774 if (fvNameExists(newFvName)) {\r
1775 JOptionPane.showMessageDialog(frame, "This FV already exists. Please choose another FV name.");\r
1776 m.setValueAt(oldFvName, row, 0);\r
1777 return;\r
1778 }\r
1779 \r
1780 tabIndexForFv = jTabbedPane.indexOfTab(oldFvName);\r
1781 if (tabIndexForFv >= startIndexOfDynamicTab) {\r
1782 jTabbedPane.setTitleAt(tabIndexForFv, newFvName);\r
1783 // change FvName in UserExtensions\r
1784 ffc.updateBuildOptionsUserExtensions(oldFvName, newFvName);\r
1785 // change FvBinding in ModuleSA\r
1786 ffc.appendFvBindingFor(oldFvName, newFvName);\r
1787 ffc.removeFvBindingAll(oldFvName);\r
1788 // change FvImageNames in Flash\r
1789 ffc.updateFvImageNameAll(oldFvName, newFvName);\r
1790 \r
1791 } else {\r
1792 jTabbedPane.addTab(newFvName, new ModuleOrderPane(newFvName, ""));\r
1793 // Add FvImageNames in Flash\r
1794 String[] fvNames = {newFvName};\r
54aa8673 1795 ffc.addFvImageFvImageNames(fvNames);\r
eb8ea829 1796 }\r
701d95b3 1797 docConsole.setSaved(false);\r
eb8ea829 1798 oldFvName = newFvName;\r
1799 }\r
701d95b3 1800 \r
72426064 1801 if (col == 1 && !sizeFromOptionDlg) {\r
701d95b3 1802 String fvSize = m.getValueAt(row, col) + "";\r
1803 if (!DataValidation.isInt(fvSize) && !DataValidation.isHexDoubleWordDataType(fvSize)) {\r
1804 JOptionPane.showMessageDialog(frame, "FV size should be Integer or Hex format.");\r
1805 return;\r
1806 }\r
1807 HashMap<String, String> mFvOpts = new HashMap<String, String>();\r
1808 ffc.getFvImagesFvImageOptions(oldFvName, mFvOpts);\r
1809 String blkSize = mFvOpts.get("EFI_BLOCK_SIZE");\r
1810 if (blkSize == null) {\r
72426064 1811 if (determinedFvBlockSize != null) {\r
1812 blkSize = determinedFvBlockSize;\r
1813 }\r
1814 else {\r
1815 blkSize = defaultBlkSize;\r
1816 }\r
1817 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", blkSize);\r
701d95b3 1818 int fs = Integer.decode(fvSize);\r
72426064 1819 int bs = Integer.decode(blkSize);\r
701d95b3 1820 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"");\r
1821 docConsole.setSaved(false);\r
1822 }\r
1823 else {\r
1824 if (!DataValidation.isInt(blkSize) && !DataValidation.isHexDoubleWordDataType(blkSize)) {\r
1825 int retVal = JOptionPane.showConfirmDialog(frame, "Confirm", "FPD file contains error block size format. Would you like to replace it with a default value?", JOptionPane.YES_NO_OPTION);\r
1826 if (retVal == JOptionPane.YES_OPTION) {\r
72426064 1827 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_BLOCK_SIZE", defaultBlkSize);\r
701d95b3 1828 int fs = Integer.decode(fvSize);\r
72426064 1829 int bs = Integer.decode(defaultBlkSize);\r
701d95b3 1830 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"");\r
1831 docConsole.setSaved(false);\r
1832 return;\r
1833 }\r
1834 else {\r
1835 return;\r
1836 }\r
1837 \r
1838 }\r
1839 int fs = Integer.decode(fvSize);\r
1840 int bs = Integer.decode(blkSize);\r
1841 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_NUM_BLOCKS", (fs/bs)+"");\r
1842 docConsole.setSaved(false);\r
1843 }\r
1844 }\r
1845 \r
72426064 1846 if (col == 2 && !fileFromOptionDlg) {\r
701d95b3 1847 ffc.setTypedNamedFvImageNameValue(oldFvName, "Options", "EFI_FILE_NAME", m.getValueAt(row, col)+"");\r
1848 docConsole.setSaved(false);\r
1849 }\r
1850 \r
eb8ea829 1851 }\r
1852 }\r
1853 });\r
3658f95e 1854 }\r
1855 return jTableFvAdditional;\r
1856 }\r
eb8ea829 1857 \r
98c20797 1858 private boolean fvNameExistsInFvInFdfTable (String fvName) {\r
eb8ea829 1859 for (int i = 0; i < jTableFvInFdf.getRowCount(); ++i) {\r
1860 if (fvInFdfTableModel.getValueAt(i, 0).equals(fvName)) {\r
1861 return true;\r
1862 }\r
1863 }\r
98c20797 1864 return false;\r
1865 }\r
1866 \r
1867 private boolean fvNameExists (String fvName) {\r
1868 if (fvNameExistsInFvInFdfTable(fvName)) {\r
1869 return true;\r
1870 }\r
1871 \r
eb8ea829 1872 for (int j = 0; j < jTableFvAdditional.getRowCount(); ++j) {\r
98c20797 1873 if (fvAdditionalTableModel.getValueAt(j, 0).equals(fvName) && j != selectedRowInFvAdditionalTable) {\r
eb8ea829 1874 return true;\r
1875 }\r
1876 }\r
1877 return false;\r
1878 }\r
3658f95e 1879\r
1880 /**\r
98c20797 1881 * This method initializes fvAdditionalTableModel \r
3658f95e 1882 * \r
1883 * @return javax.swing.table.DefaultTableModel \r
1884 */\r
98c20797 1885 private DefaultTableModel getFvAdditionalTableModel() {\r
1886 if (fvAdditionalTableModel == null) {\r
1887 fvAdditionalTableModel = new DefaultTableModel();\r
1888 fvAdditionalTableModel.addColumn("FV Name");\r
1889 fvAdditionalTableModel.addColumn("Size");\r
1890 fvAdditionalTableModel.addColumn("Corresponding File Name");\r
3658f95e 1891 }\r
98c20797 1892 return fvAdditionalTableModel;\r
3658f95e 1893 }\r
1894\r
1895 /**\r
1896 * This method initializes jButtonAddFv \r
1897 * \r
1898 * @return javax.swing.JButton \r
1899 */\r
1900 private JButton getJButtonAddFv() {\r
1901 if (jButtonAddFv == null) {\r
1902 jButtonAddFv = new JButton();\r
1903 jButtonAddFv.setPreferredSize(new java.awt.Dimension(80,20));\r
eb8ea829 1904 jButtonAddFv.setEnabled(true);\r
3658f95e 1905 jButtonAddFv.setText("New");\r
2b70a636 1906 jButtonAddFv.addActionListener(new java.awt.event.ActionListener() {\r
1907 public void actionPerformed(java.awt.event.ActionEvent e) {\r
eb8ea829 1908 if (jTableFvAdditional.isEditing()) {\r
1909 jTableFvAdditional.getCellEditor().stopCellEditing();\r
1910 }\r
1911 String[] row = {"", "", ""};\r
98c20797 1912 fvAdditionalTableModel.addRow(row);\r
2b70a636 1913 }\r
1914 });\r
3658f95e 1915 }\r
1916 return jButtonAddFv;\r
1917 }\r
1918\r
1919 /**\r
1920 * This method initializes jButtonDelFv \r
1921 * \r
1922 * @return javax.swing.JButton \r
1923 */\r
1924 private JButton getJButtonDelFv() {\r
1925 if (jButtonDelFv == null) {\r
1926 jButtonDelFv = new JButton();\r
1927 jButtonDelFv.setPreferredSize(new java.awt.Dimension(80,20));\r
98c20797 1928 jButtonDelFv.setEnabled(true);\r
3658f95e 1929 jButtonDelFv.setText("Delete");\r
2b70a636 1930 jButtonDelFv.addActionListener(new java.awt.event.ActionListener() {\r
1931 public void actionPerformed(java.awt.event.ActionEvent e) {\r
98c20797 1932 //delete row in FvAdditional table.\r
1933 int selectedRow = jTableFvAdditional.getSelectedRow();\r
1934 if (selectedRow < 0) {\r
1935 return;\r
1936 }\r
1937 String fvName = fvAdditionalTableModel.getValueAt(selectedRow, 0) + "";\r
1938 fvAdditionalTableModel.removeRow(selectedRow);\r
1939 //\r
1940 //delete tab with selected FV name.\r
1941 //\r
1942 jTabbedPane.removeTabAt(jTabbedPane.indexOfTab(fvName));\r
1943 //delete FV Name from FvImages element.\r
1944 ffc.updateFvImageNameAll(fvName, null);\r
1945 //delete FvBinding from ModuleSA.\r
1946 ffc.removeFvBindingAll(fvName);\r
1947 docConsole.setSaved(false);\r
2b70a636 1948 }\r
1949 });\r
3658f95e 1950 }\r
1951 return jButtonDelFv;\r
1952 }\r
1953\r
1954 /**\r
1955 * This method initializes jButtonAddFvOptions \r
1956 * \r
1957 * @return javax.swing.JButton \r
1958 */\r
1959 private JButton getJButtonAddFvOptions() {\r
1960 if (jButtonAddFvOptions == null) {\r
1961 jButtonAddFvOptions = new JButton();\r
1962 jButtonAddFvOptions.setPreferredSize(new java.awt.Dimension(80,20));\r
b411fc1f 1963 jButtonAddFvOptions.setEnabled(true);\r
3658f95e 1964 jButtonAddFvOptions.setText("Options");\r
2b70a636 1965 jButtonAddFvOptions.addActionListener(new java.awt.event.ActionListener() {\r
1966 public void actionPerformed(java.awt.event.ActionEvent e) {\r
72426064 1967 int selectedRow = jTableFvAdditional.getSelectedRow();\r
1968 if (selectedRow < 0) {\r
1969 return;\r
1970 }\r
1971 String fvName = jTableFvAdditional.getValueAt(selectedRow, 0)+"";\r
1972 String oldFvSize = jTableFvAdditional.getValueAt(selectedRow, 1)+"";\r
1973 String oldFileName = jTableFvAdditional.getValueAt(selectedRow, 2)+"";\r
1974 if (fvName.length() == 0) {\r
1975 return;\r
1976 }\r
1977 DefaultTableModel dtm = getFvAdditionalOptTableModel();\r
1978 new FpdFvOptions(fvName, dtm, ffc, docConsole);\r
1979 \r
1980 String[] updatedFvInfo = getBasicFvInfo (fvName);\r
1981 if (!oldFvSize.equalsIgnoreCase(updatedFvInfo[1])) {\r
1982 sizeFromOptionDlg = true;\r
1983 jTableFvAdditional.setValueAt(updatedFvInfo[1], selectedRow, 1);\r
1984 sizeFromOptionDlg = false;\r
1985 }\r
1986 if (!oldFileName.equals(updatedFvInfo[2])) {\r
1987 fileFromOptionDlg = true;\r
1988 jTableFvAdditional.setValueAt(updatedFvInfo[2], selectedRow, 2);\r
1989 fileFromOptionDlg = false;\r
1990 }\r
2b70a636 1991 }\r
1992 });\r
3658f95e 1993 }\r
1994 return jButtonAddFvOptions;\r
1995 }\r
3658f95e 1996 \r
72426064 1997 private String[] getBasicFvInfo (String fvName) {\r
1998 HashMap<String, String> mFvOpts = new HashMap<String, String>();\r
1999 ffc.getFvImagesFvImageOptions(fvName, mFvOpts);\r
2000 String bSize = "";\r
2001 String numBlks = "";\r
2002 String fvSize = "";\r
2003 String fvFile = "";\r
2004 if (mFvOpts.get("EFI_FILE_NAME") != null) {\r
2005 fvFile = mFvOpts.get("EFI_FILE_NAME");\r
2006 }\r
2007 if (mFvOpts.get("EFI_BLOCK_SIZE") != null && mFvOpts.get("EFI_NUM_BLOCKS") != null) {\r
2008 bSize = mFvOpts.get("EFI_BLOCK_SIZE");\r
2009 numBlks = mFvOpts.get("EFI_NUM_BLOCKS");\r
2010 boolean blockSizeWellFormat = true;\r
2011 boolean numOfBlockWellFormat = true;\r
2012 if (!DataValidation.isHexDoubleWordDataType(bSize) && !DataValidation.isInt(bSize)) {\r
2013 blockSizeWellFormat = false;\r
2014 JOptionPane.showMessageDialog(frame, fvName + " block size bad format.");\r
2015 } \r
2016 if (!DataValidation.isHexDoubleWordDataType(numBlks) && !DataValidation.isInt(numBlks)) {\r
2017 numOfBlockWellFormat = false;\r
2018 JOptionPane.showMessageDialog(frame, fvName + " number of blocks bad format.");\r
2019 }\r
2020 if (blockSizeWellFormat && numOfBlockWellFormat) {\r
2021 int size = Integer.decode(bSize);\r
2022 int num = Integer.decode(numBlks);\r
2023 fvSize = "0x" + Integer.toHexString(size*num);\r
2024 }\r
2025 }\r
2026 \r
2027 return new String[]{fvName, fvSize, fvFile};\r
2028\r
2029 }\r
2030 \r
2031 /**\r
2032 * This method initializes jPanelBgFvName \r
2033 * \r
2034 * @return javax.swing.JPanel \r
2035 */\r
2036 private JPanel getJPanelBgFvName() {\r
2037 if (jPanelBgFvName == null) {\r
2038 jPanelBgFvName = new JPanel();\r
2039 jPanelBgFvName.setPreferredSize(new java.awt.Dimension(80,55));\r
54aa8673 2040 jPanelBgFvName.add(getJButtonFvNameAdd(), null);\r
2041 jPanelBgFvName.add(getJButtonFvNameDel(), null);\r
72426064 2042 }\r
2043 return jPanelBgFvName;\r
2044 }\r
2045\r
2046 /**\r
2047 * This method initializes jPanelBgFvImage \r
2048 * \r
2049 * @return javax.swing.JPanel \r
2050 */\r
2051 private JPanel getJPanelBgFvImage() {\r
2052 if (jPanelBgFvImage == null) {\r
2053 jPanelBgFvImage = new JPanel();\r
2054 jPanelBgFvImage.setPreferredSize(new java.awt.Dimension(150,100));\r
2055 jPanelBgFvImage.add(getJButtonAddFvImage(), null);\r
2056 jPanelBgFvImage.add(getJButtonDelFvImage(), null);\r
2057 jPanelBgFvImage.add(getJButtonUpdateFvImage(), null);\r
2058 }\r
2059 return jPanelBgFvImage;\r
2060 }\r
2061\r
2062 /**\r
2063 * This method initializes jPanelW \r
2064 * \r
2065 * @return javax.swing.JPanel \r
2066 */\r
2067 private JPanel getJPanelW() {\r
2068 if (jPanelW == null) {\r
2069 jPanelW = new JPanel();\r
2070 jPanelW.add(getJPanelBgFvImage(), null);\r
2071 }\r
2072 return jPanelW;\r
2073 }\r
2074\r
a13899c5 2075 /**\r
2076 * @param args\r
2077 */\r
2078 public static void main(String[] args) {\r
2079 // TODO Auto-generated method stub\r
2080 new FpdFlash().setVisible(true);\r
2081 }\r
2082\r
2083 /**\r
2084 * This method initializes this\r
2085 * \r
2086 * @return void\r
2087 */\r
2088 private void initialize() {\r
72426064 2089 this.setSize(660, 650);\r
a13899c5 2090 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
2091 this.setContentPane(getJContentPane());\r
2092 this.setTitle("FPD Flash Definitions");\r
44053733 2093 this.addInternalFrameListener(new InternalFrameAdapter(){\r
2094 public void internalFrameDeactivated(InternalFrameEvent e){\r
4da2e625 2095 if (jTableFvProp.isEditing()) {\r
2096 jTableFvProp.getCellEditor().stopCellEditing();\r
44053733 2097 }\r
4da2e625 2098 if (jTableFvImageNames.isEditing()) {\r
2099 jTableFvImageNames.getCellEditor().stopCellEditing();\r
44053733 2100 }\r
4da2e625 2101 if (jTableFvInfo.isEditing()) {\r
2102 jTableFvInfo.getCellEditor().stopCellEditing();\r
44053733 2103 }\r
98c20797 2104 if (jTableFvAdditional.isEditing()) {\r
2105 jTableFvAdditional.getCellEditor().stopCellEditing();\r
2106 }\r
44053733 2107 }\r
2108 });\r
a13899c5 2109 }\r
2110\r
2111 private void init(FpdFileContents ffc) {\r
72426064 2112 initFvAttributes();\r
3658f95e 2113 \r
2114 jTextFieldFdf.setText("");\r
2115 String fdfFile = ffc.getFlashDefinitionFile();\r
701d95b3 2116 if (fdfFile != null && fdfFile.length() > 0) {\r
3658f95e 2117 jTextFieldFdf.setText(fdfFile);\r
701d95b3 2118 String fdfPath = System.getenv("WORKSPACE") + File.separator + fdfFile;\r
2119 initFvInFdfTable(fdfPath);\r
3658f95e 2120 }\r
2121 \r
eb8ea829 2122 initFvAdditionalTable();\r
a13899c5 2123 }\r
2124 \r
ae0d4fd2 2125 private void getOptionNameValue(Map<String, String> m){\r
4da2e625 2126 for (int i = 0; i < jTableFvImageOpts.getRowCount(); ++i) {\r
ae0d4fd2 2127 m.put(fvOptionTableModel.getValueAt(i, 0)+"", fvOptionTableModel.getValueAt(i, 1)+"");\r
a13899c5 2128 }\r
2129 }\r
2130 /**\r
2131 * This method initializes jContentPane\r
2132 * \r
2133 * @return javax.swing.JPanel\r
2134 */\r
2135 private JPanel getJContentPane() {\r
2136 if (jContentPane == null) {\r
2137 jContentPane = new JPanel();\r
2138 jContentPane.setLayout(new BorderLayout());\r
4da2e625 2139 jContentPane.add(getJPanelContentEast(), java.awt.BorderLayout.EAST);\r
2140 jContentPane.add(getJPanelContentSouth(), java.awt.BorderLayout.SOUTH);\r
2141 jContentPane.add(getJPanelContentWest(), java.awt.BorderLayout.WEST);\r
2142 jContentPane.add(getJPanelContentNorth(), java.awt.BorderLayout.NORTH);\r
a13899c5 2143 jContentPane.add(getJTabbedPane(), java.awt.BorderLayout.CENTER);\r
2144 }\r
2145 return jContentPane;\r
2146 }\r
3658f95e 2147 \r
701d95b3 2148 private void getFlashInfoFromFdf (String fdfPath) {\r
98c20797 2149 File fdf = new File(fdfPath);\r
2150 if (!fdf.exists()) {\r
2151 return;\r
2152 }\r
2153 int lines = 0;\r
2154\r
2155 try {\r
2156 FileReader reader = new FileReader(fdf);\r
2157 BufferedReader in = new BufferedReader(reader);\r
2158 String str;\r
2159\r
2160 while ((str = in.readLine()) != null) {\r
2161 ++lines;\r
2162 str = str.trim();\r
2163 //\r
2164 // skip empty line, comment (start with //) \r
2165 //\r
2166 if (str.length() == 0 || str.startsWith("//")) {\r
2167 continue;\r
2168 }\r
2169 //\r
2170 // ErasePolarity\r
2171 //\r
2172 if (str.startsWith("ErasePolarity")) {\r
701d95b3 2173 erasePolarity = str.substring(str.indexOf("=") + 1, str.lastIndexOf(",")).trim();\r
98c20797 2174 }\r
2175 //\r
2176 // dig into Block section.\r
2177 //\r
2178 if (str.startsWith("Block") && str.endsWith("}")) {\r
2179 String[] blockSec = str.split(",");\r
2180 String nv = blockSec[1].trim();\r
2181 String[] sizeSec = nv.split("=");\r
2182 vBlockSize.add(sizeSec[1].trim());\r
2183 }\r
2184 \r
2185 }\r
2186 \r
2187 reader.close();\r
2188 in.close();\r
2189 }\r
2190 catch (Exception e) {\r
2191 \r
2192 }\r
2193 }\r
2194 \r
3658f95e 2195 private void getFvInfoFromFdf(String fdfPath, Vector<FvInfoFromFdf> vFvInfo) {\r
2196 File fdf = new File(fdfPath);\r
2197 if (!fdf.exists()) {\r
2198 return;\r
2199 }\r
2200 int lines = 0;\r
2201\r
2202 try {\r
2203 FileReader reader = new FileReader(fdf);\r
2204 BufferedReader in = new BufferedReader(reader);\r
2205 String str;\r
2206\r
2207 while ((str = in.readLine()) != null) {\r
2208 ++lines;\r
2209 str = str.trim();\r
2210 //\r
2211 // skip empty line, comment (start with //) \r
2212 //\r
2213 if (str.length() == 0 || str.startsWith("//")) {\r
2214 continue;\r
2215 }\r
2216 //\r
2217 // dig into Region {} section, create FvInfoFromFdf object for it.\r
2218 //\r
2219 if (str.startsWith("Region") && str.endsWith("{")) {\r
2220 FvInfoFromFdf fvInfo = new FvInfoFromFdf();\r
2221 boolean nameFound = false;\r
2222 boolean sizeFound = false;\r
2223 while ((str = in.readLine()) != null) {\r
2224 ++lines;\r
2225 str = str.trim();\r
2226 //\r
2227 // skip empty line, comment (start with //) \r
2228 //\r
2229 if (str.length() == 0 || str.startsWith("//")) {\r
2230 continue;\r
2231 }\r
2232 \r
2233 if (str.startsWith("Name")) {\r
2234 int firstQuote = str.indexOf("\"");\r
2235 int lastQuote = str.lastIndexOf("\"");\r
2236 fvInfo.setFvName(str.substring(firstQuote + 1, lastQuote));\r
2237 nameFound = true;\r
2238 }\r
2239 \r
2240 if (str.startsWith("Size")) {\r
2241 int equalIndex = str.indexOf("=");\r
2242 int commaIndex = str.indexOf(",");\r
2243 fvInfo.setSize(str.substring(equalIndex + 1, commaIndex).trim());\r
2244 sizeFound = true;\r
2245 }\r
2246 \r
2247 if (nameFound && sizeFound) {\r
2248 break;\r
2249 }\r
2250 }\r
2251 \r
2252 vFvInfo.add(fvInfo);\r
2253 }\r
2254 //\r
2255 // dig into File {} section, supply file name information to existing FvInfoFromFdf object.\r
2256 //\r
2257 if (str.startsWith("File")) {\r
2258 boolean fileNameFound = false;\r
2259 boolean fvFound = false;\r
2260 String fileName = "";\r
2261 String fvName = "";\r
2262 while ((str = in.readLine()) != null) {\r
2263 ++lines;\r
2264 str = str.trim();\r
2265 //\r
2266 // skip empty line, comment (start with //) \r
2267 //\r
2268 if (str.length() == 0 || str.startsWith("//")) {\r
2269 continue;\r
2270 }\r
2271 \r
2272 if (str.startsWith("Name")) {\r
2273 int firstQuote = str.indexOf("\"");\r
2274 int lastQuote = str.lastIndexOf("\"");\r
2275 fileName = str.substring(firstQuote + 1, lastQuote);\r
2276 fileNameFound = true;\r
2277 }\r
2278 \r
2279 if (str.startsWith("Region")) {\r
2280 int firstQuote = str.indexOf("\"");\r
2281 int lastQuote = str.lastIndexOf("\"");\r
2282 fvName = str.substring(firstQuote + 1, lastQuote);\r
2283 fvFound = true;\r
2284 }\r
2285 \r
2286 if (fileNameFound && fvFound) {\r
2287 break;\r
2288 }\r
2289 }\r
2290 \r
2291 for (int i = 0; i <vFvInfo.size(); ++i) {\r
2292 if (vFvInfo.get(i).getFvName().equals(fvName)) {\r
2293 vFvInfo.get(i).setEfiFileName(fileName);\r
2294 }\r
2295 }\r
2296 }\r
2297 \r
2298 }\r
2b70a636 2299 \r
2300 reader.close();\r
2301 in.close();\r
2302 }\r
2303 catch (Exception e) {\r
3658f95e 2304 \r
2305 }\r
2306\r
2307 }\r
17bd391e 2308 \r
2309// class ModuleSAInfo {\r
2310// private int rowNumber = -1;\r
2311// private String moduleGuid = null;\r
2312// private String moduleVersion = null;\r
2313// private String packageGuid = null;\r
2314// private String packageVersion = null;\r
2315// private String arch = null;\r
2316// \r
2317// public ModuleSAInfo (String mg, String mv, String pg, String pv, String a) {\r
2318// moduleGuid = mg;\r
2319// moduleVersion = mv;\r
2320// packageGuid = pg;\r
2321// packageVersion = pv;\r
2322// arch = a;\r
2323// }\r
2324//\r
2325// /**\r
2326// * @return Returns the arch.\r
2327// */\r
2328// public String getArch() {\r
2329// return arch;\r
2330// }\r
2331//\r
2332// /**\r
2333// * @param arch The arch to set.\r
2334// */\r
2335// public void setArch(String arch) {\r
2336// this.arch = arch;\r
2337// }\r
2338//\r
2339// /**\r
2340// * @return Returns the moduleGuid.\r
2341// */\r
2342// public String getModuleGuid() {\r
2343// return moduleGuid;\r
2344// }\r
2345//\r
2346// /**\r
2347// * @param moduleGuid The moduleGuid to set.\r
2348// */\r
2349// public void setModuleGuid(String moduleGuid) {\r
2350// this.moduleGuid = moduleGuid;\r
2351// }\r
2352//\r
2353// /**\r
2354// * @return Returns the moduleVersion.\r
2355// */\r
2356// public String getModuleVersion() {\r
2357// return moduleVersion;\r
2358// }\r
2359//\r
2360// /**\r
2361// * @param moduleVersion The moduleVersion to set.\r
2362// */\r
2363// public void setModuleVersion(String moduleVersion) {\r
2364// this.moduleVersion = moduleVersion;\r
2365// }\r
2366//\r
2367// /**\r
2368// * @return Returns the packageGuid.\r
2369// */\r
2370// public String getPackageGuid() {\r
2371// return packageGuid;\r
2372// }\r
2373//\r
2374// /**\r
2375// * @param packageGuid The packageGuid to set.\r
2376// */\r
2377// public void setPackageGuid(String packageGuid) {\r
2378// this.packageGuid = packageGuid;\r
2379// }\r
2380//\r
2381// /**\r
2382// * @return Returns the packageVersion.\r
2383// */\r
2384// public String getPackageVersion() {\r
2385// return packageVersion;\r
2386// }\r
2387//\r
2388// /**\r
2389// * @param packageVersion The packageVersion to set.\r
2390// */\r
2391// public void setPackageVersion(String packageVersion) {\r
2392// this.packageVersion = packageVersion;\r
2393// }\r
2394//\r
2395// /**\r
2396// * @return Returns the rowNumber.\r
2397// */\r
2398// public int getRowNumber() {\r
2399// return rowNumber;\r
2400// }\r
2401//\r
2402// /**\r
2403// * @param rowNumber The rowNumber to set.\r
2404// */\r
2405// public void setRowNumber(int rowNumber) {\r
2406// this.rowNumber = rowNumber;\r
2407// }\r
2408// }\r
2409 \r
61919f8c 2410 private class ModuleOrderPane extends JPanel {\r
2411\r
2412 /**\r
2413 * \r
2414 */\r
2415 private static final long serialVersionUID = 1L;\r
2416 private JPanel jPanelModOrderN = null;\r
2417 private JPanel jPanelModOrderS = null;\r
2418 private JPanel jPanelModOrderC = null;\r
2419 private JScrollPane jScrollPaneModInFv = null;\r
2420 private JTable jTableModInFv = null;\r
2421 private JPanel jPanelController = null;\r
2422 private JScrollPane jScrollPaneFpdModules = null;\r
2423 private JTable jTableFpdModules = null;\r
2424 private JButton jButtonUp = null;\r
2425 private JButton jButtonInsert = null;\r
2426 private JButton jButtonRemove = null;\r
2427 private JButton jButtonDown = null;\r
2428 private JButton jButtonOk = null;\r
2429 private JButton jButtonCancel = null;\r
ed850fbf 2430 private IDefaultTableModel modInFvTableModel = null;\r
2431 private IDefaultTableModel fpdModTableModel = null;\r
17bd391e 2432// private ArrayList<ModuleSAInfo> listTableModInFvModuleSAInfo = null;\r
2433// private ArrayList<ModuleSAInfo> listTableFpdModulesModuleSAInfo = null;\r
2b70a636 2434 private String title = null;\r
2435 private String outputFileName = null;\r
61919f8c 2436 \r
2b70a636 2437 public ModuleOrderPane(String tabTitle, String file) {\r
61919f8c 2438 super(new BorderLayout());\r
2b70a636 2439 title = tabTitle;\r
2440 outputFileName = file;\r
17bd391e 2441// listTableModInFvModuleSAInfo = new ArrayList<ModuleSAInfo>();\r
2442// listTableFpdModulesModuleSAInfo = new ArrayList<ModuleSAInfo>();\r
61919f8c 2443 add(getJPanelModOrderN(), java.awt.BorderLayout.NORTH);\r
2444 add(getJPanelModOrderS(), java.awt.BorderLayout.SOUTH);\r
2445 add(getJPanelModOrderC(), java.awt.BorderLayout.CENTER);\r
2b70a636 2446 showModulesInFv(title);\r
2447 showAllModulesInPlatform();\r
61919f8c 2448 }\r
2449 \r
2450 private void showModulesInFv(String fvName) {\r
2451 int size = ffc.getUserExtsIncModCount(fvName);\r
2452 \r
2453 if (size != -1) {\r
17bd391e 2454 String[][] saa = new String[size][5];\r
61919f8c 2455 ffc.getUserExtsIncMods(fvName, saa);\r
2456\r
2457 for (int i = 0; i < size; ++i) {\r
17bd391e 2458 String moduleKey = saa[i][0] + " " + saa[i][1] + " " + saa[i][2] + " " + saa[i][3];\r
2459 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
2460 String name = "N/A";\r
2461 if (mi != null) {\r
2462 name = mi.getName();\r
2463 }\r
a0783edc 2464 \r
17bd391e 2465 String[] row = { name, saa[i][0] , saa[i][1], saa[i][2] , saa[i][3], saa[i][4] };\r
61919f8c 2466 modInFvTableModel.addRow(row);\r
2467 }\r
2468 }\r
2469 //\r
2470 // From ModuleSAs, get module guids with FvBinding = fvName.\r
2471 //\r
17bd391e 2472 Vector<String[]> vModuleSA = new Vector<String[]>();\r
2473 ffc.getFrameworkModuleSAByFvBinding(fvName, vModuleSA);\r
61919f8c 2474 //\r
2475 // If BuildOptions->UserExtensions already contain these module info,\r
2476 // no need to add them into table again.\r
2477 //\r
17bd391e 2478 Iterator<String[]> iter = vModuleSA.iterator();\r
61919f8c 2479 while (iter.hasNext()){\r
17bd391e 2480 String[] sa = iter.next();\r
2481 if (!moduleInfoInTable (sa, modInFvTableModel)) {\r
2482 String moduleKey = sa[0] + " " + sa[1] + " " + sa[2] + " " + sa[3];\r
2483 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
2484 String name = "N/A";\r
2485 if (mi != null) {\r
2486 name = mi.getName();\r
2487 }\r
2488 String[] row = { name, sa[0] , sa[1], sa[2] , sa[3], sa[4] };\r
2b70a636 2489 modInFvTableModel.addRow(row);\r
61919f8c 2490 }\r
2491 }\r
2b70a636 2492\r
61919f8c 2493 }\r
2494 \r
2495 private void showAllModulesInPlatform() {\r
2496 int size = ffc.getFrameworkModulesCount();\r
2497 String[][] saa = new String[size][5];\r
2498 ffc.getFrameworkModulesInfo(saa);\r
2499 \r
2500 for (int i = 0; i < size; ++i) {\r
17bd391e 2501 if (moduleInfoInTable(saa[i], modInFvTableModel) || moduleInfoInTable(saa[i], fpdModTableModel)) {\r
61919f8c 2502 continue;\r
2503 }\r
17bd391e 2504 String moduleKey = saa[i][0] + " " + saa[i][1] + " " + saa[i][2] + " " + saa[i][3];\r
2505 ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r
2506 String name = "N/A";\r
2507 if (mi != null) {\r
2508 name = mi.getName();\r
2509 }\r
2510 String[] row = { name, saa[i][0] , saa[i][1], saa[i][2] , saa[i][3], saa[i][4] };\r
61919f8c