]>
Commit | Line | Data |
---|---|---|
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 | |
14 | package org.tianocore.frameworkwizard.far.createui;\r | |
15 | \r | |
16 | import java.awt.event.MouseEvent;\r | |
17 | import java.awt.event.MouseListener;\r | |
18 | import java.util.ArrayList;\r | |
19 | import java.util.Iterator;\r | |
20 | import java.util.List;\r | |
21 | import java.util.Vector;\r | |
22 | \r | |
23 | import javax.swing.JButton;\r | |
24 | import javax.swing.JLabel;\r | |
25 | import javax.swing.JPanel;\r | |
26 | import javax.swing.JScrollPane;\r | |
27 | import javax.swing.JTextArea;\r | |
28 | \r | |
29 | import org.tianocore.frameworkwizard.common.Log;\r | |
30 | import org.tianocore.frameworkwizard.common.ui.IDialog;\r | |
31 | import org.tianocore.frameworkwizard.common.ui.iCheckBoxList.ICheckBoxList;\r | |
2e39c718 | 32 | import org.tianocore.frameworkwizard.far.FarStringDefinition;\r |
5a24e806 | 33 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r |
34 | import org.tianocore.frameworkwizard.platform.PlatformIdentification;\r | |
35 | import org.tianocore.frameworkwizard.workspace.WorkspaceTools;\r | |
36 | \r | |
37 | public class CreateStepTwo extends IDialog implements MouseListener {\r | |
38 | \r | |
39 | /**\r | |
40 | * \r | |
41 | */\r | |
42 | private static final long serialVersionUID = 3003841865197005528L;\r | |
43 | \r | |
44 | private JPanel jContentPane = null;\r | |
45 | \r | |
46 | private JTextArea jTextArea = null;\r | |
47 | \r | |
48 | private JLabel jLabel = null;\r | |
49 | \r | |
50 | private JLabel jLabel1 = null;\r | |
51 | \r | |
52 | private ICheckBoxList jComboBoxPackage = null;\r | |
53 | \r | |
54 | private ICheckBoxList jComboBoxPlatform = null;\r | |
55 | \r | |
56 | private JButton jButtonNext = null;\r | |
57 | \r | |
58 | private JButton jButtonCancel = null;\r | |
59 | \r | |
60 | private JScrollPane jScrollPanePackage = null;\r | |
61 | \r | |
62 | private JScrollPane jScrollPanePlatform = null;\r | |
63 | \r | |
64 | private CreateStepThree stepThree = null;\r | |
65 | \r | |
66 | private Vector<PlatformIdentification> platformVector = null;\r | |
67 | \r | |
68 | private Vector<PackageIdentification> packageVector = null;\r | |
69 | \r | |
70 | private CreateStepOne stepOne = null;\r | |
71 | \r | |
72 | private JButton jButtonPrevious = null;\r | |
73 | \r | |
74 | public CreateStepTwo(IDialog iDialog, boolean modal, CreateStepOne stepOne) {\r | |
75 | this(iDialog, modal);\r | |
76 | this.stepOne = stepOne;\r | |
77 | }\r | |
78 | \r | |
79 | /**\r | |
80 | * This method initializes jTextArea \r | |
81 | * \r | |
82 | * @return javax.swing.JTextArea \r | |
83 | */\r | |
84 | private JTextArea getJTextArea() {\r | |
85 | if (jTextArea == null) {\r | |
86 | jTextArea = new JTextArea();\r | |
87 | jTextArea.setBounds(new java.awt.Rectangle(30, 7, 642, 50));\r | |
2e39c718 | 88 | jTextArea.setText("Choose at least one package or platform. ");\r |
5a24e806 | 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 | |
a45e9a40 | 176 | jScrollPanePackage.setBounds(new java.awt.Rectangle(140,65,535,130));\r |
5a24e806 | 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 | |
a45e9a40 | 190 | jScrollPanePlatform.setBounds(new java.awt.Rectangle(140,200,535,110));\r |
5a24e806 | 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 | |
2e39c718 | 212 | this.setTitle(FarStringDefinition.CREATE_STEP_TWO_TITLE);\r |
5a24e806 | 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 | |
156ed4d0 | 255 | Log.wrn("Create far", "Choose at least one package and/or platform.");\r |
5a24e806 | 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 |