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