]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | Java class SpdLibClassDecls is GUI for create library definition elements of spd file.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | **/\r | |
13 | package org.tianocore.frameworkwizard.packaging.ui;\r | |
14 | \r | |
15 | import java.awt.Dimension;\r | |
16 | import java.awt.event.ActionEvent;\r | |
17 | import java.awt.event.ComponentEvent;\r | |
18 | import java.io.File;\r | |
19 | import java.util.HashMap;\r | |
20 | //import java.util.Iterator;\r | |
21 | //import java.util.Set;\r | |
22 | import java.util.Vector;\r | |
23 | \r | |
24 | import javax.swing.AbstractAction;\r | |
25 | import javax.swing.JFileChooser;\r | |
26 | import javax.swing.JOptionPane;\r | |
27 | import javax.swing.JPanel;\r | |
28 | import javax.swing.JTable;\r | |
29 | import javax.swing.JTextField;\r | |
30 | import javax.swing.JTextArea;\r | |
31 | import javax.swing.JComboBox;\r | |
32 | import javax.swing.JLabel;\r | |
33 | import javax.swing.JScrollPane;\r | |
34 | import javax.swing.JButton;\r | |
35 | import javax.swing.JFrame;\r | |
36 | import javax.swing.ListSelectionModel;\r | |
37 | import javax.swing.event.InternalFrameAdapter;\r | |
38 | import javax.swing.event.InternalFrameEvent;\r | |
39 | import javax.swing.event.ListSelectionEvent;\r | |
40 | import javax.swing.event.ListSelectionListener;\r | |
41 | import javax.swing.event.TableModelEvent;\r | |
42 | import javax.swing.event.TableModelListener;\r | |
43 | import javax.swing.table.DefaultTableModel;\r | |
44 | import javax.swing.table.TableColumn;\r | |
45 | import javax.swing.table.TableModel;\r | |
46 | import org.tianocore.PackageSurfaceAreaDocument;\r | |
47 | import org.tianocore.frameworkwizard.common.DataType;\r | |
48 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
49 | //import org.tianocore.frameworkwizard.common.GlobalData;\r | |
50 | import org.tianocore.frameworkwizard.common.Tools;\r | |
51 | import org.tianocore.frameworkwizard.common.Identifications.OpeningPackageType;\r | |
52 | import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r | |
53 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
54 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
55 | import org.tianocore.frameworkwizard.platform.ui.ListEditor;\r | |
56 | import org.tianocore.frameworkwizard.platform.ui.LongTextEditor;\r | |
57 | //import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r | |
58 | //import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r | |
59 | \r | |
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 | |
66 | public class SpdLibClassDecls extends IInternalFrame implements TableModelListener{\r | |
67 | /**\r | |
68 | * \r | |
69 | */\r | |
70 | private static final long serialVersionUID = 1L;\r | |
71 | \r | |
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 | |
80 | private JTextField jTextFieldAddClass = null;\r | |
81 | \r | |
82 | private JComboBox jComboBoxSelect = null;\r | |
83 | \r | |
84 | private JScrollPane jScrollPaneTable = null;\r | |
85 | \r | |
86 | private JButton jButtonAdd = null;\r | |
87 | \r | |
88 | private JButton jButtonRemove = null;\r | |
89 | \r | |
90 | private JButton jButtonRemoveAll = null;\r | |
91 | \r | |
92 | private JLabel jLabelHdr = null;\r | |
93 | \r | |
94 | private JTextField jTextFieldHdr = null;\r | |
95 | \r | |
96 | private JButton jButtonBrowse = null;\r | |
97 | \r | |
98 | private StarLabel starLabel1 = null;\r | |
99 | \r | |
100 | private StarLabel starLabel3 = null;\r | |
101 | \r | |
102 | private SpdFileContents sfc = null;\r | |
103 | \r | |
104 | private OpeningPackageType docConsole = null;\r | |
105 | \r | |
106 | private JLabel jLabel1ClassName = null;\r | |
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 | |
112 | private StarLabel starLabel2 = null;\r | |
113 | \r | |
114 | private JLabel jLabel2HelpText = null;\r | |
115 | \r | |
116 | private JTextArea jTextAreaHelp = null;\r | |
117 | \r | |
118 | private JScrollPane jHelpTextScrollPane = null;\r | |
119 | \r | |
120 | private JLabel jLabel5SupArchList = null;\r | |
121 | \r | |
122 | private JLabel jLabel6SupModList = null;\r | |
123 | \r | |
124 | private JScrollPane jScrollPaneModules = null;\r | |
125 | \r | |
126 | private JScrollPane jScrollPane1Arch = null;\r | |
127 | \r | |
128 | private ICheckBoxList iCheckBoxListModules = null;\r | |
129 | \r | |
130 | private ICheckBoxList iCheckBoxListArch = null;\r | |
131 | \r | |
132 | private int cnClassName = 0;\r | |
133 | private int cnHdrFile = 1;\r | |
134 | private int cnHelpText = 2;\r | |
135 | // private int cnRecInstName = 3;\r | |
136 | // private int cnRecInstVer = 4;\r | |
137 | private int cnSupArch = 5;\r | |
138 | private int cnSupMod = 6;\r | |
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 | |
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 | |
170 | HashMap<String, String> libNameGuidMap = new HashMap<String, String>();\r | |
171 | \r | |
172 | \r | |
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 | |
183 | /**\r | |
184 | This method initializes jTextFieldAddClass \r | |
185 | \r | |
186 | @return javax.swing.JTextField \r | |
187 | **/\r | |
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 | |
194 | }\r | |
195 | return jTextFieldAddClass;\r | |
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 | |
215 | This method initializes jScrollPaneTable \r | |
216 | \r | |
217 | @return javax.swing.JScrollPane \r | |
218 | \r | |
219 | Used for the Table of Library Classes that are provided by this package\r | |
220 | \r | |
221 | **/\r | |
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 | |
227 | }\r | |
228 | return jScrollPaneTable;\r | |
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 | |
241 | jTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);\r | |
242 | jTable.setColumnSelectionAllowed(false);\r | |
243 | model.addColumn("Class Name");\r | |
244 | model.addColumn("Header");\r | |
245 | model.addColumn("Help Text");\r | |
246 | model.addColumn("Recommended Instance");\r | |
247 | model.addColumn("Version");\r | |
248 | model.addColumn("Supported Architectures");\r | |
249 | model.addColumn("Supported Module Types");\r | |
250 | \r | |
251 | jTable.getColumnModel().getColumn(cnHelpText).setCellEditor(new LongTextEditor());\r | |
252 | \r | |
253 | jTable.removeColumn(jTable.getColumnModel().getColumn(3));\r | |
254 | jTable.removeColumn(jTable.getColumnModel().getColumn(3));\r | |
255 | \r | |
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 | |
263 | jTable.getColumnModel().getColumn(cnSupArch - 2).setCellEditor(new ListEditor(vArch));\r | |
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 | |
278 | \r | |
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 | |
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 | |
318 | int column = arg0.getColumn();\r | |
319 | TableModel m = (TableModel)arg0.getSource();\r | |
320 | if (arg0.getType() == TableModelEvent.UPDATE){\r | |
321 | \r | |
322 | String lib = m.getValueAt(row, cnClassName) + "";\r | |
323 | String hdr = m.getValueAt(row, cnHdrFile) + "";\r | |
324 | String hlp = m.getValueAt(row, cnHelpText) + "";\r | |
325 | String name = null;\r | |
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 | |
333 | String arch = null;\r | |
334 | if (m.getValueAt(row, cnSupArch) != null) {\r | |
335 | arch = m.getValueAt(row, cnSupArch).toString();\r | |
336 | }\r | |
337 | String module = null;\r | |
338 | if (m.getValueAt(row, cnSupMod) != null) {\r | |
339 | module = m.getValueAt(row, cnSupMod).toString();\r | |
340 | }\r | |
341 | String[] rowData = {lib, hdr, hlp, name};\r | |
342 | if (!dataValidation(rowData)) {\r | |
343 | return;\r | |
344 | }\r | |
345 | \r | |
346 | String guid = null;\r | |
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 | |
355 | \r | |
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 | |
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 | |
376 | }\r | |
377 | if (cellData.toString().length() == 0 && sa[column] == null) {\r | |
378 | return;\r | |
379 | }\r | |
380 | docConsole.setSaved(false);\r | |
381 | sfc.updateSpdLibClass(row, lib, hdr, hlp, guid, null, arch, module);\r | |
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 | |
393 | jButtonAdd.setText("Add");\r | |
394 | jButtonAdd.setSize(new java.awt.Dimension(buttonWidth,20));\r | |
395 | jButtonAdd.setBounds(new java.awt.Rectangle(addButtonCol,rowSeven,buttonWidth,20));\r | |
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 | |
409 | jButtonRemove.setText("Remove");\r | |
410 | jButtonRemove.setSize(new java.awt.Dimension(buttonWidth,20));\r | |
411 | jButtonRemove.setBounds(new java.awt.Rectangle(removeButtonCol,rowSeven,buttonWidth,20));\r | |
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 | |
422 | private JButton getJButtonRemoveAll() {\r | |
423 | if (jButtonRemoveAll == null) {\r | |
424 | jButtonRemoveAll = new JButton();\r | |
425 | jButtonRemoveAll.setText("Remove All");\r | |
426 | jButtonRemoveAll.setSize(new java.awt.Dimension(buttonWidth,20));\r | |
427 | jButtonRemoveAll.setBounds(new java.awt.Rectangle(removeAllButtonCol,rowSeven,buttonWidth,20));\r | |
428 | jButtonRemoveAll.addActionListener(this);\r | |
429 | }\r | |
430 | return jButtonRemoveAll;\r | |
431 | }\r | |
432 | \r | |
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 | |
448 | \r | |
449 | public SpdLibClassDecls(OpeningPackageType opt) {\r | |
450 | this(opt.getXmlSpd());\r | |
451 | docConsole = opt;\r | |
452 | }\r | |
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 | |
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 | |
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 | |
488 | \r | |
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 | |
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 | |
507 | // Library Class\r | |
508 | starLabel1 = new StarLabel();\r | |
509 | starLabel1.setLocation(new java.awt.Point(1,rowOne));\r | |
510 | jLabel1ClassName = new JLabel();\r | |
511 | jLabel1ClassName.setBounds(new java.awt.Rectangle(labelCol,rowOne,shortLabel,20));\r | |
512 | jLabel1ClassName.setText("Library Class");\r | |
513 | \r | |
514 | // Help Text\r | |
515 | starLabel2 = new StarLabel();\r | |
516 | starLabel2.setBounds(new java.awt.Rectangle(1,rowTwo,10,20));\r | |
517 | jLabel2HelpText = new JLabel();\r | |
518 | jLabel2HelpText.setBounds(new java.awt.Rectangle(labelCol,rowTwo,shortLabel,20));\r | |
519 | jLabel2HelpText.setText("Help Text");\r | |
520 | \r | |
521 | // Header File\r | |
522 | starLabel3 = new StarLabel();\r | |
523 | starLabel3.setLocation(new java.awt.Point(1,rowThree));\r | |
524 | jLabelHdr = new JLabel();\r | |
525 | jLabelHdr.setBounds(new java.awt.Rectangle(labelCol,rowThree,longLabel,20));\r | |
526 | jLabelHdr.setText("Include Header for Specified Class");\r | |
527 | \r | |
528 | jLabel6SupModList = new JLabel();\r | |
529 | jLabel6SupModList.setBounds(new java.awt.Rectangle(labelCol,rowFive,longLabel,20));\r | |
530 | jLabel6SupModList.setText("Supported Module Types");\r | |
531 | jLabel6SupModList.setEnabled(true);\r | |
532 | \r | |
533 | jLabel5SupArchList = new JLabel();\r | |
534 | jLabel5SupArchList.setBounds(new java.awt.Rectangle(labelCol,rowFour,longLabel,20));\r | |
535 | jLabel5SupArchList.setText("Supported Architectures");\r | |
536 | jLabel5SupArchList.setEnabled(true);\r | |
537 | \r | |
538 | jContentPane = new JPanel();\r | |
539 | jContentPane.setPreferredSize(new Dimension(680, 600));\r | |
540 | jContentPane.setLayout(null);\r | |
541 | jContentPane.add(jLabelHdr, null);\r | |
542 | jContentPane.add(starLabel1, null);\r | |
543 | jContentPane.add(starLabel3, null);\r | |
544 | jContentPane.add(getJTextFieldAddClass(), null);\r | |
545 | jContentPane.add(getJComboBoxSelect(), null);\r | |
546 | jContentPane.add(getJScrollPaneTable(), null);\r | |
547 | jContentPane.add(getJButtonAdd(), null);\r | |
548 | jContentPane.add(getJButtonRemove(), null);\r | |
549 | jContentPane.add(getJButtonRemoveAll(), null);\r | |
550 | \r | |
551 | jContentPane.add(getJTextFieldHdr(), null);\r | |
552 | jContentPane.add(getJButtonBrowse(), null);\r | |
553 | jContentPane.add(jLabel1ClassName, null);\r | |
554 | jContentPane.add(starLabel2, null);\r | |
555 | jContentPane.add(jLabel2HelpText, null);\r | |
556 | jContentPane.add(getJHelpTextScrollPane(), null);\r | |
557 | \r | |
558 | jContentPane.add(jLabel5SupArchList, null);\r | |
559 | jContentPane.add(jLabel6SupModList, null);\r | |
560 | \r | |
561 | jContentPane.add(getJScrollPaneModules(), null);\r | |
562 | jContentPane.add(getJScrollPane1Arch(), null);\r | |
563 | \r | |
564 | }\r | |
565 | \r | |
566 | return jContentPane;\r | |
567 | }\r | |
568 | \r | |
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 | |
574 | \r | |
575 | if (arg0.getSource() == jButtonAdd) {\r | |
576 | \r | |
577 | //ToDo: check before add\r | |
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 | |
580 | row[cnClassName] = jTextFieldAddClass.getText();\r | |
581 | row[cnHdrFile] = jTextFieldHdr.getText().replace('\\', '/');\r | |
582 | row[cnHelpText] = jTextAreaHelp.getText();\r | |
583 | // row[cnRecInstName] = jComboBox.getSelectedItem()+"";\r | |
584 | // row[cnRecInstVer] = jTextField2RecInstVer.getText();\r | |
585 | row[cnSupArch] = vectorToString(iCheckBoxListArch.getAllCheckedItemsString());\r | |
586 | if (row[cnSupArch].length() == 0) {\r | |
587 | row[cnSupArch] = null;\r | |
588 | }\r | |
589 | row[cnSupMod] = vectorToString(iCheckBoxListModules.getAllCheckedItemsString());\r | |
590 | if (row[cnSupMod].length() == 0){\r | |
591 | row[cnSupMod] = null;\r | |
592 | }\r | |
593 | if (!dataValidation(row)) {\r | |
594 | return;\r | |
595 | }\r | |
596 | //\r | |
597 | //convert to GUID before storing recommended lib instance.\r | |
598 | //\r | |
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 | |
612 | model.addRow(row);\r | |
613 | jTable.changeSelection(model.getRowCount()-1, 0, false, false);\r | |
614 | docConsole.setSaved(false);\r | |
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 | |
626 | docConsole.setSaved(false);\r | |
627 | sfc.removeSpdLibClass(rowSelected);\r | |
628 | }\r | |
629 | }\r | |
630 | \r | |
631 | if (arg0.getSource() == jButtonRemoveAll) {\r | |
632 | if (model.getRowCount() == 0) {\r | |
633 | return;\r | |
634 | }\r | |
635 | docConsole.setSaved(false);\r | |
636 | model.setRowCount(0);\r | |
637 | sfc.removeSpdLibClass();\r | |
638 | }\r | |
639 | }\r | |
640 | \r | |
641 | private boolean dataValidation(String[] row) {\r | |
642 | if (!DataValidation.isKeywordType(row[cnClassName])) {\r | |
643 | JOptionPane.showMessageDialog(frame, "Library Class name entered does not match KeyWord datatype.");\r | |
644 | return false;\r | |
645 | }\r | |
646 | if (!DataValidation.isPathAndFilename(row[cnHdrFile])) {\r | |
647 | JOptionPane.showMessageDialog(frame, "Include Header does not match the PathAndFilename datatype.");\r | |
648 | return false;\r | |
649 | }\r | |
650 | if (row[cnHelpText].length() == 0) {\r | |
651 | JOptionPane.showMessageDialog(frame, "Help Text must be entered!");\r | |
652 | return false;\r | |
653 | }\r | |
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 | |
665 | return true;\r | |
666 | }\r | |
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 | |
679 | private JTextField getJTextFieldHdr() {\r | |
680 | if (jTextFieldHdr == null) {\r | |
681 | jTextFieldHdr = new JTextField();\r | |
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 | |
685 | }\r | |
686 | return jTextFieldHdr;\r | |
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 | |
697 | jButtonBrowse.setBounds(new java.awt.Rectangle(longValueCol + shortWidth + 7,rowThree,90,20));\r | |
698 | jButtonBrowse.setText("Browse");\r | |
699 | jButtonBrowse.setPreferredSize(new java.awt.Dimension(99,20));\r | |
700 | jButtonBrowse.addActionListener(new AbstractAction() {\r | |
701 | \r | |
702 | /**\r | |
703 | * \r | |
704 | */\r | |
705 | private static final long serialVersionUID = 1L;\r | |
706 | \r | |
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 | |
724 | JOptionPane.showMessageDialog(frame, "You can only select files in current package directory structure!");\r | |
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 | |
736 | jTextFieldHdr.setText(headerDest.substring(fileIndex + 1).replace('\\', '/'));\r | |
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 | |
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 | |
754 | }\r | |
755 | \r | |
756 | /**\r | |
757 | * This method initializes jHelpTextScrollPane\r | |
758 | *\r | |
759 | * @return javax.swing.JScrollPane jHelpTextScrollPane\r | |
760 | */\r | |
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 | |
769 | }\r | |
770 | return jHelpTextScrollPane;\r | |
771 | }\r | |
772 | \r | |
773 | /**\r | |
774 | * This method initializes jTextAreaHelp \r | |
775 | * \r | |
776 | * @return javax.swing.JTextArea \r | |
777 | */\r | |
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 | |
783 | }\r | |
784 | return jTextAreaHelp;\r | |
785 | }\r | |
786 | \r | |
787 | private JScrollPane getJScrollPaneModules() {\r | |
788 | if (jScrollPaneModules == null) {\r | |
789 | jScrollPaneModules = new JScrollPane();\r | |
790 | jScrollPaneModules.setBounds(new java.awt.Rectangle(longValueCol,rowFive,medWidth,60));\r | |
791 | jScrollPaneModules.setPreferredSize(new java.awt.Dimension(medWidth, 60));\r | |
792 | jScrollPaneModules.setViewportView(getICheckBoxListSupportedModules());\r | |
793 | }\r | |
794 | return jScrollPaneModules;\r | |
795 | }\r | |
796 | \r | |
797 | private ICheckBoxList getICheckBoxListSupportedModules() {\r | |
798 | if (iCheckBoxListModules == null) {\r | |
799 | iCheckBoxListModules = new ICheckBoxList();\r | |
800 | iCheckBoxListModules.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));\r | |
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 | |
814 | iCheckBoxListModules.setAllItems(v);\r | |
815 | }\r | |
816 | return iCheckBoxListModules;\r | |
817 | }\r | |
818 | \r | |
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 | |
827 | \r | |
828 | private JScrollPane getJScrollPane1Arch() {\r | |
829 | if (jScrollPane1Arch == null) {\r | |
830 | jScrollPane1Arch = new JScrollPane();\r | |
831 | jScrollPane1Arch.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));\r | |
832 | jScrollPane1Arch.setPreferredSize(new java.awt.Dimension(medWidth, 60));\r | |
833 | jScrollPane1Arch.setViewportView(getICheckBoxListArch());\r | |
834 | }\r | |
835 | return jScrollPane1Arch;\r | |
836 | }\r | |
837 | /**\r | |
838 | * This method initializes iCheckBoxList \r | |
839 | * \r | |
840 | * @return org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList \r | |
841 | */\r | |
842 | private ICheckBoxList getICheckBoxListArch() {\r | |
843 | if (iCheckBoxListArch == null) {\r | |
844 | iCheckBoxListArch = new ICheckBoxList();\r | |
845 | iCheckBoxListArch.setBounds(new java.awt.Rectangle(longValueCol,rowFour,medWidth,60));\r | |
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 | |
853 | iCheckBoxListArch.setAllItems(v);\r | |
854 | }\r | |
855 | return iCheckBoxListArch;\r | |
856 | }\r | |
857 | \r | |
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 | |
889 | \r | |
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 | |
905 | \r | |
906 | }\r | |
907 | \r | |
908 | \r |