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
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.
14 package org
.tianocore
.frameworkwizard
.far
.createui
;
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
;
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
;
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
;
37 public class CreateStepTwo
extends IDialog
implements MouseListener
{
42 private static final long serialVersionUID
= 3003841865197005528L;
44 private JPanel jContentPane
= null;
46 private JTextArea jTextArea
= null;
48 private JLabel jLabel
= null;
50 private JLabel jLabel1
= null;
52 private ICheckBoxList jComboBoxPackage
= null;
54 private ICheckBoxList jComboBoxPlatform
= null;
56 private JButton jButtonNext
= null;
58 private JButton jButtonCancel
= null;
60 private JScrollPane jScrollPanePackage
= null;
62 private JScrollPane jScrollPanePlatform
= null;
64 private CreateStepThree stepThree
= null;
66 private Vector
<PlatformIdentification
> platformVector
= null;
68 private Vector
<PackageIdentification
> packageVector
= null;
70 private CreateStepOne stepOne
= null;
72 private JButton jButtonPrevious
= null;
74 public CreateStepTwo(IDialog iDialog
, boolean modal
, CreateStepOne stepOne
) {
76 this.stepOne
= stepOne
;
80 * This method initializes jTextArea
82 * @return javax.swing.JTextArea
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);
95 * This method initializes jComboBox
97 * @return javax.swing.JComboBox
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
.getAllPackages();
105 Iterator
<PackageIdentification
> iter
= packageVector
.iterator();
106 while (iter
.hasNext()) {
107 PackageIdentification item
= iter
.next();
108 String str
= item
.getName() + " " + item
.getVersion() + " [" + item
.getPath() + "]";
111 jComboBoxPackage
.setAllItems(v
);
113 return jComboBoxPackage
;
117 * This method initializes jComboBox1
119 * @return javax.swing.JComboBox
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() + "]";
133 jComboBoxPlatform
.setAllItems(v
);
135 return jComboBoxPlatform
;
139 * This method initializes jButtonNext
141 * @return javax.swing.JButton
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);
154 * This method initializes jButtonCancel
156 * @return javax.swing.JButton
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);
165 return jButtonCancel
;
169 * This method initializes jScrollPane
171 * @return javax.swing.JScrollPane
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());
179 return jScrollPanePackage
;
183 * This method initializes jScrollPane1
185 * @return javax.swing.JScrollPane
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());
193 return jScrollPanePlatform
;
197 * This is the default constructor
199 public CreateStepTwo(IDialog iDialog
, boolean modal
) {
200 super(iDialog
, modal
);
205 * This method initializes this
209 private void initialize() {
210 this.setSize(700, 400);
211 this.setContentPane(getJContentPane());
212 this.setTitle(FarStringDefinition
.CREATE_STEP_TWO_TITLE
);
217 * This method initializes jContentPane
219 * @return javax.swing.JPanel
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);
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
) {
251 // Add some logic process here
253 if (jComboBoxPlatform
.getAllCheckedItemsIndex().size() == 0
254 && jComboBoxPackage
.getAllCheckedItemsIndex().size() == 0) {
255 Log
.wrn("Create far", "Choose at least one package and/or platform.");
258 if (stepThree
== null) {
259 stepThree
= new CreateStepThree(this, true, this);
261 this.setVisible(false);
262 stepThree
.setVisible(true);
266 public void mousePressed(MouseEvent e
) {
267 // TODO Auto-generated method stub
271 public void mouseReleased(MouseEvent e
) {
272 // TODO Auto-generated method stub
276 public void mouseEntered(MouseEvent e
) {
277 // TODO Auto-generated method stub
281 public void mouseExited(MouseEvent e
) {
282 // TODO Auto-generated method stub
287 * This method initializes jButtonPrevious
289 * @return javax.swing.JButton
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);
298 return jButtonPrevious
;
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()));
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()));
319 public CreateStepOne
getPreviousStep() {