3 The file is used to show a new file chooser dialog
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.
15 package org
.tianocore
.frameworkwizard
;
17 import java
.awt
.event
.ActionEvent
;
19 import javax
.swing
.ButtonGroup
;
20 import javax
.swing
.JPanel
;
21 import javax
.swing
.JButton
;
22 import javax
.swing
.JRadioButton
;
24 import org
.tianocore
.frameworkwizard
.common
.DataType
;
25 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
26 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
28 public class NewFileChooser
extends IDialog
{
34 private static final long serialVersionUID
= -3657926400683618281L;
36 private JPanel jContentPane
= null;
38 private JButton jButtonNext
= null;
40 private JButton jButtonCancel
= null;
42 private JRadioButton jRadioButtonModule
= null;
44 private JRadioButton jRadioButtonPackage
= null;
46 private JRadioButton jRadioButtonPlatform
= null;
48 private JRadioButton jRadioButtonBuildXml
= null;
50 private final ButtonGroup buttonGroup
= new ButtonGroup();
53 This is the default constructor
56 public NewFileChooser() {
62 This is the default constructor
65 public NewFileChooser(IFrame parentFrame
, boolean modal
) {
66 super(parentFrame
, modal
);
71 * This method initializes jButtonOk
73 * @return javax.swing.JButton
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);
86 * This method initializes jButtonCancel
88 * @return javax.swing.JButton
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);
101 * This method initializes jRadioButtonModule
103 * @return javax.swing.JRadioButton
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);
112 return jRadioButtonModule
;
116 * This method initializes jRadioButtonPackage
118 * @return javax.swing.JRadioButton
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));
126 return jRadioButtonPackage
;
130 * This method initializes jRadioButtonPlatform
132 * @return javax.swing.JRadioButton
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));
140 return jRadioButtonPlatform
;
144 * This method initializes jRadioButtonBuildXml
146 * @return javax.swing.JRadioButton
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);
155 return jRadioButtonBuildXml
;
161 public static void main(String
[] args
) {
162 NewFileChooser nfc
= new NewFileChooser();
163 nfc
.setVisible(true);
167 * This method initializes this
171 private void init() {
172 this.setSize(310, 220);
173 this.setContentPane(getJContentPane());
174 this.setTitle("Select New File Type");
179 * This method initializes jContentPane
181 * @return javax.swing.JPanel
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());
202 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
204 * Override actionPerformed to listen all actions
206 public void actionPerformed(ActionEvent arg0
) {
207 if (arg0
.getSource() == jButtonCancel
) {
208 this.setVisible(false);
209 returnType
= DataType
.RETURN_TYPE_CANCEL
;
212 if (arg0
.getSource() == jButtonNext
) {
213 this.setVisible(false);
214 if (this.jRadioButtonModule
.isSelected()) {
215 returnType
= DataType
.RETURN_TYPE_MODULE_SURFACE_AREA
;
217 if (this.jRadioButtonPackage
.isSelected()) {
218 returnType
= DataType
.RETURN_TYPE_PACKAGE_SURFACE_AREA
;
220 if (this.jRadioButtonPlatform
.isSelected()) {
221 returnType
= DataType
.RETURN_TYPE_PLATFORM_SURFACE_AREA
;
223 if (this.jRadioButtonBuildXml
.isSelected()) {
224 returnType
= DataType
.RETURN_TYPE_BUILD_XML
;