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