3 The file is used to create, update SourceFiles 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
.event
.ActionEvent
;
18 import java
.util
.Vector
;
20 import javax
.swing
.JButton
;
21 import javax
.swing
.JLabel
;
22 import javax
.swing
.JPanel
;
23 import javax
.swing
.JScrollPane
;
24 import javax
.swing
.JTextField
;
26 import org
.tianocore
.frameworkwizard
.common
.DataType
;
27 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
28 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
29 import org
.tianocore
.frameworkwizard
.common
.Log
;
30 import org
.tianocore
.frameworkwizard
.common
.Tools
;
31 import org
.tianocore
.frameworkwizard
.common
.ui
.ArchCheckBox
;
32 import org
.tianocore
.frameworkwizard
.common
.ui
.IComboBox
;
33 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
36 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
37 import org
.tianocore
.frameworkwizard
.module
.Identifications
.ModuleIdentification
;
38 import org
.tianocore
.frameworkwizard
.module
.Identifications
.BuildOptions
.BuildOptionsIdentification
;
39 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
42 * The class is used to create, update SourceFiles section of the MSA file
47 public class BuildOptionsDlg
extends IDialog
{
50 /// Define class Serial Version UID
52 private static final long serialVersionUID
= -6765742852142775378L;
55 // Define class members
57 private JPanel jContentPane
= null;
59 private JLabel jLabelFileName
= null;
61 private JTextField jTextFieldFileOption
= null;
63 private JLabel jLabelToolChainFamily
= null;
65 private StarLabel jStarLabel1
= null;
67 private JLabel jLabelArch
= null;
69 private JScrollPane jScrollPane
= null;
71 private JLabel jLabelTagName
= null;
73 private JTextField jTextFieldTagName
= null;
75 private JLabel jLabelToolCode
= null;
77 private JTextField jTextFieldToolCode
= null;
79 private IComboBox iComboBoxToolCode
= null;
81 private JTextField jTextFieldToolChainFamily
= null;
83 private ArchCheckBox jArchCheckBox
= null;
85 private JButton jButtonOk
= null;
87 private JButton jButtonCancel
= null;
89 private JScrollPane jScrollPaneBuildTargets
= null;
91 private ICheckBoxList iCheckBoxListBuildTargets
= null;
96 private BuildOptionsIdentification id
= null;
98 private EnumerationData ed
= new EnumerationData();
100 private WorkspaceTools wt
= new WorkspaceTools();
102 private JLabel jLabelBuildTargets
= null;
105 This method initializes jTextFieldFileOption
107 @return javax.swing.JTextField jTextFieldFileOption
110 private JTextField
getJTextFieldSourceFilesDirectory() {
111 if (jTextFieldFileOption
== null) {
112 jTextFieldFileOption
= new JTextField();
113 jTextFieldFileOption
.setBounds(new java
.awt
.Rectangle(168, 12, 340, 20));
114 jTextFieldFileOption
.setPreferredSize(new java
.awt
.Dimension(340, 20));
115 jTextFieldFileOption
.setToolTipText("Path is relative to the MSA file and must include the file name");
117 return jTextFieldFileOption
;
121 This method initializes jScrollPane
123 @return javax.swing.JScrollPane
125 private JScrollPane
getJScrollPane() {
126 if (jScrollPane
== null) {
127 jScrollPane
= new JScrollPane();
128 jScrollPane
.setViewportView(getJContentPane());
134 * This method initializes jTextFieldTagName
136 * @return javax.swing.JTextField
138 private JTextField
getJTextFieldTagName() {
139 if (jTextFieldTagName
== null) {
140 jTextFieldTagName
= new JTextField();
141 jTextFieldTagName
.setBounds(new java
.awt
.Rectangle(168, 37, 340, 20));
142 jTextFieldTagName
.setPreferredSize(new java
.awt
.Dimension(340, 20));
143 jTextFieldTagName
.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");
145 return jTextFieldTagName
;
148 private IComboBox
getIComboBoxToolCode() {
149 if (iComboBoxToolCode
== null) {
150 iComboBoxToolCode
= new IComboBox();
151 iComboBoxToolCode
.setBounds(new java
.awt
.Rectangle(168, 62, 340, 20));
152 iComboBoxToolCode
.setPreferredSize(new java
.awt
.Dimension(340, 20));
153 iComboBoxToolCode
.setToolTipText("<html>You may select a specific tool command from drop down list,<br>"
154 + "or you can DOUBLE-CLICK this field to enter your customized<br>"
155 + "tool command.<br>"
156 + "Press ENTER to save your input or press ESCAPE to quit</html>");
158 return iComboBoxToolCode
;
162 * This method initializes jTextFieldToolCode
164 * @return javax.swing.JTextField
166 private JTextField
getJTextFieldToolCode() {
167 if (jTextFieldToolCode
== null) {
168 jTextFieldToolCode
= new JTextField();
169 jTextFieldToolCode
.setBounds(new java
.awt
.Rectangle(168, 62, 340, 20));
170 jTextFieldToolCode
.setPreferredSize(new java
.awt
.Dimension(340, 20));
171 jTextFieldToolCode
.setToolTipText("You may specify a specific tool command, such as ASM");
172 jTextFieldToolCode
.setVisible(false);
174 return jTextFieldToolCode
;
178 * This method initializes jTextFieldToolChainFamily
180 * @return javax.swing.JTextField
182 private JTextField
getJTextFieldToolChainFamily() {
183 if (jTextFieldToolChainFamily
== null) {
184 jTextFieldToolChainFamily
= new JTextField();
185 jTextFieldToolChainFamily
.setBounds(new java
.awt
.Rectangle(168, 87, 340, 20));
186 jTextFieldToolChainFamily
.setPreferredSize(new java
.awt
.Dimension(340, 20));
187 jTextFieldToolChainFamily
.setToolTipText("You may specify a specific tool chain family, such as GCC");
189 return jTextFieldToolChainFamily
;
193 This method initializes jButtonOk
195 @return javax.swing.JButton
198 private JButton
getJButtonOk() {
199 if (jButtonOk
== null) {
200 jButtonOk
= new JButton();
201 jButtonOk
.setBounds(new java
.awt
.Rectangle(317, 202, 90, 20));
202 jButtonOk
.setText("Ok");
203 jButtonOk
.addActionListener(this);
209 This method initializes jButtonCancel
211 @return javax.swing.JButton
214 private JButton
getJButtonCancel() {
215 if (jButtonCancel
== null) {
216 jButtonCancel
= new JButton();
217 jButtonCancel
.setBounds(new java
.awt
.Rectangle(412, 202, 90, 20));
218 jButtonCancel
.setText("Cancel");
219 jButtonCancel
.addActionListener(this);
221 return jButtonCancel
;
225 This method initializes iCheckBoxListArch
227 @return ICheckBoxList
229 private ICheckBoxList
getICheckBoxListSupModuleList() {
230 if (iCheckBoxListBuildTargets
== null) {
231 iCheckBoxListBuildTargets
= new ICheckBoxList();
233 return iCheckBoxListBuildTargets
;
237 This method initializes jScrollPaneBuildTargets
239 @return javax.swing.JScrollPane
242 private JScrollPane
getJScrollPaneBuildTargets() {
243 if (jScrollPaneBuildTargets
== null) {
244 jScrollPaneBuildTargets
= new JScrollPane();
245 jScrollPaneBuildTargets
.setBounds(new java
.awt
.Rectangle(168, 137, 340, 40));
246 jScrollPaneBuildTargets
.setPreferredSize(new java
.awt
.Dimension(340, 40));
247 jScrollPaneBuildTargets
.setViewportView(getICheckBoxListSupModuleList());
249 return jScrollPaneBuildTargets
;
252 public static void main(String
[] args
) {
257 This is the default constructor
260 public BuildOptionsDlg(BuildOptionsIdentification inBuildOptionsIdentification
, IFrame iFrame
,
261 ModuleIdentification mid
) {
263 init(inBuildOptionsIdentification
, mid
);
267 This method initializes this
270 private void init() {
271 this.setSize(525, 270);
272 this.setContentPane(getJScrollPane());
273 this.setTitle("Source Files");
274 this.setViewMode(false);
276 Tools
.generateComboBoxByVector(iComboBoxToolCode
, ed
.getVToolCode());
277 this.iCheckBoxListBuildTargets
.setAllItems(ed
.getVBuildTargets());
281 This method initializes this
282 Fill values to all fields if these values are not empty
285 @param inSourceFiles The input data of SourceFilesDocument.SourceFiles
288 private void init(BuildOptionsIdentification inBuildOptionsIdentification
, ModuleIdentification mid
) {
292 // Init arch with module's arch
294 this.jArchCheckBox
.setEnabledItems(wt
.getModuleArch(mid
));
296 if (inBuildOptionsIdentification
!= null) {
297 this.jTextFieldFileOption
.setText(inBuildOptionsIdentification
.getOption());
298 this.jTextFieldTagName
.setText(inBuildOptionsIdentification
.getTagName());
301 // Generate Tool Code selection list
303 Vector
<String
> v
= ed
.getVToolCode();
304 boolean isFind
= false;
305 String strToolCode
= inBuildOptionsIdentification
.getToolCode();
308 // If the input value is not in the default list, add it to the list
310 if (strToolCode
!= null) {
311 for (int index
= 0; index
< v
.size(); index
++) {
312 if (v
.elementAt(index
).equals(strToolCode
)) {
317 if (!isFind
&& !isEmpty(strToolCode
)) {
318 v
.addElement(strToolCode
);
322 Tools
.generateComboBoxByVector(iComboBoxToolCode
, v
);
323 this.iComboBoxToolCode
.setSelectedItem(strToolCode
);
325 this.jTextFieldToolChainFamily
.setText(inBuildOptionsIdentification
.getToolChainFamily());
327 this.jArchCheckBox
.setSelectedItems(inBuildOptionsIdentification
.getSupArchList());
329 this.iCheckBoxListBuildTargets
.setAllItemsUnchecked();
330 this.iCheckBoxListBuildTargets
.initCheckedItem(true, inBuildOptionsIdentification
.getBuildTargets());
335 Disable all components when the mode is view
337 @param isView true - The view mode; false - The non-view mode
340 public void setViewMode(boolean isView
) {
342 this.jTextFieldFileOption
.setEnabled(!isView
);
347 This method initializes jContentPane
349 @return javax.swing.JPanel jContentPane
352 private JPanel
getJContentPane() {
353 if (jContentPane
== null) {
354 jLabelBuildTargets
= new JLabel();
355 jLabelBuildTargets
.setBounds(new java
.awt
.Rectangle(12, 137, 155, 20));
356 jLabelBuildTargets
.setText("Build Targets");
357 jArchCheckBox
= new ArchCheckBox();
358 jArchCheckBox
.setBounds(new java
.awt
.Rectangle(168, 112, 340, 20));
359 jArchCheckBox
.setPreferredSize(new java
.awt
.Dimension(340, 20));
360 jLabelToolCode
= new JLabel();
361 jLabelToolCode
.setBounds(new java
.awt
.Rectangle(12, 62, 155, 20));
362 jLabelToolCode
.setText("Tool Code");
363 jLabelTagName
= new JLabel();
364 jLabelTagName
.setBounds(new java
.awt
.Rectangle(12, 37, 155, 20));
365 jLabelTagName
.setText("Tag Name");
366 jLabelArch
= new JLabel();
367 jLabelArch
.setBounds(new java
.awt
.Rectangle(12, 112, 155, 20));
368 jLabelArch
.setText("Supported Architectures");
369 jLabelToolChainFamily
= new JLabel();
370 jLabelToolChainFamily
.setBounds(new java
.awt
.Rectangle(12, 87, 155, 20));
371 jLabelToolChainFamily
.setText("Tool Chain Family");
372 jLabelFileName
= new JLabel();
373 jLabelFileName
.setText("Option String");
374 jLabelFileName
.setBounds(new java
.awt
.Rectangle(12, 12, 155, 20));
376 jContentPane
= new JPanel();
377 jContentPane
.setLayout(null);
378 jContentPane
.setPreferredSize(new java
.awt
.Dimension(505, 222));
380 jContentPane
.add(jLabelFileName
, null);
381 jContentPane
.add(getJTextFieldSourceFilesDirectory(), null);
382 jContentPane
.add(jLabelToolChainFamily
, null);
383 jStarLabel1
= new StarLabel();
384 jStarLabel1
.setLocation(new java
.awt
.Point(0, 10));
386 jContentPane
.add(jStarLabel1
, null);
387 jContentPane
.add(jLabelArch
, null);
388 jContentPane
.add(jLabelTagName
, null);
389 jContentPane
.add(getJTextFieldTagName(), null);
390 jContentPane
.add(jLabelToolCode
, null);
391 jContentPane
.add(getJTextFieldToolCode(), null);
392 jContentPane
.add(getIComboBoxToolCode(), null);
393 jContentPane
.add(getJTextFieldToolChainFamily(), null);
394 jContentPane
.add(jArchCheckBox
, null);
395 jContentPane
.add(getJButtonOk(), null);
396 jContentPane
.add(getJButtonCancel(), null);
397 jContentPane
.add(jLabelBuildTargets
, null);
398 jContentPane
.add(getJScrollPaneBuildTargets(), null);
404 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
406 * Override actionPerformed to listen all actions
409 public void actionPerformed(ActionEvent arg0
) {
410 if (arg0
.getSource() == jButtonOk
) {
413 this.returnType
= DataType
.RETURN_TYPE_OK
;
414 this.setVisible(false);
418 if (arg0
.getSource() == jButtonCancel
) {
419 this.returnType
= DataType
.RETURN_TYPE_CANCEL
;
420 this.setVisible(false);
424 private BuildOptionsIdentification
getCurrentId() {
425 String arg0
= this.jTextFieldFileOption
.getText();
426 Vector
<String
> arg1
= this.iCheckBoxListBuildTargets
.getAllCheckedItemsString();
427 String arg2
= this.jTextFieldToolChainFamily
.getText();
428 String arg3
= this.jTextFieldTagName
.getText();
429 String arg4
= this.iComboBoxToolCode
.getSelectedItem().toString();
430 if (arg4
.equals(DataType
.EMPTY_SELECT_ITEM
)) {
433 Vector
<String
> arg5
= this.jArchCheckBox
.getSelectedItemsVector();
435 id
= new BuildOptionsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
440 Data validation for all fields
442 @retval true - All datas are valid
443 @retval false - At least one data is invalid
446 public boolean checkAdd() {
450 if (isEmpty(this.jTextFieldFileOption
.getText())) {
451 Log
.wrn("Update Build Options", "Option String must be entered!");
458 if (!isEmpty(this.jTextFieldTagName
.getText())) {
459 if (!DataValidation
.isTagName(this.jTextFieldTagName
.getText())) {
460 Log
.wrn("Update Build Options", "Incorrect data type for Tag Name");
468 if (!isEmpty(this.jTextFieldToolCode
.getText())) {
469 if (!DataValidation
.isToolCode(this.jTextFieldToolCode
.getText())) {
470 Log
.wrn("Update Build Options", "Incorrect data type for Tool Code");
476 // Check ToolChainFamily
478 if (!isEmpty(this.jTextFieldToolChainFamily
.getText())) {
479 if (!DataValidation
.isToolChainFamily(this.jTextFieldToolChainFamily
.getText())) {
480 Log
.wrn("Update Build Options", "Incorrect data type for Tool Chain Family");
488 public BuildOptionsIdentification
getId() {
492 public void setId(BuildOptionsIdentification id
) {