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