]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleLibraryClassDefinitions.java
1. Restructure some folders and files
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / ModuleLibraryClassDefinitions.java
1 /** @file
2
3 The file is used to create, update Library Class Definition 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.frameworkwizard.module.ui;
16
17 import java.awt.Dimension;
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ComponentEvent;
20 import java.awt.event.ItemEvent;
21 import java.util.Vector;
22
23 import javax.swing.JButton;
24 import javax.swing.JComboBox;
25 import javax.swing.JLabel;
26 import javax.swing.JPanel;
27 import javax.swing.JScrollPane;
28 import javax.swing.JTextArea;
29 import javax.swing.JTextField;
30
31 import org.tianocore.LibraryClassDefinitionsDocument;
32 import org.tianocore.LibraryUsage;
33 import org.tianocore.ModuleSurfaceAreaDocument;
34 import org.tianocore.LibraryClassDefinitionsDocument.LibraryClassDefinitions;
35 import org.tianocore.LibraryClassDocument.LibraryClass;
36 import org.tianocore.frameworkwizard.common.DataType;
37 import org.tianocore.frameworkwizard.common.DataValidation;
38 import org.tianocore.frameworkwizard.common.EnumerationData;
39 import org.tianocore.frameworkwizard.common.Log;
40 import org.tianocore.frameworkwizard.common.Tools;
41 import org.tianocore.frameworkwizard.common.Identifications.OpeningModuleType;
42 import org.tianocore.frameworkwizard.common.ui.IInternalFrame;
43 import org.tianocore.frameworkwizard.common.ui.StarLabel;
44 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
45 import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassIdentification;
46 import org.tianocore.frameworkwizard.module.Identifications.LibraryClass.LibraryClassVector;
47 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
48
49 /**
50 The class is used to create, update Library Class Definition of MSA/MBD file
51 It extends IInternalFrame
52
53 **/
54 public class ModuleLibraryClassDefinitions extends IInternalFrame {
55
56 ///
57 /// Define class Serial Version UID
58 ///
59 private static final long serialVersionUID = -1743248695411382857L;
60
61 //
62 //Define class members
63 //
64 private JPanel jContentPane = null;
65
66 private JComboBox jComboBoxLibraryClassName = null;
67
68 private JLabel jLabelUsage = null;
69
70 private JComboBox jComboBoxUsage = null;
71
72 private JComboBox jComboBoxList = null;
73
74 private JButton jButtonAdd = null;
75
76 private JButton jButtonRemove = null;
77
78 private JButton jButtonUpdate = null;
79
80 private JLabel jLabelLibraryClassName = null;
81
82 private JScrollPane jScrollPaneList = null;
83
84 private JScrollPane jScrollPane = null;
85
86 private JTextArea jTextAreaList = null;
87
88 private StarLabel jStarLabel1 = null;
89
90 private StarLabel jStarLabel2 = null;
91
92 private ICheckBoxList iCheckBoxListArch = null;
93
94 private JScrollPane jScrollPaneArch = null;
95
96 private JLabel jLabelRecommendedInstanceVersion = null;
97
98 private JTextField jTextFieldRecommendedInstanceVersion = null;
99
100 private JLabel jLabelRecommendedInstanceGuid = null;
101
102 private JTextField jTextFieldRecommendedInstanceGuid = null;
103
104 private JButton jButtonGenerateGuid = null;
105
106 private JLabel jLabelFeatureFlag = null;
107
108 private JTextField jTextFieldFeatureFlag = null;
109
110 private JLabel jLabelArch = null;
111
112 private JLabel jLabelModuleList = null;
113
114 private JScrollPane jScrollPaneModuleList = null;
115
116 private ICheckBoxList iCheckBoxListModule = null;
117
118 private JLabel jLabelHelpText = null;
119
120 private JTextField jTextFieldHelpText = null;
121
122 //
123 // Not for UI
124 //
125 private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;
126
127 private LibraryClassDefinitions lcd = null;
128
129 private LibraryClassVector vLibraryClass = new LibraryClassVector();
130
131 private EnumerationData ed = new EnumerationData();
132
133 private Vector<String> vLib = new Vector<String>();
134
135 private int intSelectedItemId = 0;
136
137 private WorkspaceTools wt = new WorkspaceTools();
138
139 private LibraryClassIdentification lcid = null;
140
141 private OpeningModuleType omt = null;
142
143 /**
144 This method initializes jComboBoxSelect
145
146 @return javax.swing.JComboBox jComboBoxSelect
147
148 **/
149 private JComboBox getJComboBoxLibraryClassName() {
150 if (jComboBoxLibraryClassName == null) {
151 jComboBoxLibraryClassName = new JComboBox();
152 jComboBoxLibraryClassName.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
153 jComboBoxLibraryClassName.setPreferredSize(new Dimension(320, 20));
154 jComboBoxLibraryClassName.setEnabled(true);
155 }
156 return jComboBoxLibraryClassName;
157 }
158
159 /**
160 This method initializes jComboBoxUsage
161
162 @return javax.swing.JComboBox jComboBoxUsage
163
164 **/
165 private JComboBox getJComboBoxUsage() {
166 if (jComboBoxUsage == null) {
167 jComboBoxUsage = new JComboBox();
168 jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
169 jComboBoxUsage.setPreferredSize(new Dimension(320, 20));
170 }
171 return jComboBoxUsage;
172 }
173
174 /**
175 This method initializes jComboBoxFileList
176
177 @return javax.swing.JComboBox jComboBoxFileList
178
179 **/
180 private JComboBox getJComboBoxList() {
181 if (jComboBoxList == null) {
182 jComboBoxList = new JComboBox();
183 jComboBoxList.setBounds(new java.awt.Rectangle(15, 330, 210, 20));
184 jComboBoxList.setPreferredSize(new Dimension(210, 20));
185 jComboBoxList.addItemListener(this);
186 jComboBoxList.addActionListener(this);
187 }
188 return jComboBoxList;
189 }
190
191 /**
192 This method initializes jButtonAdd
193
194 @return javax.swing.JButton jButtonAdd
195
196 **/
197 private JButton getJButtonAdd() {
198 if (jButtonAdd == null) {
199 jButtonAdd = new JButton();
200 jButtonAdd.setBounds(new java.awt.Rectangle(230, 330, 80, 20));
201 jButtonAdd.setPreferredSize(new Dimension(80, 20));
202 jButtonAdd.setText("Add");
203 jButtonAdd.addActionListener(this);
204 }
205 return jButtonAdd;
206 }
207
208 /**
209 This method initializes jButtonRemove
210
211 @return javax.swing.JButton jButtonRemove
212
213 **/
214 private JButton getJButtonRemove() {
215 if (jButtonRemove == null) {
216 jButtonRemove = new JButton();
217 jButtonRemove.setBounds(new java.awt.Rectangle(400, 330, 80, 20));
218 jButtonRemove.setText("Remove");
219 jButtonRemove.setPreferredSize(new Dimension(80, 20));
220 jButtonRemove.addActionListener(this);
221 }
222 return jButtonRemove;
223 }
224
225 /**
226 This method initializes jButtonUpdate
227
228 @return javax.swing.JButton jButtonUpdate
229
230 **/
231 private JButton getJButtonUpdate() {
232 if (jButtonUpdate == null) {
233 jButtonUpdate = new JButton();
234 jButtonUpdate.setBounds(new java.awt.Rectangle(315, 330, 80, 20));
235 jButtonUpdate.setText("Update");
236 jButtonUpdate.setPreferredSize(new Dimension(80, 20));
237 jButtonUpdate.addActionListener(this);
238 }
239 return jButtonUpdate;
240 }
241
242 /**
243 This method initializes jScrollPane
244
245 @return javax.swing.JScrollPane
246 */
247 private JScrollPane getJScrollPaneList() {
248 if (jScrollPaneList == null) {
249 jScrollPaneList = new JScrollPane();
250 jScrollPaneList.setBounds(new java.awt.Rectangle(15, 355, 465, 100));
251 jScrollPaneList.setPreferredSize(new Dimension(465, 260));
252 jScrollPaneList.setViewportView(getJTextAreaList());
253 }
254 return jScrollPaneList;
255 }
256
257 /**
258 This method initializes jScrollPane
259
260 @return javax.swing.JScrollPane
261 */
262 private JScrollPane getJScrollPane() {
263 if (jScrollPane == null) {
264 jScrollPane = new JScrollPane();
265 jScrollPane.setViewportView(getJContentPane());
266 }
267 return jScrollPane;
268 }
269
270 /**
271 * This method initializes jTextAreaList
272 *
273 * @return javax.swing.JTextArea
274 */
275 private JTextArea getJTextAreaList() {
276 if (jTextAreaList == null) {
277 jTextAreaList = new JTextArea();
278 jTextAreaList.setEditable(false);
279 }
280 return jTextAreaList;
281 }
282
283 /**
284 * This method initializes jTextFieldRecommendedInstanceVersion
285 *
286 * @return javax.swing.JTextField
287 */
288 private JTextField getJTextFieldRecommendedInstanceVersion() {
289 if (jTextFieldRecommendedInstanceVersion == null) {
290 jTextFieldRecommendedInstanceVersion = new JTextField();
291 jTextFieldRecommendedInstanceVersion.setPreferredSize(new java.awt.Dimension(260, 20));
292 jTextFieldRecommendedInstanceVersion.setSize(new java.awt.Dimension(260, 20));
293 jTextFieldRecommendedInstanceVersion.setLocation(new java.awt.Point(220, 85));
294 }
295 return jTextFieldRecommendedInstanceVersion;
296 }
297
298 /**
299 * This method initializes jTextFieldRecommendedInstanceGuid
300 *
301 * @return javax.swing.JTextField
302 */
303 private JTextField getJTextFieldRecommendedInstanceGuid() {
304 if (jTextFieldRecommendedInstanceGuid == null) {
305 jTextFieldRecommendedInstanceGuid = new JTextField();
306 jTextFieldRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(220, 110, 190, 20));
307 jTextFieldRecommendedInstanceGuid.setPreferredSize(new java.awt.Dimension(190, 20));
308 }
309 return jTextFieldRecommendedInstanceGuid;
310 }
311
312 /**
313 * This method initializes jButtonGenerateGuid
314 *
315 * @return javax.swing.JButton
316 */
317 private JButton getJButtonGenerateGuid() {
318 if (jButtonGenerateGuid == null) {
319 jButtonGenerateGuid = new JButton();
320 jButtonGenerateGuid.setBounds(new java.awt.Rectangle(415, 110, 65, 20));
321 jButtonGenerateGuid.setPreferredSize(new java.awt.Dimension(65, 20));
322 jButtonGenerateGuid.setText("GEN");
323 jButtonGenerateGuid.addActionListener(this);
324 }
325 return jButtonGenerateGuid;
326 }
327
328 /**
329 * This method initializes jTextFieldFeatureFlag
330 *
331 * @return javax.swing.JTextField
332 */
333 private JTextField getJTextFieldFeatureFlag() {
334 if (jTextFieldFeatureFlag == null) {
335 jTextFieldFeatureFlag = new JTextField();
336 jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 135, 320, 20));
337 jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
338 }
339 return jTextFieldFeatureFlag;
340 }
341
342 /**
343 This method initializes iCheckBoxListArch
344
345 @return ICheckBoxList
346 **/
347 private ICheckBoxList getICheckBoxListSupportedArchitectures() {
348 if (iCheckBoxListArch == null) {
349 iCheckBoxListArch = new ICheckBoxList();
350 iCheckBoxListArch.addFocusListener(this);
351 }
352 return iCheckBoxListArch;
353 }
354
355 /**
356 This method initializes iCheckBoxListArch
357
358 @return ICheckBoxList
359 **/
360 private ICheckBoxList getICheckBoxListSupModuleList() {
361 if (iCheckBoxListModule == null) {
362 iCheckBoxListModule = new ICheckBoxList();
363 }
364 return iCheckBoxListModule;
365 }
366
367 /**
368 This method initializes jScrollPaneArch
369
370 @return javax.swing.JScrollPane
371
372 **/
373 private JScrollPane getJScrollPaneArch() {
374 if (jScrollPaneArch == null) {
375 jScrollPaneArch = new JScrollPane();
376 jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 160, 320, 80));
377 jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
378 jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
379 }
380 return jScrollPaneArch;
381 }
382
383 /**
384 This method initializes jScrollPaneModuleList
385
386 @return javax.swing.JScrollPane
387
388 **/
389 private JScrollPane getJScrollPaneModuleList() {
390 if (jScrollPaneModuleList == null) {
391 jScrollPaneModuleList = new JScrollPane();
392 jScrollPaneModuleList.setBounds(new java.awt.Rectangle(160, 245, 320, 80));
393 jScrollPaneModuleList.setPreferredSize(new java.awt.Dimension(320, 80));
394 jScrollPaneModuleList.setViewportView(getICheckBoxListSupModuleList());
395 }
396 return jScrollPaneModuleList;
397 }
398
399 /**
400 This method initializes jTextFieldHelpText
401
402 @return javax.swing.JTextField
403
404 **/
405 private JTextField getJTextFieldHelpText() {
406 if (jTextFieldHelpText == null) {
407 jTextFieldHelpText = new JTextField();
408 jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
409 jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
410 }
411 return jTextFieldHelpText;
412 }
413
414 public static void main(String[] args) {
415
416 }
417
418 /**
419 This is the default constructor
420
421 **/
422 public ModuleLibraryClassDefinitions() {
423 super();
424 init();
425 this.setVisible(true);
426 }
427
428 /**
429 This is the override edit constructor
430
431 @param
432
433 **/
434 public ModuleLibraryClassDefinitions(OpeningModuleType inOmt) {
435 super();
436 this.omt = inOmt;
437 this.msa = omt.getXmlMsa();
438 initLibraryClass();
439 init(msa.getLibraryClassDefinitions());
440 this.setVisible(true);
441 }
442
443 // private void initLibraryClass(MsaHeaderDocument.MsaHeader msaHeader) {
444 // Enum e = msaHeader.getModuleType();
445 // if (e == ModuleTypeDef.BASE) {
446 // vLib = ed.getVLibClassDefBase();
447 // } else if (e == ModuleTypeDef.PEI_CORE) {
448 // vLib = ed.getVLibClassDefPei();
449 // } else if (e == ModuleTypeDef.PEIM) {
450 // vLib = ed.getVLibClassDefPeim();
451 // } else if (e == ModuleTypeDef.DXE_CORE) {
452 // vLib = ed.getVLibClassDefDxeCore();
453 // } else if (e == ModuleTypeDef.DXE_DRIVER) {
454 // vLib = ed.getVLibClassDefDxeDriver();
455 // } else if (e == ModuleTypeDef.DXE_SMM_DRIVER) {
456 // vLib = ed.getVLibClassDefDxeSmmDriver();
457 // } else if (e == ModuleTypeDef.UEFI_DRIVER) {
458 // vLib = ed.getVLibClassDefUefiDriver();
459 // } else {
460 // //vLib = ed.getVLibClassDef();
461 // }
462 // }
463
464 /**
465
466 **/
467 private void initLibraryClass() {
468 vLib = wt.getAllLibraryClassDefinitionsFromWorkspace();
469 }
470
471 /**
472 This method initializes this
473 Fill values to all fields if these values are not empty
474
475 @param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions
476
477 **/
478 private void init(LibraryClassDefinitionsDocument.LibraryClassDefinitions inLibraryClassDefinitions) {
479 init();
480 this.lcd = inLibraryClassDefinitions;
481 if (this.lcd != null) {
482 if (this.lcd.getLibraryClassList().size() > 0) {
483 for (int index = 0; index < this.lcd.getLibraryClassList().size(); index++) {
484 String name = lcd.getLibraryClassList().get(index).getKeyword();
485 String usage = null;
486 if (lcd.getLibraryClassList().get(index).getUsage() != null) {
487 usage = lcd.getLibraryClassList().get(index).getUsage().toString();
488 }
489 String version = lcd.getLibraryClassList().get(index).getRecommendedInstanceVersion();
490 String guid = lcd.getLibraryClassList().get(index).getRecommendedInstanceGuid();
491 String featureFlag = lcd.getLibraryClassList().get(index).getFeatureFlag();
492 Vector<String> arch = Tools.convertListToVector(lcd.getLibraryClassList().get(index)
493 .getSupArchList());
494 Vector<String> module = Tools.convertListToVector(lcd.getLibraryClassList().get(index)
495 .getSupModuleList());
496 String help = lcd.getLibraryClassList().get(index).getHelpText();
497 LibraryClassIdentification lcid = new LibraryClassIdentification(name, usage, version, guid, arch,
498 featureFlag, module, help);
499 vLibraryClass.addLibraryClass(lcid);
500 }
501 }
502 }
503 //
504 // Update the list
505 //
506 Tools.generateComboBoxByVector(jComboBoxList, vLibraryClass.getLibraryClassName());
507 reloadListArea();
508 }
509
510 /**
511 This method initializes this
512
513 **/
514 private void init() {
515 this.setContentPane(getJScrollPane());
516 this.setTitle("Library Class Definitions");
517 this.setBounds(new java.awt.Rectangle(0, 0, 500, 515));
518 initFrame();
519 this.setViewMode(false);
520 }
521
522 /**
523 Disable all components when the mode is view
524
525 @param isView true - The view mode; false - The non-view mode
526
527 **/
528 public void setViewMode(boolean isView) {
529 if (isView) {
530 this.jComboBoxLibraryClassName.setEnabled(!isView);
531 this.jComboBoxUsage.setEnabled(!isView);
532 }
533 }
534
535 /**
536 This method initializes jContentPane
537
538 @return javax.swing.JPanel jContentPane
539
540 **/
541 private JPanel getJContentPane() {
542 if (jContentPane == null) {
543 jLabelHelpText = new JLabel();
544 jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
545 jLabelHelpText.setText("Help Text");
546 jLabelModuleList = new JLabel();
547 jLabelModuleList.setBounds(new java.awt.Rectangle(15, 245, 140, 20));
548 jLabelModuleList.setText("Sup Module List");
549 jLabelArch = new JLabel();
550 jLabelArch.setBounds(new java.awt.Rectangle(15, 160, 140, 20));
551 jLabelArch.setText("Sup Arch List");
552 jLabelFeatureFlag = new JLabel();
553 jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 135, 140, 20));
554 jLabelFeatureFlag.setText("Feature Flag");
555 jLabelRecommendedInstanceGuid = new JLabel();
556 jLabelRecommendedInstanceGuid.setBounds(new java.awt.Rectangle(15, 110, 200, 20));
557 jLabelRecommendedInstanceGuid.setText("Recommended Instance Guid");
558 jLabelRecommendedInstanceVersion = new JLabel();
559 jLabelRecommendedInstanceVersion.setBounds(new java.awt.Rectangle(15, 85, 200, 20));
560 jLabelRecommendedInstanceVersion.setText("Recommended Instance Version");
561 jLabelLibraryClassName = new JLabel();
562 jLabelLibraryClassName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
563 jLabelLibraryClassName.setText("Library Class Name");
564 jLabelUsage = new JLabel();
565 jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
566 jLabelUsage.setText("Usage");
567 jContentPane = new JPanel();
568 jContentPane.setLayout(null);
569 jContentPane.setPreferredSize(new java.awt.Dimension(490, 465));
570
571 jContentPane.add(getJComboBoxLibraryClassName(), null);
572 jContentPane.add(jLabelUsage, null);
573 jContentPane.add(getJComboBoxUsage(), null);
574 jContentPane.add(jLabelLibraryClassName, null);
575 jContentPane.add(getJScrollPaneList(), null);
576 jContentPane.add(getJComboBoxList(), null);
577 jContentPane.add(getJButtonAdd(), null);
578 jContentPane.add(getJButtonRemove(), null);
579 jContentPane.add(getJButtonUpdate(), null);
580 jContentPane.add(jLabelRecommendedInstanceVersion, null);
581 jContentPane.add(getJTextFieldRecommendedInstanceVersion(), null);
582 jContentPane.add(jLabelRecommendedInstanceGuid, null);
583 jContentPane.add(getJTextFieldRecommendedInstanceGuid(), null);
584 jContentPane.add(getJButtonGenerateGuid(), null);
585 jContentPane.add(jLabelFeatureFlag, null);
586 jContentPane.add(getJTextFieldFeatureFlag(), null);
587 jContentPane.add(jLabelArch, null);
588 jContentPane.add(getJScrollPaneArch(), null);
589 jStarLabel1 = new StarLabel();
590 jStarLabel1.setLocation(new java.awt.Point(0, 10));
591 jStarLabel2 = new StarLabel();
592 jStarLabel2.setLocation(new java.awt.Point(0, 35));
593
594 jContentPane.add(jStarLabel1, null);
595 jContentPane.add(jStarLabel2, null);
596 jContentPane.add(jLabelModuleList, null);
597 jContentPane.add(getJScrollPaneModuleList(), null);
598 jContentPane.add(jLabelHelpText, null);
599 jContentPane.add(getJTextFieldHelpText(), null);
600 }
601 return jContentPane;
602 }
603
604 /**
605 This method initializes all existing libraries and usage types
606
607 **/
608 private void initFrame() {
609 Tools.generateComboBoxByVector(jComboBoxLibraryClassName, vLib);
610 Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVLibraryUsage());
611 this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
612 this.iCheckBoxListModule.setAllItems(ed.getVFrameworkModuleTypes());
613 }
614
615 /* (non-Javadoc)
616 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
617 *
618 * Override actionPerformed to listen all actions
619 *
620 */
621 public void actionPerformed(ActionEvent arg0) {
622 if (arg0.getSource() == jButtonAdd) {
623 if (!checkAdd()) {
624 return;
625 }
626 addToList();
627 }
628 if (arg0.getSource() == jButtonRemove) {
629 removeFromList();
630 }
631 if (arg0.getSource() == jButtonUpdate) {
632 updateForList();
633 }
634 if (arg0.getSource() == jButtonGenerateGuid) {
635 this.jTextFieldRecommendedInstanceGuid.setText(Tools.generateUuidString());
636 }
637 }
638
639 /**
640 Data validation for all fields
641
642 @retval true - All datas are valid
643 @retval false - At least one data is invalid
644
645 **/
646 public boolean checkAdd() {
647 //
648 // Check LibraryClass
649 //
650 if (this.jComboBoxLibraryClassName.getSelectedItem() == null) {
651 Log.err("No Library Class can be added");
652 return false;
653 }
654 if (!DataValidation.isLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString())) {
655 Log.err("Incorrect data type for Library Class");
656 return false;
657 }
658
659 //
660 // Check RecommendedInstanceVersion
661 //
662 if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {
663 if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {
664 Log.err("Incorrect data type for Recommended Instance Version");
665 return false;
666 }
667 }
668
669 //
670 // Check RecommendedInstanceGuid
671 //
672 if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {
673 if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {
674 Log.err("Incorrect data type for Recommended Instance Guid");
675 return false;
676 }
677 }
678
679 //
680 // Check FeatureFlag
681 //
682 if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
683 if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
684 Log.err("Incorrect data type for Feature Flag");
685 return false;
686 }
687 }
688
689 if (this.vLibraryClass.findLibraryClass(this.jComboBoxLibraryClassName.getSelectedItem().toString()) > -1) {
690 Log.err("The Library Class has been added already!");
691 return false;
692 }
693 return true;
694 }
695
696 /**
697 Save all components of Mbd Header
698 if exists mbdHeader, set the value directly
699 if not exists mbdHeader, new an instance first
700
701 **/
702 public void save() {
703 try {
704 int intLibraryCount = this.vLibraryClass.size();
705
706 lcd = LibraryClassDefinitions.Factory.newInstance();
707 if (intLibraryCount > 0) {
708 for (int index = 0; index < intLibraryCount; index++) {
709 LibraryClass mLibraryClass = LibraryClass.Factory.newInstance();
710
711 mLibraryClass.setKeyword(vLibraryClass.getLibraryClass(index).getLibraryClassName());
712 mLibraryClass
713 .setUsage(LibraryUsage.Enum.forString(vLibraryClass.getLibraryClass(index).getUsage()));
714 if (!isEmpty(vLibraryClass.getLibraryClass(index).getRecommendedInstanceVersion())) {
715 mLibraryClass.setRecommendedInstanceVersion(vLibraryClass.getLibraryClass(index)
716 .getRecommendedInstanceVersion());
717 }
718 if (!isEmpty(vLibraryClass.getLibraryClass(index).getRecommendedInstanceGuid())) {
719 mLibraryClass.setRecommendedInstanceGuid(vLibraryClass.getLibraryClass(index)
720 .getRecommendedInstanceGuid());
721 }
722 if (!isEmpty(vLibraryClass.getLibraryClass(index).getFeatureFlag())) {
723 mLibraryClass.setFeatureFlag(vLibraryClass.getLibraryClass(index).getFeatureFlag());
724 }
725 if (vLibraryClass.getLibraryClass(index).getSupArchList() != null
726 && vLibraryClass.getLibraryClass(index).getSupArchList().size() > 0) {
727 mLibraryClass.setSupArchList(vLibraryClass.getLibraryClass(index).getSupArchList());
728 }
729 if (!isEmpty(vLibraryClass.getLibraryClass(index).getHelp())) {
730 mLibraryClass.setHelpText(vLibraryClass.getLibraryClass(index).getHelp());
731 }
732
733 this.lcd.addNewLibraryClass();
734 this.lcd.setLibraryClassArray(index, mLibraryClass);
735 }
736 }
737
738 if (msa.getLibraryClassDefinitions() == null) {
739 this.msa.addNewLibraryClassDefinitions();
740 }
741 this.msa.setLibraryClassDefinitions(this.lcd);
742
743 this.omt.setSaved(false);
744 } catch (Exception e) {
745 Log.err("Update Library Class Definitions", e.getMessage());
746 }
747 }
748
749 private LibraryClassIdentification getCurrentLibraryClass() {
750 String name = this.jComboBoxLibraryClassName.getSelectedItem().toString();
751 String usage = this.jComboBoxUsage.getSelectedItem().toString();
752 String version = this.jTextFieldRecommendedInstanceVersion.getText();
753 String guid = this.jTextFieldRecommendedInstanceGuid.getText();
754 String featureFlag = this.jTextFieldFeatureFlag.getText();
755 Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();
756 Vector<String> module = this.iCheckBoxListModule.getAllCheckedItemsString();
757 String help = this.jTextFieldHelpText.getText();
758 lcid = new LibraryClassIdentification(name, usage, version, guid, arch, featureFlag, module, help);
759 return lcid;
760 }
761
762 /**
763 Add current item to Vector
764
765 **/
766 private void addToList() {
767 intSelectedItemId = vLibraryClass.size();
768
769 vLibraryClass.addLibraryClass(getCurrentLibraryClass());
770
771 jComboBoxList.addItem(lcid.getLibraryClassName());
772 jComboBoxList.setSelectedItem(lcid.getLibraryClassName());
773
774 //
775 // Reset select item index
776 //
777 intSelectedItemId = vLibraryClass.size();
778
779 //
780 // Reload all fields of selected item
781 //
782 reloadFromList();
783
784 //
785 // Save to memory
786 //
787 save();
788 }
789
790 /**
791 Remove current item from Vector
792
793 **/
794 private void removeFromList() {
795 //
796 // Check if exist items
797 //
798 if (this.vLibraryClass.size() < 1) {
799 return;
800 }
801
802 int intTempIndex = intSelectedItemId;
803
804 jComboBoxList.removeItemAt(intSelectedItemId);
805
806 vLibraryClass.removeLibraryClass(intTempIndex);
807
808 //
809 // Reload all fields of selected item
810 //
811 reloadFromList();
812
813 //
814 // Save to memory
815 //
816 save();
817 }
818
819 /**
820 Update current item of Vector
821
822 **/
823 private void updateForList() {
824 //
825 // Check if exist items
826 //
827 if (this.vLibraryClass.size() < 1) {
828 return;
829 }
830
831 //
832 // Backup selected item index
833 //
834 int intTempIndex = intSelectedItemId;
835
836 vLibraryClass.updateLibraryClass(getCurrentLibraryClass(), intTempIndex);
837
838 jComboBoxList.removeAllItems();
839 for (int index = 0; index < vLibraryClass.size(); index++) {
840 jComboBoxList.addItem(vLibraryClass.getLibraryClass(index).getLibraryClassName());
841 }
842
843 //
844 // Restore selected item index
845 //
846 intSelectedItemId = intTempIndex;
847
848 //
849 // Reset select item index
850 //
851 jComboBoxList.setSelectedIndex(intSelectedItemId);
852
853 //
854 // Reload all fields of selected item
855 //
856 reloadFromList();
857
858 //
859 // Save to memory
860 //
861 save();
862 }
863
864 /**
865 Refresh all fields' values of selected item of Vector
866
867 **/
868 private void reloadFromList() {
869 if (vLibraryClass.size() > 0) {
870 //
871 // Get selected item index
872 //
873 intSelectedItemId = jComboBoxList.getSelectedIndex();
874
875 this.jComboBoxLibraryClassName.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId)
876 .getLibraryClassName());
877 this.jComboBoxUsage.setSelectedItem(vLibraryClass.getLibraryClass(intSelectedItemId).getUsage());
878 this.jTextFieldRecommendedInstanceVersion.setText(vLibraryClass.getLibraryClass(intSelectedItemId)
879 .getRecommendedInstanceVersion());
880 this.jTextFieldRecommendedInstanceGuid.setText(vLibraryClass.getLibraryClass(intSelectedItemId)
881 .getRecommendedInstanceGuid());
882 this.jTextFieldFeatureFlag.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getFeatureFlag());
883 this.iCheckBoxListArch.setAllItemsUnchecked();
884 this.iCheckBoxListArch.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)
885 .getSupArchList());
886 this.iCheckBoxListModule.setAllItemsUnchecked();
887 this.iCheckBoxListModule.initCheckedItem(true, vLibraryClass.getLibraryClass(intSelectedItemId)
888 .getSupModuleList());
889 this.jTextFieldHelpText.setText(vLibraryClass.getLibraryClass(intSelectedItemId).getHelp());
890 } else {
891 }
892
893 reloadListArea();
894 }
895
896 /**
897 Update list area pane via the elements of Vector
898
899 **/
900 private void reloadListArea() {
901 String strListItem = "";
902 for (int index = 0; index < vLibraryClass.size(); index++) {
903 strListItem = strListItem + vLibraryClass.getLibraryClass(index).getLibraryClassName()
904 + DataType.UNIX_LINE_SEPARATOR;
905 }
906 this.jTextAreaList.setText(strListItem);
907 }
908
909 /* (non-Javadoc)
910 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
911 *
912 * Reflesh the frame when selected item changed
913 *
914 */
915 public void itemStateChanged(ItemEvent arg0) {
916 if (arg0.getStateChange() == ItemEvent.SELECTED) {
917 reloadFromList();
918 }
919 }
920
921 /* (non-Javadoc)
922 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
923 *
924 * Override componentResized to resize all components when frame's size is changed
925 */
926 public void componentResized(ComponentEvent arg0) {
927 int intCurrentWidth = this.getJContentPane().getWidth();
928 int intCurrentHeight = this.getJContentPane().getHeight();
929 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
930 int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
931
932 resizeComponentWidth(this.jComboBoxLibraryClassName, intCurrentWidth, intPreferredWidth);
933 resizeComponentWidth(this.jComboBoxUsage, intCurrentWidth, intPreferredWidth);
934 resizeComponentWidth(this.jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
935 resizeComponentWidth(this.jTextFieldRecommendedInstanceVersion, intCurrentWidth, intPreferredWidth);
936 resizeComponentWidth(this.jTextFieldRecommendedInstanceGuid, intCurrentWidth, intPreferredWidth);
937 resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
938 resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);
939 resizeComponentWidth(this.jScrollPaneModuleList, intCurrentWidth, intPreferredWidth);
940
941 relocateComponentX(this.jButtonGenerateGuid, intCurrentWidth, intPreferredWidth,
942 DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);
943
944 resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);
945 resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
946 relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
947 relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,
948 DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
949 relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,
950 DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
951 }
952 }