]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/ModuleEditor/src/org/tianocore/packaging/module/ui/ModuleIncludes.java
1. Modify start script to
[mirror_edk2.git] / Tools / Source / ModuleEditor / src / org / tianocore / packaging / module / ui / ModuleIncludes.java
1 /** @file
2
3 The file is used to create, update Include 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.packaging.module.ui;
16
17 import java.awt.event.ActionEvent;
18 import java.awt.event.ItemEvent;
19 import java.awt.event.ItemListener;
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.JLabel;
26 import javax.swing.JPanel;
27 import javax.swing.JTextField;
28
29 import org.tianocore.IncludesDocument;
30 import org.tianocore.PackageNameDocument;
31 import org.tianocore.PackageType;
32 import org.tianocore.PackageUsage;
33 import org.tianocore.SupportedArchitectures;
34 import org.tianocore.common.DataValidation;
35 import org.tianocore.common.Log;
36 import org.tianocore.packaging.common.ui.IDefaultMutableTreeNode;
37 import org.tianocore.packaging.common.ui.IInternalFrame;
38 import org.tianocore.packaging.common.ui.StarLabel;
39 import org.tianocore.packaging.workspace.common.Workspace;
40
41 /**
42 The class is used to create, update Include of MSA/MBD file
43 It extends IInternalFrame
44
45 @since ModuleEditor 1.0
46
47 **/
48 public class ModuleIncludes extends IInternalFrame implements ItemListener {
49
50 ///
51 /// Define class Serial Version UID
52 ///
53 private static final long serialVersionUID = 3465193035145152131L;
54
55 //
56 //Define class members
57 //
58 private IncludesDocument.Includes includes = null;
59
60 private int location = -1;
61
62 private int intSelectedItemId = 0;
63
64 //
65 // 1 - Add; 2 - Update
66 //
67 private int operation = -1;
68
69 private Vector<String> vPackageName = new Vector<String>();
70
71 private Vector<String> vUsage = new Vector<String>();
72
73 private Vector<String> vPackageType = new Vector<String>();
74
75 private Vector<String> vUpdatedDate = new Vector<String>();
76
77 private JPanel jContentPane = null;
78
79 private JButton jButtonOk = null;
80
81 private JButton jButtonCancel = null;
82
83 private JLabel jLabelPackageName = null;
84
85 private JLabel jLabelPackageType = null;
86
87 private JComboBox jComboBoxPackageType = null;
88
89 private JLabel jLabelUsage = null;
90
91 private JComboBox jComboBoxUsage = null;
92
93 private StarLabel jStarLabel1 = null;
94
95 private JComboBox jComboBoxFileList = null;
96
97 private JButton jButtonAdd = null;
98
99 private JButton jButtonUpdate = null;
100
101 private JButton jButtonRemove = null;
102
103 private JLabel jLabelUpdatedDate = null;
104
105 private JTextField jTextFieldUpdatedDate = null;
106
107 private JCheckBox jCheckBoxArch = null;
108
109 private JComboBox jComboBoxArch = null;
110
111 private JComboBox jComboBoxPackageName = null;
112
113 private Workspace ws = null;
114
115 private Vector vecPackageName = null;
116
117 /**
118 This method initializes jButtonOk
119
120 @return javax.swing.JButton jButtonOk
121
122 **/
123 private JButton getJButton() {
124 if (jButtonOk == null) {
125 jButtonOk = new JButton();
126 jButtonOk.setText("OK");
127 jButtonOk.setBounds(new java.awt.Rectangle(290, 165, 90, 20));
128 jButtonOk.addActionListener(this);
129
130 }
131 return jButtonOk;
132 }
133
134 /**
135 This method initializes jButtonCancel
136
137 @return javax.swing.JButton jButtonCancel
138
139 **/
140 private JButton getJButton1() {
141 if (jButtonCancel == null) {
142 jButtonCancel = new JButton();
143 jButtonCancel.setText("Cancel");
144 jButtonCancel.setBounds(new java.awt.Rectangle(390, 165, 90, 20));
145 jButtonCancel.addActionListener(this);
146 }
147 return jButtonCancel;
148 }
149
150 /**
151 This method initializes jComboBoxPackageType
152
153 @return javax.swing.JComboBox jComboBoxPackageType
154
155 **/
156 private JComboBox getJComboBoxPackageType() {
157 if (jComboBoxPackageType == null) {
158 jComboBoxPackageType = new JComboBox();
159 jComboBoxPackageType.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
160 }
161 return jComboBoxPackageType;
162 }
163
164 /**
165 This method initializes jComboBoxUsage
166
167 @return javax.swing.JComboBox jComboBoxUsage
168
169 **/
170 private JComboBox getJComboBoxUsage() {
171 if (jComboBoxUsage == null) {
172 jComboBoxUsage = new JComboBox();
173 jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
174 }
175 return jComboBoxUsage;
176 }
177
178 /**
179 This method initializes jComboBoxFileList
180
181 @return javax.swing.JComboBox jComboBoxFileList
182
183 **/
184 private JComboBox getJComboBoxFileList() {
185 if (jComboBoxFileList == null) {
186 jComboBoxFileList = new JComboBox();
187 jComboBoxFileList.setBounds(new java.awt.Rectangle(15, 110, 210, 20));
188 jComboBoxFileList.addActionListener(this);
189 jComboBoxFileList.addItemListener(this);
190 }
191 return jComboBoxFileList;
192 }
193
194 /**
195 This method initializes jButtonAdd
196
197 @return javax.swing.JButton jButtonAdd
198
199 **/
200 private JButton getJButtonAdd() {
201 if (jButtonAdd == null) {
202 jButtonAdd = new JButton();
203 jButtonAdd.setBounds(new java.awt.Rectangle(230, 110, 80, 20));
204 jButtonAdd.setText("Add");
205 jButtonAdd.addActionListener(this);
206 }
207 return jButtonAdd;
208 }
209
210 /**
211 This method initializes jButtonUpdate
212
213 @return javax.swing.JButton jButtonUpdate
214
215 **/
216 private JButton getJButtonUpdate() {
217 if (jButtonUpdate == null) {
218 jButtonUpdate = new JButton();
219 jButtonUpdate.setBounds(new java.awt.Rectangle(315, 110, 80, 20));
220 jButtonUpdate.setText("Update");
221 jButtonUpdate.addActionListener(this);
222 }
223 return jButtonUpdate;
224 }
225
226 /**
227 This method initializes jButtonRemove
228
229 @return javax.swing.JButton jButtonRemove
230
231 **/
232 private JButton getJButtonRemove() {
233 if (jButtonRemove == null) {
234 jButtonRemove = new JButton();
235 jButtonRemove.setBounds(new java.awt.Rectangle(400, 110, 80, 20));
236 jButtonRemove.setText("Remove");
237 jButtonRemove.addActionListener(this);
238 }
239 return jButtonRemove;
240 }
241
242 /**
243 This method initializes jTextFieldUpdatedDate
244
245 @return javax.swing.JTextField jTextFieldUpdatedDate
246
247 **/
248 private JTextField getJTextFieldUpdatedDate() {
249 if (jTextFieldUpdatedDate == null) {
250 jTextFieldUpdatedDate = new JTextField();
251 jTextFieldUpdatedDate.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
252 }
253 return jTextFieldUpdatedDate;
254 }
255
256 /**
257 This method initializes jCheckBoxArch
258
259 @return javax.swing.JCheckBox jCheckBoxArch
260
261 **/
262 private JCheckBox getJCheckBoxArch() {
263 if (jCheckBoxArch == null) {
264 jCheckBoxArch = new JCheckBox();
265 jCheckBoxArch.setBounds(new java.awt.Rectangle(10, 135, 120, 20));
266 jCheckBoxArch.setText("Specific Arch");
267 jCheckBoxArch.addActionListener(this);
268 }
269 return jCheckBoxArch;
270 }
271
272 /**
273 This method initializes jComboBoxArch
274
275 @return javax.swing.JComboBox jComboBoxArch
276
277 **/
278 private JComboBox getJComboBoxArch() {
279 if (jComboBoxArch == null) {
280 jComboBoxArch = new JComboBox();
281 jComboBoxArch.setBounds(new java.awt.Rectangle(140, 135, 340, 20));
282 jComboBoxArch.setEnabled(false);
283 }
284 return jComboBoxArch;
285 }
286
287 /**
288 * This method initializes jComboBoxPackageName
289 *
290 * @return javax.swing.JComboBox
291 */
292 private JComboBox getJComboBoxPackageName() {
293 if (jComboBoxPackageName == null) {
294 jComboBoxPackageName = new JComboBox();
295 jComboBoxPackageName.setBounds(new java.awt.Rectangle(160,10,320,20));
296 }
297 return jComboBoxPackageName;
298 }
299
300 public static void main(String[] args) {
301
302 }
303
304 /**
305 This is the default constructor
306
307 **/
308 public ModuleIncludes() {
309 super();
310 init();
311 this.setVisible(true);
312 }
313
314 /**
315 This is the override edit constructor
316
317 @param inIncludes The input data of IncludesDocument.Includes
318
319 **/
320 public ModuleIncludes(IncludesDocument.Includes inIncludes) {
321 super();
322 init(inIncludes);
323 this.setVisible(true);
324 }
325
326 /**
327 This is the override edit constructor
328
329 @param inIncludes The input data of IncludesDocument.Includes
330 @param type The input data of node type
331 @param index The input data of node index
332
333 **/
334 public ModuleIncludes(IncludesDocument.Includes inIncludes, int type, int index) {
335 super();
336 this.setVisible(true);
337 }
338
339 /**
340 This is the override edit constructor
341
342 @param inIncludes The input data of IncludesDocument.Includes
343 @param type The input data of node type
344 @param index The input data of node index
345 @param inOperation The input data of current operation type
346
347 **/
348 public ModuleIncludes(IncludesDocument.Includes inIncludes, int type, int index, int inOperation) {
349 super();
350 init(inIncludes, type, index, inOperation);
351 this.operation = inOperation;
352 this.setVisible(true);
353 }
354
355 /**
356 This method initializes this
357
358 @param inIncludes
359
360 **/
361 private void init(IncludesDocument.Includes inIncludes) {
362 init();
363 this.setIncludes(inIncludes);
364 }
365
366 /**
367 This method initializes this
368 Fill values to all fields if these values are not empty
369
370 @param inIncludes The input data of IncludesDocument.Includes
371 @param type The input data of node type
372 @param index The input data of node index
373 @param inOperation The input data of current operation type
374
375 **/
376 private void init(IncludesDocument.Includes inIncludes, int type, int index, int inOperation) {
377 init(inIncludes);
378 this.location = index;
379 this.operation = inOperation;
380
381 if (operation == 2) {
382 this.jCheckBoxArch.setEnabled(false);
383 this.jComboBoxArch.setEnabled(false);
384
385 if (type == IDefaultMutableTreeNode.INCLUDES_PACKAGENAME) {
386 if (this.includes.getPackageNameList().size() > 0) {
387 for (int indexI = 0; indexI < this.includes.getPackageNameList().size(); indexI++) {
388 if (this.includes.getPackageNameArray(indexI).getStringValue() != null) {
389 vPackageName.addElement(this.includes.getPackageNameArray(indexI).getStringValue());
390 } else {
391 vPackageName.addElement("");
392 }
393 if (this.includes.getPackageNameArray(indexI).getUsage() != null) {
394 vUsage.addElement(this.includes.getPackageNameArray(indexI).getUsage().toString());
395 } else {
396 vUsage.addElement("ALWAYS_CONSUMED");
397 }
398 if (this.includes.getPackageNameArray(indexI).getPackageType() != null) {
399 vPackageType.addElement(this.includes.getPackageNameArray(indexI).getPackageType()
400 .toString());
401 } else {
402 vPackageType.addElement("SOURCE");
403 }
404 if (this.includes.getPackageNameArray(indexI).getUpdatedDate() != null) {
405 vUpdatedDate.addElement(this.includes.getPackageNameArray(indexI).getUpdatedDate());
406 } else {
407 vUpdatedDate.addElement("");
408 }
409 jComboBoxFileList.addItem(this.includes.getPackageNameArray(indexI).getStringValue());
410 }
411 }
412 }
413 if (type == IDefaultMutableTreeNode.INCLUDES_ARCH_ITEM) {
414 this.jCheckBoxArch.setSelected(true);
415 this.jComboBoxArch.setSelectedItem(this.includes.getArchArray(index).getArchType().toString());
416 for (int indexI = 0; indexI < this.includes.getArchArray(index).getPackageNameList().size(); indexI++) {
417 if (this.includes.getArchArray(index).getPackageNameArray(indexI).getStringValue() != null) {
418 vPackageName.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI)
419 .getStringValue());
420 } else {
421 vPackageName.addElement("");
422 }
423 if (this.includes.getArchArray(index).getPackageNameArray(indexI).getUsage() != null) {
424 vUsage.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI).getUsage()
425 .toString());
426 } else {
427 vUsage.addElement("");
428 }
429 if (this.includes.getArchArray(index).getPackageNameArray(indexI).getPackageType() != null) {
430 vPackageType.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI)
431 .getPackageType().toString());
432 } else {
433 vPackageType.addElement("");
434 }
435 if (this.includes.getArchArray(index).getPackageNameArray(indexI).getUpdatedDate() != null) {
436 vUpdatedDate.addElement(this.includes.getArchArray(index).getPackageNameArray(indexI)
437 .getUpdatedDate());
438 } else {
439 vUpdatedDate.addElement("");
440 }
441 jComboBoxFileList.addItem(this.includes.getArchArray(index).getPackageNameArray(indexI)
442 .getStringValue());
443 }
444 }
445 }
446 }
447
448 /**
449 This method initializes this
450
451 **/
452 private void init() {
453 this.setSize(500, 515);
454 this.setContentPane(getJContentPane());
455 this.setTitle("Includes");
456 initFrame();
457 this.setViewMode(false);
458 }
459
460 /**
461 Disable all components when the mode is view
462
463 @param isView true - The view mode; false - The non-view mode
464
465 **/
466 public void setViewMode(boolean isView) {
467 this.jButtonOk.setVisible(false);
468 this.jButtonCancel.setVisible(false);
469 if (isView) {
470 this.jComboBoxPackageType.setEnabled(!isView);
471 this.jComboBoxUsage.setEnabled(!isView);
472 this.jComboBoxPackageName.setEnabled(!isView);
473 this.jButtonAdd.setEnabled(!isView);
474 this.jButtonUpdate.setEnabled(!isView);
475 this.jButtonRemove.setEnabled(!isView);
476 this.jTextFieldUpdatedDate.setEnabled(!isView);
477 this.jCheckBoxArch.setEnabled(!isView);
478 this.jComboBoxArch.setEnabled(!isView);
479
480 this.jButtonCancel.setEnabled(!isView);
481 this.jButtonOk.setEnabled(!isView);
482 }
483 }
484
485 /**
486 This method initializes jContentPane
487
488 @return javax.swing.JPanel jContentPane
489
490 **/
491 private JPanel getJContentPane() {
492 if (jContentPane == null) {
493 jLabelUpdatedDate = new JLabel();
494 jLabelUpdatedDate.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
495 jLabelUpdatedDate.setText("Updated Date");
496 jLabelUsage = new JLabel();
497 jLabelUsage.setBounds(new java.awt.Rectangle(15, 60, 140, 20));
498 jLabelUsage.setText("Usage");
499 jLabelPackageType = new JLabel();
500 jLabelPackageType.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
501 jLabelPackageType.setText("Package Type");
502 jLabelPackageName = new JLabel();
503 jLabelPackageName.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
504 jLabelPackageName.setText("Package Name");
505 jContentPane = new JPanel();
506 jContentPane.setLayout(null);
507 jContentPane.add(getJButton(), null);
508 jContentPane.add(getJButton1(), null);
509 jContentPane.add(jLabelPackageName, null);
510 jContentPane.add(jLabelPackageType, null);
511 jContentPane.add(getJComboBoxPackageType(), null);
512 jContentPane.add(jLabelUsage, null);
513 jContentPane.add(getJComboBoxUsage(), null);
514
515 jStarLabel1 = new StarLabel();
516 jStarLabel1.setLocation(new java.awt.Point(0, 10));
517
518 jContentPane.add(jStarLabel1, null);
519 jContentPane.add(getJComboBoxFileList(), null);
520 jContentPane.add(getJButtonAdd(), null);
521 jContentPane.add(getJButtonUpdate(), null);
522 jContentPane.add(getJButtonRemove(), null);
523 jContentPane.add(jLabelUpdatedDate, null);
524 jContentPane.add(getJTextFieldUpdatedDate(), null);
525 jContentPane.add(getJCheckBoxArch(), null);
526 jContentPane.add(getJComboBoxArch(), null);
527 jContentPane.add(getJComboBoxPackageName(), null);
528 }
529 return jContentPane;
530 }
531
532 /* (non-Javadoc)
533 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
534 *
535 * Override actionPerformed to listen all actions
536 *
537 */
538 public void actionPerformed(ActionEvent arg0) {
539 if (arg0.getSource() == jButtonOk) {
540 this.setEdited(true);
541 this.save();
542 this.dispose();
543 }
544 if (arg0.getSource() == jButtonCancel) {
545 this.dispose();
546 }
547 if (arg0.getSource() == jButtonAdd) {
548 if (!checkAdd()) {
549 return;
550 }
551 addToList();
552 }
553 if (arg0.getSource() == jButtonRemove) {
554 removeFromList();
555 }
556 if (arg0.getSource() == jButtonUpdate) {
557 if (!checkAdd()) {
558 return;
559 }
560 updateForList();
561 }
562
563 //
564 //When and only when checked Arch box then can choose different arch types
565 //
566 if (arg0.getSource() == jCheckBoxArch) {
567 if (this.jCheckBoxArch.isSelected()) {
568 this.jComboBoxArch.setEnabled(true);
569 } else {
570 this.jComboBoxArch.setEnabled(false);
571 }
572 }
573 }
574
575 /**
576 This method initializes Usage type, Package type and Arch type
577
578 **/
579 private void initFrame() {
580 ws = new Workspace();
581 vecPackageName = ws.getAllPackageName();
582 for (int index = 0; index < vecPackageName.size(); index++) {
583 jComboBoxPackageName.addItem(vecPackageName.elementAt(index));
584 }
585
586 jComboBoxUsage.addItem("ALWAYS_CONSUMED");
587 jComboBoxUsage.addItem("ALWAYS_PRODUCED");
588 jComboBoxUsage.addItem("DEFAULT");
589
590 jComboBoxPackageType.addItem("SOURCE");
591 jComboBoxPackageType.addItem("BINARY");
592 jComboBoxPackageType.addItem("MIXED");
593
594 jComboBoxArch.addItem("ALL");
595 jComboBoxArch.addItem("EBC");
596 jComboBoxArch.addItem("ARM");
597 jComboBoxArch.addItem("IA32");
598 jComboBoxArch.addItem("X64");
599 jComboBoxArch.addItem("IPF");
600 jComboBoxArch.addItem("PPC");
601 }
602
603 /**
604 Add current item to Vector
605
606 **/
607 private void addToList() {
608 intSelectedItemId = vPackageName.size();
609 vPackageName.addElement(this.jComboBoxPackageName.getSelectedItem().toString());
610 vUsage.addElement(this.jComboBoxUsage.getSelectedItem().toString());
611 vPackageType.addElement(this.jComboBoxPackageType.getSelectedItem().toString());
612 vUpdatedDate.addElement(this.jTextFieldUpdatedDate.getText());
613 jComboBoxFileList.addItem(this.jComboBoxPackageName.getSelectedItem().toString());
614 jComboBoxFileList.setSelectedItem(this.jComboBoxPackageName.getSelectedItem().toString());
615
616 //
617 // Reset select item index
618 //
619 intSelectedItemId = vPackageName.size();
620
621 //
622 // Reload all fields of selected item
623 //
624 reloadFromList();
625 }
626
627 /**
628 Remove item from Vector
629
630 **/
631 private void removeFromList() {
632 int intTempIndex = intSelectedItemId;
633 if (vPackageName.size() < 1) {
634 return;
635 }
636
637 jComboBoxFileList.removeItemAt(intSelectedItemId);
638
639 vPackageName.removeElementAt(intTempIndex);
640 vUsage.removeElementAt(intTempIndex);
641 vPackageType.removeElementAt(intTempIndex);
642 vUpdatedDate.removeElementAt(intTempIndex);
643
644 //
645 // Reload all fields of selected item
646 //
647 reloadFromList();
648 }
649
650 /**
651 Update current item of Vector
652
653 **/
654 private void updateForList() {
655 //
656 // Backup selected item index
657 //
658 int intTempIndex = intSelectedItemId;
659
660 vPackageName.setElementAt(this.jComboBoxPackageName.getSelectedItem().toString(), intSelectedItemId);
661 vUsage.setElementAt(this.jComboBoxUsage.getSelectedItem().toString(), intSelectedItemId);
662 vPackageType.setElementAt(this.jComboBoxPackageType.getSelectedItem().toString(), intSelectedItemId);
663 vUpdatedDate.setElementAt(this.jTextFieldUpdatedDate.getText(), intSelectedItemId);
664
665 jComboBoxFileList.removeAllItems();
666 for (int index = 0; index < vPackageName.size(); index++) {
667 jComboBoxFileList.addItem(vPackageName.elementAt(index));
668 }
669
670 //
671 // Restore selected item index
672 //
673 intSelectedItemId = intTempIndex;
674
675 //
676 // Reset select item index
677 //
678 jComboBoxFileList.setSelectedIndex(intSelectedItemId);
679
680 //
681 // Reload all fields of selected item
682 //
683 reloadFromList();
684 }
685
686 /**
687 Refresh all fields' values of selected item of Vector
688
689 **/
690 private void reloadFromList() {
691 if (vPackageName.size() > 0) {
692 //
693 // Get selected item index
694 //
695 intSelectedItemId = jComboBoxFileList.getSelectedIndex();
696
697 this.jComboBoxPackageName.setSelectedItem(vPackageName.elementAt(intSelectedItemId).toString());
698 this.jComboBoxUsage.setSelectedItem(vUsage.elementAt(intSelectedItemId).toString());
699 this.jComboBoxPackageType.setSelectedItem(vPackageType.elementAt(intSelectedItemId).toString());
700 this.jTextFieldUpdatedDate.setText(vUpdatedDate.elementAt(intSelectedItemId).toString());
701 } else {
702 this.jComboBoxPackageName.setSelectedIndex(0);
703 this.jComboBoxUsage.setSelectedIndex(0);
704 this.jComboBoxPackageType.setSelectedIndex(0);
705 this.jTextFieldUpdatedDate.setText("");
706 }
707 }
708
709 /**
710 Get IncludesDocument.Includes
711
712 @return IncludesDocument.Includes
713
714 **/
715 public IncludesDocument.Includes getIncludes() {
716 return includes;
717 }
718
719 /**
720 Set IncludesDocument.Includes
721
722 @param includes IncludesDocument.Includes
723
724 **/
725 public void setIncludes(IncludesDocument.Includes includes) {
726 this.includes = includes;
727 }
728
729 /* (non-Javadoc)
730 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
731 *
732 * Reflesh the frame when selected item changed
733 *
734 */
735 public void itemStateChanged(ItemEvent arg0) {
736 if (arg0.getStateChange() == ItemEvent.SELECTED) {
737 reloadFromList();
738 }
739 }
740
741 /**
742 Data validation for all fields
743
744 @retval true - All datas are valid
745 @retval false - At least one data is invalid
746
747 **/
748 public boolean check() {
749 if (this.jComboBoxFileList.getItemCount() < 1) {
750 Log.err("Must have one include at least!");
751 return false;
752 }
753 return true;
754 }
755
756 /**
757 Data validation for all fields before add current item to Vector
758
759 @retval true - All datas are valid
760 @retval false - At least one data is invalid
761
762 **/
763 public boolean checkAdd() {
764 //
765 // Check if all fields have correct data types
766 //
767 if (!isEmpty(this.jTextFieldUpdatedDate.getText())
768 && !DataValidation.isDateType(this.jTextFieldUpdatedDate.getText())) {
769 Log.err("Incorrect data type for Update Date");
770 return false;
771 }
772
773 return true;
774 }
775
776 /**
777 Save all components of Includes
778 if exists includes, set the value directly
779 if not exists includes, new an instance first
780
781 **/
782 public void save() {
783 try {
784 if (this.includes == null) {
785 includes = IncludesDocument.Includes.Factory.newInstance();
786 }
787 //
788 //Save as file name
789 //
790 if (!this.jCheckBoxArch.isSelected()) {
791 if (this.operation == 2) { //Add new packageName
792 //
793 //First remove all existed packageName
794 //
795 if (includes.getPackageNameList().size() > 0) {
796 for (int index = includes.getPackageNameList().size() - 1; index >= 0; index--) {
797 includes.removePackageName(index);
798 }
799 }
800 }
801 for (int index = 0; index < vPackageName.size(); index++) {
802 PackageNameDocument.PackageName packageName = PackageNameDocument.PackageName.Factory.newInstance();
803 if (!isEmpty(vPackageName.elementAt(index).toString())) {
804 packageName.setStringValue(vPackageName.elementAt(index).toString());
805 }
806 if (!isEmpty(vUsage.elementAt(index).toString())) {
807 packageName.setUsage(PackageUsage.Enum.forString(vUsage.elementAt(index).toString()));
808 }
809 if (!isEmpty(vPackageType.elementAt(index).toString())) {
810 packageName
811 .setPackageType(PackageType.Enum.forString(vPackageType.elementAt(index).toString()));
812 }
813 if (!isEmpty(vUpdatedDate.elementAt(index).toString())) {
814 packageName.setUpdatedDate(vUpdatedDate.elementAt(index).toString());
815 }
816 includes.addNewPackageName();
817 includes.setPackageNameArray(includes.getPackageNameList().size() - 1, packageName);
818 }
819 }
820 //
821 //Save as Arch
822 //
823 if (this.jCheckBoxArch.isSelected()) {
824 IncludesDocument.Includes.Arch arch = IncludesDocument.Includes.Arch.Factory.newInstance();
825 if (this.operation == 2) {
826 //
827 //First remove all existed filename
828 //
829 for (int index = includes.getArchArray(location).getPackageNameList().size() - 1; index >= 0; index--) {
830 includes.getArchArray(location).removePackageName(index);
831 }
832 }
833
834 for (int index = 0; index < vPackageName.size(); index++) {
835 PackageNameDocument.PackageName packageName = PackageNameDocument.PackageName.Factory.newInstance();
836 if (!isEmpty(vPackageName.elementAt(index).toString())) {
837 packageName.setStringValue(vPackageName.elementAt(index).toString());
838 }
839 if (!isEmpty(vUsage.elementAt(index).toString())) {
840 packageName.setUsage(PackageUsage.Enum.forString(vUsage.elementAt(index).toString()));
841 }
842 if (!isEmpty(vPackageType.elementAt(index).toString())) {
843 packageName
844 .setPackageType(PackageType.Enum.forString(vPackageType.elementAt(index).toString()));
845 }
846 if (!isEmpty(vUpdatedDate.elementAt(index).toString())) {
847 packageName.setUpdatedDate(vUpdatedDate.elementAt(index).toString());
848 }
849 arch.addNewPackageName();
850 arch.setPackageNameArray(arch.getPackageNameList().size() - 1, packageName);
851 }
852 arch
853 .setArchType(SupportedArchitectures.Enum.forString(this.jComboBoxArch.getSelectedItem().toString()));
854 if (location > -1) {
855 includes.setArchArray(location, arch);
856 } else {
857 includes.addNewArch();
858 includes.setArchArray(includes.getArchList().size() - 1, arch);
859 }
860 }
861 } catch (Exception e) {
862 Log.err("Update Source Files", e.getMessage());
863 }
864 }
865 }