]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | \r | |
3 | The file is used to create, update SourceFile of MSA/MBD 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;\r | |
16 | \r | |
17 | import java.awt.event.ActionEvent;\r | |
18 | import java.awt.event.ComponentEvent;\r | |
19 | import java.awt.event.ItemEvent;\r | |
20 | import java.util.Vector;\r | |
21 | \r | |
22 | import javax.swing.JButton;\r | |
23 | import javax.swing.JCheckBox;\r | |
24 | import javax.swing.JComboBox;\r | |
25 | import javax.swing.JFileChooser;\r | |
26 | import javax.swing.JLabel;\r | |
27 | import javax.swing.JPanel;\r | |
28 | import javax.swing.JScrollPane;\r | |
29 | import javax.swing.JTextArea;\r | |
30 | import javax.swing.JTextField;\r | |
31 | \r | |
32 | import org.tianocore.SourceFilesDocument;\r | |
33 | import org.tianocore.FilenameDocument.Filename;\r | |
34 | import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;\r | |
35 | import org.tianocore.SourceFilesDocument.SourceFiles;\r | |
36 | import org.tianocore.frameworkwizard.common.DataType;\r | |
37 | import org.tianocore.frameworkwizard.common.DataValidation;\r | |
38 | import org.tianocore.frameworkwizard.common.EnumerationData;\r | |
39 | import org.tianocore.frameworkwizard.common.Log;\r | |
40 | import org.tianocore.frameworkwizard.common.OpeningModuleType;\r | |
41 | import org.tianocore.frameworkwizard.common.Tools;\r | |
42 | import org.tianocore.frameworkwizard.common.ui.IInternalFrame;\r | |
43 | import org.tianocore.frameworkwizard.common.ui.StarLabel;\r | |
44 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
45 | import org.tianocore.frameworkwizard.module.Identification.SourceFiles.SourceFilesIdentification;\r | |
46 | import org.tianocore.frameworkwizard.module.Identification.SourceFiles.SourceFilesVector;\r | |
47 | import org.tianocore.frameworkwizard.workspace.Workspace;\r | |
48 | \r | |
49 | /**\r | |
50 | The class is used to create, update SourceFile of MSA/MBD file\r | |
51 | It extends IInternalFrame\r | |
52 | \r | |
53 | \r | |
54 | \r | |
55 | **/\r | |
56 | public class ModuleSourceFiles extends IInternalFrame {\r | |
57 | \r | |
58 | ///\r | |
59 | /// Define class Serial Version UID\r | |
60 | ///\r | |
61 | private static final long serialVersionUID = -6765742852142775378L;\r | |
62 | \r | |
63 | //\r | |
64 | // Define class members\r | |
65 | //\r | |
66 | private SourceFilesDocument.SourceFiles sourceFiles = null;\r | |
67 | \r | |
68 | private int intSelectedItemId = 0;\r | |
69 | \r | |
70 | private JPanel jContentPane = null;\r | |
71 | \r | |
72 | private JLabel jLabelFileName = null;\r | |
73 | \r | |
74 | private JTextField jTextFieldFileName = null;\r | |
75 | \r | |
76 | private JButton jButtonOpenFile = null;\r | |
77 | \r | |
78 | private JLabel jLabelToolChainFamily = null;\r | |
79 | \r | |
80 | private StarLabel jStarLabel1 = null;\r | |
81 | \r | |
82 | private JComboBox jComboBoxList = null;\r | |
83 | \r | |
84 | private JButton jButtonAdd = null;\r | |
85 | \r | |
86 | private JButton jButtonRemove = null;\r | |
87 | \r | |
88 | private JButton jButtonUpdate = null;\r | |
89 | \r | |
90 | private JCheckBox jCheckBoxArch = null;\r | |
91 | \r | |
92 | private JScrollPane jScrollPaneList = null;\r | |
93 | \r | |
94 | private JTextArea jTextAreaList = null;\r | |
95 | \r | |
96 | private JLabel jLabelArch = null;\r | |
97 | \r | |
98 | private JScrollPane jScrollPane = null;\r | |
99 | \r | |
100 | private JLabel jLabelTagName = null;\r | |
101 | \r | |
102 | private JTextField jTextFieldTagName = null;\r | |
103 | \r | |
104 | private JLabel jLabelToolCode = null;\r | |
105 | \r | |
106 | private JTextField jTextFieldToolCode = null;\r | |
107 | \r | |
108 | private JTextField jTextFieldToolChainFamily = null;\r | |
109 | \r | |
110 | private JLabel jLabelFeatureFlag = null;\r | |
111 | \r | |
112 | private JTextField jTextFieldFeatureFlag = null;\r | |
113 | \r | |
114 | private ICheckBoxList iCheckBoxListArch = null;\r | |
115 | \r | |
116 | private JScrollPane jScrollPaneArch = null;\r | |
117 | \r | |
118 | //\r | |
119 | // Not used by UI\r | |
120 | //\r | |
121 | private OpeningModuleType omt = null;\r | |
122 | \r | |
123 | private ModuleSurfaceArea msa = null;\r | |
124 | \r | |
125 | private SourceFilesIdentification sfid = null;\r | |
126 | \r | |
127 | private SourceFilesVector vSourceFiles = new SourceFilesVector();\r | |
128 | \r | |
129 | /**\r | |
130 | This method initializes jTextFieldFileName \r | |
131 | \r | |
132 | @return javax.swing.JTextField jTextFieldFileName\r | |
133 | \r | |
134 | **/\r | |
135 | private JTextField getJTextFieldSourceFilesDirectory() {\r | |
136 | if (jTextFieldFileName == null) {\r | |
137 | jTextFieldFileName = new JTextField();\r | |
138 | jTextFieldFileName.setBounds(new java.awt.Rectangle(140, 10, 250, 20));\r | |
139 | jTextFieldFileName.setPreferredSize(new java.awt.Dimension(250, 20));\r | |
140 | jTextFieldFileName.setToolTipText("Path is relative to the MSA file and must include the file name");\r | |
141 | }\r | |
142 | return jTextFieldFileName;\r | |
143 | }\r | |
144 | \r | |
145 | /**\r | |
146 | This method initializes jButtonOpenFile \r | |
147 | \r | |
148 | @return javax.swing.JButton jButtonOpenFile\r | |
149 | \r | |
150 | **/\r | |
151 | private JButton getJButtonOpenFile() {\r | |
152 | if (jButtonOpenFile == null) {\r | |
153 | jButtonOpenFile = new JButton();\r | |
154 | jButtonOpenFile.setText("Browse");\r | |
155 | jButtonOpenFile.setBounds(new java.awt.Rectangle(395, 10, 85, 20));\r | |
156 | jButtonOpenFile.setPreferredSize(new java.awt.Dimension(85, 20));\r | |
157 | jButtonOpenFile.addActionListener(this);\r | |
158 | }\r | |
159 | return jButtonOpenFile;\r | |
160 | }\r | |
161 | \r | |
162 | /**\r | |
163 | This method initializes jComboBoxFileList \r | |
164 | \r | |
165 | @return javax.swing.JComboBox jComboBoxFileList\r | |
166 | \r | |
167 | **/\r | |
168 | private JComboBox getJComboBoxList() {\r | |
169 | if (jComboBoxList == null) {\r | |
170 | jComboBoxList = new JComboBox();\r | |
171 | jComboBoxList.setBounds(new java.awt.Rectangle(15, 220, 210, 20));\r | |
172 | jComboBoxList.addItemListener(this);\r | |
173 | jComboBoxList.addActionListener(this);\r | |
174 | jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));\r | |
175 | }\r | |
176 | return jComboBoxList;\r | |
177 | }\r | |
178 | \r | |
179 | /**\r | |
180 | This method initializes jButtonAdd \r | |
181 | \r | |
182 | @return javax.swing.JButton jButtonAdd\r | |
183 | \r | |
184 | **/\r | |
185 | private JButton getJButtonAdd() {\r | |
186 | if (jButtonAdd == null) {\r | |
187 | jButtonAdd = new JButton();\r | |
188 | jButtonAdd.setBounds(new java.awt.Rectangle(230, 220, 80, 20));\r | |
189 | jButtonAdd.setText("Add");\r | |
190 | jButtonAdd.addActionListener(this);\r | |
191 | jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));\r | |
192 | }\r | |
193 | return jButtonAdd;\r | |
194 | }\r | |
195 | \r | |
196 | /**\r | |
197 | This method initializes jButtonRemove \r | |
198 | \r | |
199 | @return javax.swing.JButton jButtonRemove\r | |
200 | \r | |
201 | **/\r | |
202 | private JButton getJButtonRemove() {\r | |
203 | if (jButtonRemove == null) {\r | |
204 | jButtonRemove = new JButton();\r | |
205 | jButtonRemove.setBounds(new java.awt.Rectangle(400, 220, 80, 20));\r | |
206 | jButtonRemove.setText("Remove");\r | |
207 | jButtonRemove.addActionListener(this);\r | |
208 | jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));\r | |
209 | }\r | |
210 | return jButtonRemove;\r | |
211 | }\r | |
212 | \r | |
213 | /**\r | |
214 | This method initializes jButtonUpdate \r | |
215 | \r | |
216 | @return javax.swing.JButton jButtonUpdate\r | |
217 | \r | |
218 | **/\r | |
219 | private JButton getJButtonUpdate() {\r | |
220 | if (jButtonUpdate == null) {\r | |
221 | jButtonUpdate = new JButton();\r | |
222 | jButtonUpdate.setBounds(new java.awt.Rectangle(315, 220, 80, 20));\r | |
223 | jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));\r | |
224 | jButtonUpdate.setText("Update");\r | |
225 | jButtonUpdate.addActionListener(this);\r | |
226 | }\r | |
227 | return jButtonUpdate;\r | |
228 | }\r | |
229 | \r | |
230 | /**\r | |
231 | * This method initializes jScrollPaneFileList \r | |
232 | * \r | |
233 | * @return javax.swing.JScrollPane \r | |
234 | */\r | |
235 | private JScrollPane getJScrollPaneList() {\r | |
236 | if (jScrollPaneList == null) {\r | |
237 | jScrollPaneList = new JScrollPane();\r | |
238 | jScrollPaneList.setBounds(new java.awt.Rectangle(15, 245, 465, 240));\r | |
239 | jScrollPaneList.setViewportView(getJTextAreaList());\r | |
240 | jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));\r | |
241 | }\r | |
242 | return jScrollPaneList;\r | |
243 | }\r | |
244 | \r | |
245 | /**\r | |
246 | * This method initializes jTextAreaFileList \r | |
247 | * \r | |
248 | * @return javax.swing.JTextArea \r | |
249 | */\r | |
250 | private JTextArea getJTextAreaList() {\r | |
251 | if (jTextAreaList == null) {\r | |
252 | jTextAreaList = new JTextArea();\r | |
253 | jTextAreaList.setEditable(false);\r | |
254 | \r | |
255 | }\r | |
256 | return jTextAreaList;\r | |
257 | }\r | |
258 | \r | |
259 | /**\r | |
260 | This method initializes jScrollPane \r | |
261 | \r | |
262 | @return javax.swing.JScrollPane \r | |
263 | */\r | |
264 | private JScrollPane getJScrollPane() {\r | |
265 | if (jScrollPane == null) {\r | |
266 | jScrollPane = new JScrollPane();\r | |
267 | jScrollPane.setViewportView(getJContentPane());\r | |
268 | }\r | |
269 | return jScrollPane;\r | |
270 | }\r | |
271 | \r | |
272 | /**\r | |
273 | * This method initializes jTextFieldTagName \r | |
274 | * \r | |
275 | * @return javax.swing.JTextField \r | |
276 | */\r | |
277 | private JTextField getJTextFieldTagName() {\r | |
278 | if (jTextFieldTagName == null) {\r | |
279 | jTextFieldTagName = new JTextField();\r | |
280 | jTextFieldTagName.setBounds(new java.awt.Rectangle(140, 35, 340, 20));\r | |
281 | jTextFieldTagName.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
282 | jTextFieldTagName.setToolTipText("You may specify a specific tool chain tag name, such as BILL1");\r | |
283 | }\r | |
284 | return jTextFieldTagName;\r | |
285 | }\r | |
286 | \r | |
287 | /**\r | |
288 | * This method initializes jTextFieldToolCode \r | |
289 | * \r | |
290 | * @return javax.swing.JTextField \r | |
291 | */\r | |
292 | private JTextField getJTextFieldToolCode() {\r | |
293 | if (jTextFieldToolCode == null) {\r | |
294 | jTextFieldToolCode = new JTextField();\r | |
295 | jTextFieldToolCode.setBounds(new java.awt.Rectangle(140, 60, 340, 20));\r | |
296 | jTextFieldToolCode.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
297 | jTextFieldToolCode.setToolTipText("You may specify a specific tool command, such as ASM");\r | |
298 | }\r | |
299 | return jTextFieldToolCode;\r | |
300 | }\r | |
301 | \r | |
302 | /**\r | |
303 | * This method initializes jTextFieldToolChainFamily \r | |
304 | * \r | |
305 | * @return javax.swing.JTextField \r | |
306 | */\r | |
307 | private JTextField getJTextFieldToolChainFamily() {\r | |
308 | if (jTextFieldToolChainFamily == null) {\r | |
309 | jTextFieldToolChainFamily = new JTextField();\r | |
310 | jTextFieldToolChainFamily.setBounds(new java.awt.Rectangle(140, 85, 340, 20));\r | |
311 | jTextFieldToolChainFamily.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
312 | jTextFieldToolChainFamily.setToolTipText("You may specify a specific tool chain family, such as GCC");\r | |
313 | }\r | |
314 | return jTextFieldToolChainFamily;\r | |
315 | }\r | |
316 | \r | |
317 | /**\r | |
318 | * This method initializes jTextFieldFeatureFlag \r | |
319 | * \r | |
320 | * @return javax.swing.JTextField \r | |
321 | */\r | |
322 | private JTextField getJTextFieldFeatureFlag() {\r | |
323 | if (jTextFieldFeatureFlag == null) {\r | |
324 | jTextFieldFeatureFlag = new JTextField();\r | |
325 | jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(140, 110, 340, 20));\r | |
326 | jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(340, 20));\r | |
327 | jTextFieldFeatureFlag.setToolTipText("RESERVED FOR FUTURE USE");\r | |
328 | }\r | |
329 | return jTextFieldFeatureFlag;\r | |
330 | }\r | |
331 | \r | |
332 | /**\r | |
333 | This method initializes iCheckBoxListArch \r | |
334 | \r | |
335 | @return ICheckBoxList \r | |
336 | **/\r | |
337 | private ICheckBoxList getICheckBoxListSupportedArchitectures() {\r | |
338 | if (iCheckBoxListArch == null) {\r | |
339 | iCheckBoxListArch = new ICheckBoxList();\r | |
340 | iCheckBoxListArch.addFocusListener(this);\r | |
341 | iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r | |
342 | }\r | |
343 | return iCheckBoxListArch;\r | |
344 | }\r | |
345 | \r | |
346 | /**\r | |
347 | This method initializes jScrollPaneArch \r | |
348 | \r | |
349 | @return javax.swing.JScrollPane \r | |
350 | \r | |
351 | **/\r | |
352 | private JScrollPane getJScrollPaneArch() {\r | |
353 | if (jScrollPaneArch == null) {\r | |
354 | jScrollPaneArch = new JScrollPane();\r | |
355 | jScrollPaneArch.setBounds(new java.awt.Rectangle(140, 135, 340, 80));\r | |
356 | jScrollPaneArch.setPreferredSize(new java.awt.Dimension(340, 80));\r | |
357 | jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());\r | |
358 | }\r | |
359 | return jScrollPaneArch;\r | |
360 | }\r | |
361 | \r | |
362 | public static void main(String[] args) {\r | |
363 | \r | |
364 | }\r | |
365 | \r | |
366 | /**\r | |
367 | This is the default constructor\r | |
368 | \r | |
369 | **/\r | |
370 | public ModuleSourceFiles() {\r | |
371 | super();\r | |
372 | init();\r | |
373 | this.setVisible(true);\r | |
374 | }\r | |
375 | \r | |
376 | /**\r | |
377 | This is the override edit constructor\r | |
378 | \r | |
379 | @param \r | |
380 | \r | |
381 | **/\r | |
382 | public ModuleSourceFiles(OpeningModuleType inOmt) {\r | |
383 | super();\r | |
384 | this.omt = inOmt;\r | |
385 | this.msa = inOmt.getXmlMsa();\r | |
386 | init(msa.getSourceFiles());\r | |
387 | this.setVisible(true);\r | |
388 | }\r | |
389 | \r | |
390 | /** \r | |
391 | This method initializes this\r | |
392 | Fill values to all fields if these values are not empty\r | |
393 | \r | |
394 | \r | |
395 | @param inSourceFiles The input data of SourceFilesDocument.SourceFiles\r | |
396 | \r | |
397 | **/\r | |
398 | private void init(SourceFilesDocument.SourceFiles inSourceFiles) {\r | |
399 | init();\r | |
400 | this.sourceFiles = inSourceFiles;\r | |
401 | \r | |
402 | if (this.sourceFiles != null) {\r | |
403 | if (this.sourceFiles.getFilenameList().size() > 0) {\r | |
404 | for (int index = 0; index < this.sourceFiles.getFilenameList().size(); index++) {\r | |
405 | String name = sourceFiles.getFilenameList().get(index).getStringValue();\r | |
406 | String tagName = sourceFiles.getFilenameList().get(index).getTagName();\r | |
407 | String toolCode = sourceFiles.getFilenameList().get(index).getToolCode();\r | |
408 | String tcf = sourceFiles.getFilenameList().get(index).getToolChainFamily();\r | |
409 | String featureFlag = sourceFiles.getFilenameList().get(index).getFeatureFlag();\r | |
410 | Vector<String> arch = Tools.convertListToVector(sourceFiles.getFilenameList().get(index)\r | |
411 | .getSupArchList());\r | |
412 | SourceFilesIdentification sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf,\r | |
413 | featureFlag, arch);\r | |
414 | vSourceFiles.addSourceFiles(sfid);\r | |
415 | }\r | |
416 | }\r | |
417 | }\r | |
418 | //\r | |
419 | // Update the list\r | |
420 | //\r | |
421 | Tools.generateComboBoxByVector(jComboBoxList, vSourceFiles.getSourceFilesName());\r | |
422 | reloadListArea();\r | |
423 | }\r | |
424 | \r | |
425 | /**\r | |
426 | This method initializes this\r | |
427 | \r | |
428 | **/\r | |
429 | private void init() {\r | |
430 | this.setSize(500, 515);\r | |
431 | this.setContentPane(getJScrollPane());\r | |
432 | this.setTitle("Source Files");\r | |
433 | initFrame();\r | |
434 | this.setViewMode(false);\r | |
435 | }\r | |
436 | \r | |
437 | /**\r | |
438 | Disable all components when the mode is view\r | |
439 | \r | |
440 | @param isView true - The view mode; false - The non-view mode\r | |
441 | \r | |
442 | **/\r | |
443 | public void setViewMode(boolean isView) {\r | |
444 | if (isView) {\r | |
445 | this.jTextFieldFileName.setEnabled(!isView);\r | |
446 | this.jButtonOpenFile.setEnabled(!isView);\r | |
447 | \r | |
448 | this.jButtonAdd.setEnabled(!isView);\r | |
449 | this.jButtonRemove.setEnabled(!isView);\r | |
450 | this.jButtonUpdate.setEnabled(!isView);\r | |
451 | this.jCheckBoxArch.setEnabled(!isView);\r | |
452 | }\r | |
453 | }\r | |
454 | \r | |
455 | /**\r | |
456 | This method initializes jContentPane\r | |
457 | \r | |
458 | @return javax.swing.JPanel jContentPane\r | |
459 | \r | |
460 | **/\r | |
461 | private JPanel getJContentPane() {\r | |
462 | if (jContentPane == null) {\r | |
463 | jLabelFeatureFlag = new JLabel();\r | |
464 | jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 110, 120, 20));\r | |
465 | jLabelFeatureFlag.setText("Feature Flag");\r | |
466 | jLabelToolCode = new JLabel();\r | |
467 | jLabelToolCode.setBounds(new java.awt.Rectangle(15, 60, 120, 20));\r | |
468 | jLabelToolCode.setText("Tool Code");\r | |
469 | jLabelTagName = new JLabel();\r | |
470 | jLabelTagName.setBounds(new java.awt.Rectangle(15, 35, 120, 20));\r | |
471 | jLabelTagName.setText("Tag Name");\r | |
472 | jLabelArch = new JLabel();\r | |
473 | jLabelArch.setBounds(new java.awt.Rectangle(15, 135, 120, 20));\r | |
474 | jLabelArch.setText("Sup Arch List");\r | |
475 | jLabelToolChainFamily = new JLabel();\r | |
476 | jLabelToolChainFamily.setBounds(new java.awt.Rectangle(15, 85, 120, 20));\r | |
477 | jLabelToolChainFamily.setText("Tool Chain Family");\r | |
478 | jLabelFileName = new JLabel();\r | |
479 | jLabelFileName.setText("File Name");\r | |
480 | jLabelFileName.setBounds(new java.awt.Rectangle(15, 10, 120, 20));\r | |
481 | \r | |
482 | jContentPane = new JPanel();\r | |
483 | jContentPane.setLayout(null);\r | |
484 | jContentPane.setPreferredSize(new java.awt.Dimension(490, 490));\r | |
485 | \r | |
486 | jContentPane.add(jLabelFileName, null);\r | |
487 | jContentPane.add(getJTextFieldSourceFilesDirectory(), null);\r | |
488 | jContentPane.add(getJButtonOpenFile(), null);\r | |
489 | jContentPane.add(jLabelToolChainFamily, null);\r | |
490 | jStarLabel1 = new StarLabel();\r | |
491 | jStarLabel1.setLocation(new java.awt.Point(0, 10));\r | |
492 | \r | |
493 | jContentPane.add(jStarLabel1, null);\r | |
494 | jContentPane.add(getJComboBoxList(), null);\r | |
495 | jContentPane.add(getJButtonAdd(), null);\r | |
496 | jContentPane.add(getJButtonRemove(), null);\r | |
497 | jContentPane.add(getJButtonUpdate(), null);\r | |
498 | jContentPane.add(getJScrollPaneList(), null);\r | |
499 | jContentPane.add(jLabelArch, null);\r | |
500 | jContentPane.add(jLabelTagName, null);\r | |
501 | jContentPane.add(getJTextFieldTagName(), null);\r | |
502 | jContentPane.add(jLabelToolCode, null);\r | |
503 | jContentPane.add(getJTextFieldToolCode(), null);\r | |
504 | jContentPane.add(getJTextFieldToolChainFamily(), null);\r | |
505 | jContentPane.add(jLabelFeatureFlag, null);\r | |
506 | jContentPane.add(getJTextFieldFeatureFlag(), null);\r | |
507 | jContentPane.add(getJScrollPaneArch(), null);\r | |
508 | }\r | |
509 | return jContentPane;\r | |
510 | }\r | |
511 | \r | |
512 | /* (non-Javadoc)\r | |
513 | * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)\r | |
514 | *\r | |
515 | * Override actionPerformed to listen all actions\r | |
516 | * \r | |
517 | */\r | |
518 | public void actionPerformed(ActionEvent arg0) {\r | |
519 | if (arg0.getSource() == jButtonOpenFile) {\r | |
520 | selectFile();\r | |
521 | }\r | |
522 | if (arg0.getSource() == jButtonAdd) {\r | |
523 | if (!checkAdd()) {\r | |
524 | return;\r | |
525 | }\r | |
526 | addToList();\r | |
527 | }\r | |
528 | if (arg0.getSource() == jButtonRemove) {\r | |
529 | removeFromList();\r | |
530 | }\r | |
531 | if (arg0.getSource() == jButtonUpdate) {\r | |
532 | if (!checkAdd()) {\r | |
533 | return;\r | |
534 | }\r | |
535 | updateForList();\r | |
536 | }\r | |
537 | }\r | |
538 | \r | |
539 | /**\r | |
540 | This method initializes Usage type and Arch type\r | |
541 | \r | |
542 | **/\r | |
543 | private void initFrame() {\r | |
544 | EnumerationData ed = new EnumerationData();\r | |
545 | \r | |
546 | this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());\r | |
547 | }\r | |
548 | \r | |
549 | private SourceFilesIdentification getCurrentSourceFiles() {\r | |
550 | String name = this.jTextFieldFileName.getText();\r | |
551 | String tagName = this.jTextFieldTagName.getText();\r | |
552 | String toolCode = this.jTextFieldToolCode.getText();\r | |
553 | String tcf = this.jTextFieldToolChainFamily.getText();\r | |
554 | String featureFlag = this.jTextFieldFeatureFlag.getText();\r | |
555 | Vector<String> arch = this.iCheckBoxListArch.getAllCheckedItemsString();\r | |
556 | sfid = new SourceFilesIdentification(name, tagName, toolCode, tcf, featureFlag, arch);\r | |
557 | return sfid;\r | |
558 | }\r | |
559 | \r | |
560 | /**\r | |
561 | Add current item to Vector\r | |
562 | \r | |
563 | **/\r | |
564 | private void addToList() {\r | |
565 | intSelectedItemId = vSourceFiles.size();\r | |
566 | \r | |
567 | vSourceFiles.addSourceFiles(getCurrentSourceFiles());\r | |
568 | \r | |
569 | jComboBoxList.addItem(sfid.getFilename());\r | |
570 | jComboBoxList.setSelectedItem(sfid.getFilename());\r | |
571 | \r | |
572 | //\r | |
573 | // Reset select item index\r | |
574 | //\r | |
575 | intSelectedItemId = vSourceFiles.size();\r | |
576 | \r | |
577 | //\r | |
578 | // Reload all fields of selected item\r | |
579 | //\r | |
580 | reloadFromList();\r | |
581 | \r | |
582 | // \r | |
583 | // Save to memory\r | |
584 | //\r | |
585 | save();\r | |
586 | }\r | |
587 | \r | |
588 | /**\r | |
589 | Remove current item from Vector\r | |
590 | \r | |
591 | **/\r | |
592 | private void removeFromList() {\r | |
593 | //\r | |
594 | // Check if exist items\r | |
595 | //\r | |
596 | if (this.vSourceFiles.size() < 1) {\r | |
597 | return;\r | |
598 | }\r | |
599 | \r | |
600 | int intTempIndex = intSelectedItemId;\r | |
601 | \r | |
602 | jComboBoxList.removeItemAt(intSelectedItemId);\r | |
603 | \r | |
604 | vSourceFiles.removeSourceFiles(intTempIndex);\r | |
605 | \r | |
606 | //\r | |
607 | // Reload all fields of selected item\r | |
608 | //\r | |
609 | reloadFromList();\r | |
610 | \r | |
611 | // \r | |
612 | // Save to memory\r | |
613 | //\r | |
614 | save();\r | |
615 | }\r | |
616 | \r | |
617 | /**\r | |
618 | Update current item of Vector\r | |
619 | \r | |
620 | **/\r | |
621 | private void updateForList() {\r | |
622 | //\r | |
623 | // Check if exist items\r | |
624 | //\r | |
625 | if (this.vSourceFiles.size() < 1) {\r | |
626 | return;\r | |
627 | }\r | |
628 | \r | |
629 | //\r | |
630 | // Backup selected item index\r | |
631 | //\r | |
632 | int intTempIndex = intSelectedItemId;\r | |
633 | \r | |
634 | vSourceFiles.updateSourceFiles(getCurrentSourceFiles(), intTempIndex);\r | |
635 | \r | |
636 | jComboBoxList.removeAllItems();\r | |
637 | for (int index = 0; index < vSourceFiles.size(); index++) {\r | |
638 | jComboBoxList.addItem(vSourceFiles.getSourceFiles(index).getFilename());\r | |
639 | }\r | |
640 | \r | |
641 | //\r | |
642 | // Restore selected item index\r | |
643 | //\r | |
644 | intSelectedItemId = intTempIndex;\r | |
645 | \r | |
646 | //\r | |
647 | // Reset select item index\r | |
648 | //\r | |
649 | jComboBoxList.setSelectedIndex(intSelectedItemId);\r | |
650 | \r | |
651 | //\r | |
652 | // Reload all fields of selected item\r | |
653 | //\r | |
654 | reloadFromList();\r | |
655 | \r | |
656 | // \r | |
657 | // Save to memory\r | |
658 | //\r | |
659 | save();\r | |
660 | }\r | |
661 | \r | |
662 | /**\r | |
663 | Refresh all fields' values of selected item of Vector\r | |
664 | \r | |
665 | **/\r | |
666 | private void reloadFromList() {\r | |
667 | if (vSourceFiles.size() > 0) {\r | |
668 | //\r | |
669 | // Get selected item index\r | |
670 | //\r | |
671 | intSelectedItemId = jComboBoxList.getSelectedIndex();\r | |
672 | \r | |
673 | this.jTextFieldFileName.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getFilename());\r | |
674 | this.jTextFieldTagName.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getTagName());\r | |
675 | this.jTextFieldToolCode.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getToolCode());\r | |
676 | this.jTextFieldToolChainFamily.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getToolChainFamily());\r | |
677 | jTextFieldFeatureFlag.setText(vSourceFiles.getSourceFiles(intSelectedItemId).getFeatureFlag());\r | |
678 | iCheckBoxListArch.setAllItemsUnchecked();\r | |
679 | iCheckBoxListArch.initCheckedItem(true, vSourceFiles.getSourceFiles(intSelectedItemId).getSupArchList());\r | |
680 | \r | |
681 | } else {\r | |
682 | }\r | |
683 | \r | |
684 | reloadListArea();\r | |
685 | }\r | |
686 | \r | |
687 | /**\r | |
688 | Update list area pane via the elements of Vector\r | |
689 | \r | |
690 | **/\r | |
691 | private void reloadListArea() {\r | |
692 | String strListItem = "";\r | |
693 | for (int index = 0; index < vSourceFiles.size(); index++) {\r | |
694 | strListItem = strListItem + vSourceFiles.getSourceFiles(index).getFilename() + DataType.UNIX_LINE_SEPARATOR;\r | |
695 | }\r | |
696 | this.jTextAreaList.setText(strListItem);\r | |
697 | }\r | |
698 | \r | |
699 | /* (non-Javadoc)\r | |
700 | * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)\r | |
701 | *\r | |
702 | * Reflesh the frame when selected item changed\r | |
703 | * \r | |
704 | */\r | |
705 | public void itemStateChanged(ItemEvent arg0) {\r | |
706 | if (arg0.getStateChange() == ItemEvent.SELECTED) {\r | |
707 | reloadFromList();\r | |
708 | }\r | |
709 | }\r | |
710 | \r | |
711 | /**\r | |
712 | Data validation for all fields\r | |
713 | \r | |
714 | @retval true - All datas are valid\r | |
715 | @retval false - At least one data is invalid\r | |
716 | \r | |
717 | **/\r | |
718 | public boolean checkAdd() {\r | |
719 | //\r | |
720 | // Check Filename\r | |
721 | //\r | |
722 | if (isEmpty(this.jTextFieldFileName.getText())) {\r | |
723 | Log.err("File Name couldn't be empty");\r | |
724 | return false;\r | |
725 | }\r | |
726 | if (!DataValidation.isFilename(this.jTextFieldFileName.getText())) {\r | |
727 | Log.err("Incorrect data type for File Name");\r | |
728 | return false;\r | |
729 | }\r | |
730 | \r | |
731 | //\r | |
732 | // Check TagName \r | |
733 | //\r | |
734 | if (!isEmpty(this.jTextFieldTagName.getText())) {\r | |
735 | if (!DataValidation.isTagName(this.jTextFieldTagName.getText())) {\r | |
736 | Log.err("Incorrect data type for Tag Name");\r | |
737 | return false;\r | |
738 | }\r | |
739 | }\r | |
740 | \r | |
741 | //\r | |
742 | // Check ToolCode \r | |
743 | //\r | |
744 | if (!isEmpty(this.jTextFieldToolCode.getText())) {\r | |
745 | if (!DataValidation.isToolCode(this.jTextFieldToolCode.getText())) {\r | |
746 | Log.err("Incorrect data type for Tool Code");\r | |
747 | return false;\r | |
748 | }\r | |
749 | }\r | |
750 | \r | |
751 | //\r | |
752 | // Check ToolChainFamily \r | |
753 | //\r | |
754 | if (!isEmpty(this.jTextFieldToolChainFamily.getText())) {\r | |
755 | if (!DataValidation.isToolChainFamily(this.jTextFieldToolChainFamily.getText())) {\r | |
756 | Log.err("Incorrect data type for Tool Chain Family");\r | |
757 | return false;\r | |
758 | }\r | |
759 | }\r | |
760 | \r | |
761 | //\r | |
762 | // Check FeatureFlag\r | |
763 | //\r | |
764 | if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {\r | |
765 | if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {\r | |
766 | Log.err("Incorrect data type for Feature Flag");\r | |
767 | return false;\r | |
768 | }\r | |
769 | }\r | |
770 | \r | |
771 | return true;\r | |
772 | }\r | |
773 | \r | |
774 | /**\r | |
775 | Save all components of SourceFiles\r | |
776 | if exists sourceFiles, set the value directly\r | |
777 | if not exists sourceFiles, new an instance first\r | |
778 | \r | |
779 | **/\r | |
780 | public void save() {\r | |
781 | try {\r | |
782 | //\r | |
783 | //Save as file name\r | |
784 | //\r | |
785 | int count = this.vSourceFiles.size();\r | |
786 | \r | |
787 | this.sourceFiles = SourceFiles.Factory.newInstance();\r | |
788 | if (count > 0) {\r | |
789 | for (int index = 0; index < count; index++) {\r | |
790 | Filename mFilename = Filename.Factory.newInstance();\r | |
791 | if (!isEmpty(vSourceFiles.getSourceFiles(index).getFilename())) {\r | |
792 | mFilename.setStringValue(vSourceFiles.getSourceFiles(index).getFilename());\r | |
793 | }\r | |
794 | if (!isEmpty(vSourceFiles.getSourceFiles(index).getTagName())) {\r | |
795 | mFilename.setTagName(vSourceFiles.getSourceFiles(index).getTagName());\r | |
796 | }\r | |
797 | if (!isEmpty(vSourceFiles.getSourceFiles(index).getToolCode())) {\r | |
798 | mFilename.setToolCode(vSourceFiles.getSourceFiles(index).getToolCode());\r | |
799 | }\r | |
800 | if (!isEmpty(vSourceFiles.getSourceFiles(index).getToolChainFamily())) {\r | |
801 | mFilename.setToolChainFamily(vSourceFiles.getSourceFiles(index).getToolChainFamily());\r | |
802 | }\r | |
803 | if (!isEmpty(vSourceFiles.getSourceFiles(index).getFeatureFlag())) {\r | |
804 | mFilename.setFeatureFlag(vSourceFiles.getSourceFiles(index).getFeatureFlag());\r | |
805 | }\r | |
806 | if (vSourceFiles.getSourceFiles(index).getSupArchList() != null\r | |
807 | && vSourceFiles.getSourceFiles(index).getSupArchList().size() > 0) {\r | |
808 | mFilename.setSupArchList(vSourceFiles.getSourceFiles(index).getSupArchList());\r | |
809 | }\r | |
810 | \r | |
811 | this.sourceFiles.addNewFilename();\r | |
812 | this.sourceFiles.setFilenameArray(index, mFilename);\r | |
813 | }\r | |
814 | }\r | |
815 | this.msa.setSourceFiles(sourceFiles);\r | |
816 | this.omt.setSaved(false);\r | |
817 | } catch (Exception e) {\r | |
818 | e.printStackTrace();\r | |
819 | Log.err("Update Source Files", e.getMessage());\r | |
820 | }\r | |
821 | }\r | |
822 | \r | |
823 | /**\r | |
824 | Display a file open browser to let user select file\r | |
825 | \r | |
826 | **/\r | |
827 | private void selectFile() {\r | |
828 | JFileChooser fc = new JFileChooser(Workspace.getCurrentWorkspace());\r | |
829 | \r | |
830 | int result = fc.showOpenDialog(new JPanel());\r | |
831 | if (result == JFileChooser.APPROVE_OPTION) {\r | |
832 | this.jTextFieldFileName.setText(fc.getSelectedFile().getName());\r | |
833 | }\r | |
834 | }\r | |
835 | \r | |
836 | /* (non-Javadoc)\r | |
837 | * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)\r | |
838 | * \r | |
839 | * Override componentResized to resize all components when frame's size is changed\r | |
840 | */\r | |
841 | public void componentResized(ComponentEvent arg0) {\r | |
842 | int intCurrentWidth = this.getJContentPane().getWidth();\r | |
843 | int intCurrentHeight = this.getJContentPane().getHeight();\r | |
844 | int intPreferredWidth = this.getJContentPane().getPreferredSize().width;\r | |
845 | int intPreferredHeight = this.getJContentPane().getPreferredSize().height;\r | |
846 | \r | |
847 | resizeComponentWidth(this.jTextFieldFileName, intCurrentWidth, intPreferredWidth);\r | |
848 | resizeComponentWidth(this.jTextFieldTagName, intCurrentWidth, intPreferredWidth);\r | |
849 | resizeComponentWidth(this.jTextFieldToolCode, intCurrentWidth, intPreferredWidth);\r | |
850 | resizeComponentWidth(this.jTextFieldToolChainFamily, intCurrentWidth, intPreferredWidth);\r | |
851 | resizeComponentWidth(this.jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);\r | |
852 | resizeComponentWidth(this.jScrollPaneArch, intCurrentWidth, intPreferredWidth);\r | |
853 | \r | |
854 | resizeComponentWidth(this.jComboBoxList, intCurrentWidth, intPreferredWidth);\r | |
855 | resizeComponent(this.jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);\r | |
856 | relocateComponentX(this.jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);\r | |
857 | relocateComponentX(this.jButtonOpenFile, intCurrentWidth, intPreferredWidth,\r | |
858 | DataType.SPACE_TO_RIGHT_FOR_GENERATE_BUTTON);\r | |
859 | relocateComponentX(this.jButtonRemove, intCurrentWidth, intPreferredWidth,\r | |
860 | DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);\r | |
861 | relocateComponentX(this.jButtonUpdate, intCurrentWidth, intPreferredWidth,\r | |
862 | DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);\r | |
863 | }\r | |
864 | }\r |