1. Fix EDKT321 A module's all top level elements' arch should be in range of the...
[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.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())) {
738 if (!DataValidation.isC_NameType(this.jTextFieldConstructor.getText())) {
739 Log.wrn("Update Externs", "Incorrect data type for Constructor");
740 return false;
741 }
742 }
743 if (!isEmpty(this.jTextFieldDestructor.getText())) {
744 if (!DataValidation.isC_NameType(this.jTextFieldDestructor.getText())) {
745 Log.wrn("Update Externs", "Incorrect data type for Destructor");
746 return false;
747 }
748 }
749 }
750
751 //
752 // Check driver
753 //
754 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_DRIVER)) {
755 if (isEmpty(this.jTextFieldDriverBinding.getText())) {
756 Log.wrn("Update Externs", "DriverBinding must have a value");
757 return false;
758 }
759 if (!isEmpty(this.jTextFieldDriverBinding.getText())) {
760 if (!DataValidation.isC_NameType(this.jTextFieldDriverBinding.getText())) {
761 Log.wrn("Update Externs", "Incorrect data type for DriverBinding");
762 return false;
763 }
764 }
765 if (!isEmpty(this.jTextFieldComponentName.getText())) {
766 if (!DataValidation.isC_NameType(this.jTextFieldComponentName.getText())) {
767 Log.wrn("Update Externs", "Incorrect data type for ComponentName");
768 return false;
769 }
770 }
771 if (!isEmpty(this.jTextFieldDriverConfig.getText())) {
772 if (!DataValidation.isC_NameType(this.jTextFieldDriverConfig.getText())) {
773 Log.wrn("Update Externs", "Incorrect data type for DriverConfig");
774 return false;
775 }
776 }
777 if (!isEmpty(this.jTextFieldDriverDiagnostic.getText())) {
778 if (!DataValidation.isC_NameType(this.jTextFieldDriverDiagnostic.getText())) {
779 Log.wrn("Update Externs", "Incorrect data type for DriverDiagnostic");
780 return false;
781 }
782 }
783 }
784
785 //
786 // Check call back
787 //
788 if (this.jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_CALL_BACK)) {
789 if (isEmpty(this.jTextFieldVirtualAddressMap.getText())
790 && isEmpty(this.jTextFieldExitBootServices.getText())) {
791 Log.wrn("Update Externs", "At least one of VirtualAddressMap or ExitBootServices should have a value");
792 return false;
793 }
794 if (!isEmpty(this.jTextFieldVirtualAddressMap.getText())) {
795 if (!DataValidation.isC_NameType(this.jTextFieldVirtualAddressMap.getText())) {
796 Log.wrn("Update Externs", "Incorrect data type for Virtual Address Map");
797 return false;
798 }
799 }
800 if (!isEmpty(this.jTextFieldExitBootServices.getText())) {
801 if (!DataValidation.isC_NameType(this.jTextFieldExitBootServices.getText())) {
802 Log.wrn("Update Externs", "Incorrect data type for Exit Boot Services");
803 return false;
804 }
805 }
806 }
807
808 //
809 // Check FeatureFlag
810 //
811 if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
812 if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
813 Log.wrn("Update Externs", "Incorrect data type for Feature Flag");
814 return false;
815 }
816 }
817
818 return true;
819 }
820
821 private ExternsIdentification getCurrentExterns() {
822 String arg0 = "";
823 String arg1 = "";
824 String arg2 = "";
825 String arg3 = "";
826
827 String type = this.jComboBoxType.getSelectedItem().toString();
828 String featureFlag = this.jTextFieldFeatureFlag.getText();
829 Vector<String> arch = this.jArchCheckBox.getSelectedItemsVector();
830
831 if (type.equals(EnumerationData.EXTERNS_SPECIFICATION)) {
832 arg0 = this.jTextFieldSpecification.getText();
833 id = new ExternsIdentification(arg0, type);
834 }
835
836 if (type.equals(EnumerationData.EXTERNS_IMAGE)) {
837 arg0 = this.jTextFieldModuleEntryPoint.getText();
838 arg1 = this.jTextFieldModuleUnloadImage.getText();
839 id = new ExternsIdentification(arg0, arg1, type, featureFlag, arch);
840 }
841
842 if (type.equals(EnumerationData.EXTERNS_LIBRARY)) {
843 arg0 = this.jTextFieldConstructor.getText();
844 arg1 = this.jTextFieldDestructor.getText();
845 id = new ExternsIdentification(arg0, arg1, type, featureFlag, arch);
846 }
847
848 if (type.equals(EnumerationData.EXTERNS_DRIVER)) {
849 arg0 = this.jTextFieldDriverBinding.getText();
850 arg1 = this.jTextFieldComponentName.getText();
851 arg2 = this.jTextFieldDriverConfig.getText();
852 arg3 = this.jTextFieldDriverDiagnostic.getText();
853 id = new ExternsIdentification(arg0, arg1, arg2, arg3, type, featureFlag, arch);
854 }
855
856 if (type.equals(EnumerationData.EXTERNS_CALL_BACK)) {
857 arg0 = this.jTextFieldVirtualAddressMap.getText();
858 arg1 = this.jTextFieldExitBootServices.getText();
859 id = new ExternsIdentification(arg0, arg1, type, featureFlag, arch);
860 }
861
862 return id;
863 }
864
865 /* (non-Javadoc)
866 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
867 *
868 * Reflesh the frame when selected item changed
869 *
870 */
871 public void itemStateChanged(ItemEvent arg0) {
872 if (arg0.getSource() == jComboBoxType && arg0.getStateChange() == ItemEvent.SELECTED) {
873 if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_SPECIFICATION)) {
874 this.jPanelSpecification.setVisible(true);
875 this.jPanelImage.setVisible(false);
876 this.jPanelLibrary.setVisible(false);
877 this.jPanelDriver.setVisible(false);
878 this.jPanelCallBack.setVisible(false);
879 this.jLabelArch.setEnabled(false);
880 this.jArchCheckBox.setAllItemsEnabled(false);
881 this.jLabelArch.setLocation(12, 62);
882 this.jArchCheckBox.setLocation(168, 62);
883 this.jLabelFeatureFlag.setLocation(12, 87);
884 this.jTextFieldFeatureFlag.setLocation(168, 87);
885 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_IMAGE)) {
886 this.jPanelSpecification.setVisible(false);
887 this.jPanelImage.setVisible(true);
888 this.jPanelLibrary.setVisible(false);
889 this.jPanelDriver.setVisible(false);
890 this.jPanelCallBack.setVisible(false);
891 this.jLabelArch.setEnabled(true);
892 this.jArchCheckBox.setEnabledItems(this.vArchList);
893 this.jLabelArch.setLocation(12, 87);
894 this.jArchCheckBox.setLocation(168, 87);
895 this.jLabelFeatureFlag.setLocation(12, 112);
896 this.jTextFieldFeatureFlag.setLocation(168, 112);
897 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_LIBRARY)) {
898 this.jPanelSpecification.setVisible(false);
899 this.jPanelImage.setVisible(false);
900 this.jPanelLibrary.setVisible(true);
901 this.jPanelDriver.setVisible(false);
902 this.jPanelCallBack.setVisible(false);
903 this.jLabelArch.setEnabled(true);
904 this.jArchCheckBox.setEnabledItems(this.vArchList);
905 this.jLabelArch.setLocation(12, 87);
906 this.jArchCheckBox.setLocation(168, 87);
907 this.jLabelFeatureFlag.setLocation(12, 112);
908 this.jTextFieldFeatureFlag.setLocation(168, 112);
909 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_DRIVER)) {
910 this.jPanelSpecification.setVisible(false);
911 this.jPanelImage.setVisible(false);
912 this.jPanelLibrary.setVisible(false);
913 this.jPanelDriver.setVisible(true);
914 this.jPanelCallBack.setVisible(false);
915 this.jLabelArch.setEnabled(true);
916 this.jArchCheckBox.setEnabledItems(this.vArchList);
917 this.jLabelArch.setLocation(12, 137);
918 this.jArchCheckBox.setLocation(168, 137);
919 this.jLabelFeatureFlag.setLocation(12, 162);
920 this.jTextFieldFeatureFlag.setLocation(168, 162);
921 } else if (jComboBoxType.getSelectedItem().toString().equals(EnumerationData.EXTERNS_CALL_BACK)) {
922 this.jPanelSpecification.setVisible(false);
923 this.jPanelImage.setVisible(false);
924 this.jPanelLibrary.setVisible(false);
925 this.jPanelDriver.setVisible(false);
926 this.jPanelCallBack.setVisible(true);
927 this.jLabelArch.setEnabled(true);
928 this.jArchCheckBox.setEnabledItems(this.vArchList);
929 this.jLabelArch.setLocation(12, 87);
930 this.jArchCheckBox.setLocation(168, 87);
931 this.jLabelFeatureFlag.setLocation(12, 112);
932 this.jTextFieldFeatureFlag.setLocation(168, 112);
933 }
934 }
935 }
936
937 public ExternsIdentification getId() {
938 return id;
939 }
940
941 public void setId(ExternsIdentification id) {
942 this.id = id;
943 }
944 }