3 The file is used to create, update Library Class Definition section of the MSA 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 section of the MSA file
47 public class LibraryClassDefsDlg
extends IDialog
{
50 /// Define class Serial Version UID
52 private static final long serialVersionUID
= -1743248695411382857L;
55 //Define class members
57 private JPanel jContentPane
= null;
59 private JComboBox jComboBoxLibraryClassName
= null;
61 private JLabel jLabelUsage
= null;
63 private JComboBox jComboBoxUsage
= null;
65 private JLabel jLabelLibraryClassName
= null;
67 private JScrollPane jScrollPane
= null;
69 private StarLabel jStarLabel1
= null;
71 private StarLabel jStarLabel2
= null;
73 private JLabel jLabelRecommendedInstanceVersion
= null;
75 private JTextField jTextFieldRecommendedInstanceVersion
= null;
77 private JLabel jLabelRecommendedInstanceGuid
= null;
79 private JTextField jTextFieldRecommendedInstanceGuid
= null;
81 private JButton jButtonGenerateGuid
= null;
83 private JLabel jLabelFeatureFlag
= null;
85 private JTextField jTextFieldFeatureFlag
= null;
87 private JLabel jLabelArch
= null;
89 private JLabel jLabelModuleList
= null;
91 private JScrollPane jScrollPaneModuleList
= null;
93 private ICheckBoxList iCheckBoxListModule
= null;
95 private JLabel jLabelHelpText
= null;
97 private JTextField jTextFieldHelpText
= null;
99 private ArchCheckBox jArchCheckBox
= null;
101 private JButton jButtonOk
= null;
103 private JButton jButtonCancel
= null;
108 private EnumerationData ed
= new EnumerationData();
110 private WorkspaceTools wt
= new WorkspaceTools();
112 private LibraryClassIdentification lcid
= null;
115 This method initializes jComboBoxSelect
117 @return javax.swing.JComboBox jComboBoxSelect
120 private JComboBox
getJComboBoxLibraryClassName() {
121 if (jComboBoxLibraryClassName
== null) {
122 jComboBoxLibraryClassName
= new JComboBox();
123 jComboBoxLibraryClassName
.setBounds(new java
.awt
.Rectangle(168, 12, 320, 20));
124 jComboBoxLibraryClassName
.setPreferredSize(new Dimension(320, 20));
125 jComboBoxLibraryClassName
.setEnabled(true);
127 return jComboBoxLibraryClassName
;
131 This method initializes jComboBoxUsage
133 @return javax.swing.JComboBox jComboBoxUsage
136 private JComboBox
getJComboBoxUsage() {
137 if (jComboBoxUsage
== null) {
138 jComboBoxUsage
= new JComboBox();
139 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(168, 37, 320, 20));
140 jComboBoxUsage
.setPreferredSize(new Dimension(320, 20));
142 return jComboBoxUsage
;
146 This method initializes jScrollPane
148 @return javax.swing.JScrollPane
150 private JScrollPane
getJScrollPane() {
151 if (jScrollPane
== null) {
152 jScrollPane
= new JScrollPane();
153 jScrollPane
.setViewportView(getJContentPane());
159 * This method initializes jTextFieldRecommendedInstanceVersion
161 * @return javax.swing.JTextField
163 private JTextField
getJTextFieldRecommendedInstanceVersion() {
164 if (jTextFieldRecommendedInstanceVersion
== null) {
165 jTextFieldRecommendedInstanceVersion
= new JTextField();
166 jTextFieldRecommendedInstanceVersion
.setPreferredSize(new java
.awt
.Dimension(260, 20));
167 jTextFieldRecommendedInstanceVersion
.setSize(new java
.awt
.Dimension(260, 20));
168 jTextFieldRecommendedInstanceVersion
.setLocation(new java
.awt
.Point(220, 85));
169 jTextFieldRecommendedInstanceVersion
.setVisible(false);
171 return jTextFieldRecommendedInstanceVersion
;
175 * This method initializes jTextFieldRecommendedInstanceGuid
177 * @return javax.swing.JTextField
179 private JTextField
getJTextFieldRecommendedInstanceGuid() {
180 if (jTextFieldRecommendedInstanceGuid
== null) {
181 jTextFieldRecommendedInstanceGuid
= new JTextField();
182 jTextFieldRecommendedInstanceGuid
.setBounds(new java
.awt
.Rectangle(220, 110, 190, 20));
183 jTextFieldRecommendedInstanceGuid
.setPreferredSize(new java
.awt
.Dimension(190, 20));
184 jTextFieldRecommendedInstanceGuid
.setVisible(false);
186 return jTextFieldRecommendedInstanceGuid
;
190 * This method initializes jButtonGenerateGuid
192 * @return javax.swing.JButton
194 private JButton
getJButtonGenerateGuid() {
195 if (jButtonGenerateGuid
== null) {
196 jButtonGenerateGuid
= new JButton();
197 jButtonGenerateGuid
.setBounds(new java
.awt
.Rectangle(415, 112, 65, 20));
198 jButtonGenerateGuid
.setPreferredSize(new java
.awt
.Dimension(65, 20));
199 jButtonGenerateGuid
.setText("GEN");
200 jButtonGenerateGuid
.setVisible(false);
201 jButtonGenerateGuid
.addActionListener(this);
203 return jButtonGenerateGuid
;
207 * This method initializes jTextFieldFeatureFlag
209 * @return javax.swing.JTextField
211 private JTextField
getJTextFieldFeatureFlag() {
212 if (jTextFieldFeatureFlag
== null) {
213 jTextFieldFeatureFlag
= new JTextField();
214 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(168,197,320,20));
215 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
216 jTextFieldFeatureFlag
.setToolTipText("Postfix expression that must evaluate to TRUE or FALSE");
217 jTextFieldFeatureFlag
.setEnabled(false);
219 return jTextFieldFeatureFlag
;
223 This method initializes iCheckBoxListArch
225 @return ICheckBoxList
227 private ICheckBoxList
getICheckBoxListSupModuleList() {
228 if (iCheckBoxListModule
== null) {
229 iCheckBoxListModule
= new ICheckBoxList();
231 return iCheckBoxListModule
;
235 This method initializes jScrollPaneModuleList
237 @return javax.swing.JScrollPane
240 private JScrollPane
getJScrollPaneModuleList() {
241 if (jScrollPaneModuleList
== null) {
242 jScrollPaneModuleList
= new JScrollPane();
243 jScrollPaneModuleList
.setBounds(new java
.awt
.Rectangle(168, 112, 320, 80));
244 jScrollPaneModuleList
.setPreferredSize(new java
.awt
.Dimension(320, 80));
245 jScrollPaneModuleList
.setViewportView(getICheckBoxListSupModuleList());
247 return jScrollPaneModuleList
;
251 This method initializes jTextFieldHelpText
253 @return javax.swing.JTextField
256 private JTextField
getJTextFieldHelpText() {
257 if (jTextFieldHelpText
== null) {
258 jTextFieldHelpText
= new JTextField();
259 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(168, 62, 320, 20));
260 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
262 return jTextFieldHelpText
;
266 This method initializes jButtonOk
268 @return javax.swing.JButton
271 private JButton
getJButtonOk() {
272 if (jButtonOk
== null) {
273 jButtonOk
= new JButton();
274 jButtonOk
.setBounds(new java
.awt
.Rectangle(300, 232, 90, 20));
275 jButtonOk
.setText("Ok");
276 jButtonOk
.addActionListener(this);
282 This method initializes jButtonCancel
284 @return javax.swing.JButton
287 private JButton
getJButtonCancel() {
288 if (jButtonCancel
== null) {
289 jButtonCancel
= new JButton();
290 jButtonCancel
.setBounds(new java
.awt
.Rectangle(400, 232, 90, 20));
291 jButtonCancel
.setText("Cancel");
292 jButtonCancel
.addActionListener(this);
294 return jButtonCancel
;
297 public static void main(String
[] args
) {
302 This is the default constructor
305 public LibraryClassDefsDlg(LibraryClassIdentification inLibraryClassIdentification
, IFrame iFrame
) {
307 init(inLibraryClassIdentification
);
311 This method initializes this
314 private void init() {
315 this.setContentPane(getJScrollPane());
316 this.setTitle("Library Class Definitions");
317 this.setBounds(new java
.awt
.Rectangle(0, 0, 505, 305));
319 this.setViewMode(false);
324 This method initializes this
327 private void init(LibraryClassIdentification inLibraryClassIdentification
) {
329 this.lcid
= inLibraryClassIdentification
;
331 this.jComboBoxLibraryClassName
.setSelectedItem(lcid
.getLibraryClassName());
332 this.jComboBoxUsage
.setSelectedItem(lcid
.getUsage());
333 this.jTextFieldRecommendedInstanceVersion
.setText(lcid
.getRecommendedInstanceVersion());
334 this.jTextFieldRecommendedInstanceGuid
.setText(lcid
.getRecommendedInstanceGuid());
335 this.jTextFieldFeatureFlag
.setText(lcid
.getFeatureFlag());
336 this.jArchCheckBox
.setSelectedItems(lcid
.getSupArchList());
337 this.iCheckBoxListModule
.setAllItemsUnchecked();
338 this.iCheckBoxListModule
.initCheckedItem(true, lcid
.getSupModuleList());
339 this.jTextFieldHelpText
.setText(lcid
.getHelp());
344 Disable all components when the mode is view
346 @param isView true - The view mode; false - The non-view mode
349 public void setViewMode(boolean isView
) {
351 this.jComboBoxLibraryClassName
.setEnabled(!isView
);
352 this.jComboBoxUsage
.setEnabled(!isView
);
357 This method initializes jContentPane
359 @return javax.swing.JPanel jContentPane
362 private JPanel
getJContentPane() {
363 if (jContentPane
== null) {
364 jArchCheckBox
= new ArchCheckBox();
365 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 87, 320, 20));
366 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(320, 20));
367 jLabelHelpText
= new JLabel();
368 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(12, 62, 168, 20));
369 jLabelHelpText
.setText("Help Text");
370 jLabelModuleList
= new JLabel();
371 jLabelModuleList
.setBounds(new java
.awt
.Rectangle(12, 112, 168, 20));
372 jLabelModuleList
.setText("Supported Module Types");
373 jLabelArch
= new JLabel();
374 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 87, 168, 20));
375 jLabelArch
.setText("Supported Architectures");
376 jLabelFeatureFlag
= new JLabel();
377 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(12,197,168,20));
378 jLabelFeatureFlag
.setText("Feature Flag Expression");
379 jLabelFeatureFlag
.setEnabled(false);
380 jLabelRecommendedInstanceGuid
= new JLabel();
381 jLabelRecommendedInstanceGuid
.setBounds(new java
.awt
.Rectangle(12, 87, 200, 20));
382 jLabelRecommendedInstanceGuid
.setText("Recommended Instance Guid");
383 jLabelRecommendedInstanceGuid
.setVisible(false);
384 jLabelRecommendedInstanceVersion
= new JLabel();
385 jLabelRecommendedInstanceVersion
.setBounds(new java
.awt
.Rectangle(12, 87, 200, 20));
386 jLabelRecommendedInstanceVersion
.setText("Recommended Instance Version");
387 jLabelRecommendedInstanceVersion
.setVisible(false);
388 jLabelLibraryClassName
= new JLabel();
389 jLabelLibraryClassName
.setBounds(new java
.awt
.Rectangle(12, 12, 168, 20));
390 jLabelLibraryClassName
.setText("Library Class Name");
391 jLabelUsage
= new JLabel();
392 jLabelUsage
.setBounds(new java
.awt
.Rectangle(12, 37, 168, 20));
393 jLabelUsage
.setText("Usage");
394 jContentPane
= new JPanel();
395 jContentPane
.setLayout(null);
396 jContentPane
.setPreferredSize(new java
.awt
.Dimension(495, 255));
398 jContentPane
.add(getJComboBoxLibraryClassName(), null);
399 jContentPane
.add(jLabelUsage
, null);
400 jContentPane
.add(getJComboBoxUsage(), null);
401 jContentPane
.add(jLabelLibraryClassName
, null);
402 jContentPane
.add(jLabelRecommendedInstanceVersion
, null);
403 jContentPane
.add(getJTextFieldRecommendedInstanceVersion(), null);
404 jContentPane
.add(jLabelRecommendedInstanceGuid
, null);
405 jContentPane
.add(getJTextFieldRecommendedInstanceGuid(), null);
406 jContentPane
.add(getJButtonGenerateGuid(), null);
407 jContentPane
.add(jLabelFeatureFlag
, null);
408 jContentPane
.add(getJTextFieldFeatureFlag(), null);
409 jContentPane
.add(jLabelArch
, null);
410 jStarLabel1
= new StarLabel();
411 jStarLabel1
.setLocation(new java
.awt
.Point(2, 10));
412 jStarLabel2
= new StarLabel();
413 jStarLabel2
.setLocation(new java
.awt
.Point(2, 35));
415 jContentPane
.add(jStarLabel1
, null);
416 jContentPane
.add(jStarLabel2
, null);
417 jContentPane
.add(jLabelModuleList
, null);
418 jContentPane
.add(getJScrollPaneModuleList(), null);
419 jContentPane
.add(jLabelHelpText
, null);
420 jContentPane
.add(getJTextFieldHelpText(), null);
421 jContentPane
.add(jArchCheckBox
, null);
422 jContentPane
.add(getJButtonOk(), null);
423 jContentPane
.add(getJButtonCancel(), null);
429 This method initializes all existing libraries and usage types
432 private void initFrame() {
433 Tools
.generateComboBoxByVector(jComboBoxLibraryClassName
, wt
.getAllLibraryClassDefinitionsFromWorkspace());
434 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVLibraryUsage());
435 this.iCheckBoxListModule
.setAllItems(ed
.getVFrameworkModuleTypes());
439 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
441 * Override actionPerformed to listen all actions
444 public void actionPerformed(ActionEvent arg0
) {
445 if (arg0
.getSource() == jButtonGenerateGuid
) {
446 this.jTextFieldRecommendedInstanceGuid
.setText(Tools
.generateUuidString());
449 if (arg0
.getSource() == jButtonOk
) {
451 getCurrentLibraryClass();
452 this.returnType
= DataType
.RETURN_TYPE_OK
;
453 this.setVisible(false);
457 if (arg0
.getSource() == jButtonCancel
) {
458 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
459 this.setVisible(false);
464 Data validation for all fields
466 @retval true - All datas are valid
467 @retval false - At least one data is invalid
470 public boolean checkAdd() {
472 // Check LibraryClass
474 if (this.jComboBoxLibraryClassName
.getSelectedItem() == null) {
475 Log
.wrn("Update Library Class Definitions", "No Library Class can be added");
478 if (!DataValidation
.isLibraryClass(this.jComboBoxLibraryClassName
.getSelectedItem().toString())) {
479 Log
.wrn("Update Library Class Definitions", "Incorrect data type for Library Class");
484 // Check RecommendedInstanceVersion
486 // if (!isEmpty(this.jTextFieldRecommendedInstanceVersion.getText())) {
487 // if (!DataValidation.isRecommendedInstanceVersion(this.jTextFieldRecommendedInstanceVersion.getText())) {
488 // Log.err("Incorrect data type for Recommended Instance Version");
494 // Check RecommendedInstanceGuid
496 // if (!isEmpty(this.jTextFieldRecommendedInstanceGuid.getText())) {
497 // if (!DataValidation.isGuid(this.jTextFieldRecommendedInstanceGuid.getText())) {
498 // Log.err("Incorrect data type for Recommended Instance Guid");
506 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
507 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
508 Log
.wrn("Update Library Class Definitions", "Incorrect data type for Feature Flag");
516 private LibraryClassIdentification
getCurrentLibraryClass() {
517 String name
= this.jComboBoxLibraryClassName
.getSelectedItem().toString();
518 String usage
= this.jComboBoxUsage
.getSelectedItem().toString();
519 String version
= this.jTextFieldRecommendedInstanceVersion
.getText();
520 String guid
= this.jTextFieldRecommendedInstanceGuid
.getText();
521 String featureFlag
= this.jTextFieldFeatureFlag
.getText();
522 Vector
<String
> arch
= this.jArchCheckBox
.getSelectedItemsVector();
523 Vector
<String
> module
= this.iCheckBoxListModule
.getAllCheckedItemsString();
524 String help
= this.jTextFieldHelpText
.getText();
525 lcid
= new LibraryClassIdentification(name
, usage
, version
, guid
, arch
, featureFlag
, module
, help
);
529 public LibraryClassIdentification
getLcid() {
533 public void setLcid(LibraryClassIdentification lcid
) {