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
.dialog
;
17 import java
.awt
.Dimension
;
18 import java
.awt
.event
.ActionEvent
;
19 import java
.util
.Vector
;
21 import javax
.swing
.JButton
;
22 import javax
.swing
.JComboBox
;
23 import javax
.swing
.JLabel
;
24 import javax
.swing
.JPanel
;
25 import javax
.swing
.JScrollPane
;
26 import javax
.swing
.JTextField
;
28 import org
.tianocore
.frameworkwizard
.common
.DataType
;
29 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
30 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
31 import org
.tianocore
.frameworkwizard
.common
.Log
;
32 import org
.tianocore
.frameworkwizard
.common
.Tools
;
33 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
37 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
38 import org
.tianocore
.frameworkwizard
.module
.Identifications
.LibraryClass
.LibraryClassIdentification
;
39 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
42 The class is used to create, update Library Class Definition of MSA/MBD file
43 It extends IInternalFrame
46 public class LibraryClassDefsDlg
extends IDialog
{
49 /// Define class Serial Version UID
51 private static final long serialVersionUID
= -1743248695411382857L;
54 //Define class members
56 private JPanel jContentPane
= null;
58 private JComboBox jComboBoxLibraryClassName
= null;
60 private JLabel jLabelUsage
= null;
62 private JComboBox jComboBoxUsage
= null;
64 private JLabel jLabelLibraryClassName
= null;
66 private JScrollPane jScrollPane
= null;
68 private StarLabel jStarLabel1
= null;
70 private StarLabel jStarLabel2
= null;
72 private JLabel jLabelRecommendedInstanceVersion
= null;
74 private JTextField jTextFieldRecommendedInstanceVersion
= null;
76 private JLabel jLabelRecommendedInstanceGuid
= null;
78 private JTextField jTextFieldRecommendedInstanceGuid
= null;
80 private JButton jButtonGenerateGuid
= null;
82 private JLabel jLabelFeatureFlag
= null;
84 private JTextField jTextFieldFeatureFlag
= null;
86 private JLabel jLabelArch
= null;
88 private JLabel jLabelModuleList
= null;
90 private JScrollPane jScrollPaneModuleList
= null;
92 private ICheckBoxList iCheckBoxListModule
= null;
94 private JLabel jLabelHelpText
= null;
96 private JTextField jTextFieldHelpText
= null;
98 private ArchCheckBox jArchCheckBox
= null;
100 private JButton jButtonOk
= null;
102 private JButton jButtonCancel
= null;
107 private EnumerationData ed
= new EnumerationData();
109 private WorkspaceTools wt
= new WorkspaceTools();
111 private LibraryClassIdentification lcid
= null;
114 This method initializes jComboBoxSelect
116 @return javax.swing.JComboBox jComboBoxSelect
119 private JComboBox
getJComboBoxLibraryClassName() {
120 if (jComboBoxLibraryClassName
== null) {
121 jComboBoxLibraryClassName
= new JComboBox();
122 jComboBoxLibraryClassName
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
123 jComboBoxLibraryClassName
.setPreferredSize(new Dimension(320, 20));
124 jComboBoxLibraryClassName
.setEnabled(true);
126 return jComboBoxLibraryClassName
;
130 This method initializes jComboBoxUsage
132 @return javax.swing.JComboBox jComboBoxUsage
135 private JComboBox
getJComboBoxUsage() {
136 if (jComboBoxUsage
== null) {
137 jComboBoxUsage
= new JComboBox();
138 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
139 jComboBoxUsage
.setPreferredSize(new Dimension(320, 20));
141 return jComboBoxUsage
;
145 This method initializes jScrollPane
147 @return javax.swing.JScrollPane
149 private JScrollPane
getJScrollPane() {
150 if (jScrollPane
== null) {
151 jScrollPane
= new JScrollPane();
152 jScrollPane
.setViewportView(getJContentPane());
158 * This method initializes jTextFieldRecommendedInstanceVersion
160 * @return javax.swing.JTextField
162 private JTextField
getJTextFieldRecommendedInstanceVersion() {
163 if (jTextFieldRecommendedInstanceVersion
== null) {
164 jTextFieldRecommendedInstanceVersion
= new JTextField();
165 jTextFieldRecommendedInstanceVersion
.setPreferredSize(new java
.awt
.Dimension(260, 20));
166 jTextFieldRecommendedInstanceVersion
.setSize(new java
.awt
.Dimension(260, 20));
167 jTextFieldRecommendedInstanceVersion
.setLocation(new java
.awt
.Point(220, 85));
168 jTextFieldRecommendedInstanceVersion
.setVisible(false);
170 return jTextFieldRecommendedInstanceVersion
;
174 * This method initializes jTextFieldRecommendedInstanceGuid
176 * @return javax.swing.JTextField
178 private JTextField
getJTextFieldRecommendedInstanceGuid() {
179 if (jTextFieldRecommendedInstanceGuid
== null) {
180 jTextFieldRecommendedInstanceGuid
= new JTextField();
181 jTextFieldRecommendedInstanceGuid
.setBounds(new java
.awt
.Rectangle(220, 110, 190, 20));
182 jTextFieldRecommendedInstanceGuid
.setPreferredSize(new java
.awt
.Dimension(190, 20));
183 jTextFieldRecommendedInstanceGuid
.setVisible(false);
185 return jTextFieldRecommendedInstanceGuid
;
189 * This method initializes jButtonGenerateGuid
191 * @return javax.swing.JButton
193 private JButton
getJButtonGenerateGuid() {
194 if (jButtonGenerateGuid
== null) {
195 jButtonGenerateGuid
= new JButton();
196 jButtonGenerateGuid
.setBounds(new java
.awt
.Rectangle(415, 110, 65, 20));
197 jButtonGenerateGuid
.setPreferredSize(new java
.awt
.Dimension(65, 20));
198 jButtonGenerateGuid
.setText("GEN");
199 jButtonGenerateGuid
.setVisible(false);
200 jButtonGenerateGuid
.addActionListener(this);
202 return jButtonGenerateGuid
;
206 * This method initializes jTextFieldFeatureFlag
208 * @return javax.swing.JTextField
210 private JTextField
getJTextFieldFeatureFlag() {
211 if (jTextFieldFeatureFlag
== null) {
212 jTextFieldFeatureFlag
= new JTextField();
213 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
214 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
216 return jTextFieldFeatureFlag
;
220 This method initializes iCheckBoxListArch
222 @return ICheckBoxList
224 private ICheckBoxList
getICheckBoxListSupModuleList() {
225 if (iCheckBoxListModule
== null) {
226 iCheckBoxListModule
= new ICheckBoxList();
228 return iCheckBoxListModule
;
232 This method initializes jScrollPaneModuleList
234 @return javax.swing.JScrollPane
237 private JScrollPane
getJScrollPaneModuleList() {
238 if (jScrollPaneModuleList
== null) {
239 jScrollPaneModuleList
= new JScrollPane();
240 jScrollPaneModuleList
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 80));
241 jScrollPaneModuleList
.setPreferredSize(new java
.awt
.Dimension(320, 80));
242 jScrollPaneModuleList
.setViewportView(getICheckBoxListSupModuleList());
244 return jScrollPaneModuleList
;
248 This method initializes jTextFieldHelpText
250 @return javax.swing.JTextField
253 private JTextField
getJTextFieldHelpText() {
254 if (jTextFieldHelpText
== null) {
255 jTextFieldHelpText
= new JTextField();
256 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
257 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
259 return jTextFieldHelpText
;
263 This method initializes jButtonOk
265 @return javax.swing.JButton
268 private JButton
getJButtonOk() {
269 if (jButtonOk
== null) {
270 jButtonOk
= new JButton();
271 jButtonOk
.setBounds(new java
.awt
.Rectangle(290, 225, 90, 20));
272 jButtonOk
.setText("Ok");
273 jButtonOk
.addActionListener(this);
279 This method initializes jButtonCancel
281 @return javax.swing.JButton
284 private JButton
getJButtonCancel() {
285 if (jButtonCancel
== null) {
286 jButtonCancel
= new JButton();
287 jButtonCancel
.setBounds(new java
.awt
.Rectangle(390, 225, 90, 20));
288 jButtonCancel
.setText("Cancel");
289 jButtonCancel
.addActionListener(this);
291 return jButtonCancel
;
294 public static void main(String
[] args
) {
299 This is the default constructor
302 public LibraryClassDefsDlg(LibraryClassIdentification inLibraryClassIdentification
, IFrame iFrame
) {
304 init(inLibraryClassIdentification
);
308 This method initializes this
311 private void init() {
312 this.setContentPane(getJScrollPane());
313 this.setTitle("Library Class Definitions");
314 this.setBounds(new java
.awt
.Rectangle(0, 0, 500, 295));
316 this.setViewMode(false);
321 This method initializes this
324 private void init(LibraryClassIdentification inLibraryClassIdentification
) {
326 this.lcid
= inLibraryClassIdentification
;
328 this.jComboBoxLibraryClassName
.setSelectedItem(lcid
.getLibraryClassName());
329 this.jComboBoxUsage
.setSelectedItem(lcid
.getUsage());
330 this.jTextFieldRecommendedInstanceVersion
.setText(lcid
.getRecommendedInstanceVersion());
331 this.jTextFieldRecommendedInstanceGuid
.setText(lcid
.getRecommendedInstanceGuid());
332 this.jTextFieldFeatureFlag
.setText(lcid
.getFeatureFlag());
333 this.jArchCheckBox
.setSelectedItems(lcid
.getSupArchList());
334 this.iCheckBoxListModule
.setAllItemsUnchecked();
335 this.iCheckBoxListModule
.initCheckedItem(true, lcid
.getSupModuleList());
336 this.jTextFieldHelpText
.setText(lcid
.getHelp());
341 Disable all components when the mode is view
343 @param isView true - The view mode; false - The non-view mode
346 public void setViewMode(boolean isView
) {
348 this.jComboBoxLibraryClassName
.setEnabled(!isView
);
349 this.jComboBoxUsage
.setEnabled(!isView
);
354 This method initializes jContentPane
356 @return javax.swing.JPanel jContentPane
359 private JPanel
getJContentPane() {
360 if (jContentPane
== null) {
361 jArchCheckBox
= new ArchCheckBox();
362 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
363 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
364 jLabelHelpText
= new JLabel();
365 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 60, 140, 20));
366 jLabelHelpText
.setText("Help Text");
367 jLabelModuleList
= new JLabel();
368 jLabelModuleList
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
369 jLabelModuleList
.setText("Sup Module List");
370 jLabelArch
= new JLabel();
371 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
372 jLabelArch
.setText("Sup Arch List");
373 jLabelFeatureFlag
= new JLabel();
374 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 85, 140, 20));
375 jLabelFeatureFlag
.setText("Feature Flag");
376 jLabelRecommendedInstanceGuid
= new JLabel();
377 jLabelRecommendedInstanceGuid
.setBounds(new java
.awt
.Rectangle(15, 110, 200, 20));
378 jLabelRecommendedInstanceGuid
.setText("Recommended Instance Guid");
379 jLabelRecommendedInstanceGuid
.setVisible(false);
380 jLabelRecommendedInstanceVersion
= new JLabel();
381 jLabelRecommendedInstanceVersion
.setBounds(new java
.awt
.Rectangle(15, 85, 200, 20));
382 jLabelRecommendedInstanceVersion
.setText("Recommended Instance Version");
383 jLabelRecommendedInstanceVersion
.setVisible(false);
384 jLabelLibraryClassName
= new JLabel();
385 jLabelLibraryClassName
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
386 jLabelLibraryClassName
.setText("Library Class Name");
387 jLabelUsage
= new JLabel();
388 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
389 jLabelUsage
.setText("Usage");
390 jContentPane
= new JPanel();
391 jContentPane
.setLayout(null);
392 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 245));
394 jContentPane
.add(getJComboBoxLibraryClassName(), null);
395 jContentPane
.add(jLabelUsage
, null);
396 jContentPane
.add(getJComboBoxUsage(), null);
397 jContentPane
.add(jLabelLibraryClassName
, null);
398 jContentPane
.add(jLabelRecommendedInstanceVersion
, null);
399 jContentPane
.add(getJTextFieldRecommendedInstanceVersion(), null);
400 jContentPane
.add(jLabelRecommendedInstanceGuid
, null);
401 jContentPane
.add(getJTextFieldRecommendedInstanceGuid(), null);
402 jContentPane
.add(getJButtonGenerateGuid(), null);
403 jContentPane
.add(jLabelFeatureFlag
, null);
404 jContentPane
.add(getJTextFieldFeatureFlag(), null);
405 jContentPane
.add(jLabelArch
, null);
406 jStarLabel1
= new StarLabel();
407 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
408 jStarLabel2
= new StarLabel();
409 jStarLabel2
.setLocation(new java
.awt
.Point(0, 35));
411 jContentPane
.add(jStarLabel1
, null);
412 jContentPane
.add(jStarLabel2
, null);
413 jContentPane
.add(jLabelModuleList
, null);
414 jContentPane
.add(getJScrollPaneModuleList(), null);
415 jContentPane
.add(jLabelHelpText
, null);
416 jContentPane
.add(getJTextFieldHelpText(), null);
417 jContentPane
.add(jArchCheckBox
, null);
418 jContentPane
.add(getJButtonOk(), null);
419 jContentPane
.add(getJButtonCancel(), null);
425 This method initializes all existing libraries and usage types
428 private void initFrame() {
429 Tools
.generateComboBoxByVector(jComboBoxLibraryClassName
, wt
.getAllLibraryClassDefinitionsFromWorkspace());
430 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVLibraryUsage());
431 this.iCheckBoxListModule
.setAllItems(ed
.getVFrameworkModuleTypes());
435 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
437 * Override actionPerformed to listen all actions
440 public void actionPerformed(ActionEvent arg0
) {
441 if (arg0
.getSource() == jButtonGenerateGuid
) {
442 this.jTextFieldRecommendedInstanceGuid
.setText(Tools
.generateUuidString());
445 if (arg0
.getSource() == jButtonOk
) {
447 getCurrentLibraryClass();
448 this.returnType
= DataType
.RETURN_TYPE_OK
;
449 this.setVisible(false);
453 if (arg0
.getSource() == jButtonCancel
) {
454 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
455 this.setVisible(false);
460 Data validation for all fields
462 @retval true - All datas are valid
463 @retval false - At least one data is invalid
466 public boolean checkAdd() {
468 // Check LibraryClass
470 if (this.jComboBoxLibraryClassName
.getSelectedItem() == null) {
471 Log
.wrn("Update Library Class Definitions", "No Library Class can be added");
474 if (!DataValidation
.isLibraryClass(this.jComboBoxLibraryClassName
.getSelectedItem().toString())) {
475 Log
.wrn("Update Library Class Definitions", "Incorrect data type for Library Class");
480 // Check RecommendedInstanceVersion
482 // if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {
483 // if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {
484 // Log.err("Incorrect data type for Recommended Instance Version");
490 // Check RecommendedInstanceGuid
492 // if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {
493 // if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {
494 // Log.err("Incorrect data type for Recommended Instance Guid");
502 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
503 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
504 Log
.wrn("Update Library Class Definitions", "Incorrect data type for Feature Flag");
512 private LibraryClassIdentification
getCurrentLibraryClass() {
513 String name
= this.jComboBoxLibraryClassName
.getSelectedItem().toString();
514 String usage
= this.jComboBoxUsage
.getSelectedItem().toString();
515 String version
= this.jTextFieldRecommendedInstanceVersion
.getText();
516 String guid
= this.jTextFieldRecommendedInstanceGuid
.getText();
517 String featureFlag
= this.jTextFieldFeatureFlag
.getText();
518 Vector
<String
> arch
= this.jArchCheckBox
.getSelectedItemsVector();
519 Vector
<String
> module
= this.iCheckBoxListModule
.getAllCheckedItemsString();
520 String help
= this.jTextFieldHelpText
.getText();
521 lcid
= new LibraryClassIdentification(name
, usage
, version
, guid
, arch
, featureFlag
, module
, help
);
525 public LibraryClassIdentification
getLcid() {
529 public void setLcid(LibraryClassIdentification lcid
) {