]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepOne.java
ecb71c3a0ed101869f3160b45b30a84d613072ca
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / far / deleteui / DeleteStepOne.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.deleteui;
15
16 import javax.swing.ImageIcon;
17 import javax.swing.JPanel;
18 import javax.swing.JButton;
19 import javax.swing.JTextArea;
20 import javax.swing.JLabel;
21 import javax.swing.JScrollPane;
22
23 import org.tianocore.frameworkwizard.common.ui.IDialog;
24 import org.tianocore.frameworkwizard.common.ui.IFrame;
25 import org.tianocore.frameworkwizard.far.AggregationOperation;
26 import org.tianocore.frameworkwizard.far.FarIdentification;
27 import org.tianocore.frameworkwizard.far.PackageQuery;
28 import org.tianocore.frameworkwizard.far.PackageQueryInterface;
29 import org.tianocore.frameworkwizard.packaging.PackageIdentification;
30 import org.tianocore.frameworkwizard.platform.PlatformIdentification;
31 import org.tianocore.frameworkwizard.workspace.WorkspaceTools;
32
33 import java.awt.Color;
34 import java.awt.Dimension;
35 import java.awt.Toolkit;
36 import java.awt.event.MouseEvent;
37 import java.awt.event.MouseListener;
38 import java.util.Iterator;
39 import java.util.List;
40 import java.util.Vector;
41
42 import javax.swing.JList;
43 import javax.swing.event.ListSelectionEvent;
44 import javax.swing.event.ListSelectionListener;
45
46 public class DeleteStepOne extends IDialog implements ListSelectionListener, MouseListener {
47
48 /**
49 *
50 */
51 private static final long serialVersionUID = 636773964435618476L;
52
53 private JPanel jContentPane = null;
54
55 private JButton jButtonCancel = null;
56
57 private JButton jButtonNext = null;
58
59 private JTextArea jTextAreaInstruction = null;
60
61 private JLabel jLabel = null;
62
63 private JScrollPane jScrollPane = null;
64
65 private JLabel jLabel2 = null;
66
67 private JLabel jLabel3 = null;
68
69 private JScrollPane jScrollPane1 = null;
70
71 private JScrollPane jScrollPane2 = null;
72
73 private JList jListPlatform = null;
74
75 private JList jListPackage = null;
76
77 private JLabel jLabel4 = null;
78
79 private JButton jButtonDetail = null;
80
81 private JList jListFar = null;
82
83 private JLabel jLabelImage = null;
84
85 private Vector<FarIdentification> farVector = null;
86
87 Vector<PackageIdentification> removePackages = null;
88
89 Vector<PlatformIdentification> removePlatforms = null;
90
91 private DeleteStepTwo stepTwo = null;
92
93 /**
94 * This method initializes jButtonCancel
95 *
96 * @return javax.swing.JButton
97 */
98 private JButton getJButtonCancel() {
99 if (jButtonCancel == null) {
100 jButtonCancel = new JButton();
101 jButtonCancel.setBounds(new java.awt.Rectangle(570, 330, 90, 20));
102 jButtonCancel.setText("Cancel");
103 jButtonCancel.addMouseListener(this);
104 }
105 return jButtonCancel;
106 }
107
108 /**
109 * This method initializes jButtonFinish
110 *
111 * @return javax.swing.JButton
112 */
113 private JButton getJButtonNext() {
114 if (jButtonNext == null) {
115 jButtonNext = new JButton();
116 jButtonNext.setBounds(new java.awt.Rectangle(470, 330, 90, 20));
117 jButtonNext.setText("Next");
118 jButtonNext.setEnabled(false);
119 }
120 return jButtonNext;
121 }
122
123 /**
124 * This method initializes jTextArea1
125 *
126 * @return javax.swing.JTextArea
127 */
128 private JTextArea getJTextArea1() {
129 if (jTextAreaInstruction == null) {
130 jTextAreaInstruction = new JTextArea();
131 jTextAreaInstruction.setBounds(new java.awt.Rectangle(30, 7, 642, 50));
132 jTextAreaInstruction.setText("Step 1: Choose FAR from framework database. \n");
133 jTextAreaInstruction.setCaretColor(Color.RED);
134 jTextAreaInstruction
135 .append("After choose FAR, the packages and platforms which belong to the FAR will display. \n");
136 jTextAreaInstruction.append("Picture \"Okay\" or \"No\" indicates whether FAR can be removed or not. ");
137 jTextAreaInstruction.setEditable(false);
138 }
139 return jTextAreaInstruction;
140 }
141
142 /**
143 * This method initializes jScrollPane
144 *
145 * @return javax.swing.JScrollPane
146 */
147 private JScrollPane getJScrollPane() {
148 if (jScrollPane == null) {
149 jScrollPane = new JScrollPane();
150 jScrollPane.setBounds(new java.awt.Rectangle(139, 64, 500, 104));
151 jScrollPane.setViewportView(getJListFar());
152 }
153 return jScrollPane;
154 }
155
156 /**
157 * This method initializes jScrollPane1
158 *
159 * @return javax.swing.JScrollPane
160 */
161 private JScrollPane getJScrollPane1() {
162 if (jScrollPane1 == null) {
163 jScrollPane1 = new JScrollPane();
164 jScrollPane1.setBounds(new java.awt.Rectangle(40, 195, 300, 115));
165 jScrollPane1.setViewportView(getJListPackage());
166 }
167 return jScrollPane1;
168 }
169
170 /**
171 * This method initializes jScrollPane2
172 *
173 * @return javax.swing.JScrollPane
174 */
175 private JScrollPane getJScrollPane2() {
176 if (jScrollPane2 == null) {
177 jScrollPane2 = new JScrollPane();
178 jScrollPane2.setBounds(new java.awt.Rectangle(360, 195, 300, 115));
179 jScrollPane2.setViewportView(getJListPlatform());
180 }
181 return jScrollPane2;
182 }
183
184 /**
185 * This method initializes jList
186 *
187 * @return javax.swing.JList
188 */
189 private JList getJListPlatform() {
190 if (jListPlatform == null) {
191 jListPlatform = new JList();
192 jListPlatform.setEnabled(false);
193 }
194 return jListPlatform;
195 }
196
197 /**
198 * This method initializes jList1
199 *
200 * @return javax.swing.JList
201 */
202 private JList getJListPackage() {
203 if (jListPackage == null) {
204 jListPackage = new JList();
205 jListPackage.setEnabled(false);
206 }
207 return jListPackage;
208 }
209
210 /**
211 * This method initializes jButtonDetail
212 *
213 * @return javax.swing.JButton
214 */
215 private JButton getJButtonDetail() {
216 if (jButtonDetail == null) {
217 jButtonDetail = new JButton();
218 jButtonDetail.setBounds(new java.awt.Rectangle(367, 325, 69, 20));
219 jButtonDetail.setText("Detail");
220 jButtonDetail.setVisible(false);
221 jButtonDetail.addMouseListener(this);
222 }
223 return jButtonDetail;
224 }
225
226 /**
227 * This method initializes jListFar
228 *
229 * @return javax.swing.JList
230 */
231 private JList getJListFar() {
232 if (jListFar == null) {
233 jListFar = new JList();
234 WorkspaceTools wt = new WorkspaceTools();
235 farVector = wt.getAllFars();
236 jListFar.setListData(farVector);
237 jListFar.addListSelectionListener(this);
238 }
239 return jListFar;
240 }
241
242 /**
243 * This is the default constructor
244 */
245 public DeleteStepOne(IFrame iFrame, boolean modal) {
246 super(iFrame, modal);
247 initialize();
248 }
249
250 /**
251 * This method initializes this
252 *
253 * @return void
254 */
255 private void initialize() {
256 this.setSize(700, 400);
257 this.setContentPane(getJContentPane());
258 this.setTitle("Delete Framework Archive(FAR) - Step 1: Choose FAR from framework database");
259 Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
260 this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);
261 }
262
263 /**
264 * This method initializes jContentPane
265 *
266 * @return javax.swing.JPanel
267 */
268 private JPanel getJContentPane() {
269 if (jContentPane == null) {
270 jLabelImage = new JLabel();
271 jLabelImage.setBounds(new java.awt.Rectangle(30, 319, 36, 36));
272 jLabel4 = new JLabel();
273 jLabel4.setBounds(new java.awt.Rectangle(71, 325, 289, 20));
274 jLabel3 = new JLabel();
275 jLabel3.setBounds(new java.awt.Rectangle(360, 170, 113, 20));
276 jLabel3.setText("FAR's Platforms");
277 jLabel2 = new JLabel();
278 jLabel2.setBounds(new java.awt.Rectangle(40, 170, 113, 20));
279 jLabel2.setText("FAR's Packages");
280 jLabel = new JLabel();
281 jLabel.setBounds(new java.awt.Rectangle(30, 64, 100, 20));
282 jLabel.setText("Select one FAR: ");
283 jContentPane = new JPanel();
284 jContentPane.setLayout(null);
285 jContentPane.add(getJButtonCancel(), null);
286 jContentPane.add(getJButtonNext(), null);
287 jContentPane.add(getJTextArea1(), null);
288 jContentPane.add(jLabel, null);
289 jContentPane.add(getJScrollPane(), null);
290 jContentPane.add(jLabel2, null);
291 jContentPane.add(jLabel3, null);
292 jContentPane.add(getJScrollPane1(), null);
293 jContentPane.add(getJScrollPane2(), null);
294 jContentPane.add(jLabel4, null);
295 jContentPane.add(getJButtonDetail(), null);
296 jContentPane.add(jLabelImage, null);
297 }
298 return jContentPane;
299 }
300
301 public void valueChanged(ListSelectionEvent e) {
302 //
303 // Add logic for FAR list value changed
304 //
305 if (e.getSource() == jListFar) {
306 boolean flag = true;
307 FarIdentification far = (FarIdentification) jListFar.getSelectedValue();
308 WorkspaceTools wt = new WorkspaceTools();
309
310 removePackages = wt.getPackagesByFar(far);
311 jListPackage.setListData(removePackages);
312 removePlatforms = wt.getPlatformsByFar(far);
313 jListPlatform.setListData(removePlatforms);
314
315 //
316 // Get Dependencies Info for current FAR
317 //
318 List<PackageIdentification> allPackages = wt.getAllPackages();
319
320 //
321 // Remain packages
322 //
323 allPackages.removeAll(removePackages);
324
325 Iterator<PackageIdentification> iter = allPackages.iterator();
326
327 PackageQueryInterface pq = new PackageQuery();
328 while (iter.hasNext()) {
329 PackageIdentification item = iter.next();
330 List<PackageIdentification> list = pq.getPackageDependencies(item.getSpdFile());
331 List<PackageIdentification> result = AggregationOperation.minus(list, allPackages);
332 if (result.size() > 0) {
333 if (AggregationOperation.intersection(result, removePackages).size() > 0) {
334 flag = false;
335 break;
336 }
337 }
338 }
339
340 if (flag) {
341 jLabelImage.setIcon(new ImageIcon(getClass().getResource("/resources/images/Yes.JPG")));
342 jLabel4.setText("Without any remain packages depend on this FAR. ");
343 jButtonDetail.setVisible(false);
344 jButtonNext.setEnabled(true);
345 jButtonNext.addMouseListener(this);
346 } else {
347 jLabelImage.setIcon(new ImageIcon(getClass().getResource("/resources/images/No.JPG")));
348 jLabel4.setText("Some remain packages still depend on this FAR. ");
349 // jButtonDetail.setVisible(true);
350 jButtonNext.setEnabled(false);
351 jButtonNext.removeMouseListener(this);
352 }
353 }
354 }
355
356 public void mouseClicked(MouseEvent e) {
357 if (e.getSource() == jButtonCancel) {
358 this.setVisible(false);
359 } else if (e.getSource() == jButtonNext) {
360 //
361 // Add some logic process here
362 //
363
364 if (stepTwo == null) {
365 stepTwo = new DeleteStepTwo(this, true, this);
366 }
367 this.setVisible(false);
368 stepTwo.setVisible(true);
369 }
370 }
371
372 public void mousePressed(MouseEvent e) {
373 // TODO Auto-generated method stub
374
375 }
376
377 public void mouseReleased(MouseEvent e) {
378 // TODO Auto-generated method stub
379
380 }
381
382 public void mouseEntered(MouseEvent e) {
383 // TODO Auto-generated method stub
384
385 }
386
387 public void mouseExited(MouseEvent e) {
388 // TODO Auto-generated method stub
389
390 }
391
392 public FarIdentification getSelecedFar() {
393 return (FarIdentification) jListFar.getSelectedValue();
394 }
395
396 }