3 The file is used to create, update Library Class Definition of MSA/MBD file
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
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.
15 package org
.tianocore
.frameworkwizard
.module
.ui
;
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
;
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
;
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
;
50 The class is used to create, update Library Class Definition of MSA/MBD file
51 It extends IInternalFrame
54 public class ModuleLibraryClassDefinitions
extends IInternalFrame
{
57 /// Define class Serial Version UID
59 private static final long serialVersionUID
= -1743248695411382857L;
62 //Define class members
64 private JPanel jContentPane
= null;
66 private JComboBox jComboBoxLibraryClassName
= null;
68 private JLabel jLabelUsage
= null;
70 private JComboBox jComboBoxUsage
= null;
72 private JComboBox jComboBoxList
= null;
74 private JButton jButtonAdd
= null;
76 private JButton jButtonRemove
= null;
78 private JButton jButtonUpdate
= null;
80 private JLabel jLabelLibraryClassName
= null;
82 private JScrollPane jScrollPaneList
= null;
84 private JScrollPane jScrollPane
= null;
86 private JTextArea jTextAreaList
= null;
88 private StarLabel jStarLabel1
= null;
90 private StarLabel jStarLabel2
= null;
92 private ICheckBoxList iCheckBoxListArch
= null;
94 private JScrollPane jScrollPaneArch
= null;
96 private JLabel jLabelRecommendedInstanceVersion
= null;
98 private JTextField jTextFieldRecommendedInstanceVersion
= null;
100 private JLabel jLabelRecommendedInstanceGuid
= null;
102 private JTextField jTextFieldRecommendedInstanceGuid
= null;
104 private JButton jButtonGenerateGuid
= null;
106 private JLabel jLabelFeatureFlag
= null;
108 private JTextField jTextFieldFeatureFlag
= null;
110 private JLabel jLabelArch
= null;
112 private JLabel jLabelModuleList
= null;
114 private JScrollPane jScrollPaneModuleList
= null;
116 private ICheckBoxList iCheckBoxListModule
= null;
118 private JLabel jLabelHelpText
= null;
120 private JTextField jTextFieldHelpText
= null;
125 private ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= null;
127 private LibraryClassDefinitions lcd
= null;
129 private LibraryClassVector vLibraryClass
= new LibraryClassVector();
131 private EnumerationData ed
= new EnumerationData();
133 private Vector
<String
> vLib
= new Vector
<String
>();
135 private int intSelectedItemId
= 0;
137 private WorkspaceTools wt
= new WorkspaceTools();
139 private LibraryClassIdentification lcid
= null;
141 private OpeningModuleType omt
= null;
144 This method initializes jComboBoxSelect
146 @return javax.swing.JComboBox jComboBoxSelect
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);
156 return jComboBoxLibraryClassName
;
160 This method initializes jComboBoxUsage
162 @return javax.swing.JComboBox jComboBoxUsage
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));
171 return jComboBoxUsage
;
175 This method initializes jComboBoxFileList
177 @return javax.swing.JComboBox jComboBoxFileList
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);
188 return jComboBoxList
;
192 This method initializes jButtonAdd
194 @return javax.swing.JButton jButtonAdd
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);
209 This method initializes jButtonRemove
211 @return javax.swing.JButton jButtonRemove
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);
222 return jButtonRemove
;
226 This method initializes jButtonUpdate
228 @return javax.swing.JButton jButtonUpdate
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);
239 return jButtonUpdate
;
243 This method initializes jScrollPane
245 @return javax.swing.JScrollPane
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());
254 return jScrollPaneList
;
258 This method initializes jScrollPane
260 @return javax.swing.JScrollPane
262 private JScrollPane
getJScrollPane() {
263 if (jScrollPane
== null) {
264 jScrollPane
= new JScrollPane();
265 jScrollPane
.setViewportView(getJContentPane());
271 * This method initializes jTextAreaList
273 * @return javax.swing.JTextArea
275 private JTextArea
getJTextAreaList() {
276 if (jTextAreaList
== null) {
277 jTextAreaList
= new JTextArea();
278 jTextAreaList
.setEditable(false);
280 return jTextAreaList
;
284 * This method initializes jTextFieldRecommendedInstanceVersion
286 * @return javax.swing.JTextField
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));
295 return jTextFieldRecommendedInstanceVersion
;
299 * This method initializes jTextFieldRecommendedInstanceGuid
301 * @return javax.swing.JTextField
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));
309 return jTextFieldRecommendedInstanceGuid
;
313 * This method initializes jButtonGenerateGuid
315 * @return javax.swing.JButton
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);
325 return jButtonGenerateGuid
;
329 * This method initializes jTextFieldFeatureFlag
331 * @return javax.swing.JTextField
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));
339 return jTextFieldFeatureFlag
;
343 This method initializes iCheckBoxListArch
345 @return ICheckBoxList
347 private ICheckBoxList
getICheckBoxListSupportedArchitectures() {
348 if (iCheckBoxListArch
== null) {
349 iCheckBoxListArch
= new ICheckBoxList();
350 iCheckBoxListArch
.addFocusListener(this);
352 return iCheckBoxListArch
;
356 This method initializes iCheckBoxListArch
358 @return ICheckBoxList
360 private ICheckBoxList
getICheckBoxListSupModuleList() {
361 if (iCheckBoxListModule
== null) {
362 iCheckBoxListModule
= new ICheckBoxList();
364 return iCheckBoxListModule
;
368 This method initializes jScrollPaneArch
370 @return javax.swing.JScrollPane
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());
380 return jScrollPaneArch
;
384 This method initializes jScrollPaneModuleList
386 @return javax.swing.JScrollPane
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());
396 return jScrollPaneModuleList
;
400 This method initializes jTextFieldHelpText
402 @return javax.swing.JTextField
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));
411 return jTextFieldHelpText
;
414 public static void main(String
[] args
) {
419 This is the default constructor
422 public ModuleLibraryClassDefinitions() {
425 this.setVisible(true);
429 This is the override edit constructor
434 public ModuleLibraryClassDefinitions(OpeningModuleType inOmt
) {
437 this.msa
= omt
.getXmlMsa();
439 init(msa
.getLibraryClassDefinitions());
440 this.setVisible(true);
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();
460 // //vLib = ed.getVLibClassDef();
467 private void initLibraryClass() {
468 vLib
= wt
.getAllLibraryClassDefinitionsFromWorkspace();
472 This method initializes this
473 Fill values to all fields if these values are not empty
475 @param inLibraryClassDefinitions The input data of LibraryClassDefinitionsDocument.LibraryClassDefinitions
478 private void init(LibraryClassDefinitionsDocument
.LibraryClassDefinitions inLibraryClassDefinitions
) {
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();
486 if (lcd
.getLibraryClassList().get(index
).getUsage() != null) {
487 usage
= lcd
.getLibraryClassList().get(index
).getUsage().toString();
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
)
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
);
506 Tools
.generateComboBoxByVector(jComboBoxList
, vLibraryClass
.getLibraryClassName());
511 This method initializes this
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));
519 this.setViewMode(false);
523 Disable all components when the mode is view
525 @param isView true - The view mode; false - The non-view mode
528 public void setViewMode(boolean isView
) {
530 this.jComboBoxLibraryClassName
.setEnabled(!isView
);
531 this.jComboBoxUsage
.setEnabled(!isView
);
536 This method initializes jContentPane
538 @return javax.swing.JPanel jContentPane
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));
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));
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);
605 This method initializes all existing libraries and usage types
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());
616 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
618 * Override actionPerformed to listen all actions
621 public void actionPerformed(ActionEvent arg0
) {
622 if (arg0
.getSource() == jButtonAdd
) {
628 if (arg0
.getSource() == jButtonRemove
) {
631 if (arg0
.getSource() == jButtonUpdate
) {
634 if (arg0
.getSource() == jButtonGenerateGuid
) {
635 this.jTextFieldRecommendedInstanceGuid
.setText(Tools
.generateUuidString());
640 Data validation for all fields
642 @retval true - All datas are valid
643 @retval false - At least one data is invalid
646 public boolean checkAdd() {
648 // Check LibraryClass
650 if (this.jComboBoxLibraryClassName
.getSelectedItem() == null) {
651 Log
.err("No Library Class can be added");
654 if (!DataValidation
.isLibraryClass(this.jComboBoxLibraryClassName
.getSelectedItem().toString())) {
655 Log
.err("Incorrect data type for Library Class");
660 // Check RecommendedInstanceVersion
662 if (!isEmpty(this.jTextFieldRecommendedInstanceVersion
.getText())) {
663 if (!DataValidation
.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion
.getText())) {
664 Log
.err("Incorrect data type for Recommended Instance Version");
670 // Check RecommendedInstanceGuid
672 if (!isEmpty(this.jTextFieldRecommendedInstanceGuid
.getText())) {
673 if (!DataValidation
.isGuid(this.jTextFieldRecommendedInstanceGuid
.getText())) {
674 Log
.err("Incorrect data type for Recommended Instance Guid");
682 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
683 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
684 Log
.err("Incorrect data type for Feature Flag");
689 if (this.vLibraryClass
.findLibraryClass(this.jComboBoxLibraryClassName
.getSelectedItem().toString()) > -1) {
690 Log
.err("The Library Class has been added already!");
697 Save all components of Mbd Header
698 if exists mbdHeader, set the value directly
699 if not exists mbdHeader, new an instance first
704 int intLibraryCount
= this.vLibraryClass
.size();
706 lcd
= LibraryClassDefinitions
.Factory
.newInstance();
707 if (intLibraryCount
> 0) {
708 for (int index
= 0; index
< intLibraryCount
; index
++) {
709 LibraryClass mLibraryClass
= LibraryClass
.Factory
.newInstance();
711 mLibraryClass
.setKeyword(vLibraryClass
.getLibraryClass(index
).getLibraryClassName());
713 .setUsage(LibraryUsage
.Enum
.forString(vLibraryClass
.getLibraryClass(index
).getUsage()));
714 if (!isEmpty(vLibraryClass
.getLibraryClass(index
).getRecommendedInstanceVersion())) {
715 mLibraryClass
.setRecommendedInstanceVersion(vLibraryClass
.getLibraryClass(index
)
716 .getRecommendedInstanceVersion());
718 if (!isEmpty(vLibraryClass
.getLibraryClass(index
).getRecommendedInstanceGuid())) {
719 mLibraryClass
.setRecommendedInstanceGuid(vLibraryClass
.getLibraryClass(index
)
720 .getRecommendedInstanceGuid());
722 if (!isEmpty(vLibraryClass
.getLibraryClass(index
).getFeatureFlag())) {
723 mLibraryClass
.setFeatureFlag(vLibraryClass
.getLibraryClass(index
).getFeatureFlag());
725 if (vLibraryClass
.getLibraryClass(index
).getSupArchList() != null
726 && vLibraryClass
.getLibraryClass(index
).getSupArchList().size() > 0) {
727 mLibraryClass
.setSupArchList(vLibraryClass
.getLibraryClass(index
).getSupArchList());
729 if (!isEmpty(vLibraryClass
.getLibraryClass(index
).getHelp())) {
730 mLibraryClass
.setHelpText(vLibraryClass
.getLibraryClass(index
).getHelp());
733 this.lcd
.addNewLibraryClass();
734 this.lcd
.setLibraryClassArray(index
, mLibraryClass
);
738 if (msa
.getLibraryClassDefinitions() == null) {
739 this.msa
.addNewLibraryClassDefinitions();
741 this.msa
.setLibraryClassDefinitions(this.lcd
);
743 this.omt
.setSaved(false);
744 } catch (Exception e
) {
745 Log
.err("Update Library Class Definitions", e
.getMessage());
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
);
763 Add current item to Vector
766 private void addToList() {
767 intSelectedItemId
= vLibraryClass
.size();
769 vLibraryClass
.addLibraryClass(getCurrentLibraryClass());
771 jComboBoxList
.addItem(lcid
.getLibraryClassName());
772 jComboBoxList
.setSelectedItem(lcid
.getLibraryClassName());
775 // Reset select item index
777 intSelectedItemId
= vLibraryClass
.size();
780 // Reload all fields of selected item
791 Remove current item from Vector
794 private void removeFromList() {
796 // Check if exist items
798 if (this.vLibraryClass
.size() < 1) {
802 int intTempIndex
= intSelectedItemId
;
804 jComboBoxList
.removeItemAt(intSelectedItemId
);
806 vLibraryClass
.removeLibraryClass(intTempIndex
);
809 // Reload all fields of selected item
820 Update current item of Vector
823 private void updateForList() {
825 // Check if exist items
827 if (this.vLibraryClass
.size() < 1) {
832 // Backup selected item index
834 int intTempIndex
= intSelectedItemId
;
836 vLibraryClass
.updateLibraryClass(getCurrentLibraryClass(), intTempIndex
);
838 jComboBoxList
.removeAllItems();
839 for (int index
= 0; index
< vLibraryClass
.size(); index
++) {
840 jComboBoxList
.addItem(vLibraryClass
.getLibraryClass(index
).getLibraryClassName());
844 // Restore selected item index
846 intSelectedItemId
= intTempIndex
;
849 // Reset select item index
851 jComboBoxList
.setSelectedIndex(intSelectedItemId
);
854 // Reload all fields of selected item
865 Refresh all fields' values of selected item of Vector
868 private void reloadFromList() {
869 if (vLibraryClass
.size() > 0) {
871 // Get selected item index
873 intSelectedItemId
= jComboBoxList
.getSelectedIndex();
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
)
886 this.iCheckBoxListModule
.setAllItemsUnchecked();
887 this.iCheckBoxListModule
.initCheckedItem(true, vLibraryClass
.getLibraryClass(intSelectedItemId
)
888 .getSupModuleList());
889 this.jTextFieldHelpText
.setText(vLibraryClass
.getLibraryClass(intSelectedItemId
).getHelp());
897 Update list area pane via the elements of Vector
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
;
906 this.jTextAreaList
.setText(strListItem
);
910 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
912 * Reflesh the frame when selected item changed
915 public void itemStateChanged(ItemEvent arg0
) {
916 if (arg0
.getStateChange() == ItemEvent
.SELECTED
) {
922 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
924 * Override componentResized to resize all components when frame's size is changed
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
;
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
);
941 relocateComponentX(this.jButtonGenerateGuid
, intCurrentWidth
, intPreferredWidth
,
942 DataType
.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON
);
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
);