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