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