]>
Commit | Line | Data |
---|---|---|
06a19cee | 1 | /** @file\r |
5b38b75b | 2 | <<The file is used to create, update SystemTable in the MSA file>>\r |
3 | \r | |
4 | <<This dialog is used to add or edit a System Table entry in the MSA file.>>\r | |
06a19cee | 5 | \r |
6 | Copyright (c) 2006, Intel Corporation\r | |
7 | All rights reserved. This program and the accompanying materials\r | |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | package org.tianocore.frameworkwizard.module.ui.dialog;\r | |
17 | \r | |
18 | import java.awt.event.ActionEvent;\r | |
19 | import java.util.Vector;\r | |
20 | \r | |
21 | import javax.swing.JButton;\r | |
22 | import javax.swing.JComboBox;\r | |
23 | import javax.swing.JLabel;\r | |
24 | import javax.swing.JPanel;\r | |
25 | import javax.swing.JScrollPane;\r | |
26 | import javax.swing.JTextField;\r | |
5b38b75b | 27 | import javax.swing.JTextArea;\r |
06a19cee | 28 | \r |
29 | import org.tianocore.frameworkwizard.common.DataType;\r | |
30 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
31 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
32 | import org.tianocore.frameworkwizard.common.Log;\r | |
33 | import org.tianocore.frameworkwizard.common.Tools;\r | |
34 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r | |
35 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
36 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r | |
37 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
e08433ef | 38 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
06a19cee | 39 | import org.tianocore.frameworkwizard.module.Identifications.SystemTables.SystemTablesIdentification;\r |
d48c170d | 40 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
06a19cee | 41 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r |
42 | \r | |
43 | /**\r | |
9e857952 | 44 | * The class is used to create, update SystemTables section of the MSA file\r |
5b38b75b | 45 | * \r |
9e857952 | 46 | * It extends IDialog\r |
5b38b75b | 47 | * \r |
48 | */\r | |
49 | public class SystemTablesDlg extends IDialog {\r | |
06a19cee | 50 | \r |
a929458e | 51 | // /\r |
52 | // / Define class Serial Version UID\r | |
53 | // /\r | |
54 | private static final long serialVersionUID = 7488769180379442276L;\r | |
06a19cee | 55 | \r |
a929458e | 56 | //\r |
57 | // Define class members\r | |
58 | //\r | |
59 | private JPanel jContentPane = null;\r | |
06a19cee | 60 | \r |
a929458e | 61 | private JLabel jLabelEntry = null;\r |
06a19cee | 62 | \r |
a929458e | 63 | private JLabel jLabelUsage = null;\r |
06a19cee | 64 | \r |
a929458e | 65 | private JComboBox jComboBoxUsage = null;\r |
06a19cee | 66 | \r |
a929458e | 67 | private StarLabel jStarLabel1 = null;\r |
06a19cee | 68 | \r |
a929458e | 69 | private StarLabel jStarLabel2 = null;\r |
06a19cee | 70 | \r |
a929458e | 71 | private JComboBox jComboBoxGuidC_Name = null;\r |
06a19cee | 72 | \r |
a929458e | 73 | private JLabel jLabelFeatureFlag = null;\r |
06a19cee | 74 | \r |
a929458e | 75 | private JTextField jTextFieldFeatureFlag = null;\r |
06a19cee | 76 | \r |
a929458e | 77 | private JLabel jLabelArch = null;\r |
06a19cee | 78 | \r |
a929458e | 79 | private JScrollPane jScrollPane = null;\r |
06a19cee | 80 | \r |
a929458e | 81 | private JLabel jLabelHelpText = null;\r |
06a19cee | 82 | \r |
a929458e | 83 | private JTextArea jTextAreaHelpText = null;\r |
06a19cee | 84 | \r |
a929458e | 85 | private JScrollPane jScrollPaneHelpText = null;\r |
06a19cee | 86 | \r |
a929458e | 87 | private ArchCheckBox jArchCheckBox = null;\r |
06a19cee | 88 | \r |
a929458e | 89 | private JButton jButtonOk = null;\r |
06a19cee | 90 | \r |
a929458e | 91 | private JButton jButtonCancel = null;\r |
06a19cee | 92 | \r |
a929458e | 93 | //\r |
94 | // Not used by UI\r | |
95 | //\r | |
96 | private SystemTablesIdentification id = null;\r | |
97 | \r | |
98 | private EnumerationData ed = new EnumerationData();\r | |
99 | \r | |
100 | private WorkspaceTools wt = new WorkspaceTools();\r | |
101 | \r | |
102 | /**\r | |
103 | * This method initializes jComboBoxGuidC_Name\r | |
104 | * \r | |
105 | * @return javax.swing.JComboBox jComboBoxGuidC_Name\r | |
106 | * \r | |
107 | */\r | |
108 | private JComboBox getJComboBoxGuidC_Name() {\r | |
109 | if (jComboBoxGuidC_Name == null) {\r | |
110 | jComboBoxGuidC_Name = new JComboBox();\r | |
3f62225f | 111 | jComboBoxGuidC_Name.setBounds(new java.awt.Rectangle(168, 12, 320, 20));\r |
a929458e | 112 | jComboBoxGuidC_Name.setPreferredSize(new java.awt.Dimension(320, 20));\r |
113 | jComboBoxGuidC_Name.setToolTipText("Select the GUID C Name of the System Table");\r | |
114 | }\r | |
115 | return jComboBoxGuidC_Name;\r | |
116 | }\r | |
06a19cee | 117 | \r |
a929458e | 118 | /**\r |
119 | * This method initializes jComboBoxUsage\r | |
120 | * \r | |
121 | * @return javax.swing.JComboBox jComboBoxUsage\r | |
122 | * \r | |
123 | */\r | |
124 | private JComboBox getJComboBoxUsage() {\r | |
125 | if (jComboBoxUsage == null) {\r | |
126 | jComboBoxUsage = new JComboBox();\r | |
3f62225f | 127 | jComboBoxUsage.setBounds(new java.awt.Rectangle(168, 37, 320, 20));\r |
a929458e | 128 | jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));\r |
129 | jComboBoxUsage\r | |
130 | .setToolTipText("<html><table>"\r | |
131 | + "<tr><td>ALWAYS_CONSUMED</td><td>Module requires a GUIDed entry in the system table</td></tr>"\r | |
132 | + "<tr><td>SOMETIMES_CONSUMED</td><td>Module consumes a GUIDed entry in the system<br>table if it is present</td>"\r | |
133 | + "</tr><tr><td>ALWAYS_PRODUCED</td><td>Module always produces a GUIDed entry in the system table</td></tr>"\r | |
134 | + "<tr><td>SOMETIMES_PRODUCED</td><td>Module produces a GUIDed entry in the system table<br>for some of its execution flows.</td></tr>"\r | |
135 | + "</table></html>");\r | |
136 | }\r | |
137 | return jComboBoxUsage;\r | |
138 | }\r | |
06a19cee | 139 | \r |
a929458e | 140 | /**\r |
141 | * This method initializes jTextFieldFeatureFlag\r | |
142 | * \r | |
143 | * @return javax.swing.JTextField\r | |
144 | */\r | |
145 | private JTextField getJTextFieldFeatureFlag() {\r | |
146 | if (jTextFieldFeatureFlag == null) {\r | |
147 | jTextFieldFeatureFlag = new JTextField();\r | |
21b42c66 | 148 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 132, 320, 20));\r |
a929458e | 149 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));\r |
150 | jTextFieldFeatureFlag.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");\r | |
21b42c66 | 151 | jTextFieldFeatureFlag.setEnabled(false);\r |
a929458e | 152 | }\r |
153 | return jTextFieldFeatureFlag;\r | |
06a19cee | 154 | }\r |
a929458e | 155 | \r |
156 | /**\r | |
157 | * This method initializes jScrollPane\r | |
158 | * \r | |
159 | * @return javax.swing.JScrollPane\r | |
160 | */\r | |
161 | private JScrollPane getJScrollPane() {\r | |
162 | if (jScrollPane == null) {\r | |
163 | jScrollPane = new JScrollPane();\r | |
164 | jScrollPane.setViewportView(getJContentPane());\r | |
165 | }\r | |
166 | return jScrollPane;\r | |
06a19cee | 167 | }\r |
a929458e | 168 | \r |
169 | /**\r | |
170 | * This method initializes jTextAreaHelpText\r | |
171 | * \r | |
172 | * @return javax.swing.JTextArea\r | |
173 | * \r | |
174 | */\r | |
175 | private JTextArea getJTextAreaHelpText() {\r | |
176 | if (jTextAreaHelpText == null) {\r | |
177 | jTextAreaHelpText = new JTextArea();\r | |
178 | jTextAreaHelpText.setLineWrap(true);\r | |
179 | jTextAreaHelpText.setWrapStyleWord(true);\r | |
180 | }\r | |
181 | return jTextAreaHelpText;\r | |
06a19cee | 182 | }\r |
a929458e | 183 | \r |
184 | /**\r | |
185 | * This method initializes jScrollPaneHelpText\r | |
186 | * \r | |
187 | * @returns javax.swing.JScrollPane jScrollPaneHelpText\r | |
188 | */\r | |
189 | private JScrollPane getJScrollPaneHelpText() {\r | |
190 | if (jScrollPaneHelpText == null) {\r | |
191 | jScrollPaneHelpText = new JScrollPane();\r | |
192 | jScrollPaneHelpText.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);\r | |
193 | jScrollPaneHelpText.setSize(new java.awt.Dimension(320, 40));\r | |
194 | jScrollPaneHelpText.setPreferredSize(new java.awt.Dimension(320, 40));\r | |
3f62225f | 195 | jScrollPaneHelpText.setLocation(new java.awt.Point(168, 62));\r |
a929458e | 196 | jScrollPaneHelpText.setViewportView(getJTextAreaHelpText());\r |
197 | }\r | |
198 | return jScrollPaneHelpText;\r | |
06a19cee | 199 | }\r |
a929458e | 200 | \r |
201 | /**\r | |
202 | * This method initializes jButtonOk\r | |
203 | * \r | |
204 | * @return javax.swing.JButton\r | |
205 | * \r | |
206 | */\r | |
207 | private JButton getJButtonOk() {\r | |
208 | if (jButtonOk == null) {\r | |
209 | jButtonOk = new JButton();\r | |
3f62225f | 210 | jButtonOk.setBounds(new java.awt.Rectangle(290, 162, 90, 20));\r |
a929458e | 211 | jButtonOk.setText("Ok");\r |
212 | jButtonOk.addActionListener(this);\r | |
213 | }\r | |
214 | return jButtonOk;\r | |
06a19cee | 215 | }\r |
a929458e | 216 | \r |
217 | /**\r | |
218 | * This method initializes jButtonCancel\r | |
219 | * \r | |
220 | * @return javax.swing.JButton\r | |
221 | * \r | |
222 | */\r | |
223 | private JButton getJButtonCancel() {\r | |
224 | if (jButtonCancel == null) {\r | |
225 | jButtonCancel = new JButton();\r | |
3f62225f | 226 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 162, 90, 20));\r |
a929458e | 227 | jButtonCancel.setText("Cancel");\r |
228 | jButtonCancel.addActionListener(this);\r | |
229 | }\r | |
230 | return jButtonCancel;\r | |
06a19cee | 231 | }\r |
a929458e | 232 | \r |
233 | public static void main(String[] args) {\r | |
234 | \r | |
06a19cee | 235 | }\r |
a929458e | 236 | \r |
237 | /**\r | |
238 | * This method initializes this\r | |
239 | * \r | |
240 | */\r | |
241 | private void init() {\r | |
3f62225f | 242 | this.setSize(505, 235);\r |
a929458e | 243 | this.setContentPane(getJScrollPane());\r |
244 | this.setTitle("System Tables");\r | |
245 | initFrame();\r | |
246 | this.setViewMode(false);\r | |
247 | this.centerWindow();\r | |
06a19cee | 248 | }\r |
a929458e | 249 | \r |
250 | /**\r | |
251 | * This method initializes this Fill values to all fields if these values are\r | |
252 | * not empty\r | |
253 | * \r | |
254 | * @param inSystemTablesId\r | |
255 | * \r | |
256 | */\r | |
e08433ef | 257 | private void init(SystemTablesIdentification inSystemTablesId, ModuleIdentification mid) {\r |
a929458e | 258 | init();\r |
259 | this.id = inSystemTablesId;\r | |
d48c170d | 260 | \r |
e08433ef | 261 | //\r |
262 | // Init arch with module's arch\r | |
263 | //\r | |
264 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r | |
d48c170d | 265 | \r |
266 | //\r | |
267 | // Get defined guids from dependent packages\r | |
268 | //\r | |
269 | Vector<PackageIdentification> vpid = wt.getPackageDependenciesOfModule(mid);\r | |
270 | if (vpid.size() <= 0) {\r | |
271 | Log\r | |
272 | .wrn("Init Guid",\r | |
273 | "This module hasn't defined any package dependency, so there is no guid value can be added for system table");\r | |
274 | }\r | |
275 | //\r | |
276 | // Init guids drop down list\r | |
277 | //\r | |
278 | Tools\r | |
279 | .generateComboBoxByVector(jComboBoxGuidC_Name,\r | |
280 | wt.getAllGuidDeclarationsFromPackages(vpid, EnumerationData.GUID_TYPE_EFI_SYSTEM_CONFIGURATION_TABLE));\r | |
281 | \r | |
282 | \r | |
a929458e | 283 | if (this.id != null) {\r |
284 | this.jComboBoxGuidC_Name.setSelectedItem(id.getName());\r | |
285 | this.jComboBoxUsage.setSelectedItem(id.getUsage());\r | |
286 | this.jTextAreaHelpText.setText(id.getHelp());\r | |
287 | this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());\r | |
288 | this.jArchCheckBox.setSelectedItems(id.getSupArchList());\r | |
289 | }\r | |
06a19cee | 290 | }\r |
a929458e | 291 | \r |
292 | /**\r | |
293 | * This is the override edit constructor\r | |
294 | * \r | |
295 | * @param inBootModesIdentification\r | |
296 | * @param iFrame\r | |
297 | * \r | |
298 | */\r | |
d48c170d | 299 | public SystemTablesDlg(SystemTablesIdentification inSystemTablesIdentification, IFrame iFrame,\r |
300 | ModuleIdentification mid) {\r | |
a929458e | 301 | super(iFrame, true);\r |
e08433ef | 302 | init(inSystemTablesIdentification, mid);\r |
06a19cee | 303 | }\r |
a929458e | 304 | \r |
305 | /**\r | |
306 | * Disable all components when the mode is view\r | |
307 | * \r | |
308 | * @param isView\r | |
309 | * true - The view mode; false - The non-view mode\r | |
310 | * \r | |
311 | */\r | |
312 | public void setViewMode(boolean isView) {\r | |
313 | if (isView) {\r | |
314 | this.jComboBoxUsage.setEnabled(!isView);\r | |
315 | }\r | |
06a19cee | 316 | }\r |
a929458e | 317 | \r |
318 | /**\r | |
319 | * This method initializes jContentPane\r | |
320 | * \r | |
321 | * @return javax.swing.JPanel jContentPane\r | |
322 | * \r | |
323 | */\r | |
324 | private JPanel getJContentPane() {\r | |
325 | if (jContentPane == null) {\r | |
326 | jStarLabel1 = new StarLabel();\r | |
3f62225f | 327 | jStarLabel1.setLocation(new java.awt.Point(2, 12));\r |
a929458e | 328 | jLabelEntry = new JLabel();\r |
329 | jLabelEntry.setText("Table's GUID C Name");\r | |
3f62225f | 330 | jLabelEntry.setBounds(new java.awt.Rectangle(12, 12, 155, 20));\r |
a929458e | 331 | jStarLabel2 = new StarLabel();\r |
3f62225f | 332 | jStarLabel2.setLocation(new java.awt.Point(2, 37));\r |
a929458e | 333 | jLabelUsage = new JLabel();\r |
334 | jLabelUsage.setText("Usage");\r | |
3f62225f | 335 | jLabelUsage.setBounds(new java.awt.Rectangle(12, 37, 155, 20));\r |
a929458e | 336 | jLabelHelpText = new JLabel();\r |
3f62225f | 337 | jLabelHelpText.setBounds(new java.awt.Rectangle(12, 62, 155, 20));\r |
a929458e | 338 | jLabelHelpText.setText("Help Text");\r |
339 | jLabelFeatureFlag = new JLabel();\r | |
21b42c66 | 340 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 132, 155, 20));\r |
a929458e | 341 | jLabelFeatureFlag.setText("Feature Flag Expression");\r |
21b42c66 | 342 | jLabelFeatureFlag.setEnabled(false);\r |
a929458e | 343 | jLabelArch = new JLabel();\r |
21b42c66 | 344 | jLabelArch.setBounds(new java.awt.Rectangle(12, 107, 155, 20));\r |
a929458e | 345 | jLabelArch.setText("Supported Architectures");\r |
346 | jArchCheckBox = new ArchCheckBox();\r | |
21b42c66 | 347 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 107, 320, 20));\r |
a929458e | 348 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));\r |
349 | \r | |
350 | jContentPane = new JPanel();\r | |
351 | jContentPane.setLayout(null);\r | |
3f62225f | 352 | jContentPane.setPreferredSize(new java.awt.Dimension(480, 180));\r |
a929458e | 353 | \r |
354 | jContentPane.add(jLabelEntry, null);\r | |
355 | jContentPane.add(jLabelFeatureFlag, null);\r | |
356 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
357 | jContentPane.add(getJComboBoxGuidC_Name(), null);\r | |
358 | jContentPane.add(jLabelArch, null);\r | |
359 | jContentPane.add(jLabelUsage, null);\r | |
360 | jContentPane.add(getJComboBoxUsage(), null);\r | |
361 | \r | |
362 | jContentPane.add(jStarLabel1, null);\r | |
363 | jContentPane.add(jStarLabel2, null);\r | |
364 | \r | |
365 | jContentPane.add(jLabelHelpText, null);\r | |
366 | jContentPane.add(getJScrollPaneHelpText(), null);\r | |
367 | jContentPane.add(jArchCheckBox, null);\r | |
368 | jContentPane.add(getJButtonOk(), null);\r | |
369 | jContentPane.add(getJButtonCancel(), null);\r | |
370 | }\r | |
371 | return jContentPane;\r | |
06a19cee | 372 | }\r |
373 | \r | |
a929458e | 374 | /**\r |
375 | * This method initializes Usage type\r | |
376 | * \r | |
377 | */\r | |
378 | private void initFrame() {\r | |
379 | Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVSystemTableUsage());\r | |
06a19cee | 380 | }\r |
381 | \r | |
a929458e | 382 | /*\r |
383 | * (non-Javadoc)\r | |
384 | * \r | |
385 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
386 | * \r | |
387 | * Override actionPerformed to listen all actions\r | |
388 | * \r | |
389 | */\r | |
390 | public void actionPerformed(ActionEvent arg0) {\r | |
391 | if (arg0.getSource() == jButtonOk) {\r | |
392 | if (checkAdd()) {\r | |
393 | getCurrentSystemTables();\r | |
394 | this.returnType = DataType.RETURN_TYPE_OK;\r | |
395 | this.setVisible(false);\r | |
396 | }\r | |
397 | }\r | |
398 | \r | |
399 | if (arg0.getSource() == jButtonCancel) {\r | |
400 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r | |
401 | this.setVisible(false);\r | |
402 | }\r | |
06a19cee | 403 | }\r |
404 | \r | |
a929458e | 405 | /**\r |
406 | * Data validation for all fields\r | |
407 | * \r | |
408 | * @retval true - All datas are valid\r | |
409 | * @retval false - At least one data is invalid\r | |
410 | * \r | |
411 | */\r | |
412 | public boolean checkAdd() {\r | |
413 | //\r | |
414 | // Check if all fields have correct data types\r | |
415 | //\r | |
d48c170d | 416 | \r |
417 | //\r | |
418 | // Check Name\r | |
419 | //\r | |
420 | if (this.jComboBoxGuidC_Name.getSelectedItem() == null) {\r | |
421 | Log.wrn("Update Guids", "Please select one System Table Name");\r | |
422 | return false;\r | |
423 | }\r | |
a929458e | 424 | \r |
425 | //\r | |
426 | // Check FeatureFlag\r | |
427 | //\r | |
428 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
429 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
430 | Log.wrn("Update System Tables", "Incorrect data type for Feature Flag");\r | |
431 | return false;\r | |
432 | }\r | |
433 | }\r | |
434 | \r | |
435 | return true;\r | |
436 | }\r | |
06a19cee | 437 | \r |
a929458e | 438 | private SystemTablesIdentification getCurrentSystemTables() {\r |
439 | String arg0 = this.jComboBoxGuidC_Name.getSelectedItem().toString();\r | |
440 | String arg1 = this.jComboBoxUsage.getSelectedItem().toString();\r | |
06a19cee | 441 | \r |
a929458e | 442 | String arg2 = this.jTextFieldFeatureFlag.getText();\r |
443 | Vector<String> arg3 = this.jArchCheckBox.getSelectedItemsVector();\r | |
444 | String arg4 = this.jTextAreaHelpText.getText();\r | |
06a19cee | 445 | \r |
a929458e | 446 | id = new SystemTablesIdentification(arg0, arg1, arg2, arg3, arg4);\r |
447 | return id;\r | |
448 | }\r | |
06a19cee | 449 | \r |
a929458e | 450 | public SystemTablesIdentification getId() {\r |
451 | return id;\r | |
452 | }\r | |
5b38b75b | 453 | \r |
a929458e | 454 | public void setId(SystemTablesIdentification id) {\r |
455 | this.id = id;\r | |
456 | }\r | |
06a19cee | 457 | }\r |