]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleExterns.java
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@671 6f19259b...
[mirror_edk2.git] / Tools / Source / ModuleEditor / src / org / tianocore / packaging / module / ui / ModuleExterns.java
1 /** @file
2
3 The file is used to create, update DataHub of MSA/MBD 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.packaging.module.ui;
16
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ItemEvent;
19 import java.awt.event.ItemListener;
20
21 import javax.swing.JButton;
22 import javax.swing.JComboBox;
23 import javax.swing.JLabel;
24 import javax.swing.JPanel;
25 import javax.swing.JTextField;
26
27 import org.tianocore.ExternUsage;
28 import org.tianocore.ExternsDocument;
29 import org.tianocore.common.DataValidation;
30 import org.tianocore.common.Log;
31 import org.tianocore.packaging.common.ui.IComboBox;
32 import org.tianocore.packaging.common.ui.IInternalFrame;
33
34 /**
35 The class is used to create, update DataHub of MSA/MBD file
36 It extends IInternalFrame
37
38 @since ModuleEditor 1.0
39
40 **/
41 public class ModuleExterns extends IInternalFrame implements ItemListener {
42
43 ///
44 /// Define class Serial Version UID
45 ///
46 private static final long serialVersionUID = -7382008402932047191L;
47
48 //
49 //Define class members
50 //
51 private ExternsDocument.Externs externs = null;
52
53 private int location = -1;
54
55 private JPanel jContentPane = null;
56
57 private JLabel jLabelName = null;
58
59 private JLabel jLabelUsage = null;
60
61 private JComboBox jComboBoxUsage = null;
62
63 private JButton jButtonOk = null;
64
65 private JButton jButtonCancel = null;
66
67 private JLabel jLabelOverrideID = null;
68
69 private JTextField jTextFieldOverrideID = null;
70
71 private JPanel jPanelType1 = null;
72
73 private JLabel jLabelModuleEntryPoint = null;
74
75 private JLabel jLabelModuleUnloadImage = null;
76
77 private IComboBox iComboBoxModuleEntryPoint = null;
78
79 private IComboBox iComboBoxModuleUnloadImage = null;
80
81 private JPanel jPanelType2 = null;
82
83 private JLabel jLabelConstructor = null;
84
85 private JTextField jTextFieldConstructor = null;
86
87 private JLabel jLabelDestructor = null;
88
89 private JTextField jTextFieldDestructor = null;
90
91 private JComboBox jComboBoxType = null;
92
93 private JPanel jPanelType3 = null;
94
95 private JLabel jLabelDriverBinding = null;
96
97 private JLabel jLabelComponentName = null;
98
99 private IComboBox iComboBoxComponentName = null;
100
101 private IComboBox iComboBoxDriverBinding = null;
102
103 private JLabel jLabelDriverConfig = null;
104
105 private JLabel jLabelDriverDiag = null;
106
107 private IComboBox iComboBoxDriverDiag = null;
108
109 private IComboBox iComboBoxDriverConfig = null;
110
111 private JPanel jPanelType4 = null;
112
113 private JLabel jLabelSetVirtualAddressMapCallBack = null;
114
115 private IComboBox iComboBoxSetVirtualAddressMapCallBack = null;
116
117 private JLabel jLabelExitBootServicesCallBack = null;
118
119 private IComboBox iComboBoxExitBootServicesCallBack = null;
120
121 private JPanel jPanelType5 = null;
122
123 private JLabel jLabelUserDefined = null;
124
125 private IComboBox iComboBoxUserDefined = null;
126
127 /**
128 This method initializes jComboBoxUsage
129
130 @return javax.swing.JComboBox jComboBoxUsage
131
132 **/
133 private JComboBox getJComboBoxUsage() {
134 if (jComboBoxUsage == null) {
135 jComboBoxUsage = new JComboBox();
136 jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
137 }
138 return jComboBoxUsage;
139 }
140
141 /**
142 This method initializes jButtonOk
143
144 @return javax.swing.JButton jButtonOk
145
146 **/
147 private JButton getJButtonOk() {
148 if (jButtonOk == null) {
149 jButtonOk = new JButton();
150 jButtonOk.setText("OK");
151 jButtonOk.setLocation(new java.awt.Point(290, 215));
152 jButtonOk.setSize(new java.awt.Dimension(90, 20));
153 jButtonOk.addActionListener(this);
154 }
155 return jButtonOk;
156 }
157
158 /**
159 This method initializes jButtonCancel
160
161 @return javax.swing.JButton jButtonCancel
162
163 **/
164 private JButton getJButtonCancel() {
165 if (jButtonCancel == null) {
166 jButtonCancel = new JButton();
167 jButtonCancel.setText("Cancel");
168 jButtonCancel.setLocation(new java.awt.Point(390, 215));
169 jButtonCancel.setSize(new java.awt.Dimension(90, 20));
170 jButtonCancel.addActionListener(this);
171 }
172 return jButtonCancel;
173 }
174
175 /**
176 This method initializes jTextFieldOverrideID
177
178 @return javax.swing.JTextField jTextFieldOverrideID
179
180 **/
181 private JTextField getJTextFieldOverrideID() {
182 if (jTextFieldOverrideID == null) {
183 jTextFieldOverrideID = new JTextField();
184 jTextFieldOverrideID.setBounds(new java.awt.Rectangle(160, 60, 50, 20));
185 }
186 return jTextFieldOverrideID;
187 }
188
189 /**
190 This method initializes jPanelType1
191
192 @return javax.swing.JPanel jPanelType1
193
194 **/
195 private JPanel getJPanelType1() {
196 if (jPanelType1 == null) {
197 jLabelModuleUnloadImage = new JLabel();
198 jLabelModuleUnloadImage.setBounds(new java.awt.Rectangle(15, 30, 140, 20));
199 jLabelModuleUnloadImage.setText("Module Unload Image");
200 jLabelModuleEntryPoint = new JLabel();
201 jLabelModuleEntryPoint.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
202 jLabelModuleEntryPoint.setText("Module Entry Point");
203 jPanelType1 = new JPanel();
204 jPanelType1.setLayout(null);
205 jPanelType1.setBounds(new java.awt.Rectangle(0, 105, 490, 55));
206 jPanelType1.add(jLabelModuleEntryPoint, null);
207 jPanelType1.add(jLabelModuleUnloadImage, null);
208 jPanelType1.add(getIComboBoxModuleUnloadImage(), null);
209 jPanelType1.add(getIComboBoxModuleEntryPoint(), null);
210 }
211 return jPanelType1;
212 }
213
214 /**
215 This method initializes jComboBoxModuleEntryPoint
216
217 @return javax.swing.JComboBox iComboBoxModuleEntryPoint
218
219 **/
220 private IComboBox getIComboBoxModuleEntryPoint() {
221 if (iComboBoxModuleEntryPoint == null) {
222 iComboBoxModuleEntryPoint = new IComboBox();
223 iComboBoxModuleEntryPoint.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
224 }
225 return iComboBoxModuleEntryPoint;
226 }
227
228 /**
229 This method initializes jComboBoxModuleUnloadImage
230
231 @return javax.swing.JComboBox iComboBoxModuleUnloadImage
232
233 **/
234 private IComboBox getIComboBoxModuleUnloadImage() {
235 if (iComboBoxModuleUnloadImage == null) {
236 iComboBoxModuleUnloadImage = new IComboBox();
237 iComboBoxModuleUnloadImage.setBounds(new java.awt.Rectangle(160, 30, 320, 20));
238 }
239 return iComboBoxModuleUnloadImage;
240 }
241
242 /**
243 This method initializes jPanelType2
244
245 @return javax.swing.JPanel jPanelType2
246
247 **/
248 private JPanel getJPanelType2() {
249 if (jPanelType2 == null) {
250 jLabelDestructor = new JLabel();
251 jLabelDestructor.setBounds(new java.awt.Rectangle(15, 30, 140, 20));
252 jLabelDestructor.setText("Destructor");
253 jLabelConstructor = new JLabel();
254 jLabelConstructor.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
255 jLabelConstructor.setText("Constructor");
256 jPanelType2 = new JPanel();
257 jPanelType2.setLayout(null);
258 jPanelType2.setBounds(new java.awt.Rectangle(0, 105, 490, 55));
259 jPanelType2.add(jLabelConstructor, null);
260 jPanelType2.add(getJTextFieldConstructor(), null);
261 jPanelType2.add(jLabelDestructor, null);
262 jPanelType2.add(getJTextFieldDestructor(), null);
263 }
264 return jPanelType2;
265 }
266
267 /**
268 This method initializes jTextFieldConstructor
269
270 @return javax.swing.JTextField jTextFieldConstructor
271
272 **/
273 private JTextField getJTextFieldConstructor() {
274 if (jTextFieldConstructor == null) {
275 jTextFieldConstructor = new JTextField();
276 jTextFieldConstructor.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
277 }
278 return jTextFieldConstructor;
279 }
280
281 /**
282 This method initializes jTextFieldDestructor
283
284 @return javax.swing.JTextField jTextFieldDestructor
285
286 **/
287 private JTextField getJTextFieldDestructor() {
288 if (jTextFieldDestructor == null) {
289 jTextFieldDestructor = new JTextField();
290 jTextFieldDestructor.setBounds(new java.awt.Rectangle(160, 30, 320, 20));
291 }
292 return jTextFieldDestructor;
293 }
294
295 /**
296 This method initializes jComboBoxType
297
298 @return javax.swing.JComboBox jComboBoxType
299
300 **/
301 private JComboBox getJComboBoxType() {
302 if (jComboBoxType == null) {
303 jComboBoxType = new JComboBox();
304 jComboBoxType.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
305 jComboBoxType.addItemListener(this);
306 }
307 return jComboBoxType;
308 }
309
310 /**
311 This method initializes jPanelType3
312
313 @return javax.swing.JPanel jPanelType3
314
315 **/
316 private JPanel getJPanelType3() {
317 if (jPanelType3 == null) {
318 jLabelDriverDiag = new JLabel();
319 jLabelDriverDiag.setBounds(new java.awt.Rectangle(15, 80, 140, 20));
320 jLabelDriverDiag.setText("Driver Diag");
321 jLabelDriverConfig = new JLabel();
322 jLabelDriverConfig.setBounds(new java.awt.Rectangle(15, 55, 140, 20));
323 jLabelDriverConfig.setText("Driver Config");
324 jLabelComponentName = new JLabel();
325 jLabelComponentName.setBounds(new java.awt.Rectangle(15, 30, 140, 20));
326 jLabelComponentName.setText("Component Name");
327 jLabelDriverBinding = new JLabel();
328 jLabelDriverBinding.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
329 jLabelDriverBinding.setText("Driver Binding");
330 jPanelType3 = new JPanel();
331 jPanelType3.setLayout(null);
332 jPanelType3.setBounds(new java.awt.Rectangle(0, 105, 490, 105));
333 jPanelType3.add(jLabelDriverBinding, null);
334 jPanelType3.add(jLabelComponentName, null);
335 jPanelType3.add(getIComboBoxComponentName(), null);
336 jPanelType3.add(getIComboBoxDriverBinding(), null);
337 jPanelType3.add(jLabelDriverConfig, null);
338 jPanelType3.add(jLabelDriverDiag, null);
339 jPanelType3.add(getIComboBoxDriverDiag(), null);
340 jPanelType3.add(getIComboBoxDriverConfig(), null);
341 }
342 return jPanelType3;
343 }
344
345 /**
346 This method initializes jComboBoxComponentName
347
348 @return javax.swing.JComboBox iComboBoxComponentName
349
350 **/
351 private IComboBox getIComboBoxComponentName() {
352 if (iComboBoxComponentName == null) {
353 iComboBoxComponentName = new IComboBox();
354 iComboBoxComponentName.setBounds(new java.awt.Rectangle(160, 30, 320, 20));
355 }
356 return iComboBoxComponentName;
357 }
358
359 /**
360 This method initializes jComboBoxDriverBinding
361
362 @return javax.swing.JComboBox iComboBoxDriverBinding
363
364 **/
365 private IComboBox getIComboBoxDriverBinding() {
366 if (iComboBoxDriverBinding == null) {
367 iComboBoxDriverBinding = new IComboBox();
368 iComboBoxDriverBinding.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
369 }
370 return iComboBoxDriverBinding;
371 }
372
373 /**
374 This method initializes jComboBoxDriverDiag
375
376 @return javax.swing.JComboBox iComboBoxDriverDiag
377
378 **/
379 private IComboBox getIComboBoxDriverDiag() {
380 if (iComboBoxDriverDiag == null) {
381 iComboBoxDriverDiag = new IComboBox();
382 iComboBoxDriverDiag.setBounds(new java.awt.Rectangle(160, 80, 320, 20));
383 }
384 return iComboBoxDriverDiag;
385 }
386
387 /**
388 This method initializes jComboBoxDriverConfig
389
390 @return javax.swing.JComboBox iComboBoxDriverConfig
391
392 */
393 private IComboBox getIComboBoxDriverConfig() {
394 if (iComboBoxDriverConfig == null) {
395 iComboBoxDriverConfig = new IComboBox();
396 iComboBoxDriverConfig.setBounds(new java.awt.Rectangle(160, 55, 320, 20));
397 }
398 return iComboBoxDriverConfig;
399 }
400
401 /**
402 This method initializes jPanelType4
403
404 @return javax.swing.JPanel jPanelType4
405
406 **/
407 private JPanel getJPanelType4() {
408 if (jPanelType4 == null) {
409 jLabelExitBootServicesCallBack = new JLabel();
410 jLabelExitBootServicesCallBack.setBounds(new java.awt.Rectangle(15, 30, 200, 20));
411 jLabelExitBootServicesCallBack.setText("Exit Boot Services Call Back");
412 jLabelSetVirtualAddressMapCallBack = new JLabel();
413 jLabelSetVirtualAddressMapCallBack.setBounds(new java.awt.Rectangle(15, 5, 200, 20));
414 jLabelSetVirtualAddressMapCallBack.setText("Set Virtual Address Map Call Back");
415 jPanelType4 = new JPanel();
416 jPanelType4.setLayout(null);
417 jPanelType4.setBounds(new java.awt.Rectangle(0, 105, 490, 55));
418 jPanelType4.add(jLabelSetVirtualAddressMapCallBack, null);
419 jPanelType4.add(getIComboBoxSetVirtualAddressMapCallBack(), null);
420 jPanelType4.add(jLabelExitBootServicesCallBack, null);
421 jPanelType4.add(getIComboBoxExitBootServicesCallBack(), null);
422 }
423 return jPanelType4;
424 }
425
426 /**
427 This method initializes jComboBoxSetVirtualAddressMapCallBack
428
429 @return javax.swing.JComboBox iComboBoxSetVirtualAddressMapCallBack
430
431 **/
432 private IComboBox getIComboBoxSetVirtualAddressMapCallBack() {
433 if (iComboBoxSetVirtualAddressMapCallBack == null) {
434 iComboBoxSetVirtualAddressMapCallBack = new IComboBox();
435 iComboBoxSetVirtualAddressMapCallBack.setBounds(new java.awt.Rectangle(220, 5, 260, 20));
436 }
437 return iComboBoxSetVirtualAddressMapCallBack;
438 }
439
440 /**
441 This method initializes jComboBoxExitBootServicesCallBack
442
443 @return javax.swing.JComboBox iComboBoxExitBootServicesCallBack
444
445 **/
446 private IComboBox getIComboBoxExitBootServicesCallBack() {
447 if (iComboBoxExitBootServicesCallBack == null) {
448 iComboBoxExitBootServicesCallBack = new IComboBox();
449 iComboBoxExitBootServicesCallBack.setBounds(new java.awt.Rectangle(220, 30, 260, 20));
450 }
451 return iComboBoxExitBootServicesCallBack;
452 }
453
454 /**
455 This method initializes jPanelType5
456
457 @return javax.swing.JPanel jPanelType5
458
459 **/
460 private JPanel getJPanelType5() {
461 if (jPanelType5 == null) {
462 jLabelUserDefined = new JLabel();
463 jLabelUserDefined.setBounds(new java.awt.Rectangle(15, 5, 140, 20));
464 jLabelUserDefined.setText("User Defined");
465 jPanelType5 = new JPanel();
466 jPanelType5.setLayout(null);
467 jPanelType5.setBounds(new java.awt.Rectangle(0, 105, 490, 30));
468 jPanelType5.add(jLabelUserDefined, null);
469 jPanelType5.add(getIComboBoxUserDefined(), null);
470 }
471 return jPanelType5;
472 }
473
474 /**
475 This method initializes jComboBoxUserDefined
476
477 @return javax.swing.JComboBox iComboBoxUserDefined
478
479 **/
480 private IComboBox getIComboBoxUserDefined() {
481 if (iComboBoxUserDefined == null) {
482 iComboBoxUserDefined = new IComboBox();
483 iComboBoxUserDefined.setBounds(new java.awt.Rectangle(160, 5, 320, 20));
484 }
485 return iComboBoxUserDefined;
486 }
487
488 public static void main(String[] args) {
489
490 }
491
492 /**
493 This is the default constructor
494
495 **/
496 public ModuleExterns() {
497 super();
498 init();
499 this.setVisible(true);
500 }
501
502 /**
503 This is the override edit constructor
504
505 @param inExterns The input data of ExternsDocument.Externs
506
507 **/
508 public ModuleExterns(ExternsDocument.Externs inExterns) {
509 super();
510 init(inExterns);
511 this.setVisible(true);
512 }
513
514 /**
515 This is the override edit constructor
516
517 @param inExterns The input data of ExternsDocument.Externs
518 @param type The input data of node type
519 @param index The input data of node index
520
521 **/
522 public ModuleExterns(ExternsDocument.Externs inExterns, int type, int index) {
523 super();
524 init(inExterns, type, index);
525 this.setVisible(true);
526 }
527
528 /**
529 This method initializes this
530
531 @param inExterns The input data of ExternsDocument.Externs
532
533 **/
534 private void init(ExternsDocument.Externs inExterns) {
535 init();
536 this.setExterns(inExterns);
537 }
538
539 /**
540 This method initializes this
541 Fill values to all fields if these values are not empty
542
543 @param inExterns The input data of ExternsDocument.Externs
544 @param type The input data of node type
545 @param index The input data of node index
546
547 **/
548 private void init(ExternsDocument.Externs inExterns, int type, int index) {
549 init(inExterns);
550 this.location = index;
551 if (this.externs.getExternList().size() > 0) {
552 //
553 //Get common fields
554 //
555 if (this.externs.getExternArray(index).getUsage() != null) {
556 this.jComboBoxUsage.setSelectedItem(this.externs.getExternArray(index).getUsage().toString());
557 }
558 this.jTextFieldOverrideID.setText(String.valueOf(this.externs.getExternArray(index).getOverrideID()));
559 //
560 //Type 1
561 //
562 if (this.externs.getExternArray(index).getModuleEntryPointList().size() > 0) {
563 this.jComboBoxType.setSelectedIndex(0);
564 for (int indexI = 0; indexI < this.externs.getExternArray(index).getModuleEntryPointList().size(); indexI++) {
565 this.iComboBoxModuleEntryPoint.addItem(this.externs.getExternArray(index)
566 .getModuleEntryPointArray(indexI));
567 }
568 }
569 if (this.externs.getExternArray(index).getModuleUnloadImageList().size() > 0) {
570 this.jComboBoxType.setSelectedIndex(0);
571 for (int indexI = 0; indexI < this.externs.getExternArray(index).getModuleUnloadImageList().size(); indexI++) {
572 this.iComboBoxModuleUnloadImage.addItem(this.externs.getExternArray(index)
573 .getModuleUnloadImageArray(indexI));
574 }
575 }
576
577 //
578 //Type 2
579 //
580 if (this.externs.getExternArray(index).getConstructor() != null) {
581 this.jComboBoxType.setSelectedIndex(1);
582 this.jTextFieldConstructor.setText(this.externs.getExternArray(index).getConstructor());
583 }
584 if (this.externs.getExternArray(index).getDestructor() != null) {
585 this.jComboBoxType.setSelectedIndex(1);
586 this.jTextFieldDestructor.setText(this.externs.getExternArray(index).getDestructor());
587 }
588
589 //
590 //Type 3
591 //
592 if (this.externs.getExternArray(index).getDriverBindingList().size() > 0) {
593 this.jComboBoxType.setSelectedIndex(2);
594 for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverBindingList().size(); indexI++) {
595 this.iComboBoxDriverBinding.addItem(this.externs.getExternArray(index)
596 .getDriverBindingArray(indexI));
597 }
598 }
599 if (this.externs.getExternArray(index).getComponentNameList().size() > 0) {
600 this.jComboBoxType.setSelectedIndex(2);
601 for (int indexI = 0; indexI < this.externs.getExternArray(index).getComponentNameList().size(); indexI++) {
602 this.iComboBoxComponentName.addItem(this.externs.getExternArray(index)
603 .getComponentNameArray(indexI));
604 }
605 }
606 if (this.externs.getExternArray(index).getDriverConfigList().size() > 0) {
607 this.jComboBoxType.setSelectedIndex(2);
608 for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverConfigList().size(); indexI++) {
609 this.iComboBoxDriverConfig.addItem(this.externs.getExternArray(index).getDriverConfigArray(indexI));
610 }
611 }
612 if (this.externs.getExternArray(index).getDriverDiagList().size() > 0) {
613 this.jComboBoxType.setSelectedIndex(2);
614 for (int indexI = 0; indexI < this.externs.getExternArray(index).getDriverDiagList().size(); indexI++) {
615 this.iComboBoxDriverDiag.addItem(this.externs.getExternArray(index).getDriverDiagArray(indexI));
616 }
617 }
618
619 //
620 //Type 4
621 //
622 if (this.externs.getExternArray(index).getSetVirtualAddressMapCallBackList().size() > 0) {
623 this.jComboBoxType.setSelectedIndex(3);
624 for (int indexI = 0; indexI < this.externs.getExternArray(index).getSetVirtualAddressMapCallBackList()
625 .size(); indexI++) {
626 this.iComboBoxSetVirtualAddressMapCallBack
627 .addItem(this.externs
628 .getExternArray(index)
629 .getSetVirtualAddressMapCallBackArray(
630 indexI));
631 }
632 }
633 if (this.externs.getExternArray(index).getExitBootServicesCallBackList().size() > 0) {
634 this.jComboBoxType.setSelectedIndex(3);
635 for (int indexI = 0; indexI < this.externs.getExternArray(index).getExitBootServicesCallBackList()
636 .size(); indexI++) {
637 this.iComboBoxExitBootServicesCallBack
638 .addItem(this.externs
639 .getExternArray(index)
640 .getExitBootServicesCallBackArray(indexI));
641 }
642 }
643
644 //
645 //Type 5
646 //
647 if (this.externs.getExternArray(index).getUserDefinedList().size() > 0) {
648 this.jComboBoxType.setSelectedIndex(4);
649 for (int indexI = 0; indexI < this.externs.getExternArray(index).getUserDefinedList().size(); indexI++) {
650 this.iComboBoxUserDefined.addItem(this.externs.getExternArray(index).getUserDefinedArray(indexI));
651 }
652 }
653
654 this.jComboBoxType.setEnabled(false);
655 switchType();
656 }
657 }
658
659 /**
660 This method initializes this
661
662 **/
663 private void init() {
664 this.setSize(500, 515);
665 this.setContentPane(getJContentPane());
666 this.setTitle("Externs");
667 initFrame();
668 this.setViewMode(false);
669 }
670
671 /**
672 Disable all components when the mode is view
673
674 @param isView true - The view mode; false - The non-view mode
675
676 **/
677 public void setViewMode(boolean isView) {
678 this.jButtonOk.setVisible(false);
679 this.jButtonCancel.setVisible(false);
680 if (isView) {
681 this.jComboBoxUsage.setEnabled(!isView);
682 this.jTextFieldOverrideID.setEnabled(!isView);
683 //
684 //Type 1
685 //
686 this.iComboBoxModuleEntryPoint.setEnabled(!isView);
687 this.iComboBoxModuleUnloadImage.setEnabled(!isView);
688
689 //
690 //Type 2
691 //
692 this.jTextFieldConstructor.setEnabled(!isView);
693 this.jTextFieldDestructor.setEnabled(!isView);
694
695 //
696 //Type 3
697 //
698 this.iComboBoxDriverBinding.setEnabled(!isView);
699 this.iComboBoxComponentName.setEnabled(!isView);
700 this.iComboBoxDriverConfig.setEnabled(!isView);
701 this.iComboBoxDriverDiag.setEnabled(!isView);
702
703 //
704 //Type 4
705 //
706 this.iComboBoxSetVirtualAddressMapCallBack.setEnabled(!isView);
707 this.iComboBoxExitBootServicesCallBack.setEnabled(!isView);
708
709 //
710 //Type 5
711 //
712 this.iComboBoxUserDefined.setEnabled(!isView);
713
714 this.jComboBoxType.setEnabled(!isView);
715 this.jButtonCancel.setEnabled(!isView);
716 this.jButtonOk.setEnabled(!isView);
717 }
718 }
719
720 /**
721 This method initializes jContentPane
722
723 @return javax.swing.JPanel jContentPane
724
725 **/
726 private JPanel getJContentPane() {
727 if (jContentPane == null) {
728 jLabelOverrideID = new JLabel();
729 jLabelOverrideID.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
730 jLabelOverrideID.setText("Override ID");
731 jLabelUsage = new JLabel();
732 jLabelUsage.setText("Usage");
733 jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
734 jLabelName = new JLabel();
735 jLabelName.setText("Choose Type");
736 jLabelName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
737 jContentPane = new JPanel();
738 jContentPane.setLayout(null);
739 jContentPane.setSize(new java.awt.Dimension(490, 244));
740 jContentPane.add(getJPanelType2(), null);
741 jContentPane.add(jLabelName, null);
742 jContentPane.add(getJComboBoxType(), null);
743 jContentPane.add(getJPanelType3(), null);
744 jContentPane.add(getJPanelType4(), null);
745 jContentPane.add(getJPanelType5(), null);
746 jContentPane.add(jLabelUsage, null);
747 jContentPane.add(getJComboBoxUsage(), null);
748 jContentPane.add(getJButtonOk(), null);
749 jContentPane.add(getJButtonCancel(), null);
750 jContentPane.add(jLabelOverrideID, null);
751 jContentPane.add(getJTextFieldOverrideID(), null);
752
753 jContentPane.add(getJPanelType1(), null);
754 }
755 return jContentPane;
756 }
757
758 /**
759 This method initializes Usage type and Externs type
760
761 **/
762 private void initFrame() {
763 jComboBoxUsage.addItem("ALWAYS_CONSUMED");
764 jComboBoxUsage.addItem("ALWAYS_PRODUCED");
765
766 jComboBoxType.addItem("Entry/Unload");
767 jComboBoxType.addItem("Library");
768 jComboBoxType.addItem("Driver Bindings");
769 jComboBoxType.addItem("Call Backs");
770 jComboBoxType.addItem("Other");
771
772 jPanelType1.setVisible(true);
773 jPanelType2.setVisible(false);
774 jPanelType3.setVisible(false);
775 jPanelType4.setVisible(false);
776 jPanelType5.setVisible(false);
777 }
778
779 /* (non-Javadoc)
780 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
781 *
782 * Override actionPerformed to listen all actions
783 *
784 */
785 public void actionPerformed(ActionEvent arg0) {
786 if (arg0.getSource() == jButtonOk) {
787 this.setEdited(true);
788 this.save();
789 this.dispose();
790 }
791
792 if (arg0.getSource() == jButtonCancel) {
793 this.dispose();
794 }
795 }
796
797 public void itemStateChanged(ItemEvent arg0) {
798 if (arg0.getSource() == jComboBoxType) {
799 if (arg0.getStateChange() == ItemEvent.SELECTED) {
800 switchType();
801 }
802 }
803 }
804
805 /**
806 Show/Hide relevant fields via select different types
807
808 **/
809 private void switchType() {
810 if (jComboBoxType.getSelectedIndex() == 0) {
811 jPanelType1.setVisible(true);
812 jPanelType2.setVisible(false);
813 jPanelType3.setVisible(false);
814 jPanelType4.setVisible(false);
815 jPanelType5.setVisible(false);
816 }
817 if (jComboBoxType.getSelectedIndex() == 1) {
818 jPanelType1.setVisible(false);
819 jPanelType2.setVisible(true);
820 jPanelType3.setVisible(false);
821 jPanelType4.setVisible(false);
822 jPanelType5.setVisible(false);
823 }
824 if (jComboBoxType.getSelectedIndex() == 2) {
825 jPanelType1.setVisible(false);
826 jPanelType2.setVisible(false);
827 jPanelType3.setVisible(true);
828 jPanelType4.setVisible(false);
829 jPanelType5.setVisible(false);
830 }
831 if (jComboBoxType.getSelectedIndex() == 3) {
832 jPanelType1.setVisible(false);
833 jPanelType2.setVisible(false);
834 jPanelType3.setVisible(false);
835 jPanelType4.setVisible(true);
836 jPanelType5.setVisible(false);
837 }
838 if (jComboBoxType.getSelectedIndex() == 4) {
839 jPanelType1.setVisible(false);
840 jPanelType2.setVisible(false);
841 jPanelType3.setVisible(false);
842 jPanelType4.setVisible(false);
843 jPanelType5.setVisible(true);
844 }
845 }
846
847 /**
848 Set ExternsDocument.Externs
849
850 @return ExternsDocument.Externs
851
852
853 **/
854 public ExternsDocument.Externs getExterns() {
855 return externs;
856 }
857
858 /**
859 Get ExternsDocument.Externs
860
861 @param externs The input ExternsDocument.Externs
862
863 **/
864 public void setExterns(ExternsDocument.Externs externs) {
865 this.externs = externs;
866 }
867
868 /**
869 Data validation for all fields
870
871 @retval true - All datas are valid
872 @retval false - At least one data is invalid
873
874 **/
875 public boolean check() {
876 //
877 // Check if all fields have correct data types
878 //
879 if (this.jComboBoxType.getSelectedIndex() == 1) {
880 if (!isEmpty(this.jTextFieldConstructor.getText())
881 && !DataValidation.isConstructor(this.jTextFieldConstructor.getText())) {
882 Log.err("Incorrect data type for Constructor");
883 return false;
884 }
885 if (!isEmpty(this.jTextFieldDestructor.getText())
886 && !DataValidation.isDestructor(this.jTextFieldDestructor.getText())) {
887 Log.err("Incorrect data type for Destructor");
888 return false;
889 }
890 }
891
892 if (!isEmpty(this.jTextFieldOverrideID.getText())
893 && !DataValidation.isOverrideID(this.jTextFieldOverrideID.getText())) {
894 Log.err("Incorrect data type for Override ID");
895 return false;
896 }
897
898 return true;
899 }
900
901 /**
902 Save all components of Externs
903 if exists externs, set the value directly
904 if not exists externs, new an instance first
905
906 **/
907 public void save() {
908 try {
909 if (this.externs == null) {
910 externs = ExternsDocument.Externs.Factory.newInstance();
911 }
912 ExternsDocument.Externs.Extern extern = ExternsDocument.Externs.Extern.Factory.newInstance();
913 //
914 //Save common fields
915 //
916 extern.setUsage(ExternUsage.Enum.forString(jComboBoxUsage.getSelectedItem().toString()));
917 if (!isEmpty(this.jTextFieldOverrideID.getText())) {
918 extern.setOverrideID(Integer.parseInt(this.jTextFieldOverrideID.getText()));
919 }
920
921 //
922 //Save type 1
923 //
924 if (this.jComboBoxType.getSelectedIndex() == 0) {
925 if (this.iComboBoxModuleEntryPoint.getItemCount() > 0) {
926 for (int index = 0; index < this.iComboBoxModuleEntryPoint.getItemCount(); index++) {
927 extern.addNewModuleEntryPoint();
928 extern.setModuleEntryPointArray(index, this.iComboBoxModuleEntryPoint.getItemAt(index)
929 .toString());
930 }
931 }
932 if (this.iComboBoxModuleEntryPoint.getItemCount() > 0) {
933 for (int index = 0; index < this.iComboBoxModuleUnloadImage.getItemCount(); index++) {
934 extern.addNewModuleUnloadImage();
935 extern.setModuleUnloadImageArray(index, this.iComboBoxModuleUnloadImage.getItemAt(index)
936 .toString());
937 }
938 }
939 }
940
941 //
942 //Save type 2
943 //
944 if (this.jComboBoxType.getSelectedIndex() == 1) {
945 if (!isEmpty(this.jTextFieldConstructor.getText())) {
946 extern.setConstructor(this.jTextFieldConstructor.getText());
947 }
948 if (!isEmpty(this.jTextFieldDestructor.getText())) {
949 extern.setDestructor(this.jTextFieldDestructor.getText());
950 }
951 }
952
953 //
954 //Save type 3
955 //
956 if (this.jComboBoxType.getSelectedIndex() == 2) {
957 if (this.iComboBoxDriverBinding.getItemCount() > 0) {
958 for (int index = 0; index < this.iComboBoxDriverBinding.getItemCount(); index++) {
959 extern.addNewDriverBinding();
960 extern.setDriverBindingArray(index, this.iComboBoxDriverBinding.getItemAt(index).toString());
961 }
962 }
963 if (this.iComboBoxComponentName.getItemCount() > 0) {
964 for (int index = 0; index < this.iComboBoxComponentName.getItemCount(); index++) {
965 extern.addNewComponentName();
966 extern.setComponentNameArray(index, this.iComboBoxComponentName.getItemAt(index).toString());
967 }
968 }
969 if (this.iComboBoxDriverConfig.getItemCount() > 0) {
970 for (int index = 0; index < this.iComboBoxDriverConfig.getItemCount(); index++) {
971 extern.addNewDriverConfig();
972 extern.setDriverConfigArray(index, this.iComboBoxDriverConfig.getItemAt(index).toString());
973 }
974 }
975 if (this.iComboBoxDriverDiag.getItemCount() > 0) {
976 for (int index = 0; index < this.iComboBoxDriverDiag.getItemCount(); index++) {
977 extern.addNewDriverDiag();
978 extern.setDriverDiagArray(index, this.iComboBoxDriverDiag.getItemAt(index).toString());
979 }
980 }
981 }
982
983 //
984 //Save type 4
985 //
986 if (this.jComboBoxType.getSelectedIndex() == 3) {
987 if (this.iComboBoxSetVirtualAddressMapCallBack.getItemCount() > 0) {
988 for (int index = 0; index < this.iComboBoxSetVirtualAddressMapCallBack.getItemCount(); index++) {
989 extern.addNewSetVirtualAddressMapCallBack();
990 extern
991 .setSetVirtualAddressMapCallBackArray(
992 index,
993 this.iComboBoxSetVirtualAddressMapCallBack
994 .getItemAt(
995 index)
996 .toString());
997 }
998 }
999 if (this.iComboBoxExitBootServicesCallBack.getItemCount() > 0) {
1000 for (int index = 0; index < this.iComboBoxExitBootServicesCallBack.getItemCount(); index++) {
1001 extern.addNewExitBootServicesCallBack();
1002 extern.setExitBootServicesCallBackArray(index,
1003 this.iComboBoxExitBootServicesCallBack.getItemAt(index)
1004 .toString());
1005 }
1006 }
1007 }
1008 //
1009 //Save type 5
1010 //
1011 if (this.jComboBoxType.getSelectedIndex() == 4) {
1012 if (this.iComboBoxUserDefined.getItemCount() > 0) {
1013 for (int index = 0; index < this.iComboBoxUserDefined.getItemCount(); index++) {
1014 extern.addNewUserDefined();
1015 extern.setUserDefinedArray(index, this.iComboBoxUserDefined.getItemAt(index).toString());
1016 }
1017 }
1018 }
1019
1020 if (location > -1) {
1021 externs.setExternArray(location, extern);
1022 } else {
1023 externs.addNewExtern();
1024 externs.setExternArray(externs.getExternList().size() - 1, extern);
1025 }
1026 } catch (Exception e) {
1027 Log.err("Update Externs", e.getMessage());
1028 }
1029 }
1030 }