]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/dialog/ExternsDlg.java
1. Fix EDKT273 "Externs are not being grouped together in MSA Files"
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / dialog / ExternsDlg.java
1 /** @file
2
3 The file is used to create, update Externs section of the MSA file
4
5 Copyright (c) 2006, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15 package org.tianocore.frameworkwizard.module.ui.dialog;
16
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ItemEvent;
19 import java.awt.event.ItemListener;
20 import java.util.Vector;
21
22 import javax.swing.JButton;
23 import javax.swing.JComboBox;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JScrollPane;
27 import javax.swing.JTextField;
28
29 import org.tianocore.frameworkwizard.common.DataType;
30 import org.tianocore.frameworkwizard.common.DataValidation;
31 import org.tianocore.frameworkwizard.common.EnumerationData;
32 import org.tianocore.frameworkwizard.common.Log;
33 import org.tianocore.frameworkwizard.common.Tools;
34 import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;
35 import org.tianocore.frameworkwizard.common.ui.IDialog;
36 import org.tianocore.frameworkwizard.common.ui.IFrame;
37 import org.tianocore.frameworkwizard.common.ui.StarLabel;
38 import org.tianocore.frameworkwizard.module.Identifications.Externs.ExternsIdentification;
39
40 /**
41 * The class is used to create, update Externs section of the MSA file
42 *
43 * It extends IDialog
44 *
45 */
46 public class ExternsDlg extends IDialog implements ItemListener {
47
48 ///
49 /// Define class Serial Version UID
50 ///
51 private static final long serialVersionUID = -7382008402932047191L;
52
53 //
54 //Define class members
55 //
56 private JPanel jContentPane = null;
57
58 private JLabel jLabelName = null;
59
60 private JComboBox jComboBoxType = null;
61
62 private JScrollPane jScrollPane = null;
63
64 private JLabel jLabelSpecification = null;
65
66 private JTextField jTextFieldSpecification = null;
67
68 private JLabel jLabelFeatureFlag = null;
69
70 private JLabel jLabelArch = null;
71
72 private JTextField jTextFieldFeatureFlag = null;
73
74 private ArchCheckBox jArchCheckBox = null;
75
76 private JButton jButtonOk = null;
77
78 private JButton jButtonCancel = null;
79
80 private StarLabel jStarLabel1 = null;
81
82 private JPanel jPanelSpecification = null;
83
84 private JPanel jPanelImage = null;
85
86 private JPanel jPanelDriver = null;
87
88 private JPanel jPanelLibrary = null;
89
90 private JPanel jPanelCallBack = null;
91
92 private JLabel jLabelModuleEntryPoint = null;
93
94 private JTextField jTextFieldModuleEntryPoint = null;
95
96 private JLabel jLabelModuleUnloadImage = null;
97
98 private JTextField jTextFieldModuleUnloadImage = null;
99
100 private JLabel jLabelDriverBinding = null;
101
102 private JTextField jTextFieldDriverBinding = null;
103
104 private JLabel jLabelComponentName = null;
105
106 private JTextField jTextFieldComponentName = null;
107
108 private JLabel jLabelDriverConfig = null;
109
110 private JTextField jTextFieldDriverConfig = null;
111
112 private JLabel jLabelDriverDiagnostic = null;
113
114 private JTextField jTextFieldDriverDiagnostic = null;
115
116 private JLabel jLabelConstructor = null;
117
118 private JTextField jTextFieldConstructor = null;
119
120 private JLabel jLabelDestructor = null;
121
122 private JTextField jTextFieldDestructor = null;
123
124 private JLabel jLabelVirtualAddressMap = null;
125
126 private JTextField jTextFieldVirtualAddressMap = null;
127
128 private JLabel jLabelExitBootServices = null;
129
130 private JTextField jTextFieldExitBootServices = null;
131
132 //
133 // Not used by UI
134 //
135 private ExternsIdentification id = null;
136
137 private EnumerationData ed = new EnumerationData();
138
139 /**
140 This method initializes jComboBoxType
141
142 @return javax.swing.JComboBox jComboBoxType
143
144 **/
145 private JComboBox getJComboBoxType() {
146 if (jComboBoxType == null) {
147 jComboBoxType = new JComboBox();
148 jComboBoxType.setBounds(new java.awt.Rectangle(168, 12, 320, 20));
149 jComboBoxType.setPreferredSize(new java.awt.Dimension(320, 20));
150 jComboBoxType.addItemListener(this);
151 }
152 return jComboBoxType;
153 }
154
155 /**
156 This method initializes jScrollPane
157
158 @return javax.swing.JScrollPane
159 */
160 private JScrollPane getJScrollPane() {
161 if (jScrollPane == null) {
162 jScrollPane = new JScrollPane();
163 jScrollPane.setViewportView(getJContentPane());
164 }
165 return jScrollPane;
166 }
167
168 /**
169 This method initializes jTextFieldC_Name
170
171 @return javax.swing.JTextField
172
173 **/
174 private JTextField getJTextFieldSpecification() {
175 if (jTextFieldSpecification == null) {
176 jTextFieldSpecification = new JTextField();
177 jTextFieldSpecification.setPreferredSize(new java.awt.Dimension(320, 20));
178 jTextFieldSpecification.setBounds(new java.awt.Rectangle(168, 0, 320, 20));
179 }
180 return jTextFieldSpecification;
181 }
182
183 /**
184 This method initializes jTextFieldFeatureFlag
185
186 @return javax.swing.JTextField
187
188 **/
189 private JTextField getJTextFieldFeatureFlag() {
190 if (jTextFieldFeatureFlag == null) {
191 jTextFieldFeatureFlag = new JTextField();
192 jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(168, 87, 320, 20));
193 jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
194 jTextFieldFeatureFlag.setEnabled(false);
195 }
196 return jTextFieldFeatureFlag;
197 }
198
199 /**
200 This method initializes jButtonOk
201
202 @return javax.swing.JButton
203
204 **/
205 private JButton getJButtonOk() {
206 if (jButtonOk == null) {
207 jButtonOk = new JButton();
208 jButtonOk.setBounds(new java.awt.Rectangle(300, 187, 90, 20));
209 jButtonOk.setText("Ok");
210 jButtonOk.addActionListener(this);
211 }
212 return jButtonOk;
213 }
214
215 /**
216 This method initializes jButtonCancel
217
218 @return javax.swing.JButton
219
220 **/
221 private JButton getJButtonCancel() {
222 if (jButtonCancel == null) {
223 jButtonCancel = new JButton();
224 jButtonCancel.setBounds(new java.awt.Rectangle(400, 187, 90, 20));
225 jButtonCancel.setText("Cancel");
226 jButtonCancel.addActionListener(this);
227 }
228 return jButtonCancel;
229 }
230
231 /**
232 * This method initializes jPanelSpecification
233 *
234 * @return javax.swing.JPanel
235 */
236 private JPanel getJPanelSpecification() {
237 if (jPanelSpecification == null) {
238 jPanelSpecification = new JPanel();
239 jPanelSpecification.setBounds(new java.awt.Rectangle(0, 37, 505, 20));
240 jPanelSpecification.setLayout(null);
241
242 jLabelSpecification = new JLabel();
243 jLabelSpecification.setBounds(new java.awt.Rectangle(12, 0, 140, 20));
244 jLabelSpecification.setText("Specification Name");
245
246 jPanelSpecification.add(jLabelSpecification, null);
247 jPanelSpecification.add(getJTextFieldSpecification(), null);
248 }
249 return jPanelSpecification;
250 }
251
252 /**
253 * This method initializes jPanelImage
254 *
255 * @return javax.swing.JPanel
256 */
257 private JPanel getJPanelImage() {
258 if (jPanelImage == null) {
259 jLabelModuleUnloadImage = new JLabel();
260 jLabelModuleUnloadImage.setBounds(new java.awt.Rectangle(12, 25, 140, 20));
261 jLabelModuleUnloadImage.setText("Module Unload Image");
262 jLabelModuleEntryPoint = new JLabel();
263 jLabelModuleEntryPoint.setBounds(new java.awt.Rectangle(12, 0, 140, 20));
264 jLabelModuleEntryPoint.setText("Module Entry Point");
265 jPanelImage = new JPanel();
266 jPanelImage.setBounds(new java.awt.Rectangle(0, 37, 505, 45));
267 jPanelImage.setLayout(null);
268 jPanelImage.add(jLabelModuleEntryPoint, null);
269 jPanelImage.add(getJTextFieldModuleEntryPoint(), null);
270 jPanelImage.add(jLabelModuleUnloadImage, null);
271 jPanelImage.add(getJTextFieldModuleUnloadImage(), null);
272 }
273 return jPanelImage;
274 }
275
276 /**
277 * This method initializes jPanelDriver
278 *
279 * @return javax.swing.JPanel
280 */
281 private JPanel getJPanelDriver() {
282 if (jPanelDriver == null) {
283 jStarLabel1 = new StarLabel();
284 jStarLabel1.setLocation(new java.awt.Point(0, 0));
285 jLabelDriverDiagnostic = new JLabel();
286 jLabelDriverDiagnostic.setBounds(new java.awt.Rectangle(12, 75, 140, 20));
287 jLabelDriverDiagnostic.setText("Driver Diagnostic");
288 jLabelDriverConfig = new JLabel();
289 jLabelDriverConfig.setBounds(new java.awt.Rectangle(12, 50, 140, 20));
290 jLabelDriverConfig.setText("Driver Config");
291 jLabelComponentName = new JLabel();
292 jLabelComponentName.setBounds(new java.awt.Rectangle(12, 25, 140, 20));
293 jLabelComponentName.setText("Component Name");
294 jLabelDriverBinding = new JLabel();
295 jLabelDriverBinding.setBounds(new java.awt.Rectangle(12, 0, 140, 20));
296 jLabelDriverBinding.setText("Driver Binding");
297 jPanelDriver = new JPanel();
298 jPanelDriver.setBounds(new java.awt.Rectangle(0, 37, 505, 95));
299 jPanelDriver.setLayout(null);
300 jPanelDriver.add(jStarLabel1, null);
301 jPanelDriver.add(jLabelDriverBinding, null);
302 jPanelDriver.add(getJTextFieldDriverBinding(), null);
303 jPanelDriver.add(jLabelComponentName, null);
304 jPanelDriver.add(getJTextFieldComponentName(), null);
305 jPanelDriver.add(jLabelDriverConfig, null);
306 jPanelDriver.add(getJTextFieldDriverConfig(), null);
307 jPanelDriver.add(jLabelDriverDiagnostic, null);
308 jPanelDriver.add(getJTextFieldDriverDiagnostic(), null);
309 }
310 return jPanelDriver;
311 }
312
313 /**
314 * This method initializes jPanelLibrary
315 *
316 * @return javax.swing.JPanel
317 */
318 private JPanel getJPanelLibrary() {
319 if (jPanelLibrary == null) {
320 jLabelDestructor = new JLabel();
321 jLabelDestructor.setBounds(new java.awt.Rectangle(12, 25, 140, 20));
322 jLabelDestructor.setText("Destructor");
323 jLabelConstructor = new JLabel();
324 jLabelConstructor.setBounds(new java.awt.Rectangle(12, 0, 140, 20));
325 jLabelConstructor.setText("Constructor");
326 jPanelLibrary = new JPanel();
327 jPanelLibrary.setBounds(new java.awt.Rectangle(0, 37, 505, 45));
328 jPanelLibrary.setLayout(null);
329 jPanelLibrary.add(jLabelConstructor, null);
330 jPanelLibrary.add(getJTextFieldConstructor(), null);
331 jPanelLibrary.add(jLabelDestructor, null);
332 jPanelLibrary.add(getJTextFieldDestructor(), null);
333 }
334 return jPanelLibrary;
335 }
336
337 /**
338 * This method initializes jPanelCallBack
339 *
340 * @return javax.swing.JPanel
341 */
342 private JPanel getJPanelCallBack() {
343 if (jPanelCallBack == null) {
344 jLabelExitBootServices = new JLabel();
345 jLabelExitBootServices.setBounds(new java.awt.Rectangle(12, 25, 140, 20));
346 jLabelExitBootServices.setText("Exit Boot Services");
347 jLabelVirtualAddressMap = new JLabel();
348 jLabelVirtualAddressMap.setBounds(new java.awt.Rectangle(12, 0, 140, 20));
349 jLabelVirtualAddressMap.setText("Virtual Address Map");
350 jPanelCallBack = new JPanel();
351 jPanelCallBack.setBounds(new java.awt.Rectangle(0, 37, 505, 45));
352 jPanelCallBack.setLayout(null);
353 jPanelCallBack.add(jLabelVirtualAddressMap, null);
354 jPanelCallBack.add(getJTextFieldVirtualAddressMap(), null);
355 jPanelCallBack.add(jLabelExitBootServices, null);
356 jPanelCallBack.add(getJTextFieldExitBootServices(), null);
357 }
358 return jPanelCallBack;
359 }
360
361 /**
362 * This method initializes jTextFieldModuleEntryPoint
363 *
364 * @return javax.swing.JTextField
365 */
366 private JTextField getJTextFieldModuleEntryPoint() {
367 if (jTextFieldModuleEntryPoint == null) {
368 jTextFieldModuleEntryPoint = new JTextField();
369 jTextFieldModuleEntryPoint.setBounds(new java.awt.Rectangle(168, 0, 320, 20));
370 }
371 return jTextFieldModuleEntryPoint;
372 }
373
374 /**
375 * This method initializes jTextFieldModuleUnloadImage
376 *
377 * @return javax.swing.JTextField
378 */
379 private JTextField getJTextFieldModuleUnloadImage() {
380 if (jTextFieldModuleUnloadImage == null) {
381 jTextFieldModuleUnloadImage = new JTextField();
382 jTextFieldModuleUnloadImage.setBounds(new java.awt.Rectangle(168, 25, 320, 20));
383 }
384 return jTextFieldModuleUnloadImage;
385 }
386
387 /**
388 * This method initializes jTextFieldDriverBinding
389 *
390 * @return javax.swing.JTextField
391 */
392 private JTextField getJTextFieldDriverBinding() {
393 if (jTextFieldDriverBinding == null) {
394 jTextFieldDriverBinding = new JTextField();
395 jTextFieldDriverBinding.setBounds(new java.awt.Rectangle(168, 0, 320, 20));
396 }
397 return jTextFieldDriverBinding;
398 }
399
400 /**
401 * This method initializes jTextFieldComponentName
402 *
403 * @return javax.swing.JTextField
404 */
405 private JTextField getJTextFieldComponentName() {
406 if (jTextFieldComponentName == null) {
407 jTextFieldComponentName = new JTextField();
408 jTextFieldComponentName.setBounds(new java.awt.Rectangle(168, 25, 320, 20));
409 }
410 return jTextFieldComponentName;
411 }
412
413 /**
414 * This method initializes jTextFieldDriverConfig
415 *
416 * @return javax.swing.JTextField
417 */
418 private JTextField getJTextFieldDriverConfig() {
419 if (jTextFieldDriverConfig == null) {
420 jTextFieldDriverConfig = new JTextField();
421 jTextFieldDriverConfig.setBounds(new java.awt.Rectangle(168, 50, 320, 20));
422 }
423 return jTextFieldDriverConfig;
424 }
425
426 /**
427 * This method initializes jTextFieldDriverDiagnostic
428 *
429 * @return javax.swing.JTextField
430 */
431 private JTextField getJTextFieldDriverDiagnostic() {
432 if (jTextFieldDriverDiagnostic == null) {
433 jTextFieldDriverDiagnostic = new JTextField();
434 jTextFieldDriverDiagnostic.setBounds(new java.awt.Rectangle(168, 75, 320, 20));
435 }
436 return jTextFieldDriverDiagnostic;
437 }
438
439 /**
440 * This method initializes jTextFieldConstructor
441 *
442 * @return javax.swing.JTextField
443 */
444 private JTextField getJTextFieldConstructor() {
445 if (jTextFieldConstructor == null) {
446 jTextFieldConstructor = new JTextField();
447 jTextFieldConstructor.setBounds(new java.awt.Rectangle(168, 0, 320, 20));
448 }
449 return jTextFieldConstructor;
450 }
451
452 /**
453 * This method initializes jTextFieldDestructor
454 *
455 * @return javax.swing.JTextField
456 */
457 private JTextField getJTextFieldDestructor() {
458 if (jTextFieldDestructor == null) {
459 jTextFieldDestructor = new JTextField();
460 jTextFieldDestructor.setBounds(new java.awt.Rectangle(168, 25, 320, 20));
461 }
462 return jTextFieldDestructor;
463 }
464
465 /**
466 * This method initializes jTextFieldVirtualAddressMap
467 *
468 * @return javax.swing.JTextField
469 */
470 private JTextField getJTextFieldVirtualAddressMap() {
471 if (jTextFieldVirtualAddressMap == null) {
472 jTextFieldVirtualAddressMap = new JTextField();
473 jTextFieldVirtualAddressMap.setBounds(new java.awt.Rectangle(168, 0, 320, 20));
474 }
475 return jTextFieldVirtualAddressMap;
476 }
477
478 /**
479 * This method initializes jTextFieldExitBootServices
480 *
481 * @return javax.swing.JTextField
482 */
483 private JTextField getJTextFieldExitBootServices() {
484 if (jTextFieldExitBootServices == null) {
485 jTextFieldExitBootServices = new JTextField();
486 jTextFieldExitBootServices.setBounds(new java.awt.Rectangle(168, 25, 320, 20));
487 }
488 return jTextFieldExitBootServices;
489 }
490
491 public static void main(String[] args) {
492
493 }
494
495 /**
496 This method initializes this
497
498 **/
499 private void init() {
500 this.setSize(515, 250);
501 this.setContentPane(getJScrollPane());
502 this.setTitle("Externs");
503 initFrame();
504 this.centerWindow();
505 }
506
507 /**
508 This method initializes this
509 Fill values to all fields if these values are not empty
510
511 @param inExternsId
512
513 **/
514 private void init(ExternsIdentification inExternsId) {
515 init();
516 this.id = inExternsId;
517
518 if (this.id != null) {
519 String type = id.getType();
520 //
521 // Filter the type to lock down the type
522 //
523 this.jComboBoxType.removeAllItems();
524 this.jComboBoxType.addItem(type);
525
526 this.jTextFieldFeatureFlag.setText(id.getFeatureFlag());
527 this.jArchCheckBox.setSelectedItems(id.getSupArchList());
528
529 //
530 // Init specification
531 //
532 if (type.equals(EnumerationData.EXTERNS_SPECIFICATION)) {
533 this.jTextFieldSpecification.setText(id.getName0());
534 }
535
536 //
537 // Init image
538 //
539 if (type.equals(EnumerationData.EXTERNS_IMAGE)) {
540 this.jTextFieldModuleEntryPoint.setText(id.getName0());
541 this.jTextFieldModuleUnloadImage.setText(id.getName1());
542 }
543
544 //
545 // Init library
546 //
547 if (type.equals(EnumerationData.EXTERNS_LIBRARY)) {
548 this.jTextFieldConstructor.setText(id.getName0());
549 this.jTextFieldDestructor.setText(id.getName1());
550 }
551
552 //
553 // Init driver
554 //
555 if (type.equals(EnumerationData.EXTERNS_DRIVER)) {
556 this.jTextFieldDriverBinding.setText(id.getName0());
557 this.jTextFieldComponentName.setText(id.getName1());
558 this.jTextFieldDriverConfig.setText(id.getName2());
559 this.jTextFieldDriverDiagnostic.setText(id.getName3());
560 }
561
562 //
563 // Init library
564 //
565 if (type.equals(EnumerationData.EXTERNS_CALL_BACK)) {
566 this.jTextFieldVirtualAddressMap.setText(id.getName0());
567 this.jTextFieldExitBootServices.setText(id.getName1());
568 }
569 }
570 }
571
572 /**
573 This is the override edit constructor
574
575 @param inBootModesIdentification
576 @param iFrame
577
578 **/
579 public ExternsDlg(ExternsIdentification inExternsIdentification, IFrame iFrame) {
580 super(iFrame, true);
581 init(inExternsIdentification);
582 }
583
584 /**
585 This method initializes jContentPane
586
587 @return javax.swing.JPanel jContentPane
588
589 **/
590 private JPanel getJContentPane() {
591 if (jContentPane == null) {
592 jArchCheckBox = new ArchCheckBox();
593 jArchCheckBox.setBounds(new java.awt.Rectangle(168, 62, 320, 20));
594 jArchCheckBox.setPreferredSize(new java.awt.Dimension(320, 20));
595
596 jLabelName = new JLabel();
597 jLabelName.setText("Choose Extern Type");
598 jLabelName.setBounds(new java.awt.Rectangle(12, 12, 155, 20));
599 jLabelArch = new JLabel();
600 jLabelArch.setBounds(new java.awt.Rectangle(12, 62, 155, 20));
601 jLabelArch.setText("Supported Architectures");
602 jLabelFeatureFlag = new JLabel();
603 jLabelFeatureFlag.setBounds(new java.awt.Rectangle(12, 87, 155, 20));
604 jLabelFeatureFlag.setText("Feature Flag Expression");
605 jLabelFeatureFlag.setEnabled(false);
606
607 jContentPane = new JPanel();
608 jContentPane.setLayout(null);
609 jContentPane.setPreferredSize(new java.awt.Dimension(505, 200));
610
611 jContentPane.add(jLabelName, null);
612 jContentPane.add(getJComboBoxType(), null);
613 jContentPane.add(jLabelFeatureFlag, null);
614 jContentPane.add(jLabelArch, null);
615 jContentPane.add(getJTextFieldFeatureFlag(), null);
616
617 jContentPane.add(jArchCheckBox, null);
618 jContentPane.add(getJButtonOk(), null);
619 jContentPane.add(getJButtonCancel(), null);
620
621 jContentPane.add(getJPanelSpecification(), null);
622 jContentPane.add(getJPanelImage(), null);
623 jContentPane.add(getJPanelDriver(), null);
624 jContentPane.add(getJPanelLibrary(), null);
625 jContentPane.add(getJPanelCallBack(), null);
626 }
627 return jContentPane;
628 }
629
630 /**
631 This method initializes Usage type and Externs type
632
633 **/
634 private void initFrame() {
635 Tools.generateComboBoxByVector(this.jComboBoxType, ed.getVExternTypes());
636 this.jPanelSpecification.setVisible(true);
637 this.jPanelImage.setVisible(false);
638 this.jPanelLibrary.setVisible(false);
639 this.jPanelDriver.setVisible(false);
640 this.jPanelCallBack.setVisible(false);
641 }
642
643 /* (non-Javadoc)
644 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
645 *
646 * Override actionPerformed to listen all actions
647 *
648 */
649 public void actionPerformed(ActionEvent arg0) {
650 if (arg0.getSource() == jButtonOk) {
651 if (checkAdd()) {
652 this.getCurrentExterns();
653 this.returnType = DataType.RETURN_TYPE_OK;
654 this.setVisible(false);
655 }
656 }
657
658 if (arg0.getSource() == jButtonCancel) {
659 this.returnType = DataType.RETURN_TYPE_CANCEL;
660 this.setVisible(false);
661 }
662 }
663
664 /**
665 Data validation for all fields
666
667 @retval true - All datas are valid
668 @retval false - At least one data is invalid
669
670 **/
671 public boolean checkAdd() {
672 //
673 // Check if all fields have correct data types
674 //
675
676 //
677 // Check specification
678 //
679 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
680 if (isEmpty(this.jTextFieldSpecification.getText())) {
681 Log.wrn("Update Externs", "Please type specification's name");
682 return false;
683 }
684 if (!DataValidation.isSentence(this.jTextFieldSpecification.getText())) {
685 Log.wrn("Update Externs", "Incorrect data type for Specification");
686 return false;
687 }
688
689 //
690 // No need to check feature flag, return true directly here.
691 //
692 return true;
693 }
694
695 //
696 // Check image
697 //
698 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_IMAGE)) {
699 if (isEmpty(this.jTextFieldModuleEntryPoint.getText())
700 && isEmpty(this.jTextFieldModuleUnloadImage.getText())) {
701 Log.wrn("Update Externs", "At least one of ModuleEntryPoint or ModuleUnloadImage should have a value");
702 return false;
703 }
704 if (!isEmpty(this.jTextFieldModuleEntryPoint.getText())) {
705 if (!DataValidation.isC_NameType(this.jTextFieldModuleEntryPoint.getText())) {
706 Log.wrn("Update Externs", "Incorrect data type for Module Entry Point");
707 return false;
708 }
709 }
710 if (!isEmpty(this.jTextFieldModuleUnloadImage.getText())) {
711 if (!DataValidation.isC_NameType(this.jTextFieldModuleUnloadImage.getText())) {
712 Log.wrn("Update Externs", "Incorrect data type for Module Unload Image");
713 return false;
714 }
715 }
716 }
717
718 //
719 // Check library
720 //
721 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_LIBRARY)) {
722 if (isEmpty(this.jTextFieldConstructor.getText()) && isEmpty(this.jTextFieldDestructor.getText())) {
723 Log.wrn("Update Externs", "At least one of Constructor or Destructor should have a value");
724 return false;
725 }
726 if (!isEmpty(this.jTextFieldConstructor.getText())) {
727 if (!DataValidation.isC_NameType(this.jTextFieldConstructor.getText())) {
728 Log.wrn("Update Externs", "Incorrect data type for Constructor");
729 return false;
730 }
731 }
732 if (!isEmpty(this.jTextFieldDestructor.getText())) {
733 if (!DataValidation.isC_NameType(this.jTextFieldDestructor.getText())) {
734 Log.wrn("Update Externs", "Incorrect data type for Destructor");
735 return false;
736 }
737 }
738 }
739
740 //
741 // Check driver
742 //
743 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_DRIVER)) {
744 if (isEmpty(this.jTextFieldDriverBinding.getText())) {
745 Log.wrn("Update Externs", "DriverBinding must have a value");
746 return false;
747 }
748 if (!isEmpty(this.jTextFieldDriverBinding.getText())) {
749 if (!DataValidation.isC_NameType(this.jTextFieldDriverBinding.getText())) {
750 Log.wrn("Update Externs", "Incorrect data type for DriverBinding");
751 return false;
752 }
753 }
754 if (!isEmpty(this.jTextFieldComponentName.getText())) {
755 if (!DataValidation.isC_NameType(this.jTextFieldComponentName.getText())) {
756 Log.wrn("Update Externs", "Incorrect data type for ComponentName");
757 return false;
758 }
759 }
760 if (!isEmpty(this.jTextFieldDriverConfig.getText())) {
761 if (!DataValidation.isC_NameType(this.jTextFieldDriverConfig.getText())) {
762 Log.wrn("Update Externs", "Incorrect data type for DriverConfig");
763 return false;
764 }
765 }
766 if (!isEmpty(this.jTextFieldDriverDiagnostic.getText())) {
767 if (!DataValidation.isC_NameType(this.jTextFieldDriverDiagnostic.getText())) {
768 Log.wrn("Update Externs", "Incorrect data type for DriverDiagnostic");
769 return false;
770 }
771 }
772 }
773
774 //
775 // Check call back
776 //
777 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_CALL_BACK)) {
778 if (isEmpty(this.jTextFieldVirtualAddressMap.getText())
779 && isEmpty(this.jTextFieldExitBootServices.getText())) {
780 Log.wrn("Update Externs", "At least one of VirtualAddressMap or ExitBootServices should have a value");
781 return false;
782 }
783 if (!isEmpty(this.jTextFieldVirtualAddressMap.getText())) {
784 if (!DataValidation.isC_NameType(this.jTextFieldVirtualAddressMap.getText())) {
785 Log.wrn("Update Externs", "Incorrect data type for Virtual Address Map");
786 return false;
787 }
788 }
789 if (!isEmpty(this.jTextFieldExitBootServices.getText())) {
790 if (!DataValidation.isC_NameType(this.jTextFieldExitBootServices.getText())) {
791 Log.wrn("Update Externs", "Incorrect data type for Exit Boot Services");
792 return false;
793 }
794 }
795 }
796
797 //
798 // Check FeatureFlag
799 //
800 if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
801 if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
802 Log.wrn("Update Externs", "Incorrect data type for Feature Flag");
803 return false;
804 }
805 }
806
807 return true;
808 }
809
810 private ExternsIdentification getCurrentExterns() {
811 String arg0 = "";
812 String arg1 = "";
813 String arg2 = "";
814 String arg3 = "";
815
816 String type = this.jComboBoxType.getSelectedItem().toString();
817 String featureFlag = this.jTextFieldFeatureFlag.getText();
818 Vector<String> arch = this.jArchCheckBox.getSelectedItemsVector();
819
820 if (type.equals(EnumerationData.EXTERNS_SPECIFICATION)) {
821 arg0 = this.jTextFieldSpecification.getText();
822 id = new ExternsIdentification(arg0, type);
823 }
824
825 if (type.equals(EnumerationData.EXTERNS_IMAGE)) {
826 arg0 = this.jTextFieldModuleEntryPoint.getText();
827 arg1 = this.jTextFieldModuleUnloadImage.getText();
828 id = new ExternsIdentification(arg0, arg1, type, featureFlag, arch);
829 }
830
831 if (type.equals(EnumerationData.EXTERNS_LIBRARY)) {
832 arg0 = this.jTextFieldConstructor.getText();
833 arg1 = this.jTextFieldDestructor.getText();
834 id = new ExternsIdentification(arg0, arg1, type, featureFlag, arch);
835 }
836
837 if (type.equals(EnumerationData.EXTERNS_DRIVER)) {
838 arg0 = this.jTextFieldDriverBinding.getText();
839 arg1 = this.jTextFieldComponentName.getText();
840 arg2 = this.jTextFieldDriverConfig.getText();
841 arg3 = this.jTextFieldDriverDiagnostic.getText();
842 id = new ExternsIdentification(arg0, arg1, arg2, arg3, type, featureFlag, arch);
843 }
844
845 if (type.equals(EnumerationData.EXTERNS_CALL_BACK)) {
846 arg0 = this.jTextFieldVirtualAddressMap.getText();
847 arg1 = this.jTextFieldExitBootServices.getText();
848 id = new ExternsIdentification(arg0, arg1, type, featureFlag, arch);
849 }
850
851 return id;
852 }
853
854 /* (non-Javadoc)
855 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
856 *
857 * Reflesh the frame when selected item changed
858 *
859 */
860 public void itemStateChanged(ItemEvent arg0) {
861 if (arg0.getSource() == jComboBoxType && arg0.getStateChange() == ItemEvent.SELECTED) {
862 if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
863 this.jPanelSpecification.setVisible(true);
864 this.jPanelImage.setVisible(false);
865 this.jPanelLibrary.setVisible(false);
866 this.jPanelDriver.setVisible(false);
867 this.jPanelCallBack.setVisible(false);
868 this.jLabelArch.setEnabled(false);
869 this.jArchCheckBox.setAllItemsEnabled(false);
870 this.jLabelArch.setLocation(12, 62);
871 this.jArchCheckBox.setLocation(168, 62);
872 this.jLabelFeatureFlag.setLocation(12, 87);
873 this.jTextFieldFeatureFlag.setLocation(168, 87);
874 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_IMAGE)) {
875 this.jPanelSpecification.setVisible(false);
876 this.jPanelImage.setVisible(true);
877 this.jPanelLibrary.setVisible(false);
878 this.jPanelDriver.setVisible(false);
879 this.jPanelCallBack.setVisible(false);
880 this.jLabelArch.setEnabled(true);
881 this.jArchCheckBox.setAllItemsEnabled(true);
882 this.jLabelArch.setLocation(12, 87);
883 this.jArchCheckBox.setLocation(168, 87);
884 this.jLabelFeatureFlag.setLocation(12, 112);
885 this.jTextFieldFeatureFlag.setLocation(168, 112);
886 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_LIBRARY)) {
887 this.jPanelSpecification.setVisible(false);
888 this.jPanelImage.setVisible(false);
889 this.jPanelLibrary.setVisible(true);
890 this.jPanelDriver.setVisible(false);
891 this.jPanelCallBack.setVisible(false);
892 this.jLabelArch.setEnabled(true);
893 this.jArchCheckBox.setAllItemsEnabled(true);
894 this.jLabelArch.setLocation(12, 87);
895 this.jArchCheckBox.setLocation(168, 87);
896 this.jLabelFeatureFlag.setLocation(12, 112);
897 this.jTextFieldFeatureFlag.setLocation(168, 112);
898 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_DRIVER)) {
899 this.jPanelSpecification.setVisible(false);
900 this.jPanelImage.setVisible(false);
901 this.jPanelLibrary.setVisible(false);
902 this.jPanelDriver.setVisible(true);
903 this.jPanelCallBack.setVisible(false);
904 this.jLabelArch.setEnabled(true);
905 this.jArchCheckBox.setAllItemsEnabled(true);
906 this.jLabelArch.setLocation(12, 137);
907 this.jArchCheckBox.setLocation(168, 137);
908 this.jLabelFeatureFlag.setLocation(12, 162);
909 this.jTextFieldFeatureFlag.setLocation(168, 162);
910 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_CALL_BACK)) {
911 this.jPanelSpecification.setVisible(false);
912 this.jPanelImage.setVisible(false);
913 this.jPanelLibrary.setVisible(false);
914 this.jPanelDriver.setVisible(false);
915 this.jPanelCallBack.setVisible(true);
916 this.jLabelArch.setEnabled(true);
917 this.jArchCheckBox.setAllItemsEnabled(true);
918 this.jLabelArch.setLocation(12, 87);
919 this.jArchCheckBox.setLocation(168, 87);
920 this.jLabelFeatureFlag.setLocation(12, 112);
921 this.jTextFieldFeatureFlag.setLocation(168, 112);
922 }
923 }
924 }
925
926 public ExternsIdentification getId() {
927 return id;
928 }
929
930 public void setId(ExternsIdentification id) {
931 this.id = id;
932 }
933 }