summaryrefslogtreecommitdiff
path: root/Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/NewFileChooser.java
blob: 18cbdb8a8ba2e49c244004577bc73bde4a368446 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/** @file
 
 The file is used to show a new file chooser dialog
 
 Copyright (c) 2006, Intel Corporation
 All rights reserved. This program and the accompanying materials
 are licensed and made available under the terms and conditions of the BSD License
 which accompanies this distribution.  The full text of the license may be found at
 http://opensource.org/licenses/bsd-license.php
 
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

 **/
package org.tianocore.frameworkwizard;

import java.awt.event.ActionEvent;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JRadioButton;

import org.tianocore.frameworkwizard.common.DataType;
import org.tianocore.frameworkwizard.common.ui.IDialog;
import org.tianocore.frameworkwizard.common.ui.IFrame;

public class NewFileChooser extends IDialog {

    /**
     Define class members
     
     **/
    private static final long serialVersionUID = -3657926400683618281L;

    private JPanel jContentPane = null;

    private JButton jButtonNext = null;

    private JButton jButtonCancel = null;

    private JRadioButton jRadioButtonModule = null;

    private JRadioButton jRadioButtonPackage = null;

    private JRadioButton jRadioButtonPlatform = null;

    private JRadioButton jRadioButtonBuildXml = null;

    private final ButtonGroup buttonGroup = new ButtonGroup();

    /**
     This is the default constructor
     
     **/
    public NewFileChooser() {
        super();
        init();
    }

    /**
     This is the default constructor
     
     **/
    public NewFileChooser(IFrame parentFrame, boolean modal) {
        super(parentFrame, modal);
        init();
    }

    /**
     * This method initializes jButtonOk	
     * 	
     * @return javax.swing.JButton	
     */
    private JButton getJButtonOk() {
        if (jButtonNext == null) {
            jButtonNext = new JButton();
            jButtonNext.setBounds(new java.awt.Rectangle(90, 150, 80, 20));
            jButtonNext.setText("Next");
            jButtonNext.addActionListener(this);
        }
        return jButtonNext;
    }

    /**
     * This method initializes jButtonCancel	
     * 	
     * @return javax.swing.JButton	
     */
    private JButton getJButtonCancel() {
        if (jButtonCancel == null) {
            jButtonCancel = new JButton();
            jButtonCancel.setBounds(new java.awt.Rectangle(180, 150, 80, 20));
            jButtonCancel.setText("Cancel");
            jButtonCancel.addActionListener(this);
        }
        return jButtonCancel;
    }

    /**
     * This method initializes jRadioButtonModule	
     * 	
     * @return javax.swing.JRadioButton	
     */
    private JRadioButton getJRadioButtonModule() {
        if (jRadioButtonModule == null) {
            jRadioButtonModule = new JRadioButton();
            jRadioButtonModule.setText(DataType.MODULE_SURFACE_AREA);
            jRadioButtonModule.setBounds(new java.awt.Rectangle(20, 20, 240, 20));
            jRadioButtonModule.setSelected(true);
        }
        return jRadioButtonModule;
    }

    /**
     * This method initializes jRadioButtonPackage	
     * 	
     * @return javax.swing.JRadioButton	
     */
    private JRadioButton getJRadioButtonPackage() {
        if (jRadioButtonPackage == null) {
            jRadioButtonPackage = new JRadioButton();
            jRadioButtonPackage.setText(DataType.PACKAGE_SURFACE_AREA);
            jRadioButtonPackage.setBounds(new java.awt.Rectangle(20, 50, 240, 20));
        }
        return jRadioButtonPackage;
    }

    /**
     * This method initializes jRadioButtonPlatform	
     * 	
     * @return javax.swing.JRadioButton	
     */
    private JRadioButton getJRadioButtonPlatform() {
        if (jRadioButtonPlatform == null) {
            jRadioButtonPlatform = new JRadioButton();
            jRadioButtonPlatform.setText(DataType.PLATFORM_SURFACE_AREA);
            jRadioButtonPlatform.setBounds(new java.awt.Rectangle(20, 80, 240, 20));
        }
        return jRadioButtonPlatform;
    }

    /**
     * This method initializes jRadioButtonBuildXml	
     * 	
     * @return javax.swing.JRadioButton	
     */
    private JRadioButton getJRadioButtonBuildXml() {
        if (jRadioButtonBuildXml == null) {
            jRadioButtonBuildXml = new JRadioButton();
            jRadioButtonBuildXml.setText(DataType.ANT_BUILD_FILE);
            jRadioButtonBuildXml.setBounds(new java.awt.Rectangle(20, 110, 240, 20));
            jRadioButtonBuildXml.setVisible(false);
        }
        return jRadioButtonBuildXml;
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        NewFileChooser nfc = new NewFileChooser();
        nfc.setVisible(true);
    }

    /**
     * This method initializes this
     * 
     * @return void
     */
    private void init() {
        this.setSize(310, 220);
        this.setContentPane(getJContentPane());
        this.setTitle("Select New File Type");
        this.centerWindow();
    }

    /**
     * This method initializes jContentPane
     * 
     * @return javax.swing.JPanel
     */
    private JPanel getJContentPane() {
        if (jContentPane == null) {
            jContentPane = new JPanel();
            jContentPane.setLayout(null);
            jContentPane.add(getJButtonOk(), null);
            jContentPane.add(getJButtonCancel(), null);
            jContentPane.add(getJRadioButtonModule(), null);
            jContentPane.add(getJRadioButtonPackage(), null);
            jContentPane.add(getJRadioButtonPlatform(), null);
            jContentPane.add(getJRadioButtonBuildXml(), null);
            buttonGroup.add(this.getJRadioButtonModule());
            buttonGroup.add(this.getJRadioButtonPackage());
            buttonGroup.add(this.getJRadioButtonPlatform());
            buttonGroup.add(this.getJRadioButtonBuildXml());
        }
        return jContentPane;
    }

    /* (non-Javadoc)
     * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
     * 
     * Override actionPerformed to listen all actions
     */
    public void actionPerformed(ActionEvent arg0) {
        if (arg0.getSource() == jButtonCancel) {
            this.setVisible(false);
            returnType = DataType.RETURN_TYPE_CANCEL;
        }

        if (arg0.getSource() == jButtonNext) {
            this.setVisible(false);
            if (this.jRadioButtonModule.isSelected()) {
                returnType = DataType.RETURN_TYPE_MODULE_SURFACE_AREA;
            }
            if (this.jRadioButtonPackage.isSelected()) {
                returnType = DataType.RETURN_TYPE_PACKAGE_SURFACE_AREA;
            }
            if (this.jRadioButtonPlatform.isSelected()) {
                returnType = DataType.RETURN_TYPE_PLATFORM_SURFACE_AREA;
            }
            if (this.jRadioButtonBuildXml.isSelected()) {
                returnType = DataType.RETURN_TYPE_BUILD_XML;
            }
        }
    }
}