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