]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/module/ui/ModuleDataHubs.java
cf342d24c4be41d11d8b55db24e5cdd7cd0b4096
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / module / ui / ModuleDataHubs.java
1 /** @file
2
3 The file is used to create, update DataHub 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
16 package org.tianocore.frameworkwizard.module.ui;
17
18 import java.awt.event.ActionEvent;
19 import java.awt.event.ComponentEvent;
20 import java.awt.event.ItemEvent;
21 import java.util.Vector;
22
23 import javax.swing.JButton;
24 import javax.swing.JComboBox;
25 import javax.swing.JLabel;
26 import javax.swing.JPanel;
27 import javax.swing.JScrollPane;
28 import javax.swing.JTextArea;
29 import javax.swing.JTextField;
30
31 import org.tianocore.DataHubUsage;
32 import org.tianocore.DataHubsDocument;
33 import org.tianocore.DataHubsDocument.DataHubs;
34 import org.tianocore.DataHubsDocument.DataHubs.DataHubRecord;
35 import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
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.DataHubs.DataHubsIdentification;
46 import org.tianocore.frameworkwizard.module.Identifications.DataHubs.DataHubsVector;
47
48 /**
49 The class is used to create, update DataHub of MSA/MBD file
50 It extends IInternalFrame
51
52
53
54 **/
55 public class ModuleDataHubs extends IInternalFrame {
56
57 ///
58 /// Define class Serial Version UID
59 ///
60 private static final long serialVersionUID = -3667906991966638892L;
61
62 //
63 //Define class members
64 //
65 private JPanel jContentPane = null;
66
67 private JLabel jLabelUsage = null;
68
69 private JComboBox jComboBoxUsage = null;
70
71 private JLabel jLabelDataHubRecord = null;
72
73 private JTextField jTextFieldDataHubRecord = null;
74
75 private StarLabel jStarLabel1 = null;
76
77 private StarLabel jStarLabel2 = null;
78
79 private JLabel jLabelFeatureFlag = null;
80
81 private JTextField jTextFieldFeatureFlag = null;
82
83 private JLabel jLabelArch = null;
84
85 private JTextArea jTextAreaList = null;
86
87 private JComboBox jComboBoxList = null;
88
89 private JButton jButtonAdd = null;
90
91 private JButton jButtonRemove = null;
92
93 private JButton jButtonUpdate = null;
94
95 private JScrollPane jScrollPane = null;
96
97 private JScrollPane jScrollPaneList = null;
98
99 private ICheckBoxList iCheckBoxListArch = null;
100
101 private JScrollPane jScrollPaneArch = null;
102
103 private JLabel jLabelHelpText = null;
104
105 private JTextField jTextFieldHelpText = null;
106
107 //
108 // Not used by UI
109 //
110 private int intSelectedItemId = 0;
111
112 private OpeningModuleType omt = null;
113
114 private ModuleSurfaceArea msa = null;
115
116 private DataHubsDocument.DataHubs dataHubs = null;
117
118 private DataHubsIdentification id = null;
119
120 private DataHubsVector vid = new DataHubsVector();
121
122 private EnumerationData ed = new EnumerationData();
123
124 /**
125 This method initializes jComboBoxUsage
126
127 @return javax.swing.JComboBox jComboBoxUsage
128
129 **/
130 private JComboBox getJComboBoxUsage() {
131 if (jComboBoxUsage == null) {
132 jComboBoxUsage = new JComboBox();
133 jComboBoxUsage.setBounds(new java.awt.Rectangle(160, 35, 320, 20));
134 jComboBoxUsage.setPreferredSize(new java.awt.Dimension(320, 20));
135 }
136 return jComboBoxUsage;
137 }
138
139 /**
140 This method initializes jTextFieldDataHubRecord
141
142 @return javax.swing.JTextField jTextFieldDataHubRecord
143
144 **/
145 private JTextField getJTextFieldDataHubRecord() {
146 if (jTextFieldDataHubRecord == null) {
147 jTextFieldDataHubRecord = new JTextField();
148 jTextFieldDataHubRecord.setBounds(new java.awt.Rectangle(160, 10, 320, 20));
149 jTextFieldDataHubRecord.setPreferredSize(new java.awt.Dimension(320, 20));
150 jTextFieldDataHubRecord.setToolTipText("Enter the C Name of the Data Hub Record");
151 }
152 return jTextFieldDataHubRecord;
153 }
154
155 /**
156 * This method initializes jTextFieldFeatureFlag
157 *
158 * @return javax.swing.JTextField
159 */
160 private JTextField getJTextFieldFeatureFlag() {
161 if (jTextFieldFeatureFlag == null) {
162 jTextFieldFeatureFlag = new JTextField();
163 jTextFieldFeatureFlag.setBounds(new java.awt.Rectangle(160, 85, 320, 20));
164 jTextFieldFeatureFlag.setPreferredSize(new java.awt.Dimension(320, 20));
165 }
166 return jTextFieldFeatureFlag;
167 }
168
169 /**
170 This method initializes jComboBoxFileList
171
172 @return javax.swing.JComboBox jComboBoxFileList
173
174 **/
175 private JComboBox getJComboBoxList() {
176 if (jComboBoxList == null) {
177 jComboBoxList = new JComboBox();
178 jComboBoxList.setBounds(new java.awt.Rectangle(15, 195, 210, 20));
179 jComboBoxList.addItemListener(this);
180 jComboBoxList.addActionListener(this);
181 jComboBoxList.setPreferredSize(new java.awt.Dimension(210, 20));
182 }
183 return jComboBoxList;
184 }
185
186 /**
187 This method initializes jButtonAdd
188
189 @return javax.swing.JButton jButtonAdd
190
191 **/
192 private JButton getJButtonAdd() {
193 if (jButtonAdd == null) {
194 jButtonAdd = new JButton();
195 jButtonAdd.setBounds(new java.awt.Rectangle(230, 195, 80, 20));
196 jButtonAdd.setText("Add");
197 jButtonAdd.addActionListener(this);
198 jButtonAdd.setPreferredSize(new java.awt.Dimension(80, 20));
199 }
200 return jButtonAdd;
201 }
202
203 /**
204 This method initializes jButtonRemove
205
206 @return javax.swing.JButton jButtonRemove
207
208 **/
209 private JButton getJButtonRemove() {
210 if (jButtonRemove == null) {
211 jButtonRemove = new JButton();
212 jButtonRemove.setBounds(new java.awt.Rectangle(400, 195, 80, 20));
213 jButtonRemove.setText("Remove");
214 jButtonRemove.addActionListener(this);
215 jButtonRemove.setPreferredSize(new java.awt.Dimension(80, 20));
216 }
217 return jButtonRemove;
218 }
219
220 /**
221 This method initializes jButtonUpdate
222
223 @return javax.swing.JButton jButtonUpdate
224
225 **/
226 private JButton getJButtonUpdate() {
227 if (jButtonUpdate == null) {
228 jButtonUpdate = new JButton();
229 jButtonUpdate.setBounds(new java.awt.Rectangle(315, 195, 80, 20));
230 jButtonUpdate.setPreferredSize(new java.awt.Dimension(80, 20));
231 jButtonUpdate.setText("Update");
232 jButtonUpdate.addActionListener(this);
233 }
234 return jButtonUpdate;
235 }
236
237 /**
238 * This method initializes jScrollPaneFileList
239 *
240 * @return javax.swing.JScrollPane
241 */
242 private JScrollPane getJScrollPaneList() {
243 if (jScrollPaneList == null) {
244 jScrollPaneList = new JScrollPane();
245 jScrollPaneList.setBounds(new java.awt.Rectangle(15, 220, 465, 240));
246 jScrollPaneList.setViewportView(getJTextAreaList());
247 jScrollPaneList.setPreferredSize(new java.awt.Dimension(465, 240));
248 }
249 return jScrollPaneList;
250 }
251
252 /**
253 This method initializes jScrollPane
254
255 @return javax.swing.JScrollPane
256 */
257 private JScrollPane getJScrollPane() {
258 if (jScrollPane == null) {
259 jScrollPane = new JScrollPane();
260 jScrollPane.setViewportView(getJContentPane());
261 }
262 return jScrollPane;
263 }
264
265 /**
266 * This method initializes jTextAreaFileList
267 *
268 * @return javax.swing.JTextArea
269 */
270 private JTextArea getJTextAreaList() {
271 if (jTextAreaList == null) {
272 jTextAreaList = new JTextArea();
273 jTextAreaList.setEditable(false);
274
275 }
276 return jTextAreaList;
277 }
278
279 /**
280 This method initializes iCheckBoxListArch
281
282 @return ICheckBoxList
283 **/
284 private ICheckBoxList getICheckBoxListSupportedArchitectures() {
285 if (iCheckBoxListArch == null) {
286 iCheckBoxListArch = new ICheckBoxList();
287 iCheckBoxListArch.addFocusListener(this);
288 iCheckBoxListArch.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);
289 }
290 return iCheckBoxListArch;
291 }
292
293 /**
294 This method initializes jScrollPaneArch
295
296 @return javax.swing.JScrollPane
297
298 **/
299 private JScrollPane getJScrollPaneArch() {
300 if (jScrollPaneArch == null) {
301 jScrollPaneArch = new JScrollPane();
302 jScrollPaneArch.setBounds(new java.awt.Rectangle(160, 110, 320, 80));
303 jScrollPaneArch.setPreferredSize(new java.awt.Dimension(320, 80));
304 jScrollPaneArch.setViewportView(getICheckBoxListSupportedArchitectures());
305 }
306 return jScrollPaneArch;
307 }
308
309 /**
310 This method initializes jTextFieldHelpText
311
312 @return javax.swing.JTextField
313
314 **/
315 private JTextField getJTextFieldHelpText() {
316 if (jTextFieldHelpText == null) {
317 jTextFieldHelpText = new JTextField();
318 jTextFieldHelpText.setBounds(new java.awt.Rectangle(160, 60, 320, 20));
319 jTextFieldHelpText.setPreferredSize(new java.awt.Dimension(320, 20));
320 }
321 return jTextFieldHelpText;
322 }
323
324 public static void main(String[] args) {
325
326 }
327
328 /**
329 This method initializes this
330
331 **/
332 private void init() {
333 this.setSize(500, 515);
334 this.setContentPane(getJScrollPane());
335 this.setTitle("Data Hubs");
336 initFrame();
337 this.setViewMode(false);
338 }
339
340 /**
341 This method initializes this
342 Fill values to all fields if these values are not empty
343
344 @param inPackageDependencies
345
346 **/
347 private void init(DataHubs inDataHubs) {
348 init();
349 this.dataHubs = inDataHubs;
350
351 if (this.dataHubs != null) {
352 if (this.dataHubs.getDataHubRecordList().size() > 0) {
353 for (int index = 0; index < this.dataHubs.getDataHubRecordList().size(); index++) {
354 String arg0 = dataHubs.getDataHubRecordList().get(index).getDataHubCName();
355 String arg1 = null;
356 if (dataHubs.getDataHubRecordList().get(index).getUsage() != null) {
357 arg1 = dataHubs.getDataHubRecordList().get(index).getUsage().toString();
358 }
359
360 String arg2 = dataHubs.getDataHubRecordList().get(index).getFeatureFlag();
361 Vector<String> arg3 = Tools.convertListToVector(dataHubs.getDataHubRecordList().get(index)
362 .getSupArchList());
363 String arg4 = dataHubs.getDataHubRecordList().get(index).getHelpText();
364
365 id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
366 vid.addDataHubs(id);
367 }
368 }
369 }
370 //
371 // Update the list
372 //
373 Tools.generateComboBoxByVector(jComboBoxList, vid.getDataHubsName());
374 reloadListArea();
375 }
376
377 /**
378 This is the default constructor
379
380 **/
381 public ModuleDataHubs() {
382 super();
383 init();
384 this.setVisible(true);
385 }
386
387 /**
388 This is the override edit constructor
389
390 @param inDataHubs The input DataHubsDocument.DataHubs
391
392 **/
393 public ModuleDataHubs(OpeningModuleType inOmt) {
394 super();
395 this.omt = inOmt;
396 this.msa = omt.getXmlMsa();
397 init(msa.getDataHubs());
398 this.setVisible(true);
399 }
400
401 /**
402 Disable all components when the mode is view
403
404 @param isView true - The view mode; false - The non-view mode
405
406 **/
407 public void setViewMode(boolean isView) {
408 if (isView) {
409 this.jTextFieldDataHubRecord.setEnabled(!isView);
410 this.jComboBoxUsage.setEnabled(!isView);
411 }
412 }
413
414 /**
415 This method initializes jContentPane
416
417 @return javax.swing.JPanel jContentPane
418
419 **/
420 private JPanel getJContentPane() {
421 if (jContentPane == null) {
422 jLabelDataHubRecord = new JLabel();
423 jLabelDataHubRecord.setBounds(new java.awt.Rectangle(15, 10, 140, 20));
424 jLabelDataHubRecord.setText("Data Hub Record");
425 jLabelUsage = new JLabel();
426 jLabelUsage.setText("Usage");
427 jLabelUsage.setBounds(new java.awt.Rectangle(15, 35, 140, 20));
428 jLabelArch = new JLabel();
429 jLabelArch.setBounds(new java.awt.Rectangle(15, 110, 140, 20));
430 jLabelArch.setText("Arch");
431 jLabelFeatureFlag = new JLabel();
432 jLabelFeatureFlag.setBounds(new java.awt.Rectangle(15, 85, 140, 20));
433 jLabelFeatureFlag.setText("Feature Flag");
434 jLabelHelpText = new JLabel();
435 jLabelHelpText.setBounds(new java.awt.Rectangle(14, 60, 140, 20));
436 jLabelHelpText.setText("Help Text");
437
438 jContentPane = new JPanel();
439 jContentPane.setLayout(null);
440 jContentPane.setPreferredSize(new java.awt.Dimension(490, 475));
441
442 jContentPane.add(jLabelDataHubRecord, null);
443 jContentPane.add(jLabelUsage, null);
444 jContentPane.add(jLabelFeatureFlag, null);
445 jContentPane.add(jLabelArch, null);
446
447 jContentPane.add(getJTextFieldDataHubRecord(), null);
448 jContentPane.add(getJComboBoxUsage(), null);
449 jContentPane.add(getJTextFieldFeatureFlag(), null);
450
451 jStarLabel1 = new StarLabel();
452 jStarLabel1.setLocation(new java.awt.Point(0, 10));
453 jStarLabel2 = new StarLabel();
454 jStarLabel2.setLocation(new java.awt.Point(0, 35));
455
456 jContentPane.add(jStarLabel1, null);
457 jContentPane.add(jStarLabel2, null);
458
459 jContentPane.add(getJComboBoxList(), null);
460 jContentPane.add(getJButtonAdd(), null);
461 jContentPane.add(getJButtonRemove(), null);
462 jContentPane.add(getJButtonUpdate(), null);
463 jContentPane.add(getJScrollPaneList(), null);
464 jContentPane.add(getJScrollPaneArch(), null);
465 jContentPane.add(jLabelHelpText, null);
466 jContentPane.add(getJTextFieldHelpText(), null);
467 }
468 return jContentPane;
469 }
470
471 /**
472 This method initializes Usage type
473
474 **/
475 private void initFrame() {
476 Tools.generateComboBoxByVector(jComboBoxUsage, ed.getVDataHubUsage());
477 this.iCheckBoxListArch.setAllItems(ed.getVSupportedArchitectures());
478 }
479
480 /* (non-Javadoc)
481 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
482 *
483 * Override actionPerformed to listen all actions
484 *
485 */
486 public void actionPerformed(ActionEvent arg0) {
487 if (arg0.getSource() == jButtonAdd) {
488 if (!checkAdd()) {
489 return;
490 }
491 addToList();
492 }
493 if (arg0.getSource() == jButtonRemove) {
494 removeFromList();
495 }
496 if (arg0.getSource() == jButtonUpdate) {
497 if (!checkAdd()) {
498 return;
499 }
500 updateForList();
501 }
502 }
503
504 /**
505 Data validation for all fields
506
507 @retval true - All datas are valid
508 @retval false - At least one data is invalid
509
510 **/
511 public boolean checkAdd() {
512 //
513 // Check if all fields have correct data types
514 //
515
516 //
517 // Check DataHubRecord
518 //
519 if (isEmpty(this.jTextFieldDataHubRecord.getText())) {
520 Log.err("Data Hub Record couldn't be empty");
521 return false;
522 }
523
524 if (!isEmpty(this.jTextFieldDataHubRecord.getText())) {
525 if (!DataValidation.isC_NameType(this.jTextFieldDataHubRecord.getText())) {
526 Log.err("Incorrect data type for Data Hub Record");
527 return false;
528 }
529 }
530
531 //
532 // Check FeatureFlag
533 //
534 if (!isEmpty(this.jTextFieldFeatureFlag.getText())) {
535 if (!DataValidation.isFeatureFlag(this.jTextFieldFeatureFlag.getText())) {
536 Log.err("Incorrect data type for Feature Flag");
537 return false;
538 }
539 }
540
541 return true;
542 }
543
544 /**
545 Save all components of DataHubs
546 if exists dataHubs, set the value directly
547 if not exists dataHubs, new an instance first
548
549 **/
550 public void save() {
551 try {
552 int count = this.vid.size();
553
554 this.dataHubs = DataHubs.Factory.newInstance();
555 if (count > 0) {
556 for (int index = 0; index < count; index++) {
557 DataHubRecord p = DataHubRecord.Factory.newInstance();
558 if (!isEmpty(vid.getDataHubs(index).getName())) {
559 p.setDataHubCName(vid.getDataHubs(index).getName());
560 }
561 if (!isEmpty(vid.getDataHubs(index).getUsage())) {
562 p.setUsage(DataHubUsage.Enum.forString(vid.getDataHubs(index).getUsage()));
563 }
564 if (!isEmpty(vid.getDataHubs(index).getFeatureFlag())) {
565 p.setFeatureFlag(vid.getDataHubs(index).getFeatureFlag());
566 }
567 if (vid.getDataHubs(index).getSupArchList() != null
568 && vid.getDataHubs(index).getSupArchList().size() > 0) {
569 p.setSupArchList(vid.getDataHubs(index).getSupArchList());
570 }
571 if (!isEmpty(vid.getDataHubs(index).getHelp())) {
572 p.setHelpText(vid.getDataHubs(index).getHelp());
573 }
574 this.dataHubs.addNewDataHubRecord();
575 this.dataHubs.setDataHubRecordArray(dataHubs.getDataHubRecordList().size() - 1, p);
576 }
577 }
578
579 this.msa.setDataHubs(dataHubs);
580 this.omt.setSaved(false);
581 } catch (Exception e) {
582 Log.err("Update Data Hubs", e.getMessage());
583 }
584 }
585
586 /* (non-Javadoc)
587 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
588 *
589 * Override componentResized to resize all components when frame's size is changed
590 */
591 public void componentResized(ComponentEvent arg0) {
592 int intCurrentWidth = this.getJContentPane().getWidth();
593 int intCurrentHeight = this.getJContentPane().getHeight();
594 int intPreferredWidth = this.getJContentPane().getPreferredSize().width;
595 int intPreferredHeight = this.getJContentPane().getPreferredSize().height;
596
597 resizeComponentWidth(jTextFieldDataHubRecord, intCurrentWidth, intPreferredWidth);
598 resizeComponentWidth(jComboBoxUsage, intCurrentWidth, intPreferredWidth);
599 resizeComponentWidth(jTextFieldHelpText, intCurrentWidth, intPreferredWidth);
600 resizeComponentWidth(jTextFieldFeatureFlag, intCurrentWidth, intPreferredWidth);
601 resizeComponentWidth(jScrollPaneArch, intCurrentWidth, intPreferredWidth);
602
603 resizeComponentWidth(jComboBoxList, intCurrentWidth, intPreferredWidth);
604 resizeComponent(jScrollPaneList, intCurrentWidth, intCurrentHeight, intPreferredWidth, intPreferredHeight);
605
606 relocateComponentX(jButtonAdd, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_ADD_BUTTON);
607 relocateComponentX(jButtonRemove, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON);
608 relocateComponentX(jButtonUpdate, intCurrentWidth, intPreferredWidth, DataType.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON);
609 }
610
611 private DataHubsIdentification getCurrentDataHubs() {
612 String arg0 = this.jTextFieldDataHubRecord.getText();
613 String arg1 = this.jComboBoxUsage.getSelectedItem().toString();
614
615 String arg2 = this.jTextFieldFeatureFlag.getText();
616 Vector<String> arg3 = this.iCheckBoxListArch.getAllCheckedItemsString();
617 String arg4 = this.jTextFieldHelpText.getText();
618
619 id = new DataHubsIdentification(arg0, arg1, arg2, arg3, arg4);
620 return id;
621 }
622
623 /**
624 Add current item to Vector
625
626 **/
627 private void addToList() {
628 intSelectedItemId = vid.size();
629
630 vid.addDataHubs(getCurrentDataHubs());
631
632 jComboBoxList.addItem(id.getName());
633 jComboBoxList.setSelectedItem(id.getName());
634
635 //
636 // Reset select item index
637 //
638 intSelectedItemId = vid.size();
639
640 //
641 // Reload all fields of selected item
642 //
643 reloadFromList();
644
645 //
646 // Save to memory
647 //
648 save();
649 }
650
651 /**
652 Remove current item from Vector
653
654 **/
655 private void removeFromList() {
656 //
657 // Check if exist items
658 //
659 if (this.vid.size() < 1) {
660 return;
661 }
662
663 int intTempIndex = intSelectedItemId;
664
665 jComboBoxList.removeItemAt(intSelectedItemId);
666
667 vid.removeDataHubs(intTempIndex);
668
669 //
670 // Reload all fields of selected item
671 //
672 reloadFromList();
673
674 //
675 // Save to memory
676 //
677 save();
678 }
679
680 /**
681 Update current item of Vector
682
683 **/
684 private void updateForList() {
685 //
686 // Check if exist items
687 //
688 if (this.vid.size() < 1) {
689 return;
690 }
691
692 //
693 // Backup selected item index
694 //
695 int intTempIndex = intSelectedItemId;
696
697 vid.updateDataHubs(getCurrentDataHubs(), intTempIndex);
698
699 jComboBoxList.removeAllItems();
700 for (int index = 0; index < vid.size(); index++) {
701 jComboBoxList.addItem(vid.getDataHubs(index).getName());
702 }
703
704 //
705 // Restore selected item index
706 //
707 intSelectedItemId = intTempIndex;
708
709 //
710 // Reset select item index
711 //
712 jComboBoxList.setSelectedIndex(intSelectedItemId);
713
714 //
715 // Reload all fields of selected item
716 //
717 reloadFromList();
718
719 //
720 // Save to memory
721 //
722 save();
723 }
724
725 /**
726 Refresh all fields' values of selected item of Vector
727
728 **/
729 private void reloadFromList() {
730 if (vid.size() > 0) {
731 //
732 // Get selected item index
733 //
734 intSelectedItemId = jComboBoxList.getSelectedIndex();
735
736 this.jTextFieldDataHubRecord.setText(vid.getDataHubs(intSelectedItemId).getName());
737 this.jComboBoxUsage.setSelectedItem(vid.getDataHubs(intSelectedItemId).getUsage());
738 this.jTextFieldHelpText.setText(vid.getDataHubs(intSelectedItemId).getHelp());
739
740 jTextFieldFeatureFlag.setText(vid.getDataHubs(intSelectedItemId).getFeatureFlag());
741 iCheckBoxListArch.setAllItemsUnchecked();
742 iCheckBoxListArch.initCheckedItem(true, vid.getDataHubs(intSelectedItemId).getSupArchList());
743
744 } else {
745 }
746
747 reloadListArea();
748 }
749
750 /**
751 Update list area pane via the elements of Vector
752
753 **/
754 private void reloadListArea() {
755 String strListItem = "";
756 for (int index = 0; index < vid.size(); index++) {
757 strListItem = strListItem + vid.getDataHubs(index).getName() + DataType.UNIX_LINE_SEPARATOR;
758 }
759 this.jTextAreaList.setText(strListItem);
760 }
761
762 /* (non-Javadoc)
763 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
764 *
765 * Reflesh the frame when selected item changed
766 *
767 */
768 public void itemStateChanged(ItemEvent arg0) {
769 if (arg0.getSource() == this.jComboBoxList && arg0.getStateChange() == ItemEvent.SELECTED) {
770 reloadFromList();
771 }
772 }
773 }