]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Java/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/createui/CreateStepTwo.java
Fixed EDKT400.
[mirror_edk2.git] / Tools / Java / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / far / createui / CreateStepTwo.java
1 /** @file
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 **/
13
14 package org.tianocore.frameworkwizard.far.createui;
15
16 import java.awt.event.MouseEvent;
17 import java.awt.event.MouseListener;
18 import java.util.ArrayList;
19 import java.util.Iterator;
20 import java.util.List;
21 import java.util.Vector;
22
23 import javax.swing.JButton;
24 import javax.swing.JLabel;
25 import javax.swing.JPanel;
26 import javax.swing.JScrollPane;
27 import javax.swing.JTextArea;
28
29 import org.tianocore.frameworkwizard.common.Log;
30 import org.tianocore.frameworkwizard.common.ui.IDialog;
31 import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;
32 import org.tianocore.frameworkwizard.far.FarStringDefinition;
33 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
34 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
35 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
36
37 public class CreateStepTwo extends IDialog implements MouseListener {
38
39 /**
40 *
41 */
42 private static final long serialVersionUID = 3003841865197005528L;
43
44 private JPanel jContentPane = null;
45
46 private JTextArea jTextArea = null;
47
48 private JLabel jLabel = null;
49
50 private JLabel jLabel1 = null;
51
52 private ICheckBoxList jComboBoxPackage = null;
53
54 private ICheckBoxList jComboBoxPlatform = null;
55
56 private JButton jButtonNext = null;
57
58 private JButton jButtonCancel = null;
59
60 private JScrollPane jScrollPanePackage = null;
61
62 private JScrollPane jScrollPanePlatform = null;
63
64 private CreateStepThree stepThree = null;
65
66 private Vector<PlatformIdentification> platformVector = null;
67
68 private Vector<PackageIdentification> packageVector = null;
69
70 private CreateStepOne stepOne = null;
71
72 private JButton jButtonPrevious = null;
73
74 public CreateStepTwo(IDialog iDialog, boolean modal, CreateStepOne stepOne) {
75 this(iDialog, modal);
76 this.stepOne = stepOne;
77 }
78
79 /**
80 * This method initializes jTextArea
81 *
82 * @return javax.swing.JTextArea
83 */
84 private JTextArea getJTextArea() {
85 if (jTextArea == null) {
86 jTextArea = new JTextArea();
87 jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));
88 jTextArea.setText("Choose at least one package or platform. ");
89 jTextArea.setEditable(false);
90 }
91 return jTextArea;
92 }
93
94 /**
95 * This method initializes jComboBox
96 *
97 * @return javax.swing.JComboBox
98 */
99 private ICheckBoxList getJComboBoxPackage() {
100 if (jComboBoxPackage == null) {
101 jComboBoxPackage = new ICheckBoxList();
102 WorkspaceTools wt = new WorkspaceTools();
103 Vector<String> v = new Vector<String>();
104 packageVector = wt.getAllRepackagablePackages();
105 Iterator<PackageIdentification> iter = packageVector.iterator();
106 while (iter.hasNext()) {
107 PackageIdentification item = iter.next();
108 String str = item.getName() + " " + item.getVersion() + " [" + item.getPath() + "]";
109 v.addElement(str);
110 }
111 jComboBoxPackage.setAllItems(v);
112 }
113 return jComboBoxPackage;
114 }
115
116 /**
117 * This method initializes jComboBox1
118 *
119 * @return javax.swing.JComboBox
120 */
121 private ICheckBoxList getJComboBoxPlatform() {
122 if (jComboBoxPlatform == null) {
123 jComboBoxPlatform = new ICheckBoxList();
124 WorkspaceTools wt = new WorkspaceTools();
125 Vector<String> v = new Vector<String>();
126 platformVector = wt.getAllPlatforms();
127 Iterator<PlatformIdentification> iter = platformVector.iterator();
128 while (iter.hasNext()) {
129 PlatformIdentification item = iter.next();
130 String str = item.getName() + " " + item.getVersion() + " [" + item.getPath() + "]";
131 v.addElement(str);
132 }
133 jComboBoxPlatform.setAllItems(v);
134 }
135 return jComboBoxPlatform;
136 }
137
138 /**
139 * This method initializes jButtonNext
140 *
141 * @return javax.swing.JButton
142 */
143 private JButton getJButtonNext() {
144 if (jButtonNext == null) {
145 jButtonNext = new JButton();
146 jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));
147 jButtonNext.setText("Next");
148 jButtonNext.addMouseListener(this);
149 }
150 return jButtonNext;
151 }
152
153 /**
154 * This method initializes jButtonCancel
155 *
156 * @return javax.swing.JButton
157 */
158 private JButton getJButtonCancel() {
159 if (jButtonCancel == null) {
160 jButtonCancel = new JButton();
161 jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));
162 jButtonCancel.setText("Cancel");
163 jButtonCancel.addMouseListener(this);
164 }
165 return jButtonCancel;
166 }
167
168 /**
169 * This method initializes jScrollPane
170 *
171 * @return javax.swing.JScrollPane
172 */
173 private JScrollPane getJScrollPanePackage() {
174 if (jScrollPanePackage == null) {
175 jScrollPanePackage = new JScrollPane();
176 jScrollPanePackage.setBounds(new java.awt.Rectangle(140,65,535,130));
177 jScrollPanePackage.setViewportView(getJComboBoxPackage());
178 }
179 return jScrollPanePackage;
180 }
181
182 /**
183 * This method initializes jScrollPane1
184 *
185 * @return javax.swing.JScrollPane
186 */
187 private JScrollPane getJScrollPanePlatform() {
188 if (jScrollPanePlatform == null) {
189 jScrollPanePlatform = new JScrollPane();
190 jScrollPanePlatform.setBounds(new java.awt.Rectangle(140,200,535,110));
191 jScrollPanePlatform.setViewportView(getJComboBoxPlatform());
192 }
193 return jScrollPanePlatform;
194 }
195
196 /**
197 * This is the default constructor
198 */
199 public CreateStepTwo(IDialog iDialog, boolean modal) {
200 super(iDialog, modal);
201 initialize();
202 }
203
204 /**
205 * This method initializes this
206 *
207 * @return void
208 */
209 private void initialize() {
210 this.setSize(700, 400);
211 this.setContentPane(getJContentPane());
212 this.setTitle(FarStringDefinition.CREATE_STEP_TWO_TITLE);
213 this.centerWindow();
214 }
215
216 /**
217 * This method initializes jContentPane
218 *
219 * @return javax.swing.JPanel
220 */
221 private JPanel getJContentPane() {
222 if (jContentPane == null) {
223 jLabel1 = new JLabel();
224 jLabel1.setBounds(new java.awt.Rectangle(30, 200, 100, 20));
225 jLabel1.setText("Platforms: ");
226 jLabel = new JLabel();
227 jLabel.setBounds(new java.awt.Rectangle(30, 64, 100, 20));
228 jLabel.setText("Packages:");
229 jContentPane = new JPanel();
230 jContentPane.setLayout(null);
231 jContentPane.add(getJTextArea(), null);
232 jContentPane.add(jLabel, null);
233 jContentPane.add(jLabel1, null);
234 jContentPane.add(getJButtonNext(), null);
235 jContentPane.add(getJButtonCancel(), null);
236 jContentPane.add(getJScrollPanePackage(), null);
237 jContentPane.add(getJScrollPanePlatform(), null);
238 jContentPane.add(getJButtonPrevious(), null);
239 }
240 return jContentPane;
241 }
242
243 public void mouseClicked(MouseEvent e) {
244 if (e.getSource() == jButtonCancel) {
245 this.setVisible(false);
246 } else if (e.getSource() == jButtonPrevious) {
247 this.setVisible(false);
248 stepOne.setVisible(true);
249 } else if (e.getSource() == jButtonNext) {
250 //
251 // Add some logic process here
252 //
253 if (jComboBoxPlatform.getAllCheckedItemsIndex().size() == 0
254 && jComboBoxPackage.getAllCheckedItemsIndex().size() == 0) {
255 Log.wrn("Create far", "Choose at least one package and/or platform.");
256 return;
257 }
258 if (stepThree == null) {
259 stepThree = new CreateStepThree(this, true, this);
260 }
261 this.setVisible(false);
262 stepThree.setVisible(true);
263 }
264 }
265
266 public void mousePressed(MouseEvent e) {
267 // TODO Auto-generated method stub
268
269 }
270
271 public void mouseReleased(MouseEvent e) {
272 // TODO Auto-generated method stub
273
274 }
275
276 public void mouseEntered(MouseEvent e) {
277 // TODO Auto-generated method stub
278
279 }
280
281 public void mouseExited(MouseEvent e) {
282 // TODO Auto-generated method stub
283
284 }
285
286 /**
287 * This method initializes jButtonPrevious
288 *
289 * @return javax.swing.JButton
290 */
291 private JButton getJButtonPrevious() {
292 if (jButtonPrevious == null) {
293 jButtonPrevious = new JButton();
294 jButtonPrevious.setBounds(new java.awt.Rectangle(370, 330, 90, 20));
295 jButtonPrevious.setText("Previous");
296 jButtonPrevious.addMouseListener(this);
297 }
298 return jButtonPrevious;
299 }
300
301 public List<PackageIdentification> getSelectedPackages() {
302 Vector<Integer> v = jComboBoxPackage.getAllCheckedItemsIndex();
303 List<PackageIdentification> result = new ArrayList<PackageIdentification>();
304 for (int i = 0; i < v.size(); i++) {
305 result.add(packageVector.get(v.get(i).intValue()));
306 }
307 return result;
308 }
309
310 public List<PlatformIdentification> getSelectedPlatforms() {
311 Vector<Integer> v = jComboBoxPlatform.getAllCheckedItemsIndex();
312 List<PlatformIdentification> result = new ArrayList<PlatformIdentification>();
313 for (int i = 0; i < v.size(); i++) {
314 result.add(platformVector.get(v.get(i).intValue()));
315 }
316 return result;
317 }
318
319 public CreateStepOne getPreviousStep() {
320 return stepOne;
321 }
322 }