3 The file is used to create, update Protocol of MSA/MBD file
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
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.
16 package org
.tianocore
.frameworkwizard
.module
.ui
;
18 import java
.awt
.event
.ActionEvent
;
19 import java
.awt
.event
.ComponentEvent
;
20 import java
.awt
.event
.ItemEvent
;
21 import java
.util
.Vector
;
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
;
31 import org
.tianocore
.ProtocolNotifyUsage
;
32 import org
.tianocore
.ProtocolUsage
;
33 import org
.tianocore
.ProtocolsDocument
;
34 import org
.tianocore
.ModuleSurfaceAreaDocument
.ModuleSurfaceArea
;
35 import org
.tianocore
.ProtocolsDocument
.Protocols
;
36 import org
.tianocore
.ProtocolsDocument
.Protocols
.Protocol
;
37 import org
.tianocore
.ProtocolsDocument
.Protocols
.ProtocolNotify
;
38 import org
.tianocore
.frameworkwizard
.common
.DataType
;
39 import org
.tianocore
.frameworkwizard
.common
.DataValidation
;
40 import org
.tianocore
.frameworkwizard
.common
.EnumerationData
;
41 import org
.tianocore
.frameworkwizard
.common
.Log
;
42 import org
.tianocore
.frameworkwizard
.common
.Tools
;
43 import org
.tianocore
.frameworkwizard
.common
.Identifications
.OpeningModuleType
;
44 import org
.tianocore
.frameworkwizard
.common
.ui
.IInternalFrame
;
45 import org
.tianocore
.frameworkwizard
.common
.ui
.StarLabel
;
46 import org
.tianocore
.frameworkwizard
.common
.ui
.iCheckBoxList
.ICheckBoxList
;
47 import org
.tianocore
.frameworkwizard
.module
.Identifications
.Protocols
.ProtocolsIdentification
;
48 import org
.tianocore
.frameworkwizard
.module
.Identifications
.Protocols
.ProtocolsVector
;
49 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
52 The class is used to create, update Protocol of MSA/MBD file
53 It extends IInternalFrame
58 public class ModuleProtocols
extends IInternalFrame
{
61 /// Define class Serial Version UID
63 private static final long serialVersionUID
= -9084913640747858848L;
66 //Define class members
68 private JPanel jContentPane
= null;
70 private JLabel jLabelC_Name
= null;
72 private JLabel jLabelFeatureFlag
= null;
74 private JTextField jTextFieldFeatureFlag
= null;
76 private JLabel jLabelUsage
= null;
78 private JComboBox jComboBoxUsage
= null;
80 private StarLabel jStarLabel1
= null;
82 private StarLabel jStarLabel2
= null;
84 private JLabel jLabelProtocolType
= null;
86 private JLabel jLabelArch
= null;
88 private JTextArea jTextAreaList
= null;
90 private JComboBox jComboBoxList
= null;
92 private JButton jButtonAdd
= null;
94 private JButton jButtonRemove
= null;
96 private JButton jButtonUpdate
= null;
98 private JScrollPane jScrollPane
= null;
100 private JScrollPane jScrollPaneList
= null;
102 private JComboBox jComboBoxProtocolType
= null;
104 private JComboBox jComboBoxCName
= null;
106 private ICheckBoxList iCheckBoxListArch
= null;
108 private JScrollPane jScrollPaneArch
= null;
110 private JLabel jLabelHelpText
= null;
112 private JTextField jTextFieldHelpText
= null;
117 private int intSelectedItemId
= 0;
119 private OpeningModuleType omt
= null;
121 private ModuleSurfaceArea msa
= null;
123 private ProtocolsDocument
.Protocols protocols
= null;
125 private ProtocolsIdentification id
= null;
127 private ProtocolsVector vid
= new ProtocolsVector();
129 private WorkspaceTools wt
= new WorkspaceTools();
131 private EnumerationData ed
= new EnumerationData();
134 This method initializes jTextFieldFeatureFlag
136 @return javax.swing.JTextField jTextFieldFeatureFlag
139 private JTextField
getJTextFieldFeatureFlag() {
140 if (jTextFieldFeatureFlag
== null) {
141 jTextFieldFeatureFlag
= new JTextField();
142 jTextFieldFeatureFlag
.setBounds(new java
.awt
.Rectangle(160, 110, 320, 20));
143 jTextFieldFeatureFlag
.setPreferredSize(new java
.awt
.Dimension(320, 20));
145 return jTextFieldFeatureFlag
;
149 This method initializes jComboBoxUsage
151 @return javax.swing.JComboBox jComboBoxUsage
154 private JComboBox
getJComboBoxProtocolUsage() {
155 if (jComboBoxUsage
== null) {
156 jComboBoxUsage
= new JComboBox();
157 jComboBoxUsage
.setBounds(new java
.awt
.Rectangle(160, 60, 320, 20));
158 jComboBoxUsage
.setPreferredSize(new java
.awt
.Dimension(320, 20));
160 return jComboBoxUsage
;
164 This method initializes jComboBoxFileList
166 @return javax.swing.JComboBox jComboBoxFileList
169 private JComboBox
getJComboBoxList() {
170 if (jComboBoxList
== null) {
171 jComboBoxList
= new JComboBox();
172 jComboBoxList
.setBounds(new java
.awt
.Rectangle(15, 220, 210, 20));
173 jComboBoxList
.addItemListener(this);
174 jComboBoxList
.addActionListener(this);
175 jComboBoxList
.setPreferredSize(new java
.awt
.Dimension(210, 20));
177 return jComboBoxList
;
181 This method initializes jButtonAdd
183 @return javax.swing.JButton jButtonAdd
186 private JButton
getJButtonAdd() {
187 if (jButtonAdd
== null) {
188 jButtonAdd
= new JButton();
189 jButtonAdd
.setBounds(new java
.awt
.Rectangle(230, 220, 80, 20));
190 jButtonAdd
.setText("Add");
191 jButtonAdd
.addActionListener(this);
192 jButtonAdd
.setPreferredSize(new java
.awt
.Dimension(80, 20));
198 This method initializes jButtonRemove
200 @return javax.swing.JButton jButtonRemove
203 private JButton
getJButtonRemove() {
204 if (jButtonRemove
== null) {
205 jButtonRemove
= new JButton();
206 jButtonRemove
.setBounds(new java
.awt
.Rectangle(400, 220, 80, 20));
207 jButtonRemove
.setText("Remove");
208 jButtonRemove
.addActionListener(this);
209 jButtonRemove
.setPreferredSize(new java
.awt
.Dimension(80, 20));
211 return jButtonRemove
;
215 This method initializes jButtonUpdate
217 @return javax.swing.JButton jButtonUpdate
220 private JButton
getJButtonUpdate() {
221 if (jButtonUpdate
== null) {
222 jButtonUpdate
= new JButton();
223 jButtonUpdate
.setBounds(new java
.awt
.Rectangle(315, 220, 80, 20));
224 jButtonUpdate
.setPreferredSize(new java
.awt
.Dimension(80, 20));
225 jButtonUpdate
.setText("Update");
226 jButtonUpdate
.addActionListener(this);
228 return jButtonUpdate
;
232 * This method initializes jScrollPaneFileList
234 * @return javax.swing.JScrollPane
236 private JScrollPane
getJScrollPaneList() {
237 if (jScrollPaneList
== null) {
238 jScrollPaneList
= new JScrollPane();
239 jScrollPaneList
.setBounds(new java
.awt
.Rectangle(15, 245, 465, 240));
240 jScrollPaneList
.setViewportView(getJTextAreaList());
241 jScrollPaneList
.setPreferredSize(new java
.awt
.Dimension(465, 240));
243 return jScrollPaneList
;
247 This method initializes jScrollPane
249 @return javax.swing.JScrollPane
251 private JScrollPane
getJScrollPane() {
252 if (jScrollPane
== null) {
253 jScrollPane
= new JScrollPane();
254 jScrollPane
.setViewportView(getJContentPane());
260 * This method initializes jTextAreaFileList
262 * @return javax.swing.JTextArea
264 private JTextArea
getJTextAreaList() {
265 if (jTextAreaList
== null) {
266 jTextAreaList
= new JTextArea();
267 jTextAreaList
.setEditable(false);
270 return jTextAreaList
;
274 * This method initializes jComboBoxProtocolType
276 * @return javax.swing.JComboBox
278 private JComboBox
getJComboBoxProtocolType() {
279 if (jComboBoxProtocolType
== null) {
280 jComboBoxProtocolType
= new JComboBox();
281 jComboBoxProtocolType
.setBounds(new java
.awt
.Rectangle(160, 10, 320, 20));
282 jComboBoxProtocolType
.setPreferredSize(new java
.awt
.Dimension(320, 20));
283 jComboBoxProtocolType
.addItemListener(this);
284 jComboBoxProtocolType
.setToolTipText("Select Protocol Type");
286 return jComboBoxProtocolType
;
290 * This method initializes jComboBoxCName
292 * @return javax.swing.JComboBox
294 private JComboBox
getJComboBoxCName() {
295 if (jComboBoxCName
== null) {
296 jComboBoxCName
= new JComboBox();
297 jComboBoxCName
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
298 jComboBoxCName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
301 return jComboBoxCName
;
305 This method initializes iCheckBoxListArch
307 @return ICheckBoxList
309 private ICheckBoxList
getICheckBoxListSupportedArchitectures() {
310 if (iCheckBoxListArch
== null) {
311 iCheckBoxListArch
= new ICheckBoxList();
312 iCheckBoxListArch
.addFocusListener(this);
313 iCheckBoxListArch
.setToolTipText(DataType
.SUP_ARCH_LIST_HELP_TEXT
);
315 return iCheckBoxListArch
;
319 This method initializes jScrollPaneArch
321 @return javax.swing.JScrollPane
324 private JScrollPane
getJScrollPaneArch() {
325 if (jScrollPaneArch
== null) {
326 jScrollPaneArch
= new JScrollPane();
327 jScrollPaneArch
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 80));
328 jScrollPaneArch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
329 jScrollPaneArch
.setViewportView(getICheckBoxListSupportedArchitectures());
331 return jScrollPaneArch
;
335 This method initializes jTextFieldHelpText
337 @return javax.swing.JTextField
340 private JTextField
getJTextFieldHelpText() {
341 if (jTextFieldHelpText
== null) {
342 jTextFieldHelpText
= new JTextField();
343 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
344 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
346 return jTextFieldHelpText
;
349 public static void main(String
[] args
) {
354 This method initializes this
357 private void init() {
358 this.setSize(500, 515);
359 this.setContentPane(getJScrollPane());
360 this.setTitle("Protocols");
362 this.setViewMode(false);
366 This method initializes this
367 Fill values to all fields if these values are not empty
369 @param inPackageDependencies
372 private void init(Protocols inProtocols
) {
374 this.protocols
= inProtocols
;
376 if (this.protocols
!= null) {
377 if (this.protocols
.getProtocolList().size() > 0) {
378 for (int index
= 0; index
< this.protocols
.getProtocolList().size(); index
++) {
379 String arg0
= protocols
.getProtocolList().get(index
).getProtocolCName();
380 String arg1
= ed
.getVProtocolType().get(0);
382 if (protocols
.getProtocolList().get(index
).getUsage() != null) {
383 arg2
= protocols
.getProtocolList().get(index
).getUsage().toString();
386 String arg3
= protocols
.getProtocolList().get(index
).getFeatureFlag();
387 Vector
<String
> arg4
= Tools
.convertListToVector(protocols
.getProtocolList().get(index
)
389 String arg5
= protocols
.getProtocolList().get(index
).getHelpText();
390 id
= new ProtocolsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
391 vid
.addProtocols(id
);
394 if (this.protocols
.getProtocolNotifyList().size() > 0) {
395 for (int index
= 0; index
< this.protocols
.getProtocolNotifyList().size(); index
++) {
396 String arg0
= protocols
.getProtocolNotifyList().get(index
).getProtocolNotifyCName();
397 String arg1
= ed
.getVProtocolType().get(1);
399 if (protocols
.getProtocolNotifyList().get(index
).getUsage() != null) {
400 arg2
= protocols
.getProtocolNotifyList().get(index
).getUsage().toString();
403 String arg3
= protocols
.getProtocolNotifyList().get(index
).getFeatureFlag();
404 Vector
<String
> arg4
= Tools
.convertListToVector(protocols
.getProtocolNotifyList().get(index
)
406 String arg5
= protocols
.getProtocolNotifyList().get(index
).getHelpText();
407 id
= new ProtocolsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
408 vid
.addProtocols(id
);
415 Tools
.generateComboBoxByVector(jComboBoxList
, vid
.getProtocolsName());
420 This is the default constructor
423 public ModuleProtocols() {
426 this.setVisible(true);
430 This is the override edit constructor
432 @param inProtocol The input data of ProtocolsDocument.Protocols
435 public ModuleProtocols(OpeningModuleType inOmt
) {
438 this.msa
= omt
.getXmlMsa();
439 init(msa
.getProtocols());
440 this.setVisible(true);
444 Disable all components when the mode is view
446 @param isView true - The view mode; false - The non-view mode
449 public void setViewMode(boolean isView
) {
451 this.jComboBoxUsage
.setEnabled(!isView
);
452 this.jTextFieldFeatureFlag
.setEnabled(!isView
);
457 This method initializes jContentPane
459 @return javax.swing.JPanel jContentPane
462 private JPanel
getJContentPane() {
463 if (jContentPane
== null) {
464 jLabelHelpText
= new JLabel();
465 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 85, 140, 20));
466 jLabelHelpText
.setText("Help Text");
467 jLabelArch
= new JLabel();
468 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
469 jLabelArch
.setText("Arch Type");
470 jLabelProtocolType
= new JLabel();
471 jLabelProtocolType
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
472 jLabelProtocolType
.setText("Protocol Type");
473 jLabelUsage
= new JLabel();
474 jLabelUsage
.setText("Usage");
475 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
476 jLabelFeatureFlag
= new JLabel();
477 jLabelFeatureFlag
.setText("Feature Flag");
478 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
479 jLabelC_Name
= new JLabel();
480 jLabelC_Name
.setText("C_Name Type");
481 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
483 jContentPane
= new JPanel();
484 jContentPane
.setLayout(null);
485 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 495));
487 jContentPane
.add(jLabelC_Name
, null);
488 jContentPane
.add(jLabelFeatureFlag
, null);
489 jContentPane
.add(getJTextFieldFeatureFlag(), null);
490 jContentPane
.add(jLabelUsage
, null);
491 jContentPane
.add(getJComboBoxProtocolUsage(), null);
492 jContentPane
.add(jLabelProtocolType
, null);
494 jStarLabel1
= new StarLabel();
495 jStarLabel1
.setBounds(new java
.awt
.Rectangle(0, 10, 10, 20));
496 jStarLabel2
= new StarLabel();
497 jStarLabel2
.setBounds(new java
.awt
.Rectangle(0, 35, 10, 20));
499 jContentPane
.add(jStarLabel1
, null);
500 jContentPane
.add(jStarLabel2
, null);
501 jContentPane
.add(jLabelArch
, null);
502 jContentPane
.add(getJComboBoxList(), null);
503 jContentPane
.add(getJButtonAdd(), null);
504 jContentPane
.add(getJButtonRemove(), null);
505 jContentPane
.add(getJButtonUpdate(), null);
506 jContentPane
.add(getJScrollPaneList(), null);
508 jContentPane
.add(getJComboBoxProtocolType(), null);
509 jContentPane
.add(getJComboBoxCName(), null);
510 jContentPane
.add(getJScrollPaneArch(), null);
511 jContentPane
.add(jLabelHelpText
, null);
512 jContentPane
.add(getJTextFieldHelpText(), null);
518 This method initializes Usage type
521 private void initFrame() {
522 Tools
.generateComboBoxByVector(jComboBoxProtocolType
, ed
.getVProtocolType());
523 Tools
.generateComboBoxByVector(jComboBoxCName
, wt
.getAllProtocolDeclarationsFromWorkspace());
524 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVProtocolUsage());
526 this.iCheckBoxListArch
.setAllItems(ed
.getVSupportedArchitectures());
530 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
532 * Override actionPerformed to listen all actions
535 public void actionPerformed(ActionEvent arg0
) {
536 if (arg0
.getSource() == jButtonAdd
) {
542 if (arg0
.getSource() == jButtonRemove
) {
545 if (arg0
.getSource() == jButtonUpdate
) {
554 Data validation for all fields
556 @retval true - All datas are valid
557 @retval false - At least one data is invalid
560 public boolean checkAdd() {
562 // Check if all fields have correct data types
568 if (!isEmpty(this.jComboBoxCName
.getSelectedItem().toString())) {
569 if (!DataValidation
.isC_NameType(this.jComboBoxCName
.getSelectedItem().toString())) {
570 Log
.err("Incorrect data type for Protocol/ProtocolNotify Name");
578 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
579 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
580 Log
.err("Incorrect data type for Feature Flag");
589 Save all components of Protocols
590 if exists protocols, set the value directly
591 if not exists protocols, new an instance first
596 int count
= this.vid
.size();
598 this.protocols
= Protocols
.Factory
.newInstance();
600 for (int index
= 0; index
< count
; index
++) {
601 if (vid
.getProtocols(index
).getType().equals(ed
.getVProtocolType().get(0))) {
602 Protocol p
= Protocol
.Factory
.newInstance();
603 if (!isEmpty(vid
.getProtocols(index
).getName())) {
604 p
.setProtocolCName(vid
.getProtocols(index
).getName());
606 if (!isEmpty(vid
.getProtocols(index
).getUsage())) {
607 p
.setUsage(ProtocolUsage
.Enum
.forString(vid
.getProtocols(index
).getUsage()));
609 if (!isEmpty(vid
.getProtocols(index
).getFeatureFlag())) {
610 p
.setFeatureFlag(vid
.getProtocols(index
).getFeatureFlag());
612 if (vid
.getProtocols(index
).getSupArchList() != null
613 && vid
.getProtocols(index
).getSupArchList().size() > 0) {
614 p
.setSupArchList(vid
.getProtocols(index
).getSupArchList());
616 if (!isEmpty(vid
.getProtocols(index
).getHelp())) {
617 p
.setHelpText(vid
.getProtocols(index
).getHelp());
619 this.protocols
.addNewProtocol();
620 this.protocols
.setProtocolArray(protocols
.getProtocolList().size() - 1, p
);
622 if (vid
.getProtocols(index
).getType().equals(ed
.getVProtocolType().get(1))) {
623 ProtocolNotify p
= ProtocolNotify
.Factory
.newInstance();
624 if (!isEmpty(vid
.getProtocols(index
).getName())) {
625 p
.setProtocolNotifyCName(vid
.getProtocols(index
).getName());
627 if (!isEmpty(vid
.getProtocols(index
).getUsage())) {
628 p
.setUsage(ProtocolNotifyUsage
.Enum
.forString(vid
.getProtocols(index
).getUsage()));
630 if (!isEmpty(vid
.getProtocols(index
).getFeatureFlag())) {
631 p
.setFeatureFlag(vid
.getProtocols(index
).getFeatureFlag());
633 if (vid
.getProtocols(index
).getSupArchList() != null
634 && vid
.getProtocols(index
).getSupArchList().size() > 0) {
635 p
.setSupArchList(vid
.getProtocols(index
).getSupArchList());
637 if (!isEmpty(vid
.getProtocols(index
).getHelp())) {
638 p
.setHelpText(vid
.getProtocols(index
).getHelp());
640 this.protocols
.addNewProtocolNotify();
641 this.protocols
.setProtocolNotifyArray(protocols
.getProtocolNotifyList().size() - 1, p
);
646 this.msa
.setProtocols(protocols
);
647 this.omt
.setSaved(false);
648 } catch (Exception e
) {
650 Log
.err("Update Protocols", e
.getMessage());
655 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
657 * Override componentResized to resize all components when frame's size is changed
659 public void componentResized(ComponentEvent arg0
) {
660 int intCurrentWidth
= this.getJContentPane().getWidth();
661 int intCurrentHeight
= this.getJContentPane().getHeight();
662 int intPreferredWidth
= this.getJContentPane().getPreferredSize().width
;
663 int intPreferredHeight
= this.getJContentPane().getPreferredSize().height
;
665 resizeComponentWidth(this.jComboBoxProtocolType
, intCurrentWidth
, intPreferredWidth
);
666 resizeComponentWidth(this.jComboBoxCName
, intCurrentWidth
, intPreferredWidth
);
667 resizeComponentWidth(this.jComboBoxUsage
, intCurrentWidth
, intPreferredWidth
);
668 resizeComponentWidth(this.jTextFieldHelpText
, intCurrentWidth
, intPreferredWidth
);
669 resizeComponentWidth(this.jTextFieldFeatureFlag
, intCurrentWidth
, intPreferredWidth
);
670 resizeComponentWidth(this.jScrollPaneArch
, intCurrentWidth
, intPreferredWidth
);
672 resizeComponentWidth(this.jComboBoxList
, intCurrentWidth
, intPreferredWidth
);
673 resizeComponent(this.jScrollPaneList
, intCurrentWidth
, intCurrentHeight
, intPreferredWidth
, intPreferredHeight
);
675 relocateComponentX(this.jButtonAdd
, intCurrentWidth
, intPreferredWidth
, DataType
.SPACE_TO_RIGHT_FOR_ADD_BUTTON
);
676 relocateComponentX(this.jButtonRemove
, intCurrentWidth
, intPreferredWidth
,
677 DataType
.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON
);
678 relocateComponentX(this.jButtonUpdate
, intCurrentWidth
, intPreferredWidth
,
679 DataType
.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON
);
682 private ProtocolsIdentification
getCurrentProtocols() {
683 String arg0
= this.jComboBoxCName
.getSelectedItem().toString();
684 String arg1
= this.jComboBoxProtocolType
.getSelectedItem().toString();
685 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
687 String arg3
= this.jTextFieldFeatureFlag
.getText();
688 Vector
<String
> arg4
= this.iCheckBoxListArch
.getAllCheckedItemsString();
689 String arg5
= this.jTextFieldHelpText
.getText();
690 id
= new ProtocolsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
695 Add current item to Vector
698 private void addToList() {
699 intSelectedItemId
= vid
.size();
701 vid
.addProtocols(getCurrentProtocols());
703 jComboBoxList
.addItem(id
.getName());
704 jComboBoxList
.setSelectedItem(id
.getName());
707 // Reset select item index
709 intSelectedItemId
= vid
.size();
712 // Reload all fields of selected item
723 Remove current item from Vector
726 private void removeFromList() {
728 // Check if exist items
730 if (this.vid
.size() < 1) {
734 int intTempIndex
= intSelectedItemId
;
736 jComboBoxList
.removeItemAt(intSelectedItemId
);
738 vid
.removeProtocols(intTempIndex
);
741 // Reload all fields of selected item
752 Update current item of Vector
755 private void updateForList() {
757 // Check if exist items
759 if (this.vid
.size() < 1) {
764 // Backup selected item index
766 int intTempIndex
= intSelectedItemId
;
768 vid
.updateProtocols(getCurrentProtocols(), intTempIndex
);
770 jComboBoxList
.removeAllItems();
771 for (int index
= 0; index
< vid
.size(); index
++) {
772 jComboBoxList
.addItem(vid
.getProtocols(index
).getName());
776 // Restore selected item index
778 intSelectedItemId
= intTempIndex
;
781 // Reset select item index
783 jComboBoxList
.setSelectedIndex(intSelectedItemId
);
786 // Reload all fields of selected item
797 Refresh all fields' values of selected item of Vector
800 private void reloadFromList() {
801 if (vid
.size() > 0) {
803 // Get selected item index
805 intSelectedItemId
= jComboBoxList
.getSelectedIndex();
807 this.jComboBoxCName
.setSelectedItem(vid
.getProtocols(intSelectedItemId
).getName());
808 this.jComboBoxProtocolType
.setSelectedItem(vid
.getProtocols(intSelectedItemId
).getType());
809 this.jComboBoxUsage
.setSelectedItem(vid
.getProtocols(intSelectedItemId
).getUsage());
810 this.jTextFieldHelpText
.setText(vid
.getProtocols(intSelectedItemId
).getHelp());
812 jTextFieldFeatureFlag
.setText(vid
.getProtocols(intSelectedItemId
).getFeatureFlag());
813 iCheckBoxListArch
.setAllItemsUnchecked();
814 iCheckBoxListArch
.initCheckedItem(true, vid
.getProtocols(intSelectedItemId
).getSupArchList());
824 Update list area pane via the elements of Vector
827 private void reloadListArea() {
828 String strListItem
= "";
829 for (int index
= 0; index
< vid
.size(); index
++) {
830 strListItem
= strListItem
+ vid
.getProtocols(index
).getName() + DataType
.UNIX_LINE_SEPARATOR
;
832 this.jTextAreaList
.setText(strListItem
);
836 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
838 * Reflesh the frame when selected item changed
841 public void itemStateChanged(ItemEvent arg0
) {
842 if (arg0
.getSource() == this.jComboBoxList
&& arg0
.getStateChange() == ItemEvent
.SELECTED
) {
845 if (arg0
.getSource() == this.jComboBoxProtocolType
&& arg0
.getStateChange() == ItemEvent
.SELECTED
) {
846 if (this.jComboBoxProtocolType
.getSelectedItem().toString().equals(ed
.getVProtocolType().get(0))) {
847 Tools
.generateComboBoxByVector(this.jComboBoxUsage
, ed
.getVProtocolUsage());
849 Tools
.generateComboBoxByVector(this.jComboBoxUsage
, ed
.getVProtocolNotifyUsage());