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