]>
Commit | Line | Data |
---|---|---|
b3cb8ee7 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to create, update SourceFiles section of the MSA file\r | |
4 | \r | |
5 | Copyright (c) 2006, Intel Corporation\r | |
6 | All rights reserved. This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | package org.tianocore.frameworkwizard.module.ui.dialog;\r | |
16 | \r | |
17 | import java.awt.event.ActionEvent;\r | |
18 | import java.util.Vector;\r | |
19 | \r | |
20 | import javax.swing.JButton;\r | |
21 | import javax.swing.JLabel;\r | |
22 | import javax.swing.JPanel;\r | |
23 | import javax.swing.JScrollPane;\r | |
24 | import javax.swing.JTextField;\r | |
25 | \r | |
26 | import org.tianocore.frameworkwizard.common.DataType;\r | |
27 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
28 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
29 | import org.tianocore.frameworkwizard.common.Log;\r | |
30 | import org.tianocore.frameworkwizard.common.Tools;\r | |
31 | import org.tianocore.frameworkwizard.common.ui.ArchCheckBox;\r | |
32 | import org.tianocore.frameworkwizard.common.ui.IComboBox;\r | |
33 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
34 | import org.tianocore.frameworkwizard.common.ui.IFrame;\r | |
35 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
36 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
37 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r | |
38 | import org.tianocore.frameworkwizard.module.Identifications.BuildOptions.BuildOptionsIdentification;\r | |
39 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r | |
40 | \r | |
41 | /**\r | |
42 | * The class is used to create, update SourceFiles section of the MSA file\r | |
43 | *\r | |
44 | * It extends IDialog\r | |
45 | * \r | |
46 | **/\r | |
47 | public class BuildOptionsDlg extends IDialog {\r | |
48 | \r | |
49 | ///\r | |
50 | /// Define class Serial Version UID\r | |
51 | ///\r | |
52 | private static final long serialVersionUID = -6765742852142775378L;\r | |
53 | \r | |
54 | //\r | |
55 | // Define class members\r | |
56 | //\r | |
57 | private JPanel jContentPane = null;\r | |
58 | \r | |
59 | private JLabel jLabelFileName = null;\r | |
60 | \r | |
61 | private JTextField jTextFieldFileOption = null;\r | |
62 | \r | |
63 | private JLabel jLabelToolChainFamily = null;\r | |
64 | \r | |
65 | private StarLabel jStarLabel1 = null;\r | |
66 | \r | |
67 | private JLabel jLabelArch = null;\r | |
68 | \r | |
69 | private JScrollPane jScrollPane = null;\r | |
70 | \r | |
71 | private JLabel jLabelTagName = null;\r | |
72 | \r | |
73 | private JTextField jTextFieldTagName = null;\r | |
74 | \r | |
75 | private JLabel jLabelToolCode = null;\r | |
76 | \r | |
77 | private JTextField jTextFieldToolCode = null;\r | |
78 | \r | |
79 | private IComboBox iComboBoxToolCode = null;\r | |
80 | \r | |
81 | private JTextField jTextFieldToolChainFamily = null;\r | |
82 | \r | |
83 | private ArchCheckBox jArchCheckBox = null;\r | |
84 | \r | |
85 | private JButton jButtonOk = null;\r | |
86 | \r | |
87 | private JButton jButtonCancel = null;\r | |
88 | \r | |
89 | private JScrollPane jScrollPaneBuildTargets = null;\r | |
90 | \r | |
91 | private ICheckBoxList iCheckBoxListBuildTargets = null;\r | |
92 | \r | |
93 | //\r | |
94 | // Not used by UI\r | |
95 | //\r | |
96 | private BuildOptionsIdentification id = null;\r | |
97 | \r | |
98 | private EnumerationData ed = new EnumerationData();\r | |
99 | \r | |
100 | private WorkspaceTools wt = new WorkspaceTools();\r | |
101 | \r | |
102 | private JLabel jLabelBuildTargets = null;\r | |
103 | \r | |
104 | /**\r | |
105 | This method initializes jTextFieldFileOption \r | |
106 | \r | |
107 | @return javax.swing.JTextField jTextFieldFileOption\r | |
108 | \r | |
109 | **/\r | |
110 | private JTextField getJTextFieldSourceFilesDirectory() {\r | |
111 | if (jTextFieldFileOption == null) {\r | |
112 | jTextFieldFileOption = new JTextField();\r | |
113 | jTextFieldFileOption.setBounds(new java.awt.Rectangle(168, 12, 340, 20));\r | |
114 | jTextFieldFileOption.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
115 | jTextFieldFileOption.setToolTipText("Path is relative to the MSA file and must include the file name");\r | |
116 | }\r | |
117 | return jTextFieldFileOption;\r | |
118 | }\r | |
119 | \r | |
120 | /**\r | |
121 | This method initializes jScrollPane \r | |
122 | \r | |
123 | @return javax.swing.JScrollPane \r | |
124 | */\r | |
125 | private JScrollPane getJScrollPane() {\r | |
126 | if (jScrollPane == null) {\r | |
127 | jScrollPane = new JScrollPane();\r | |
128 | jScrollPane.setViewportView(getJContentPane());\r | |
129 | }\r | |
130 | return jScrollPane;\r | |
131 | }\r | |
132 | \r | |
133 | /**\r | |
134 | * This method initializes jTextFieldTagName \r | |
135 | * \r | |
136 | * @return javax.swing.JTextField \r | |
137 | */\r | |
138 | private JTextField getJTextFieldTagName() {\r | |
139 | if (jTextFieldTagName == null) {\r | |
140 | jTextFieldTagName = new JTextField();\r | |
141 | jTextFieldTagName.setBounds(new java.awt.Rectangle(168, 37, 340, 20));\r | |
142 | jTextFieldTagName.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
143 | jTextFieldTagName.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");\r | |
144 | }\r | |
145 | return jTextFieldTagName;\r | |
146 | }\r | |
147 | \r | |
148 | private IComboBox getIComboBoxToolCode() {\r | |
149 | if (iComboBoxToolCode == null) {\r | |
150 | iComboBoxToolCode = new IComboBox();\r | |
151 | iComboBoxToolCode.setBounds(new java.awt.Rectangle(168, 62, 340, 20));\r | |
152 | iComboBoxToolCode.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
153 | iComboBoxToolCode.setToolTipText("<html>You may select a specific tool command from drop down list,<br>"\r | |
154 | + "or you can DOUBLE-CLICK this field to enter your customized<br>"\r | |
155 | + "tool command.<br>"\r | |
156 | + "Press ENTER to save your input or press ESCAPE to quit</html>");\r | |
157 | }\r | |
158 | return iComboBoxToolCode;\r | |
159 | }\r | |
160 | \r | |
161 | /**\r | |
162 | * This method initializes jTextFieldToolCode \r | |
163 | * \r | |
164 | * @return javax.swing.JTextField \r | |
165 | */\r | |
166 | private JTextField getJTextFieldToolCode() {\r | |
167 | if (jTextFieldToolCode == null) {\r | |
168 | jTextFieldToolCode = new JTextField();\r | |
169 | jTextFieldToolCode.setBounds(new java.awt.Rectangle(168, 62, 340, 20));\r | |
170 | jTextFieldToolCode.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
171 | jTextFieldToolCode.setToolTipText("You may specify a specific tool command, such as ASM");\r | |
172 | jTextFieldToolCode.setVisible(false);\r | |
173 | }\r | |
174 | return jTextFieldToolCode;\r | |
175 | }\r | |
176 | \r | |
177 | /**\r | |
178 | * This method initializes jTextFieldToolChainFamily \r | |
179 | * \r | |
180 | * @return javax.swing.JTextField \r | |
181 | */\r | |
182 | private JTextField getJTextFieldToolChainFamily() {\r | |
183 | if (jTextFieldToolChainFamily == null) {\r | |
184 | jTextFieldToolChainFamily = new JTextField();\r | |
185 | jTextFieldToolChainFamily.setBounds(new java.awt.Rectangle(168, 87, 340, 20));\r | |
186 | jTextFieldToolChainFamily.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
187 | jTextFieldToolChainFamily.setToolTipText("You may specify a specific tool chain family, such as GCC");\r | |
188 | }\r | |
189 | return jTextFieldToolChainFamily;\r | |
190 | }\r | |
191 | \r | |
192 | /**\r | |
193 | This method initializes jButtonOk \r | |
194 | \r | |
195 | @return javax.swing.JButton \r | |
196 | \r | |
197 | **/\r | |
198 | private JButton getJButtonOk() {\r | |
199 | if (jButtonOk == null) {\r | |
200 | jButtonOk = new JButton();\r | |
201 | jButtonOk.setBounds(new java.awt.Rectangle(317, 202, 90, 20));\r | |
202 | jButtonOk.setText("Ok");\r | |
203 | jButtonOk.addActionListener(this);\r | |
204 | }\r | |
205 | return jButtonOk;\r | |
206 | }\r | |
207 | \r | |
208 | /**\r | |
209 | This method initializes jButtonCancel \r | |
210 | \r | |
211 | @return javax.swing.JButton \r | |
212 | \r | |
213 | **/\r | |
214 | private JButton getJButtonCancel() {\r | |
215 | if (jButtonCancel == null) {\r | |
216 | jButtonCancel = new JButton();\r | |
217 | jButtonCancel.setBounds(new java.awt.Rectangle(412, 202, 90, 20));\r | |
218 | jButtonCancel.setText("Cancel");\r | |
219 | jButtonCancel.addActionListener(this);\r | |
220 | }\r | |
221 | return jButtonCancel;\r | |
222 | }\r | |
223 | \r | |
224 | /**\r | |
225 | This method initializes iCheckBoxListArch \r | |
226 | \r | |
227 | @return ICheckBoxList \r | |
228 | **/\r | |
229 | private ICheckBoxList getICheckBoxListSupModuleList() {\r | |
230 | if (iCheckBoxListBuildTargets == null) {\r | |
231 | iCheckBoxListBuildTargets = new ICheckBoxList();\r | |
232 | }\r | |
233 | return iCheckBoxListBuildTargets;\r | |
234 | }\r | |
235 | \r | |
236 | /**\r | |
237 | This method initializes jScrollPaneBuildTargets \r | |
238 | \r | |
239 | @return javax.swing.JScrollPane \r | |
240 | \r | |
241 | **/\r | |
242 | private JScrollPane getJScrollPaneBuildTargets() {\r | |
243 | if (jScrollPaneBuildTargets == null) {\r | |
244 | jScrollPaneBuildTargets = new JScrollPane();\r | |
245 | jScrollPaneBuildTargets.setBounds(new java.awt.Rectangle(168, 137, 340, 40));\r | |
246 | jScrollPaneBuildTargets.setPreferredSize(new java.awt.Dimension(340, 40));\r | |
247 | jScrollPaneBuildTargets.setViewportView(getICheckBoxListSupModuleList());\r | |
248 | }\r | |
249 | return jScrollPaneBuildTargets;\r | |
250 | }\r | |
251 | \r | |
252 | public static void main(String[] args) {\r | |
253 | \r | |
254 | }\r | |
255 | \r | |
256 | /**\r | |
257 | This is the default constructor\r | |
258 | \r | |
259 | **/\r | |
260 | public BuildOptionsDlg(BuildOptionsIdentification inBuildOptionsIdentification, IFrame iFrame,\r | |
261 | ModuleIdentification mid) {\r | |
262 | super(iFrame, true);\r | |
263 | init(inBuildOptionsIdentification, mid);\r | |
264 | }\r | |
265 | \r | |
266 | /**\r | |
267 | This method initializes this\r | |
268 | \r | |
269 | **/\r | |
270 | private void init() {\r | |
271 | this.setSize(525, 270);\r | |
272 | this.setContentPane(getJScrollPane());\r | |
273 | this.setTitle("Source Files");\r | |
274 | this.setViewMode(false);\r | |
275 | this.centerWindow();\r | |
276 | Tools.generateComboBoxByVector(iComboBoxToolCode, ed.getVToolCode());\r | |
277 | this.iCheckBoxListBuildTargets.setAllItems(ed.getVBuildTargets());\r | |
278 | }\r | |
279 | \r | |
280 | /** \r | |
281 | This method initializes this\r | |
282 | Fill values to all fields if these values are not empty\r | |
283 | \r | |
284 | \r | |
285 | @param inSourceFiles The input data of SourceFilesDocument.SourceFiles\r | |
286 | \r | |
287 | **/\r | |
288 | private void init(BuildOptionsIdentification inBuildOptionsIdentification, ModuleIdentification mid) {\r | |
289 | init();\r | |
290 | \r | |
291 | //\r | |
292 | // Init arch with module's arch\r | |
293 | //\r | |
294 | this.jArchCheckBox.setEnabledItems(wt.getModuleArch(mid));\r | |
295 | \r | |
296 | if (inBuildOptionsIdentification != null) {\r | |
297 | this.jTextFieldFileOption.setText(inBuildOptionsIdentification.getOption());\r | |
298 | this.jTextFieldTagName.setText(inBuildOptionsIdentification.getTagName());\r | |
299 | \r | |
300 | //\r | |
301 | // Generate Tool Code selection list\r | |
302 | //\r | |
303 | Vector<String> v = ed.getVToolCode();\r | |
304 | boolean isFind = false;\r | |
305 | String strToolCode = inBuildOptionsIdentification.getToolCode();\r | |
306 | \r | |
307 | //\r | |
308 | // If the input value is not in the default list, add it to the list\r | |
309 | //\r | |
310 | if (strToolCode != null) {\r | |
311 | for (int index = 0; index < v.size(); index++) {\r | |
312 | if (v.elementAt(index).equals(strToolCode)) {\r | |
313 | isFind = true;\r | |
314 | break;\r | |
315 | }\r | |
316 | }\r | |
317 | if (!isFind && !isEmpty(strToolCode)) {\r | |
318 | v.addElement(strToolCode);\r | |
319 | }\r | |
320 | }\r | |
321 | \r | |
322 | Tools.generateComboBoxByVector(iComboBoxToolCode, v);\r | |
323 | this.iComboBoxToolCode.setSelectedItem(strToolCode);\r | |
324 | \r | |
325 | this.jTextFieldToolChainFamily.setText(inBuildOptionsIdentification.getToolChainFamily());\r | |
326 | \r | |
327 | this.jArchCheckBox.setSelectedItems(inBuildOptionsIdentification.getSupArchList());\r | |
328 | \r | |
329 | this.iCheckBoxListBuildTargets.setAllItemsUnchecked();\r | |
330 | this.iCheckBoxListBuildTargets.initCheckedItem(true, inBuildOptionsIdentification.getBuildTargets());\r | |
331 | }\r | |
332 | }\r | |
333 | \r | |
334 | /**\r | |
335 | Disable all components when the mode is view\r | |
336 | \r | |
337 | @param isView true - The view mode; false - The non-view mode\r | |
338 | \r | |
339 | **/\r | |
340 | public void setViewMode(boolean isView) {\r | |
341 | if (isView) {\r | |
342 | this.jTextFieldFileOption.setEnabled(!isView);\r | |
343 | }\r | |
344 | }\r | |
345 | \r | |
346 | /**\r | |
347 | This method initializes jContentPane\r | |
348 | \r | |
349 | @return javax.swing.JPanel jContentPane\r | |
350 | \r | |
351 | **/\r | |
352 | private JPanel getJContentPane() {\r | |
353 | if (jContentPane == null) {\r | |
354 | jLabelBuildTargets = new JLabel();\r | |
355 | jLabelBuildTargets.setBounds(new java.awt.Rectangle(12, 137, 155, 20));\r | |
356 | jLabelBuildTargets.setText("Build Targets");\r | |
357 | jArchCheckBox = new ArchCheckBox();\r | |
358 | jArchCheckBox.setBounds(new java.awt.Rectangle(168, 112, 340, 20));\r | |
359 | jArchCheckBox.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
360 | jLabelToolCode = new JLabel();\r | |
361 | jLabelToolCode.setBounds(new java.awt.Rectangle(12, 62, 155, 20));\r | |
362 | jLabelToolCode.setText("Tool Code");\r | |
363 | jLabelTagName = new JLabel();\r | |
364 | jLabelTagName.setBounds(new java.awt.Rectangle(12, 37, 155, 20));\r | |
365 | jLabelTagName.setText("Tag Name");\r | |
366 | jLabelArch = new JLabel();\r | |
367 | jLabelArch.setBounds(new java.awt.Rectangle(12, 112, 155, 20));\r | |
368 | jLabelArch.setText("Supported Architectures");\r | |
369 | jLabelToolChainFamily = new JLabel();\r | |
370 | jLabelToolChainFamily.setBounds(new java.awt.Rectangle(12, 87, 155, 20));\r | |
371 | jLabelToolChainFamily.setText("Tool Chain Family");\r | |
372 | jLabelFileName = new JLabel();\r | |
373 | jLabelFileName.setText("Option String");\r | |
374 | jLabelFileName.setBounds(new java.awt.Rectangle(12, 12, 155, 20));\r | |
375 | \r | |
376 | jContentPane = new JPanel();\r | |
377 | jContentPane.setLayout(null);\r | |
378 | jContentPane.setPreferredSize(new java.awt.Dimension(505, 222));\r | |
379 | \r | |
380 | jContentPane.add(jLabelFileName, null);\r | |
381 | jContentPane.add(getJTextFieldSourceFilesDirectory(), null);\r | |
382 | jContentPane.add(jLabelToolChainFamily, null);\r | |
383 | jStarLabel1 = new StarLabel();\r | |
384 | jStarLabel1.setLocation(new java.awt.Point(0, 10));\r | |
385 | \r | |
386 | jContentPane.add(jStarLabel1, null);\r | |
387 | jContentPane.add(jLabelArch, null);\r | |
388 | jContentPane.add(jLabelTagName, null);\r | |
389 | jContentPane.add(getJTextFieldTagName(), null);\r | |
390 | jContentPane.add(jLabelToolCode, null);\r | |
391 | jContentPane.add(getJTextFieldToolCode(), null);\r | |
392 | jContentPane.add(getIComboBoxToolCode(), null);\r | |
393 | jContentPane.add(getJTextFieldToolChainFamily(), null);\r | |
394 | jContentPane.add(jArchCheckBox, null);\r | |
395 | jContentPane.add(getJButtonOk(), null);\r | |
396 | jContentPane.add(getJButtonCancel(), null);\r | |
397 | jContentPane.add(jLabelBuildTargets, null);\r | |
398 | jContentPane.add(getJScrollPaneBuildTargets(), null);\r | |
399 | }\r | |
400 | return jContentPane;\r | |
401 | }\r | |
402 | \r | |
403 | /* (non-Javadoc)\r | |
404 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
405 | *\r | |
406 | * Override actionPerformed to listen all actions\r | |
407 | * \r | |
408 | */\r | |
409 | public void actionPerformed(ActionEvent arg0) {\r | |
410 | if (arg0.getSource() == jButtonOk) {\r | |
411 | if (checkAdd()) {\r | |
412 | getCurrentId();\r | |
413 | this.returnType = DataType.RETURN_TYPE_OK;\r | |
414 | this.setVisible(false);\r | |
415 | }\r | |
416 | }\r | |
417 | \r | |
418 | if (arg0.getSource() == jButtonCancel) {\r | |
419 | this.returnType = DataType.RETURN_TYPE_CANCEL;\r | |
420 | this.setVisible(false);\r | |
421 | }\r | |
422 | }\r | |
423 | \r | |
424 | private BuildOptionsIdentification getCurrentId() {\r | |
425 | String arg0 = this.jTextFieldFileOption.getText();\r | |
426 | Vector<String> arg1 = this.iCheckBoxListBuildTargets.getAllCheckedItemsString();\r | |
427 | String arg2 = this.jTextFieldToolChainFamily.getText();\r | |
428 | String arg3 = this.jTextFieldTagName.getText();\r | |
429 | String arg4 = this.iComboBoxToolCode.getSelectedItem().toString();\r | |
430 | if (arg4.equals(DataType.EMPTY_SELECT_ITEM)) {\r | |
431 | arg4 = "";\r | |
432 | }\r | |
433 | Vector<String> arg5 = this.jArchCheckBox.getSelectedItemsVector();\r | |
434 | \r | |
435 | id = new BuildOptionsIdentification(arg0, arg1, arg2, arg3, arg4, arg5);\r | |
436 | return id;\r | |
437 | }\r | |
438 | \r | |
439 | /**\r | |
440 | Data validation for all fields\r | |
441 | \r | |
442 | @retval true - All datas are valid\r | |
443 | @retval false - At least one data is invalid\r | |
444 | \r | |
445 | **/\r | |
446 | public boolean checkAdd() {\r | |
447 | //\r | |
448 | // Check Option\r | |
449 | //\r | |
450 | if (isEmpty(this.jTextFieldFileOption.getText())) {\r | |
451 | Log.wrn("Update Build Options", "Option String must be entered!");\r | |
452 | return false;\r | |
453 | }\r | |
454 | \r | |
455 | //\r | |
456 | // Check TagName \r | |
457 | //\r | |
458 | if (!isEmpty(this.jTextFieldTagName.getText())) {\r | |
459 | if (!DataValidation.isTagName(this.jTextFieldTagName.getText())) {\r | |
460 | Log.wrn("Update Build Options", "Incorrect data type for Tag Name");\r | |
461 | return false;\r | |
462 | }\r | |
463 | }\r | |
464 | \r | |
465 | //\r | |
466 | // Check ToolCode \r | |
467 | //\r | |
468 | if (!isEmpty(this.jTextFieldToolCode.getText())) {\r | |
469 | if (!DataValidation.isToolCode(this.jTextFieldToolCode.getText())) {\r | |
470 | Log.wrn("Update Build Options", "Incorrect data type for Tool Code");\r | |
471 | return false;\r | |
472 | }\r | |
473 | }\r | |
474 | \r | |
475 | //\r | |
476 | // Check ToolChainFamily \r | |
477 | //\r | |
478 | if (!isEmpty(this.jTextFieldToolChainFamily.getText())) {\r | |
479 | if (!DataValidation.isToolChainFamily(this.jTextFieldToolChainFamily.getText())) {\r | |
480 | Log.wrn("Update Build Options", "Incorrect data type for Tool Chain Family");\r | |
481 | return false;\r | |
482 | }\r | |
483 | }\r | |
484 | \r | |
485 | return true;\r | |
486 | }\r | |
487 | \r | |
488 | public BuildOptionsIdentification getId() {\r | |
489 | return id;\r | |
490 | }\r | |
491 | \r | |
492 | public void setId(BuildOptionsIdentification id) {\r | |
493 | this.id = id;\r | |
494 | }\r | |
495 | }\r |