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