76c29da157b25116a307eaace13d48af6cd6de2e
[people/mcb30/edk2.git] / edk2 / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / ui / ArchCheckBox.java
1 /** @file\r
2  \r
3  The file is used to provid 6 kinds of arch in one jpanel \r
4  \r
5  Copyright (c) 2006, Intel Corporation\r
6  All rights reserved. This program and the accompanying materials\r
7  are licensed and made available under the terms and conditions of the BSD License\r
8  which accompanies this distribution.  The full text of the license may be found at\r
9  http://opensource.org/licenses/bsd-license.php\r
10  \r
11  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13  \r
14  **/\r
15 \r
16 package org.tianocore.frameworkwizard.common.ui;\r
17 \r
18 import java.util.Vector;\r
19 \r
20 import javax.swing.JCheckBox;\r
21 import javax.swing.JPanel;\r
22 \r
23 import org.tianocore.frameworkwizard.common.DataType;\r
24 \r
25 public class ArchCheckBox extends JPanel {\r
26 \r
27     ///\r
28     /// Define class members\r
29     ///\r
30     private static final long serialVersionUID = 4792669775676953990L;\r
31 \r
32     private JCheckBox jCheckBoxIa32 = null;\r
33 \r
34     private JCheckBox jCheckBoxX64 = null;\r
35 \r
36     private JCheckBox jCheckBoxIpf = null;\r
37 \r
38     private JCheckBox jCheckBoxEbc = null;\r
39 \r
40     private JCheckBox jCheckBoxArm = null;\r
41 \r
42     private JCheckBox jCheckBoxPpc = null;\r
43     \r
44     /**\r
45      * This method initializes jCheckBoxIa32    \r
46      *  \r
47      * @return javax.swing.JCheckBox    \r
48      */\r
49     private JCheckBox getJCheckBoxIa32() {\r
50         if (jCheckBoxIa32 == null) {\r
51             jCheckBoxIa32 = new JCheckBox();\r
52             jCheckBoxIa32.setBounds(new java.awt.Rectangle(0, 0, 55, 20));\r
53             jCheckBoxIa32.setText("IA32");\r
54             jCheckBoxIa32.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
55         }\r
56         return jCheckBoxIa32;\r
57     }\r
58 \r
59     /**\r
60      * This method initializes jCheckBoxX64     \r
61      *  \r
62      * @return javax.swing.JCheckBox    \r
63      */\r
64     private JCheckBox getJCheckBoxX64() {\r
65         if (jCheckBoxX64 == null) {\r
66             jCheckBoxX64 = new JCheckBox();\r
67             jCheckBoxX64.setBounds(new java.awt.Rectangle(55, 0, 53, 20));\r
68             jCheckBoxX64.setText("X64");\r
69             jCheckBoxX64.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
70         }\r
71         return jCheckBoxX64;\r
72     }\r
73 \r
74     /**\r
75      * This method initializes jCheckBoxIpf     \r
76      *  \r
77      * @return javax.swing.JCheckBox    \r
78      */\r
79     private JCheckBox getJCheckBoxIpf() {\r
80         if (jCheckBoxIpf == null) {\r
81             jCheckBoxIpf = new JCheckBox();\r
82             jCheckBoxIpf.setBounds(new java.awt.Rectangle(108, 0, 52, 20));\r
83             jCheckBoxIpf.setText("IPF");\r
84             jCheckBoxIpf.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
85         }\r
86         return jCheckBoxIpf;\r
87     }\r
88 \r
89     /**\r
90      * This method initializes jCheckBoxEbc     \r
91      *  \r
92      * @return javax.swing.JCheckBox    \r
93      */\r
94     private JCheckBox getJCheckBoxEbc() {\r
95         if (jCheckBoxEbc == null) {\r
96             jCheckBoxEbc = new JCheckBox();\r
97             jCheckBoxEbc.setBounds(new java.awt.Rectangle(160, 0, 53, 20));\r
98             jCheckBoxEbc.setText("EBC");\r
99             jCheckBoxEbc.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
100         }\r
101         return jCheckBoxEbc;\r
102     }\r
103 \r
104     /**\r
105      * This method initializes jCheckBoxArm     \r
106      *  \r
107      * @return javax.swing.JCheckBox    \r
108      */\r
109     private JCheckBox getJCheckBoxArm() {\r
110         if (jCheckBoxArm == null) {\r
111             jCheckBoxArm = new JCheckBox();\r
112             jCheckBoxArm.setBounds(new java.awt.Rectangle(213, 0, 54, 20));\r
113             jCheckBoxArm.setText("ARM");\r
114             jCheckBoxArm.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
115         }\r
116         return jCheckBoxArm;\r
117     }\r
118 \r
119     /**\r
120      * This method initializes jCheckBoxPpc     \r
121      *  \r
122      * @return javax.swing.JCheckBox    \r
123      */\r
124     private JCheckBox getJCheckBoxPpc() {\r
125         if (jCheckBoxPpc == null) {\r
126             jCheckBoxPpc = new JCheckBox();\r
127             jCheckBoxPpc.setBounds(new java.awt.Rectangle(267, 0, 53, 20));\r
128             jCheckBoxPpc.setText("PPC");\r
129             jCheckBoxPpc.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
130         }\r
131         return jCheckBoxPpc;\r
132     }\r
133 \r
134     /**\r
135      * This is the default constructor\r
136      */\r
137     public ArchCheckBox() {\r
138         super();\r
139         initialize();\r
140     }\r
141 \r
142     /**\r
143      * This method initializes this\r
144      * \r
145      * @return void\r
146      */\r
147     private void initialize() {\r
148         this.setSize(320, 20);\r
149         this.setLayout(null);\r
150         this.add(getJCheckBoxIa32(), null);\r
151         this.add(getJCheckBoxX64(), null);\r
152         this.add(getJCheckBoxIpf(), null);\r
153         this.add(getJCheckBoxEbc(), null);\r
154         this.add(getJCheckBoxArm(), null);\r
155         this.add(getJCheckBoxPpc(), null);\r
156         this.setToolTipText(DataType.SUP_ARCH_LIST_HELP_TEXT);\r
157     }\r
158     \r
159     public Vector<String> getSelectedItemsVector() {\r
160         Vector<String> v = new Vector<String>();\r
161         if (this.jCheckBoxIa32.isSelected()) {\r
162             v.addElement(jCheckBoxIa32.getText());\r
163         }\r
164         if (this.jCheckBoxX64.isSelected()) {\r
165             v.addElement(jCheckBoxX64.getText());\r
166         }\r
167         if (this.jCheckBoxIpf.isSelected()) {\r
168             v.addElement(jCheckBoxIpf.getText());\r
169         }\r
170         if (this.jCheckBoxEbc.isSelected()) {\r
171             v.addElement(jCheckBoxEbc.getText());\r
172         }\r
173         if (this.jCheckBoxArm.isSelected()) {\r
174             v.addElement(jCheckBoxArm.getText());\r
175         }\r
176         if (this.jCheckBoxPpc.isSelected()) {\r
177             v.addElement(jCheckBoxPpc.getText());\r
178         }\r
179         return v;\r
180     }\r
181     \r
182     public String getSelectedItemsString() {\r
183         String s = "";\r
184         if (this.jCheckBoxIa32.isSelected()) {\r
185             s = s + jCheckBoxIa32.getText() + " ";\r
186         }\r
187         if (this.jCheckBoxX64.isSelected()) {\r
188             s = s + jCheckBoxX64.getText() + " ";\r
189         }\r
190         if (this.jCheckBoxIpf.isSelected()) {\r
191             s = s + jCheckBoxIpf.getText() + " ";\r
192         }\r
193         if (this.jCheckBoxEbc.isSelected()) {\r
194             s = s + jCheckBoxEbc.getText() + " ";\r
195         }\r
196         if (this.jCheckBoxArm.isSelected()) {\r
197             s = s + jCheckBoxArm.getText() + " ";\r
198         }\r
199         if (this.jCheckBoxPpc.isSelected()) {\r
200             s = s + jCheckBoxPpc.getText() + " ";\r
201         }\r
202         return s.trim();\r
203     }\r
204     \r
205     public void setAllItemsSelected(boolean isSelected) {\r
206         this.jCheckBoxIa32.setSelected(isSelected);\r
207         this.jCheckBoxX64.setSelected(isSelected);\r
208         this.jCheckBoxIpf.setSelected(isSelected);\r
209         this.jCheckBoxEbc.setSelected(isSelected);\r
210         this.jCheckBoxArm.setSelected(isSelected);\r
211         this.jCheckBoxPpc.setSelected(isSelected);\r
212     }\r
213     \r
214     public void setSelectedItems(Vector<String> v) {\r
215         setAllItemsSelected(false);\r
216         if (v != null) {\r
217             for (int index = 0; index < v.size(); index++) {\r
218                 if (v.get(index).equals(this.jCheckBoxIa32.getText())) {\r
219                     this.jCheckBoxIa32.setSelected(true);\r
220                     continue;\r
221                 }\r
222                 if (v.get(index).equals(this.jCheckBoxIpf.getText())) {\r
223                     this.jCheckBoxIpf.setSelected(true);\r
224                     continue;\r
225                 }\r
226                 if (v.get(index).equals(this.jCheckBoxX64.getText())) {\r
227                     this.jCheckBoxX64.setSelected(true);\r
228                     continue;\r
229                 }\r
230                 if (v.get(index).equals(this.jCheckBoxEbc.getText())) {\r
231                     this.jCheckBoxEbc.setSelected(true);\r
232                     continue;\r
233                 }\r
234                 if (v.get(index).equals(this.jCheckBoxArm.getText())) {\r
235                     this.jCheckBoxArm.setSelected(true);\r
236                     continue;\r
237                 }\r
238                 if (v.get(index).equals(this.jCheckBoxPpc.getText())) {\r
239                     this.jCheckBoxPpc.setSelected(true);\r
240                     continue;\r
241                 }\r
242             }\r
243         }\r
244     }\r
245 }\r