]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/packaging/ui/SpdLibClassDecls.java
Remove all recommended lib instances logic in SpdLibClassDecls.java as recommmended...
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / packaging / ui / SpdLibClassDecls.java
CommitLineData
a13899c5 1/** @file\r
2 Java class SpdLibClassDecls is GUI for create library definition elements of 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.packaging.ui;\r
14\r
a13899c5 15import java.awt.Dimension;\r
a13899c5 16import java.awt.event.ActionEvent;\r
a13899c5 17import java.awt.event.ComponentEvent;\r
a13899c5 18import java.io.File;\r
af25df16 19import java.util.HashMap;\r
5a502bd4 20//import java.util.Iterator;\r
21//import java.util.Set;\r
a13899c5 22import java.util.Vector;\r
23\r
24import javax.swing.AbstractAction;\r
a13899c5 25import javax.swing.JFileChooser;\r
26import javax.swing.JOptionPane;\r
27import javax.swing.JPanel;\r
a13899c5 28import javax.swing.JTable;\r
29import javax.swing.JTextField;\r
0a35c6e2 30import javax.swing.JTextArea;\r
a13899c5 31import javax.swing.JComboBox;\r
32import javax.swing.JLabel;\r
a13899c5 33import javax.swing.JScrollPane;\r
34import javax.swing.JButton;\r
35import javax.swing.JFrame;\r
36import javax.swing.ListSelectionModel;\r
37import javax.swing.event.InternalFrameAdapter;\r
38import javax.swing.event.InternalFrameEvent;\r
39import javax.swing.event.ListSelectionEvent;\r
40import javax.swing.event.ListSelectionListener;\r
41import javax.swing.event.TableModelEvent;\r
42import javax.swing.event.TableModelListener;\r
43import javax.swing.table.DefaultTableModel;\r
5a502bd4 44import javax.swing.table.TableColumn;\r
a13899c5 45import javax.swing.table.TableModel;\r
a13899c5 46import org.tianocore.PackageSurfaceAreaDocument;\r
0a35c6e2 47import org.tianocore.frameworkwizard.common.DataType;\r
ce73a791 48import org.tianocore.frameworkwizard.common.DataValidation;\r
5a502bd4 49//import org.tianocore.frameworkwizard.common.GlobalData;\r
a13899c5 50import org.tianocore.frameworkwizard.common.Tools;\r
d6d24759 51import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;\r
a13899c5 52import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r
53import org.tianocore.frameworkwizard.common.ui.StarLabel;\r
54import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r
ce73a791 55import org.tianocore.frameworkwizard.platform.ui.ListEditor;\r
fbf730ff 56import org.tianocore.frameworkwizard.platform.ui.LongTextEditor;\r
5a502bd4 57//import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
58//import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
a13899c5 59\r
a13899c5 60\r
61/**\r
62 GUI for create library definition elements of spd file.\r
63 \r
64 @since PackageEditor 1.0\r
65**/\r
66public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{\r
ce73a791 67 /**\r
68 * \r
69 */\r
70 private static final long serialVersionUID = 1L;\r
71\r
a13899c5 72 static JFrame frame;\r
73 \r
74 private JTable jTable = null;\r
75\r
76 private DefaultTableModel model = null;\r
77\r
78 private JPanel jContentPane = null;\r
79\r
0a35c6e2 80 private JTextField jTextFieldAddClass = null;\r
a13899c5 81\r
82 private JComboBox jComboBoxSelect = null;\r
83\r
0a35c6e2 84 private JScrollPane jScrollPaneTable = null;\r
a13899c5 85\r
86 private JButton jButtonAdd = null;\r
87\r
88 private JButton jButtonRemove = null;\r
89\r
97796eaa 90 private JButton jButtonRemoveAll = null;\r
a13899c5 91\r
97796eaa 92 private JLabel jLabelHdr = null;\r
a13899c5 93\r
97796eaa 94 private JTextField jTextFieldHdr = null;\r
a13899c5 95\r
96 private JButton jButtonBrowse = null;\r
97 \r
0a35c6e2 98 private StarLabel starLabel1 = null;\r
a13899c5 99 \r
0a35c6e2 100 private StarLabel starLabel3 = null;\r
a13899c5 101 \r
102 private SpdFileContents sfc = null;\r
d6d24759 103 \r
104 private OpeningPackageType docConsole = null;\r
a13899c5 105\r
2f8a7517 106 private JLabel jLabel1ClassName = null;\r
a13899c5 107 \r
108 private JScrollPane topScrollPane = null; // @jve:decl-index=0:visual-constraint="10,53"\r
109 \r
110 private int selectedRow = -1;\r
111\r
0a35c6e2 112 private StarLabel starLabel2 = null;\r
a13899c5 113\r
2f8a7517 114 private JLabel jLabel2HelpText = null;\r
a13899c5 115\r
0a35c6e2 116 private JTextArea jTextAreaHelp = null;\r
117\r
118 private JScrollPane jHelpTextScrollPane = null;\r
a13899c5 119\r
2f8a7517 120 private JLabel jLabel5SupArchList = null;\r
a13899c5 121\r
2f8a7517 122 private JLabel jLabel6SupModList = null;\r
a13899c5 123 \r
97796eaa 124 private JScrollPane jScrollPaneModules = null;\r
a13899c5 125 \r
97796eaa 126 private JScrollPane jScrollPane1Arch = null;\r
af25df16 127 \r
97796eaa 128 private ICheckBoxList iCheckBoxListModules = null;\r
a13899c5 129\r
4da2e625 130 private ICheckBoxList iCheckBoxListArch = null;\r
af25df16 131\r
97796eaa 132 private int cnClassName = 0;\r
133 private int cnHdrFile = 1;\r
134 private int cnHelpText = 2;\r
5a502bd4 135// private int cnRecInstName = 3;\r
136// private int cnRecInstVer = 4;\r
97796eaa 137 private int cnSupArch = 5;\r
138 private int cnSupMod = 6;\r
5a502bd4 139 \r
140 private final int classNameMinWidth = 200;\r
141 private final int hdrFileMinWidth = 300;\r
142 private final int helpTextMinWidth = 300;\r
143 private final int supArchMinWidth = 200;\r
144 private final int supModMinWidth = 200;\r
0a35c6e2 145\r
146 private final int shortLabel = 90;\r
147 private final int longLabel = 220;\r
148 private final int labelCol = 12;\r
149 private final int shortValueCol = labelCol + shortLabel + 6;\r
150 private final int longValueCol = labelCol + longLabel + 6;\r
151 private final int longValueWidth = 347;\r
152 private final int shortWidth = 140;\r
153 private final int medWidth = 240;\r
154 \r
155 private final int buttonWidth = 99;\r
156\r
157 private final int addButtonCol = shortValueCol + 10;\r
158 private final int removeButtonCol = addButtonCol + buttonWidth + 10;\r
159 private final int removeAllButtonCol = removeButtonCol + buttonWidth + 10;\r
160\r
161 private final int rowOne = 12;\r
162 private final int rowTwo = rowOne + 25;\r
163 private final int rowThree = rowTwo + 60 + 25;\r
164 private final int rowFour = rowThree + 25;\r
165 private final int rowFive = rowFour + 40 + 25;\r
166 private final int rowSix = rowFive + 40 + 25;\r
167 private final int rowSeven = rowSix;\r
168 private final int rowEight = rowSeven + 30;\r
169\r
af25df16 170 HashMap<String, String> libNameGuidMap = new HashMap<String, String>();\r
ce73a791 171\r
ce73a791 172\r
a13899c5 173 /**\r
174 This method initializes this\r
175 \r
176 **/\r
177 private void initialize() {\r
178 \r
179 this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
180\r
181 }\r
182\r
a13899c5 183 /**\r
0a35c6e2 184 This method initializes jTextFieldAddClass \r
a13899c5 185 \r
186 @return javax.swing.JTextField \r
187 **/\r
0a35c6e2 188 private JTextField getJTextFieldAddClass() {\r
189 if (jTextFieldAddClass == null) {\r
190 jTextFieldAddClass = new JTextField();\r
191 jTextFieldAddClass.setBounds(new java.awt.Rectangle(shortValueCol,rowOne,longValueWidth,20));\r
192 jTextFieldAddClass.setPreferredSize(new java.awt.Dimension(longValueWidth,20));\r
193 jTextFieldAddClass.setEnabled(true);\r
a13899c5 194 }\r
0a35c6e2 195 return jTextFieldAddClass;\r
a13899c5 196 }\r
197\r
198 /**\r
199 This method initializes jComboBoxSelect \r
200 \r
201 @return javax.swing.JComboBox \r
202 **/\r
203 private JComboBox getJComboBoxSelect() {\r
204 if (jComboBoxSelect == null) {\r
205 jComboBoxSelect = new JComboBox();\r
206 jComboBoxSelect.setBounds(new java.awt.Rectangle(220, 10, 260, 20));\r
207 jComboBoxSelect.setPreferredSize(new java.awt.Dimension(260,22));\r
208 jComboBoxSelect.setEnabled(true);\r
209 jComboBoxSelect.setVisible(false);\r
210 }\r
211 return jComboBoxSelect;\r
212 }\r
213\r
214 /**\r
0a35c6e2 215 This method initializes jScrollPaneTable \r
a13899c5 216 \r
217 @return javax.swing.JScrollPane \r
97796eaa 218\r
219 Used for the Table of Library Classes that are provided by this package\r
220\r
a13899c5 221 **/\r
0a35c6e2 222 private JScrollPane getJScrollPaneTable() {\r
223 if (jScrollPaneTable == null) {\r
224 jScrollPaneTable = new JScrollPane();\r
225 jScrollPaneTable.setBounds(new java.awt.Rectangle(labelCol,rowEight,400,253));\r
226 jScrollPaneTable.setViewportView(getJTable());\r
a13899c5 227 }\r
0a35c6e2 228 return jScrollPaneTable;\r
a13899c5 229 }\r
230\r
231 /**\r
232 This method initializes jTable \r
233 \r
234 @return javax.swing.JTable \r
235 **/\r
236 private JTable getJTable() {\r
237 if (jTable == null) {\r
238 model = new DefaultTableModel();\r
239 jTable = new JTable(model);\r
240 jTable.setRowHeight(20);\r
d129bd96 241 jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r
97796eaa 242 jTable.setColumnSelectionAllowed(false);\r
243 model.addColumn("Class Name");\r
244 model.addColumn("Header");\r
245 model.addColumn("Help Text");\r
d129bd96 246 model.addColumn("Recommended Instance");\r
247 model.addColumn("Version");\r
816ea437 248 model.addColumn("Supported Architectures");\r
249 model.addColumn("Supported Module Types");\r
ce73a791 250 \r
fbf730ff 251 jTable.getColumnModel().getColumn(cnHelpText).setCellEditor(new LongTextEditor());\r
252 \r
5a502bd4 253 jTable.removeColumn(jTable.getColumnModel().getColumn(3));\r
254 jTable.removeColumn(jTable.getColumnModel().getColumn(3));\r
255 \r
ce73a791 256 Vector<String> vArch = new Vector<String>();\r
257 vArch.add("IA32");\r
258 vArch.add("X64");\r
259 vArch.add("IPF");\r
260 vArch.add("EBC");\r
261 vArch.add("ARM");\r
262 vArch.add("PPC");\r
5a502bd4 263 jTable.getColumnModel().getColumn(cnSupArch - 2).setCellEditor(new ListEditor(vArch));\r
ce73a791 264 \r
265 Vector<String> vModule = new Vector<String>();\r
266 vModule.add("BASE");\r
267 vModule.add("SEC");\r
268 vModule.add("PEI_CORE");\r
269 vModule.add("PEIM");\r
270 vModule.add("DXE_CORE");\r
271 vModule.add("DXE_DRIVER");\r
272 vModule.add("DXE_RUNTIME_DRIVER");\r
273 vModule.add("DXE_SAL_DRIVER");\r
274 vModule.add("DXE_SMM_DRIVER");\r
275 vModule.add("UEFI_DRIVER");\r
276 vModule.add("UEFI_APPLICATION");\r
277 vModule.add("USER_DEFINED");\r
97796eaa 278\r
5a502bd4 279 jTable.getColumnModel().getColumn(cnSupMod - 2).setCellEditor(new ListEditor(vModule));\r
280 \r
281 TableColumn column = jTable.getColumnModel().getColumn(this.cnClassName);\r
282 column.setMinWidth(this.classNameMinWidth);\r
283 column = jTable.getColumnModel().getColumn(this.cnHdrFile);\r
284 column.setMinWidth(this.hdrFileMinWidth);\r
285 column = jTable.getColumnModel().getColumn(this.cnHelpText);\r
286 column.setMinWidth(this.helpTextMinWidth);\r
287 column = jTable.getColumnModel().getColumn(this.cnSupArch - 2);\r
288 column.setMinWidth(this.supArchMinWidth);\r
289 column = jTable.getColumnModel().getColumn(this.cnSupMod - 2);\r
290 column.setMinWidth(this.supModMinWidth);\r
291 \r
a13899c5 292 jTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);\r
293 jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener(){\r
294 public void valueChanged(ListSelectionEvent e) {\r
295 if (e.getValueIsAdjusting()){\r
296 return;\r
297 }\r
298 ListSelectionModel lsm = (ListSelectionModel)e.getSource();\r
299 if (lsm.isSelectionEmpty()) {\r
300 return;\r
301 }\r
302 else{\r
303 selectedRow = lsm.getMinSelectionIndex();\r
304 }\r
305 }\r
306 });\r
307 \r
308 jTable.getModel().addTableModelListener(this);\r
309\r
310 }\r
311 return jTable;\r
312 }\r
313 \r
314 \r
315 public void tableChanged(TableModelEvent arg0) {\r
316 // TODO Auto-generated method stub\r
317 int row = arg0.getFirstRow();\r
a490bca8 318 int column = arg0.getColumn();\r
a13899c5 319 TableModel m = (TableModel)arg0.getSource();\r
320 if (arg0.getType() == TableModelEvent.UPDATE){\r
a490bca8 321 \r
97796eaa 322 String lib = m.getValueAt(row, cnClassName) + "";\r
323 String hdr = m.getValueAt(row, cnHdrFile) + "";\r
324 String hlp = m.getValueAt(row, cnHelpText) + "";\r
a490bca8 325 String name = null;\r
5a502bd4 326// if (m.getValueAt(row, cnRecInstName) != null) {\r
327// name = m.getValueAt(row, cnRecInstName).toString();\r
328// } \r
329// String ver = null;\r
330// if (m.getValueAt(row, cnRecInstVer) != null){\r
331// ver = m.getValueAt(row, cnRecInstVer).toString();\r
332// }\r
a13899c5 333 String arch = null;\r
97796eaa 334 if (m.getValueAt(row, cnSupArch) != null) {\r
335 arch = m.getValueAt(row, cnSupArch).toString();\r
a13899c5 336 }\r
337 String module = null;\r
97796eaa 338 if (m.getValueAt(row, cnSupMod) != null) {\r
339 module = m.getValueAt(row, cnSupMod).toString();\r
a13899c5 340 }\r
5a502bd4 341 String[] rowData = {lib, hdr, hlp, name};\r
ce73a791 342 if (!dataValidation(rowData)) {\r
343 return;\r
344 }\r
12e17a0a 345 \r
a490bca8 346 String guid = null;\r
5a502bd4 347// if (name != null && name.length() > 0) {\r
348// getLibInstances(lib);\r
349// guid = nameToGuid(name);\r
350// if (guid == null){\r
351// JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");\r
352// return;\r
353// }\r
354// }\r
12e17a0a 355 \r
a490bca8 356 String[] sa = new String[7];\r
357 sfc.getSpdLibClassDeclaration(sa, row);\r
358 Object cellData = m.getValueAt(row, column);\r
359 if (cellData == null) {\r
360 cellData = "";\r
361 }\r
5a502bd4 362// if (column == cnRecInstName) {\r
363// if (guid == null) {\r
364// if (sa[cnRecInstName] == null) {\r
365// return;\r
366// }\r
367// }\r
368// else {\r
369// if (guid.equals(sa[cnRecInstName])) {\r
370// return;\r
371// }\r
372// }\r
373// }\r
374 if (cellData.equals(sa[column])) {\r
375 return;\r
a490bca8 376 }\r
5a502bd4 377 if (cellData.toString().length() == 0 && sa[column] == null) {\r
378 return;\r
a490bca8 379 }\r
380 docConsole.setSaved(false);\r
5a502bd4 381 sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, null, arch, module);\r
a13899c5 382 }\r
383 }\r
384\r
385 /**\r
386 This method initializes jButtonAdd \r
387 \r
388 @return javax.swing.JButton \r
389 **/\r
390 private JButton getJButtonAdd() {\r
391 if (jButtonAdd == null) {\r
392 jButtonAdd = new JButton();\r
a13899c5 393 jButtonAdd.setText("Add");\r
0a35c6e2 394 jButtonAdd.setSize(new java.awt.Dimension(buttonWidth,20));\r
395 jButtonAdd.setBounds(new java.awt.Rectangle(addButtonCol,rowSeven,buttonWidth,20));\r
a13899c5 396 jButtonAdd.addActionListener(this);\r
397 }\r
398 return jButtonAdd;\r
399 }\r
400\r
401 /**\r
402 This method initializes jButtonRemove \r
403 \r
404 @return javax.swing.JButton \r
405 **/\r
406 private JButton getJButtonRemove() {\r
407 if (jButtonRemove == null) {\r
408 jButtonRemove = new JButton();\r
a13899c5 409 jButtonRemove.setText("Remove");\r
0a35c6e2 410 jButtonRemove.setSize(new java.awt.Dimension(buttonWidth,20));\r
411 jButtonRemove.setBounds(new java.awt.Rectangle(removeButtonCol,rowSeven,buttonWidth,20));\r
a13899c5 412 jButtonRemove.addActionListener(this);\r
413 }\r
414 return jButtonRemove;\r
415 }\r
416\r
417 /**\r
418 This method initializes jButtonRemoveAll \r
419 \r
420 @return javax.swing.JButton \r
421 **/\r
97796eaa 422 private JButton getJButtonRemoveAll() {\r
423 if (jButtonRemoveAll == null) {\r
424 jButtonRemoveAll = new JButton();\r
425 jButtonRemoveAll.setText("Remove All");\r
0a35c6e2 426 jButtonRemoveAll.setSize(new java.awt.Dimension(buttonWidth,20));\r
427 jButtonRemoveAll.setBounds(new java.awt.Rectangle(removeAllButtonCol,rowSeven,buttonWidth,20));\r
97796eaa 428 jButtonRemoveAll.addActionListener(this);\r
a13899c5 429 }\r
97796eaa 430 return jButtonRemoveAll;\r
a13899c5 431 }\r
432\r
a13899c5 433 /**\r
434 This is the default constructor\r
435 **/\r
436 public SpdLibClassDecls() {\r
437 super();\r
438 initialize();\r
439 init();\r
440 \r
441 }\r
442\r
443 public SpdLibClassDecls(PackageSurfaceAreaDocument.PackageSurfaceArea inPsa){\r
444 this();\r
445 sfc = new SpdFileContents(inPsa);\r
446 init(sfc);\r
447 }\r
d6d24759 448 \r
449 public SpdLibClassDecls(OpeningPackageType opt) {\r
450 this(opt.getXmlSpd());\r
451 docConsole = opt;\r
452 }\r
a13899c5 453 /**\r
454 This method initializes this\r
455 \r
456 @return void\r
457 **/\r
458 private void init() {\r
459 \r
460 this.setContentPane(getJContentPane());\r
461 this.setTitle("Library Class Declarations");\r
462 this.setBounds(new java.awt.Rectangle(0, 0, 500, 370));\r
463 this.setVisible(true);\r
464 this.addInternalFrameListener(new InternalFrameAdapter(){\r
465 public void internalFrameDeactivated(InternalFrameEvent e){\r
466 if (jTable.isEditing()) {\r
467 jTable.getCellEditor().stopCellEditing();\r
468 }\r
469 }\r
470 });\r
a13899c5 471 }\r
472\r
473 private void init(SpdFileContents sfc) {\r
474 if (sfc.getSpdLibClassDeclarationCount() == 0) {\r
475 return ;\r
476 }\r
477 //\r
478 // initialize table using SpdFileContents object\r
479 //\r
480 String[][] saa = new String[sfc.getSpdLibClassDeclarationCount()][7];\r
481 sfc.getSpdLibClassDeclarations(saa);\r
482 int i = 0;\r
483 while (i < saa.length) {\r
5a502bd4 484// if (saa[i][3] != null && saa[i][3].length() > 0) {\r
485// getLibInstances(saa[i][0]);\r
486// saa[i][3] = guidToName(saa[i][3]);\r
487// }\r
12e17a0a 488 \r
a13899c5 489 model.addRow(saa[i]);\r
490 i++;\r
491 }\r
492 }\r
493 private JScrollPane getJContentPane(){\r
494 if (topScrollPane == null){\r
495 topScrollPane = new JScrollPane();\r
a13899c5 496 topScrollPane.setViewportView(getJContentPane1());\r
497 }\r
498 return topScrollPane;\r
499 }\r
500 /**\r
501 This method initializes jContentPane\r
502 \r
503 @return javax.swing.JPanel\r
504 **/\r
505 private JPanel getJContentPane1() {\r
506 if (jContentPane == null) {\r
97796eaa 507 // Library Class\r
0a35c6e2 508 starLabel1 = new StarLabel();\r
509 starLabel1.setLocation(new java.awt.Point(1,rowOne));\r
97796eaa 510 jLabel1ClassName = new JLabel();\r
0a35c6e2 511 jLabel1ClassName.setBounds(new java.awt.Rectangle(labelCol,rowOne,shortLabel,20));\r
97796eaa 512 jLabel1ClassName.setText("Library Class");\r
513\r
514 // Help Text\r
0a35c6e2 515 starLabel2 = new StarLabel();\r
516 starLabel2.setBounds(new java.awt.Rectangle(1,rowTwo,10,20));\r
97796eaa 517 jLabel2HelpText = new JLabel();\r
0a35c6e2 518 jLabel2HelpText.setBounds(new java.awt.Rectangle(labelCol,rowTwo,shortLabel,20));\r
97796eaa 519 jLabel2HelpText.setText("Help Text");\r
520\r
521 // Header File\r
0a35c6e2 522 starLabel3 = new StarLabel();\r
523 starLabel3.setLocation(new java.awt.Point(1,rowThree));\r
97796eaa 524 jLabelHdr = new JLabel();\r
0a35c6e2 525 jLabelHdr.setBounds(new java.awt.Rectangle(labelCol,rowThree,longLabel,20));\r
97796eaa 526 jLabelHdr.setText("Include Header for Specified Class");\r
527\r
2f8a7517 528 jLabel6SupModList = new JLabel();\r
0a35c6e2 529 jLabel6SupModList.setBounds(new java.awt.Rectangle(labelCol,rowFive,longLabel,20));\r
530 jLabel6SupModList.setText("Supported Module Types");\r
2f8a7517 531 jLabel6SupModList.setEnabled(true);\r
97796eaa 532\r
2f8a7517 533 jLabel5SupArchList = new JLabel();\r
0a35c6e2 534 jLabel5SupArchList.setBounds(new java.awt.Rectangle(labelCol,rowFour,longLabel,20));\r
535 jLabel5SupArchList.setText("Supported Architectures");\r
2f8a7517 536 jLabel5SupArchList.setEnabled(true);\r
0a35c6e2 537\r
a13899c5 538 jContentPane = new JPanel();\r
1be13d3f 539 jContentPane.setPreferredSize(new Dimension(680, 600));\r
a13899c5 540 jContentPane.setLayout(null);\r
97796eaa 541 jContentPane.add(jLabelHdr, null);\r
0a35c6e2 542 jContentPane.add(starLabel1, null);\r
543 jContentPane.add(starLabel3, null);\r
544 jContentPane.add(getJTextFieldAddClass(), null);\r
a13899c5 545 jContentPane.add(getJComboBoxSelect(), null);\r
0a35c6e2 546 jContentPane.add(getJScrollPaneTable(), null);\r
a13899c5 547 jContentPane.add(getJButtonAdd(), null);\r
548 jContentPane.add(getJButtonRemove(), null);\r
97796eaa 549 jContentPane.add(getJButtonRemoveAll(), null);\r
a13899c5 550 \r
97796eaa 551 jContentPane.add(getJTextFieldHdr(), null);\r
a13899c5 552 jContentPane.add(getJButtonBrowse(), null);\r
2f8a7517 553 jContentPane.add(jLabel1ClassName, null);\r
0a35c6e2 554 jContentPane.add(starLabel2, null);\r
2f8a7517 555 jContentPane.add(jLabel2HelpText, null);\r
0a35c6e2 556 jContentPane.add(getJHelpTextScrollPane(), null);\r
d129bd96 557\r
2f8a7517 558 jContentPane.add(jLabel5SupArchList, null);\r
559 jContentPane.add(jLabel6SupModList, null);\r
a13899c5 560 \r
97796eaa 561 jContentPane.add(getJScrollPaneModules(), null);\r
562 jContentPane.add(getJScrollPane1Arch(), null);\r
af25df16 563 \r
a13899c5 564 }\r
565 \r
566 return jContentPane;\r
567 }\r
568\r
a13899c5 569\r
570 /* (non-Javadoc)\r
571 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r
572 */\r
573 public void actionPerformed(ActionEvent arg0) {\r
d6d24759 574 \r
a13899c5 575 if (arg0.getSource() == jButtonAdd) {\r
576 \r
577 //ToDo: check before add\r
2f8a7517 578 // LAH WAS String[] row = {null, null, null, jComboBox.getSelectedItem()+"", jTextField2RecInstVer.getText(), null, null};\r
579 String[] row = {null, null, null, null, null, null, null};\r
0a35c6e2 580 row[cnClassName] = jTextFieldAddClass.getText();\r
97796eaa 581 row[cnHdrFile] = jTextFieldHdr.getText().replace('\\', '/');\r
0a35c6e2 582 row[cnHelpText] = jTextAreaHelp.getText();\r
5a502bd4 583// row[cnRecInstName] = jComboBox.getSelectedItem()+"";\r
584// row[cnRecInstVer] = jTextField2RecInstVer.getText();\r
4da2e625 585 row[cnSupArch] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());\r
97796eaa 586 if (row[cnSupArch].length() == 0) {\r
587 row[cnSupArch] = null;\r
a13899c5 588 }\r
97796eaa 589 row[cnSupMod] = vectorToString(iCheckBoxListModules.getAllCheckedItemsString());\r
590 if (row[cnSupMod].length() == 0){\r
591 row[cnSupMod] = null;\r
a13899c5 592 }\r
ce73a791 593 if (!dataValidation(row)) {\r
594 return;\r
595 }\r
12e17a0a 596 //\r
597 //convert to GUID before storing recommended lib instance.\r
598 //\r
5a502bd4 599// getLibInstances(row[cnClassName]);\r
600// String recommendGuid = nameToGuid(row[cnRecInstName]);\r
601// if (row[cnRecInstName].equals("null")) {\r
602// row[cnRecInstName] = null;\r
603// }\r
604// else{\r
605// if (recommendGuid == null) {\r
606// JOptionPane.showMessageDialog(frame, "Recommended Instance does not exist.");\r
607// return;\r
608// }\r
609// }\r
610\r
611 sfc.genSpdLibClassDeclarations(row[cnClassName], null, row[cnHdrFile], row[cnHelpText], row[cnSupArch], null, null, null, null, row[cnSupMod]);\r
a490bca8 612 model.addRow(row);\r
613 jTable.changeSelection(model.getRowCount()-1, 0, false, false);\r
614 docConsole.setSaved(false);\r
a13899c5 615 }\r
616 //\r
617 // remove selected line\r
618 //\r
619 if (arg0.getSource() == jButtonRemove) {\r
620 if (jTable.isEditing()){\r
621 jTable.getCellEditor().stopCellEditing();\r
622 }\r
623 int rowSelected = selectedRow;\r
624 if (rowSelected >= 0) {\r
625 model.removeRow(rowSelected);\r
d129bd96 626 docConsole.setSaved(false);\r
a13899c5 627 sfc.removeSpdLibClass(rowSelected);\r
628 }\r
629 }\r
630\r
97796eaa 631 if (arg0.getSource() == jButtonRemoveAll) {\r
a13899c5 632 if (model.getRowCount() == 0) {\r
633 return;\r
634 }\r
d129bd96 635 docConsole.setSaved(false);\r
a13899c5 636 model.setRowCount(0);\r
637 sfc.removeSpdLibClass();\r
638 }\r
a13899c5 639 }\r
640\r
ce73a791 641 private boolean dataValidation(String[] row) {\r
97796eaa 642 if (!DataValidation.isKeywordType(row[cnClassName])) {\r
816ea437 643 JOptionPane.showMessageDialog(frame, "Library Class name entered does not match KeyWord datatype.");\r
ce73a791 644 return false;\r
645 }\r
97796eaa 646 if (!DataValidation.isPathAndFilename(row[cnHdrFile])) {\r
816ea437 647 JOptionPane.showMessageDialog(frame, "Include Header does not match the PathAndFilename datatype.");\r
d129bd96 648 return false;\r
ce73a791 649 }\r
97796eaa 650 if (row[cnHelpText].length() == 0) {\r
816ea437 651 JOptionPane.showMessageDialog(frame, "Help Text must be entered!");\r
d129bd96 652 return false;\r
653 }\r
5a502bd4 654// if (row[cnRecInstVer] != null && row[cnRecInstVer].length() > 0) {\r
655// if (row[cnRecInstName] == null || row[cnRecInstName].length() == 0) {\r
656// JOptionPane.showMessageDialog(frame, "Recommended Instance Version must associate with the Instance Name.");\r
657// return false;\r
658// }\r
659// \r
660// if (!DataValidation.isVersionDataType(row[cnRecInstVer])) {\r
661// JOptionPane.showMessageDialog(frame, "Recommended Instance Version does not match Version datatype.");\r
662// return false;\r
663// }\r
664// }\r
ce73a791 665 return true;\r
666 }\r
a13899c5 667 /**\r
668 Add contents in list to sfc\r
669 **/\r
670 protected void save() {\r
671 \r
672 }\r
673\r
674 /**\r
675 This method initializes jTextField \r
676 \r
677 @return javax.swing.JTextField \r
678 **/\r
97796eaa 679 private JTextField getJTextFieldHdr() {\r
680 if (jTextFieldHdr == null) {\r
681 jTextFieldHdr = new JTextField();\r
0a35c6e2 682 jTextFieldHdr.setPreferredSize(new java.awt.Dimension(shortWidth,20));\r
683 jTextFieldHdr.setLocation(new java.awt.Point(longValueCol,rowThree));\r
684 jTextFieldHdr.setSize(new java.awt.Dimension(shortWidth,20));\r
a13899c5 685 }\r
97796eaa 686 return jTextFieldHdr;\r
a13899c5 687 }\r
688\r
689 /**\r
690 This method initializes jButtonBrowse \r
691 \r
692 @return javax.swing.JButton \r
693 **/\r
694 private JButton getJButtonBrowse() {\r
695 if (jButtonBrowse == null) {\r
696 jButtonBrowse = new JButton();\r
0a35c6e2 697 jButtonBrowse.setBounds(new java.awt.Rectangle(longValueCol + shortWidth + 7,rowThree,90,20));\r
a13899c5 698 jButtonBrowse.setText("Browse");\r
97796eaa 699 jButtonBrowse.setPreferredSize(new java.awt.Dimension(99,20));\r
a13899c5 700 jButtonBrowse.addActionListener(new AbstractAction() {\r
701 \r
ce73a791 702 /**\r
703 * \r
704 */\r
705 private static final long serialVersionUID = 1L;\r
706\r
a13899c5 707 public void actionPerformed(ActionEvent arg0) {\r
708 //\r
709 // Select files from current pkg\r
710 //\r
711 String dirPrefix = Tools.dirForNewSpd.substring(0, Tools.dirForNewSpd.lastIndexOf(File.separator));\r
712 JFileChooser chooser = new JFileChooser(dirPrefix);\r
713 File theFile = null;\r
714 String headerDest = null;\r
715 \r
716 chooser.setMultiSelectionEnabled(false);\r
717 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);\r
718 int retval = chooser.showOpenDialog(frame);\r
719 if (retval == JFileChooser.APPROVE_OPTION) {\r
720\r
721 theFile = chooser.getSelectedFile();\r
722 String file = theFile.getPath();\r
723 if (!file.startsWith(dirPrefix)) {\r
816ea437 724 JOptionPane.showMessageDialog(frame, "You can only select files in current package directory structure!");\r
a13899c5 725 return;\r
726 }\r
727 \r
728 \r
729 }\r
730 else {\r
731 return;\r
732 }\r
733 \r
734 headerDest = theFile.getPath();\r
735 int fileIndex = headerDest.indexOf(System.getProperty("file.separator"), dirPrefix.length());\r
97796eaa 736 jTextFieldHdr.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));\r
a13899c5 737 \r
738 }\r
739\r
740 });\r
741 }\r
742 return jButtonBrowse;\r
743 }\r
744 \r
745 public void componentResized(ComponentEvent arg0) {\r
746 int intPreferredWidth = 500;\r
747 \r
0a35c6e2 748 Tools.resizeComponentWidth(this.jTextFieldAddClass, this.getWidth(), intPreferredWidth-28);\r
749 Tools.resizeComponentWidth(this.jHelpTextScrollPane, this.getWidth(), intPreferredWidth-28);\r
750 Tools.resizeComponentWidth(this.jScrollPaneTable, this.getWidth(), intPreferredWidth-10);\r
751 Tools.resizeComponentWidth(this.jTextFieldHdr, this.getWidth(), intPreferredWidth - 7);\r
752 Tools.relocateComponentX(this.jButtonBrowse, this.getWidth(), intPreferredWidth,\r
753 DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON); \r
a13899c5 754 }\r
755\r
756 /**\r
0a35c6e2 757 * This method initializes jHelpTextScrollPane\r
758 *\r
759 * @return javax.swing.JScrollPane jHelpTextScrollPane\r
a13899c5 760 */\r
0a35c6e2 761 private JScrollPane getJHelpTextScrollPane() {\r
762 if (jHelpTextScrollPane == null) {\r
763 jHelpTextScrollPane = new JScrollPane();\r
764 jHelpTextScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r
765 jHelpTextScrollPane.setPreferredSize(new java.awt.Dimension(longValueWidth, 80));\r
766 jHelpTextScrollPane.setSize(new java.awt.Dimension(longValueWidth, 80));\r
767 jHelpTextScrollPane.setLocation(new java.awt.Point(shortValueCol,rowTwo));\r
768 jHelpTextScrollPane.setViewportView(getJTextAreaHelp());\r
a13899c5 769 }\r
0a35c6e2 770 return jHelpTextScrollPane;\r
a13899c5 771 }\r
772\r
773 /**\r
0a35c6e2 774 * This method initializes jTextAreaHelp \r
a13899c5 775 * \r
0a35c6e2 776 * @return javax.swing.JTextArea \r
a13899c5 777 */\r
0a35c6e2 778 private JTextArea getJTextAreaHelp() {\r
779 if (jTextAreaHelp == null) {\r
780 jTextAreaHelp = new JTextArea();\r
781 jTextAreaHelp.setLineWrap(true);\r
782 jTextAreaHelp.setWrapStyleWord(true);\r
a13899c5 783 }\r
0a35c6e2 784 return jTextAreaHelp;\r
a13899c5 785 }\r
786\r
97796eaa 787 private JScrollPane getJScrollPaneModules() {\r
788 if (jScrollPaneModules == null) {\r
789 jScrollPaneModules = new JScrollPane();\r
0a35c6e2 790 jScrollPaneModules.setBounds(new java.awt.Rectangle(longValueCol,rowFive,medWidth,60));\r
791 jScrollPaneModules.setPreferredSize(new java.awt.Dimension(medWidth, 60));\r
97796eaa 792 jScrollPaneModules.setViewportView(getICheckBoxListSupportedModules());\r
a13899c5 793 }\r
97796eaa 794 return jScrollPaneModules;\r
a13899c5 795 }\r
796 \r
97796eaa 797 private ICheckBoxList getICheckBoxListSupportedModules() {\r
798 if (iCheckBoxListModules == null) {\r
799 iCheckBoxListModules = new ICheckBoxList();\r
0a35c6e2 800 iCheckBoxListModules.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));\r
a13899c5 801 Vector<String> v = new Vector<String>();\r
802 v.add("BASE");\r
803 v.add("SEC");\r
804 v.add("PEI_CORE");\r
805 v.add("PEIM");\r
806 v.add("DXE_CORE");\r
807 v.add("DXE_DRIVER");\r
808 v.add("DXE_RUNTIME_DRIVER");\r
809 v.add("DXE_SAL_DRIVER");\r
810 v.add("DXE_SMM_DRIVER");\r
811 v.add("UEFI_DRIVER");\r
812 v.add("UEFI_APPLICATION");\r
813 v.add("USER_DEFINED");\r
97796eaa 814 iCheckBoxListModules.setAllItems(v);\r
a13899c5 815 }\r
97796eaa 816 return iCheckBoxListModules;\r
a13899c5 817 }\r
818 \r
a13899c5 819 private String vectorToString(Vector<String> v) {\r
820 String s = " ";\r
821 for (int i = 0; i < v.size(); ++i) {\r
822 s += v.get(i);\r
823 s += " ";\r
824 }\r
825 return s.trim();\r
826 }\r
af25df16 827 \r
97796eaa 828 private JScrollPane getJScrollPane1Arch() {\r
829 if (jScrollPane1Arch == null) {\r
830 jScrollPane1Arch = new JScrollPane();\r
0a35c6e2 831 jScrollPane1Arch.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));\r
832 jScrollPane1Arch.setPreferredSize(new java.awt.Dimension(medWidth, 60));\r
4da2e625 833 jScrollPane1Arch.setViewportView(getICheckBoxListArch());\r
af25df16 834 }\r
97796eaa 835 return jScrollPane1Arch;\r
af25df16 836 }\r
ce73a791 837 /**\r
af25df16 838 * This method initializes iCheckBoxList \r
ce73a791 839 * \r
af25df16 840 * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList \r
ce73a791 841 */\r
4da2e625 842 private ICheckBoxList getICheckBoxListArch() {\r
843 if (iCheckBoxListArch == null) {\r
844 iCheckBoxListArch = new ICheckBoxList();\r
0a35c6e2 845 iCheckBoxListArch.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));\r
af25df16 846 Vector<String> v = new Vector<String>();\r
847 v.add("IA32");\r
848 v.add("X64");\r
849 v.add("IPF");\r
850 v.add("EBC");\r
851 v.add("ARM");\r
852 v.add("PPC");\r
4da2e625 853 iCheckBoxListArch.setAllItems(v);\r
ce73a791 854 }\r
4da2e625 855 return iCheckBoxListArch;\r
ce73a791 856 }\r
857\r
5a502bd4 858// private void getLibInstances(String libClass){\r
859// libNameGuidMap.clear();\r
860// try {\r
861// Iterator ismi = GlobalData.vModuleList.iterator();\r
862// while (ismi.hasNext()) {\r
863// ModuleIdentification mi = (ModuleIdentification) ismi.next();\r
864// \r
865// Vector<String> classProduced = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED", mi);\r
866// for (int i = 0; i < classProduced.size(); ++i) {\r
867// if (classProduced.get(i).equals(libClass)) {\r
868// libNameGuidMap.put(mi.getName(), mi.getGuid());\r
869// }\r
870// }\r
871// }\r
872// \r
873// }\r
874// catch(Exception e){\r
875// JOptionPane.showMessageDialog(frame, "Search Instances Failed.");\r
876// }\r
877// \r
878// }\r
879\r
880// private String nameToGuid(String name) {\r
881// String s = null;\r
882// if (!libNameGuidMap.containsKey(name)) {\r
883// return s;\r
884// }\r
885// \r
886// s = libNameGuidMap.get(name);\r
887// return s;\r
888// }\r
12e17a0a 889 \r
5a502bd4 890// private String guidToName(String guid){\r
891// String s = "";\r
892// if (!libNameGuidMap.containsValue(guid)) {\r
893// return s;\r
894// }\r
895// Set<String> key = libNameGuidMap.keySet();\r
896// Iterator<String> is = key.iterator();\r
897// while(is.hasNext()) {\r
898// s = is.next();\r
899// if (libNameGuidMap.get(s).equals(guid)) {\r
900// break;\r
901// }\r
902// }\r
903// return s;\r
904// }\r
12e17a0a 905\r
a13899c5 906}\r
907\r
908\r