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