]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/NewFileChooser.java
Fixed grammar in messages.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / NewFileChooser.java
1 /** @file
2
3 The file is used to show a new file chooser dialog
4
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
10
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.
13
14 **/
15 package org.tianocore.frameworkwizard;
16
17 import java.awt.event.ActionEvent;
18
19 import javax.swing.ButtonGroup;
20 import javax.swing.JPanel;
21 import javax.swing.JButton;
22 import javax.swing.JRadioButton;
23
24 import org.tianocore.frameworkwizard.common.DataType;
25 import org.tianocore.frameworkwizard.common.ui.IDialog;
26 import org.tianocore.frameworkwizard.common.ui.IFrame;
27
28 public class NewFileChooser extends IDialog {
29
30 /**
31 Define class members
32
33 **/
34 private static final long serialVersionUID = -3657926400683618281L;
35
36 private JPanel jContentPane = null;
37
38 private JButton jButtonNext = null;
39
40 private JButton jButtonCancel = null;
41
42 private JRadioButton jRadioButtonModule = null;
43
44 private JRadioButton jRadioButtonPackage = null;
45
46 private JRadioButton jRadioButtonPlatform = null;
47
48 private JRadioButton jRadioButtonBuildXml = null;
49
50 private final ButtonGroup buttonGroup = new ButtonGroup();
51
52 /**
53 This is the default constructor
54
55 **/
56 public NewFileChooser() {
57 super();
58 init();
59 }
60
61 /**
62 This is the default constructor
63
64 **/
65 public NewFileChooser(IFrame parentFrame, boolean modal) {
66 super(parentFrame, modal);
67 init();
68 }
69
70 /**
71 * This method initializes jButtonOk
72 *
73 * @return javax.swing.JButton
74 */
75 private JButton getJButtonOk() {
76 if (jButtonNext == null) {
77 jButtonNext = new JButton();
78 jButtonNext.setBounds(new java.awt.Rectangle(90, 150, 80, 20));
79 jButtonNext.setText("Next");
80 jButtonNext.addActionListener(this);
81 }
82 return jButtonNext;
83 }
84
85 /**
86 * This method initializes jButtonCancel
87 *
88 * @return javax.swing.JButton
89 */
90 private JButton getJButtonCancel() {
91 if (jButtonCancel == null) {
92 jButtonCancel = new JButton();
93 jButtonCancel.setBounds(new java.awt.Rectangle(180, 150, 80, 20));
94 jButtonCancel.setText("Cancel");
95 jButtonCancel.addActionListener(this);
96 }
97 return jButtonCancel;
98 }
99
100 /**
101 * This method initializes jRadioButtonModule
102 *
103 * @return javax.swing.JRadioButton
104 */
105 private JRadioButton getJRadioButtonModule() {
106 if (jRadioButtonModule == null) {
107 jRadioButtonModule = new JRadioButton();
108 jRadioButtonModule.setText(DataType.MODULE_SURFACE_AREA);
109 jRadioButtonModule.setBounds(new java.awt.Rectangle(20, 20, 240, 20));
110 jRadioButtonModule.setSelected(true);
111 }
112 return jRadioButtonModule;
113 }
114
115 /**
116 * This method initializes jRadioButtonPackage
117 *
118 * @return javax.swing.JRadioButton
119 */
120 private JRadioButton getJRadioButtonPackage() {
121 if (jRadioButtonPackage == null) {
122 jRadioButtonPackage = new JRadioButton();
123 jRadioButtonPackage.setText(DataType.PACKAGE_SURFACE_AREA);
124 jRadioButtonPackage.setBounds(new java.awt.Rectangle(20, 50, 240, 20));
125 }
126 return jRadioButtonPackage;
127 }
128
129 /**
130 * This method initializes jRadioButtonPlatform
131 *
132 * @return javax.swing.JRadioButton
133 */
134 private JRadioButton getJRadioButtonPlatform() {
135 if (jRadioButtonPlatform == null) {
136 jRadioButtonPlatform = new JRadioButton();
137 jRadioButtonPlatform.setText(DataType.PLATFORM_SURFACE_AREA);
138 jRadioButtonPlatform.setBounds(new java.awt.Rectangle(20, 80, 240, 20));
139 }
140 return jRadioButtonPlatform;
141 }
142
143 /**
144 * This method initializes jRadioButtonBuildXml
145 *
146 * @return javax.swing.JRadioButton
147 */
148 private JRadioButton getJRadioButtonBuildXml() {
149 if (jRadioButtonBuildXml == null) {
150 jRadioButtonBuildXml = new JRadioButton();
151 jRadioButtonBuildXml.setText(DataType.ANT_BUILD_FILE);
152 jRadioButtonBuildXml.setBounds(new java.awt.Rectangle(20, 110, 240, 20));
153 jRadioButtonBuildXml.setVisible(false);
154 }
155 return jRadioButtonBuildXml;
156 }
157
158 /**
159 * @param args
160 */
161 public static void main(String[] args) {
162 NewFileChooser nfc = new NewFileChooser();
163 nfc.setVisible(true);
164 }
165
166 /**
167 * This method initializes this
168 *
169 * @return void
170 */
171 private void init() {
172 this.setSize(310, 220);
173 this.setContentPane(getJContentPane());
174 this.setTitle("Select New File Type");
175 this.centerWindow();
176 }
177
178 /**
179 * This method initializes jContentPane
180 *
181 * @return javax.swing.JPanel
182 */
183 private JPanel getJContentPane() {
184 if (jContentPane == null) {
185 jContentPane = new JPanel();
186 jContentPane.setLayout(null);
187 jContentPane.add(getJButtonOk(), null);
188 jContentPane.add(getJButtonCancel(), null);
189 jContentPane.add(getJRadioButtonModule(), null);
190 jContentPane.add(getJRadioButtonPackage(), null);
191 jContentPane.add(getJRadioButtonPlatform(), null);
192 jContentPane.add(getJRadioButtonBuildXml(), null);
193 buttonGroup.add(this.getJRadioButtonModule());
194 buttonGroup.add(this.getJRadioButtonPackage());
195 buttonGroup.add(this.getJRadioButtonPlatform());
196 buttonGroup.add(this.getJRadioButtonBuildXml());
197 }
198 return jContentPane;
199 }
200
201 /* (non-Javadoc)
202 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
203 *
204 * Override actionPerformed to listen all actions
205 */
206 public void actionPerformed(ActionEvent arg0) {
207 if (arg0.getSource() == jButtonCancel) {
208 this.setVisible(false);
209 returnType = DataType.RETURN_TYPE_CANCEL;
210 }
211
212 if (arg0.getSource() == jButtonNext) {
213 this.setVisible(false);
214 if (this.jRadioButtonModule.isSelected()) {
215 returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;
216 }
217 if (this.jRadioButtonPackage.isSelected()) {
218 returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;
219 }
220 if (this.jRadioButtonPlatform.isSelected()) {
221 returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;
222 }
223 if (this.jRadioButtonBuildXml.isSelected()) {
224 returnType = DataType.RETURN_TYPE_BUILD_XML;
225 }
226 }
227 }
228 }