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
.OpeningModuleType
;
43 import org
.tianocore
.frameworkwizard
.common
.Tools
;
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
.Identification
.Protocols
.ProtocolsIdentification
;
48 import org
.tianocore
.frameworkwizard
.module
.Identification
.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);
285 return jComboBoxProtocolType
;
289 * This method initializes jComboBoxCName
291 * @return javax.swing.JComboBox
293 private JComboBox
getJComboBoxCName() {
294 if (jComboBoxCName
== null) {
295 jComboBoxCName
= new JComboBox();
296 jComboBoxCName
.setBounds(new java
.awt
.Rectangle(160, 35, 320, 20));
297 jComboBoxCName
.setPreferredSize(new java
.awt
.Dimension(320, 20));
300 return jComboBoxCName
;
304 This method initializes iCheckBoxListArch
306 @return ICheckBoxList
308 private ICheckBoxList
getICheckBoxListSupportedArchitectures() {
309 if (iCheckBoxListArch
== null) {
310 iCheckBoxListArch
= new ICheckBoxList();
311 iCheckBoxListArch
.addFocusListener(this);
312 iCheckBoxListArch
.setToolTipText(DataType
.SUP_ARCH_LIST_HELP_TEXT
);
314 return iCheckBoxListArch
;
318 This method initializes jScrollPaneArch
320 @return javax.swing.JScrollPane
323 private JScrollPane
getJScrollPaneArch() {
324 if (jScrollPaneArch
== null) {
325 jScrollPaneArch
= new JScrollPane();
326 jScrollPaneArch
.setBounds(new java
.awt
.Rectangle(160, 135, 320, 80));
327 jScrollPaneArch
.setPreferredSize(new java
.awt
.Dimension(320, 80));
328 jScrollPaneArch
.setViewportView(getICheckBoxListSupportedArchitectures());
330 return jScrollPaneArch
;
334 This method initializes jTextFieldHelpText
336 @return javax.swing.JTextField
339 private JTextField
getJTextFieldHelpText() {
340 if (jTextFieldHelpText
== null) {
341 jTextFieldHelpText
= new JTextField();
342 jTextFieldHelpText
.setBounds(new java
.awt
.Rectangle(160, 85, 320, 20));
343 jTextFieldHelpText
.setPreferredSize(new java
.awt
.Dimension(320, 20));
345 return jTextFieldHelpText
;
348 public static void main(String
[] args
) {
353 This method initializes this
356 private void init() {
357 this.setSize(500, 515);
358 this.setContentPane(getJScrollPane());
359 this.setTitle("Protocols");
361 this.setViewMode(false);
365 This method initializes this
366 Fill values to all fields if these values are not empty
368 @param inPackageDependencies
371 private void init(Protocols inProtocols
) {
373 this.protocols
= inProtocols
;
375 if (this.protocols
!= null) {
376 if (this.protocols
.getProtocolList().size() > 0) {
377 for (int index
= 0; index
< this.protocols
.getProtocolList().size(); index
++) {
378 String arg0
= protocols
.getProtocolList().get(index
).getProtocolCName();
379 String arg1
= ed
.getVProtocolType().get(0);
381 if (protocols
.getProtocolList().get(index
).getUsage() != null) {
382 arg2
= protocols
.getProtocolList().get(index
).getUsage().toString();
385 String arg3
= protocols
.getProtocolList().get(index
).getFeatureFlag();
386 Vector
<String
> arg4
= Tools
.convertListToVector(protocols
.getProtocolList().get(index
)
388 String arg5
= protocols
.getProtocolList().get(index
).getHelpText();
389 id
= new ProtocolsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
390 vid
.addProtocols(id
);
393 if (this.protocols
.getProtocolNotifyList().size() > 0) {
394 for (int index
= 0; index
< this.protocols
.getProtocolNotifyList().size(); index
++) {
395 String arg0
= protocols
.getProtocolNotifyList().get(index
).getProtocolNotifyCName();
396 String arg1
= ed
.getVProtocolType().get(1);
398 if (protocols
.getProtocolNotifyList().get(index
).getUsage() != null) {
399 arg2
= protocols
.getProtocolNotifyList().get(index
).getUsage().toString();
402 String arg3
= protocols
.getProtocolNotifyList().get(index
).getFeatureFlag();
403 Vector
<String
> arg4
= Tools
.convertListToVector(protocols
.getProtocolNotifyList().get(index
)
405 String arg5
= protocols
.getProtocolNotifyList().get(index
).getHelpText();
406 id
= new ProtocolsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
407 vid
.addProtocols(id
);
414 Tools
.generateComboBoxByVector(jComboBoxList
, vid
.getProtocolsName());
419 This is the default constructor
422 public ModuleProtocols() {
425 this.setVisible(true);
429 This is the override edit constructor
431 @param inProtocol The input data of ProtocolsDocument.Protocols
434 public ModuleProtocols(OpeningModuleType inOmt
) {
437 this.msa
= omt
.getXmlMsa();
438 init(msa
.getProtocols());
439 this.setVisible(true);
443 Disable all components when the mode is view
445 @param isView true - The view mode; false - The non-view mode
448 public void setViewMode(boolean isView
) {
450 this.jComboBoxUsage
.setEnabled(!isView
);
451 this.jTextFieldFeatureFlag
.setEnabled(!isView
);
456 This method initializes jContentPane
458 @return javax.swing.JPanel jContentPane
461 private JPanel
getJContentPane() {
462 if (jContentPane
== null) {
463 jLabelHelpText
= new JLabel();
464 jLabelHelpText
.setBounds(new java
.awt
.Rectangle(14, 85, 140, 20));
465 jLabelHelpText
.setText("Help Text");
466 jLabelArch
= new JLabel();
467 jLabelArch
.setBounds(new java
.awt
.Rectangle(15, 135, 140, 20));
468 jLabelArch
.setText("Arch Type");
469 jLabelProtocolType
= new JLabel();
470 jLabelProtocolType
.setBounds(new java
.awt
.Rectangle(15, 10, 140, 20));
471 jLabelProtocolType
.setText("Protocol Type");
472 jLabelUsage
= new JLabel();
473 jLabelUsage
.setText("Usage");
474 jLabelUsage
.setBounds(new java
.awt
.Rectangle(15, 60, 140, 20));
475 jLabelFeatureFlag
= new JLabel();
476 jLabelFeatureFlag
.setText("Feature Flag");
477 jLabelFeatureFlag
.setBounds(new java
.awt
.Rectangle(15, 110, 140, 20));
478 jLabelC_Name
= new JLabel();
479 jLabelC_Name
.setText("C_Name Type");
480 jLabelC_Name
.setBounds(new java
.awt
.Rectangle(15, 35, 140, 20));
482 jContentPane
= new JPanel();
483 jContentPane
.setLayout(null);
484 jContentPane
.setPreferredSize(new java
.awt
.Dimension(490, 495));
486 jContentPane
.add(jLabelC_Name
, null);
487 jContentPane
.add(jLabelFeatureFlag
, null);
488 jContentPane
.add(getJTextFieldFeatureFlag(), null);
489 jContentPane
.add(jLabelUsage
, null);
490 jContentPane
.add(getJComboBoxProtocolUsage(), null);
491 jContentPane
.add(jLabelProtocolType
, null);
493 jStarLabel1
= new StarLabel();
494 jStarLabel1
.setBounds(new java
.awt
.Rectangle(0, 10, 10, 20));
495 jStarLabel2
= new StarLabel();
496 jStarLabel2
.setBounds(new java
.awt
.Rectangle(0, 35, 10, 20));
498 jContentPane
.add(jStarLabel1
, null);
499 jContentPane
.add(jStarLabel2
, null);
500 jContentPane
.add(jLabelArch
, null);
501 jContentPane
.add(getJComboBoxList(), null);
502 jContentPane
.add(getJButtonAdd(), null);
503 jContentPane
.add(getJButtonRemove(), null);
504 jContentPane
.add(getJButtonUpdate(), null);
505 jContentPane
.add(getJScrollPaneList(), null);
507 jContentPane
.add(getJComboBoxProtocolType(), null);
508 jContentPane
.add(getJComboBoxCName(), null);
509 jContentPane
.add(getJScrollPaneArch(), null);
510 jContentPane
.add(jLabelHelpText
, null);
511 jContentPane
.add(getJTextFieldHelpText(), null);
517 This method initializes Usage type
520 private void initFrame() {
521 Tools
.generateComboBoxByVector(jComboBoxProtocolType
, ed
.getVProtocolType());
522 Tools
.generateComboBoxByVector(jComboBoxCName
, wt
.getAllProtocolDeclarationsFromWorkspace());
523 Tools
.generateComboBoxByVector(jComboBoxUsage
, ed
.getVProtocolUsage());
525 this.iCheckBoxListArch
.setAllItems(ed
.getVSupportedArchitectures());
529 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
531 * Override actionPerformed to listen all actions
534 public void actionPerformed(ActionEvent arg0
) {
535 if (arg0
.getSource() == jButtonAdd
) {
541 if (arg0
.getSource() == jButtonRemove
) {
544 if (arg0
.getSource() == jButtonUpdate
) {
553 Data validation for all fields
555 @retval true - All datas are valid
556 @retval false - At least one data is invalid
559 public boolean checkAdd() {
561 // Check if all fields have correct data types
567 if (!isEmpty(this.jComboBoxCName
.getSelectedItem().toString())) {
568 if (!DataValidation
.isC_NameType(this.jComboBoxCName
.getSelectedItem().toString())) {
569 Log
.err("Incorrect data type for Protocol/ProtocolNotify Name");
577 if (!isEmpty(this.jTextFieldFeatureFlag
.getText())) {
578 if (!DataValidation
.isFeatureFlag(this.jTextFieldFeatureFlag
.getText())) {
579 Log
.err("Incorrect data type for Feature Flag");
588 Save all components of Protocols
589 if exists protocols, set the value directly
590 if not exists protocols, new an instance first
595 int count
= this.vid
.size();
597 this.protocols
= Protocols
.Factory
.newInstance();
599 for (int index
= 0; index
< count
; index
++) {
600 if (vid
.getProtocols(index
).getType().equals(ed
.getVProtocolType().get(0))) {
601 Protocol p
= Protocol
.Factory
.newInstance();
602 if (!isEmpty(vid
.getProtocols(index
).getName())) {
603 p
.setProtocolCName(vid
.getProtocols(index
).getName());
605 if (!isEmpty(vid
.getProtocols(index
).getUsage())) {
606 p
.setUsage(ProtocolUsage
.Enum
.forString(vid
.getProtocols(index
).getUsage()));
608 if (!isEmpty(vid
.getProtocols(index
).getFeatureFlag())) {
609 p
.setFeatureFlag(vid
.getProtocols(index
).getFeatureFlag());
611 if (vid
.getProtocols(index
).getSupArchList() != null
612 && vid
.getProtocols(index
).getSupArchList().size() > 0) {
613 p
.setSupArchList(vid
.getProtocols(index
).getSupArchList());
615 if (!isEmpty(vid
.getProtocols(index
).getHelp())) {
616 p
.setHelpText(vid
.getProtocols(index
).getHelp());
618 this.protocols
.addNewProtocol();
619 this.protocols
.setProtocolArray(protocols
.getProtocolList().size() - 1, p
);
621 if (vid
.getProtocols(index
).getType().equals(ed
.getVProtocolType().get(1))) {
622 ProtocolNotify p
= ProtocolNotify
.Factory
.newInstance();
623 if (!isEmpty(vid
.getProtocols(index
).getName())) {
624 p
.setProtocolNotifyCName(vid
.getProtocols(index
).getName());
626 if (!isEmpty(vid
.getProtocols(index
).getUsage())) {
627 p
.setUsage(ProtocolNotifyUsage
.Enum
.forString(vid
.getProtocols(index
).getUsage()));
629 if (!isEmpty(vid
.getProtocols(index
).getFeatureFlag())) {
630 p
.setFeatureFlag(vid
.getProtocols(index
).getFeatureFlag());
632 if (vid
.getProtocols(index
).getSupArchList() != null
633 && vid
.getProtocols(index
).getSupArchList().size() > 0) {
634 p
.setSupArchList(vid
.getProtocols(index
).getSupArchList());
636 if (!isEmpty(vid
.getProtocols(index
).getHelp())) {
637 p
.setHelpText(vid
.getProtocols(index
).getHelp());
639 this.protocols
.addNewProtocolNotify();
640 this.protocols
.setProtocolNotifyArray(protocols
.getProtocolNotifyList().size() - 1, p
);
645 this.msa
.setProtocols(protocols
);
646 this.omt
.setSaved(false);
647 } catch (Exception e
) {
649 Log
.err("Update Protocols", e
.getMessage());
654 * @see java.awt.event.ComponentListener#componentResized(java.awt.event.ComponentEvent)
656 * Override componentResized to resize all components when frame's size is changed
658 public void componentResized(ComponentEvent arg0
) {
659 int intCurrentWidth
= this.getJContentPane().getWidth();
660 int intCurrentHeight
= this.getJContentPane().getHeight();
661 int intPreferredWidth
= this.getJContentPane().getPreferredSize().width
;
662 int intPreferredHeight
= this.getJContentPane().getPreferredSize().height
;
664 resizeComponentWidth(this.jComboBoxProtocolType
, intCurrentWidth
, intPreferredWidth
);
665 resizeComponentWidth(this.jComboBoxCName
, intCurrentWidth
, intPreferredWidth
);
666 resizeComponentWidth(this.jComboBoxUsage
, intCurrentWidth
, intPreferredWidth
);
667 resizeComponentWidth(this.jTextFieldHelpText
, intCurrentWidth
, intPreferredWidth
);
668 resizeComponentWidth(this.jTextFieldFeatureFlag
, intCurrentWidth
, intPreferredWidth
);
669 resizeComponentWidth(this.jScrollPaneArch
, intCurrentWidth
, intPreferredWidth
);
671 resizeComponentWidth(this.jComboBoxList
, intCurrentWidth
, intPreferredWidth
);
672 resizeComponent(this.jScrollPaneList
, intCurrentWidth
, intCurrentHeight
, intPreferredWidth
, intPreferredHeight
);
674 relocateComponentX(this.jButtonAdd
, intCurrentWidth
, intPreferredWidth
, DataType
.SPACE_TO_RIGHT_FOR_ADD_BUTTON
);
675 relocateComponentX(this.jButtonRemove
, intCurrentWidth
, intPreferredWidth
,
676 DataType
.SPACE_TO_RIGHT_FOR_REMOVE_BUTTON
);
677 relocateComponentX(this.jButtonUpdate
, intCurrentWidth
, intPreferredWidth
,
678 DataType
.SPACE_TO_RIGHT_FOR_UPDATE_BUTTON
);
681 private ProtocolsIdentification
getCurrentProtocols() {
682 String arg0
= this.jComboBoxCName
.getSelectedItem().toString();
683 String arg1
= this.jComboBoxProtocolType
.getSelectedItem().toString();
684 String arg2
= this.jComboBoxUsage
.getSelectedItem().toString();
686 String arg3
= this.jTextFieldFeatureFlag
.getText();
687 Vector
<String
> arg4
= this.iCheckBoxListArch
.getAllCheckedItemsString();
688 String arg5
= this.jTextFieldHelpText
.getText();
689 id
= new ProtocolsIdentification(arg0
, arg1
, arg2
, arg3
, arg4
, arg5
);
694 Add current item to Vector
697 private void addToList() {
698 intSelectedItemId
= vid
.size();
700 vid
.addProtocols(getCurrentProtocols());
702 jComboBoxList
.addItem(id
.getName());
703 jComboBoxList
.setSelectedItem(id
.getName());
706 // Reset select item index
708 intSelectedItemId
= vid
.size();
711 // Reload all fields of selected item
722 Remove current item from Vector
725 private void removeFromList() {
727 // Check if exist items
729 if (this.vid
.size() < 1) {
733 int intTempIndex
= intSelectedItemId
;
735 jComboBoxList
.removeItemAt(intSelectedItemId
);
737 vid
.removeProtocols(intTempIndex
);
740 // Reload all fields of selected item
751 Update current item of Vector
754 private void updateForList() {
756 // Check if exist items
758 if (this.vid
.size() < 1) {
763 // Backup selected item index
765 int intTempIndex
= intSelectedItemId
;
767 vid
.updateProtocols(getCurrentProtocols(), intTempIndex
);
769 jComboBoxList
.removeAllItems();
770 for (int index
= 0; index
< vid
.size(); index
++) {
771 jComboBoxList
.addItem(vid
.getProtocols(index
).getName());
775 // Restore selected item index
777 intSelectedItemId
= intTempIndex
;
780 // Reset select item index
782 jComboBoxList
.setSelectedIndex(intSelectedItemId
);
785 // Reload all fields of selected item
796 Refresh all fields' values of selected item of Vector
799 private void reloadFromList() {
800 if (vid
.size() > 0) {
802 // Get selected item index
804 intSelectedItemId
= jComboBoxList
.getSelectedIndex();
806 this.jComboBoxCName
.setSelectedItem(vid
.getProtocols(intSelectedItemId
).getName());
807 this.jComboBoxProtocolType
.setSelectedItem(vid
.getProtocols(intSelectedItemId
).getType());
808 this.jComboBoxUsage
.setSelectedItem(vid
.getProtocols(intSelectedItemId
).getUsage());
809 this.jTextFieldHelpText
.setText(vid
.getProtocols(intSelectedItemId
).getHelp());
811 jTextFieldFeatureFlag
.setText(vid
.getProtocols(intSelectedItemId
).getFeatureFlag());
812 iCheckBoxListArch
.setAllItemsUnchecked();
813 iCheckBoxListArch
.initCheckedItem(true, vid
.getProtocols(intSelectedItemId
).getSupArchList());
823 Update list area pane via the elements of Vector
826 private void reloadListArea() {
827 String strListItem
= "";
828 for (int index
= 0; index
< vid
.size(); index
++) {
829 strListItem
= strListItem
+ vid
.getProtocols(index
).getName() + DataType
.UNIX_LINE_SEPARATOR
;
831 this.jTextAreaList
.setText(strListItem
);
835 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
837 * Reflesh the frame when selected item changed
840 public void itemStateChanged(ItemEvent arg0
) {
841 if (arg0
.getSource() == this.jComboBoxList
&& arg0
.getStateChange() == ItemEvent
.SELECTED
) {
844 if (arg0
.getSource() == this.jComboBoxProtocolType
&& arg0
.getStateChange() == ItemEvent
.SELECTED
) {
845 if (this.jComboBoxProtocolType
.getSelectedItem().toString().equals(ed
.getVProtocolType().get(0))) {
846 Tools
.generateComboBoxByVector(this.jComboBoxUsage
, ed
.getVProtocolUsage());
848 Tools
.generateComboBoxByVector(this.jComboBoxUsage
, ed
.getVProtocolNotifyUsage());