]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Java class PackageGuids is GUI for create GUID elements of spd file.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | **/\r | |
13 | package org.tianocore.packaging;\r | |
14 | \r | |
15 | import java.awt.Dimension;\r | |
16 | import java.awt.Toolkit;\r | |
17 | import java.awt.event.ActionEvent;\r | |
18 | import java.awt.event.ActionListener;\r | |
19 | \r | |
20 | import javax.swing.DefaultListModel;\r | |
21 | import javax.swing.JPanel;\r | |
22 | import javax.swing.JLabel;\r | |
23 | import javax.swing.JTextField;\r | |
24 | import javax.swing.JRadioButton;\r | |
25 | import javax.swing.JComboBox;\r | |
26 | import javax.swing.JButton;\r | |
27 | import javax.swing.JFrame;\r | |
28 | \r | |
29 | import javax.swing.JScrollPane;\r | |
30 | import javax.swing.JList;\r | |
31 | \r | |
32 | import org.tianocore.common.Tools;\r | |
33 | import org.tianocore.packaging.common.ui.StarLabel;\r | |
34 | \r | |
35 | /**\r | |
36 | GUI for create GUID elements of spd file\r | |
37 | \r | |
38 | @since PackageEditor 1.0\r | |
39 | **/\r | |
40 | public class PackageGuids extends JFrame implements ActionListener {\r | |
41 | \r | |
42 | private SpdFileContents sfc = null;\r | |
43 | \r | |
44 | private static String separator = "::";\r | |
45 | \r | |
46 | private JPanel jContentPane = null;\r | |
47 | \r | |
48 | private JLabel jLabelC_Name = null;\r | |
49 | \r | |
50 | private JTextField jTextFieldC_Name = null;\r | |
51 | \r | |
52 | private JLabel jLabelGuidValue = null;\r | |
53 | \r | |
54 | private JTextField jTextFieldGuidValue = null;\r | |
55 | \r | |
56 | private JLabel jLabelHelpText = null;\r | |
57 | \r | |
58 | private JTextField jTextFieldName = null;\r | |
59 | \r | |
60 | private JLabel jLabelEnableFeature = null;\r | |
61 | \r | |
62 | private JRadioButton jRadioButtonEnableFeature = null;\r | |
63 | \r | |
64 | private JRadioButton jRadioButtonDisableFeature = null;\r | |
65 | \r | |
66 | private JButton jButtonOk = null;\r | |
67 | \r | |
68 | private JButton jButtonCancel = null;\r | |
69 | \r | |
70 | private JButton jButtonGenerateGuid = null;\r | |
71 | \r | |
72 | private StarLabel starLabel = null;\r | |
73 | \r | |
74 | private StarLabel starLabel1 = null;\r | |
75 | \r | |
76 | /**\r | |
77 | This method initializes this\r | |
78 | \r | |
79 | **/\r | |
80 | private void initialize() {\r | |
81 | this.setTitle("Guid Declarations");\r | |
82 | this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r | |
83 | \r | |
84 | }\r | |
85 | \r | |
86 | /**\r | |
87 | This method initializes jTextFieldC_Name \r | |
88 | \r | |
89 | @return javax.swing.JTextField \r | |
90 | **/\r | |
91 | private JTextField getJTextFieldC_Name() {\r | |
92 | if (jTextFieldC_Name == null) {\r | |
93 | jTextFieldC_Name = new JTextField();\r | |
94 | jTextFieldC_Name.setBounds(new java.awt.Rectangle(160, 10, 320, 20));\r | |
95 | }\r | |
96 | return jTextFieldC_Name;\r | |
97 | }\r | |
98 | \r | |
99 | /**\r | |
100 | This method initializes jTextFieldGuidValsue \r | |
101 | \r | |
102 | @return javax.swing.JTextField \r | |
103 | **/\r | |
104 | private JTextField getJTextFieldGuidValsue() {\r | |
105 | if (jTextFieldGuidValue == null) {\r | |
106 | jTextFieldGuidValue = new JTextField();\r | |
107 | jTextFieldGuidValue.setBounds(new java.awt.Rectangle(160, 35, 240, 20));\r | |
108 | }\r | |
109 | return jTextFieldGuidValue;\r | |
110 | }\r | |
111 | \r | |
112 | /**\r | |
113 | This method initializes jTextFieldName \r | |
114 | \r | |
115 | @return javax.swing.JTextField \r | |
116 | **/\r | |
117 | private JTextField getJTextFieldName() {\r | |
118 | if (jTextFieldName == null) {\r | |
119 | jTextFieldName = new JTextField();\r | |
120 | jTextFieldName.setBounds(new java.awt.Rectangle(160, 70, 320, 20));\r | |
121 | }\r | |
122 | return jTextFieldName;\r | |
123 | }\r | |
124 | \r | |
125 | /**\r | |
126 | This method initializes jRadioButtonEnableFeature \r | |
127 | \r | |
128 | @return javax.swing.JRadioButton \r | |
129 | **/\r | |
130 | private JRadioButton getJRadioButtonEnableFeature() {\r | |
131 | if (jRadioButtonEnableFeature == null) {\r | |
132 | jRadioButtonEnableFeature = new JRadioButton();\r | |
133 | jRadioButtonEnableFeature.setText("Enable");\r | |
134 | jRadioButtonEnableFeature.setBounds(new java.awt.Rectangle(160, 104, 90, 20));\r | |
135 | jRadioButtonEnableFeature.setEnabled(false);\r | |
136 | jRadioButtonEnableFeature.setSelected(true);\r | |
137 | }\r | |
138 | return jRadioButtonEnableFeature;\r | |
139 | }\r | |
140 | \r | |
141 | /**\r | |
142 | This method initializes jRadioButtonDisableFeature \r | |
143 | \r | |
144 | @return javax.swing.JRadioButton \r | |
145 | **/\r | |
146 | private JRadioButton getJRadioButtonDisableFeature() {\r | |
147 | if (jRadioButtonDisableFeature == null) {\r | |
148 | jRadioButtonDisableFeature = new JRadioButton();\r | |
149 | jRadioButtonDisableFeature.setText("Disable");\r | |
150 | jRadioButtonDisableFeature.setEnabled(false);\r | |
151 | jRadioButtonDisableFeature.setBounds(new java.awt.Rectangle(250, 104, 90, 20));\r | |
152 | }\r | |
153 | return jRadioButtonDisableFeature;\r | |
154 | }\r | |
155 | \r | |
156 | /**\r | |
157 | This method initializes jButtonOk \r | |
158 | \r | |
159 | @return javax.swing.JButton \r | |
160 | **/\r | |
161 | private JButton getJButtonOk() {\r | |
162 | if (jButtonOk == null) {\r | |
163 | jButtonOk = new JButton();\r | |
164 | jButtonOk.setText("OK");\r | |
165 | jButtonOk.setBounds(new java.awt.Rectangle(300, 240, 75, 20));\r | |
166 | jButtonOk.addActionListener(this);\r | |
167 | }\r | |
168 | return jButtonOk;\r | |
169 | }\r | |
170 | \r | |
171 | /**\r | |
172 | This method initializes jButtonCancel \r | |
173 | \r | |
174 | @return javax.swing.JButton \r | |
175 | **/\r | |
176 | private JButton getJButtonCancel() {\r | |
177 | if (jButtonCancel == null) {\r | |
178 | jButtonCancel = new JButton();\r | |
179 | jButtonCancel.setText("Cancel");\r | |
180 | jButtonCancel.setBounds(new java.awt.Rectangle(390, 240, 74, 20));\r | |
181 | jButtonCancel.addActionListener(this);\r | |
182 | }\r | |
183 | return jButtonCancel;\r | |
184 | }\r | |
185 | \r | |
186 | /**\r | |
187 | This method initializes jButtonGenerateGuid \r | |
188 | \r | |
189 | @return javax.swing.JButton \r | |
190 | **/\r | |
191 | private JButton getJButtonGenerateGuid() {\r | |
192 | if (jButtonGenerateGuid == null) {\r | |
193 | jButtonGenerateGuid = new JButton();\r | |
194 | jButtonGenerateGuid.setBounds(new java.awt.Rectangle(405, 35, 75, 20));\r | |
195 | jButtonGenerateGuid.setText("GEN");\r | |
196 | jButtonGenerateGuid.addActionListener(this);\r | |
197 | }\r | |
198 | return jButtonGenerateGuid;\r | |
199 | }\r | |
200 | \r | |
201 | /**\r | |
202 | This is the default constructor\r | |
203 | **/\r | |
204 | public PackageGuids(SpdFileContents sfc) {\r | |
205 | super();\r | |
206 | initialize();\r | |
207 | init();\r | |
208 | this.setVisible(true);\r | |
209 | this.sfc = sfc;\r | |
210 | }\r | |
211 | \r | |
212 | /**\r | |
213 | Start the window at the center of screen\r | |
214 | \r | |
215 | **/\r | |
216 | protected void centerWindow(int intWidth, int intHeight) {\r | |
217 | Dimension d = Toolkit.getDefaultToolkit().getScreenSize();\r | |
218 | this.setLocation((d.width - intWidth) / 2, (d.height - intHeight) / 2);\r | |
219 | }\r | |
220 | \r | |
221 | /**\r | |
222 | Start the window at the center of screen\r | |
223 | \r | |
224 | **/\r | |
225 | protected void centerWindow() {\r | |
226 | centerWindow(this.getSize().width, this.getSize().height);\r | |
227 | }\r | |
228 | \r | |
229 | /**\r | |
230 | This method initializes this\r | |
231 | \r | |
232 | @return void\r | |
233 | **/\r | |
234 | private void init() {\r | |
235 | this.setSize(500, 300);\r | |
236 | this.setContentPane(getJContentPane());\r | |
237 | this.setTitle("Add Guids");\r | |
238 | this.centerWindow();\r | |
239 | initFrame();\r | |
240 | }\r | |
241 | \r | |
242 | /**\r | |
243 | This method initializes jContentPane\r | |
244 | \r | |
245 | @return javax.swing.JPanel\r | |
246 | **/\r | |
247 | private JPanel getJContentPane() {\r | |
248 | if (jContentPane == null) {\r | |
249 | starLabel1 = new StarLabel();\r | |
250 | starLabel1.setBounds(new java.awt.Rectangle(5, 34, 10, 20));\r | |
251 | starLabel = new StarLabel();\r | |
252 | starLabel.setBounds(new java.awt.Rectangle(6, 10, 10, 20));\r | |
253 | jLabelEnableFeature = new JLabel();\r | |
254 | jLabelEnableFeature.setText("Enable Feature");\r | |
255 | jLabelEnableFeature.setEnabled(false);\r | |
256 | jLabelEnableFeature.setBounds(new java.awt.Rectangle(15, 104, 140, 20));\r | |
257 | jLabelHelpText = new JLabel();\r | |
258 | jLabelHelpText.setText("Name");\r | |
259 | jLabelHelpText.setBounds(new java.awt.Rectangle(15, 70, 140, 20));\r | |
260 | jLabelGuidValue = new JLabel();\r | |
261 | jLabelGuidValue.setText("Guid Value");\r | |
262 | jLabelGuidValue.setBounds(new java.awt.Rectangle(15, 35, 140, 20));\r | |
263 | jLabelC_Name = new JLabel();\r | |
264 | jLabelC_Name.setText("C_Name");\r | |
265 | jLabelC_Name.setBounds(new java.awt.Rectangle(15, 10, 140, 20));\r | |
266 | jContentPane = new JPanel();\r | |
267 | jContentPane.setLayout(null);\r | |
268 | jContentPane.add(jLabelC_Name, null);\r | |
269 | jContentPane.add(getJTextFieldC_Name(), null);\r | |
270 | jContentPane.add(jLabelGuidValue, null);\r | |
271 | jContentPane.add(getJTextFieldGuidValsue(), null);\r | |
272 | \r | |
273 | jContentPane.add(jLabelHelpText, null);\r | |
274 | jContentPane.add(getJTextFieldName(), null);\r | |
275 | jContentPane.add(jLabelEnableFeature, null);\r | |
276 | jContentPane.add(getJRadioButtonEnableFeature(), null);\r | |
277 | jContentPane.add(getJRadioButtonDisableFeature(), null);\r | |
278 | jContentPane.add(getJButtonOk(), null);\r | |
279 | jContentPane.add(getJButtonCancel(), null);\r | |
280 | jContentPane.add(getJButtonGenerateGuid(), null);\r | |
281 | \r | |
282 | jContentPane.add(starLabel, null);\r | |
283 | jContentPane.add(starLabel1, null);\r | |
284 | \r | |
285 | initFrame();\r | |
286 | \r | |
287 | }\r | |
288 | return jContentPane;\r | |
289 | }\r | |
290 | \r | |
291 | /**\r | |
292 | This method initializes events groups and usage type\r | |
293 | \r | |
294 | **/\r | |
295 | private void initFrame() {\r | |
296 | \r | |
297 | }\r | |
298 | \r | |
299 | public void actionPerformed(ActionEvent arg0) {\r | |
300 | //\r | |
301 | // save and exit\r | |
302 | //\r | |
303 | if (arg0.getSource() == jButtonOk) {\r | |
304 | \r | |
305 | this.save();\r | |
306 | this.dispose();\r | |
307 | }\r | |
308 | //\r | |
309 | // exit\r | |
310 | //\r | |
311 | if (arg0.getSource() == jButtonCancel) {\r | |
312 | this.dispose();\r | |
313 | }\r | |
314 | //\r | |
315 | // generate a new GUID\r | |
316 | //\r | |
317 | if (arg0.getSource() == jButtonGenerateGuid) {\r | |
318 | jTextFieldGuidValue.setText(Tools.generateUuidString());\r | |
319 | }\r | |
320 | \r | |
321 | if (arg0.getSource() == jRadioButtonEnableFeature) {\r | |
322 | if (jRadioButtonEnableFeature.isSelected()) {\r | |
323 | jRadioButtonDisableFeature.setSelected(false);\r | |
324 | }\r | |
325 | if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {\r | |
326 | jRadioButtonEnableFeature.setSelected(true);\r | |
327 | }\r | |
328 | }\r | |
329 | \r | |
330 | if (arg0.getSource() == jRadioButtonDisableFeature) {\r | |
331 | if (jRadioButtonDisableFeature.isSelected()) {\r | |
332 | jRadioButtonEnableFeature.setSelected(false);\r | |
333 | }\r | |
334 | if (!jRadioButtonDisableFeature.isSelected() && !jRadioButtonEnableFeature.isSelected()) {\r | |
335 | jRadioButtonDisableFeature.setSelected(true);\r | |
336 | }\r | |
337 | }\r | |
338 | }\r | |
339 | \r | |
340 | /**\r | |
341 | Add GUID entry to SpdFileContents object with element values from jTextFields*\r | |
342 | **/\r | |
343 | protected void save() {\r | |
344 | try {\r | |
345 | String strName = jTextFieldName.getText();\r | |
346 | String strCName = jTextFieldC_Name.getText();\r | |
347 | String strGuid = jTextFieldGuidValue.getText();\r | |
348 | sfc.genSpdGuidDeclarations(strName, strCName, strGuid, null);\r | |
349 | \r | |
350 | } catch (Exception e) {\r | |
351 | System.out.println(e.toString());\r | |
352 | }\r | |
353 | }\r | |
354 | } // @jve:decl-index=0:visual-constraint="10,10"\r |