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