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
.deleteui
;
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
;
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
;
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
;
42 import javax
.swing
.JList
;
43 import javax
.swing
.event
.ListSelectionEvent
;
44 import javax
.swing
.event
.ListSelectionListener
;
46 public class DeleteStepOne
extends IDialog
implements ListSelectionListener
, MouseListener
{
51 private static final long serialVersionUID
= 636773964435618476L;
53 private JPanel jContentPane
= null;
55 private JButton jButtonCancel
= null;
57 private JButton jButtonNext
= null;
59 private JTextArea jTextAreaInstruction
= null;
61 private JLabel jLabel
= null;
63 private JScrollPane jScrollPane
= null;
65 private JLabel jLabel2
= null;
67 private JLabel jLabel3
= null;
69 private JScrollPane jScrollPane1
= null;
71 private JScrollPane jScrollPane2
= null;
73 private JList jListPlatform
= null;
75 private JList jListPackage
= null;
77 private JLabel jLabel4
= null;
79 private JButton jButtonDetail
= null;
81 private JList jListFar
= null;
83 private JLabel jLabelImage
= null;
85 private Vector
<FarIdentification
> farVector
= null;
87 Vector
<PackageIdentification
> removePackages
= null;
89 Vector
<PlatformIdentification
> removePlatforms
= null;
91 private DeleteStepTwo stepTwo
= null;
94 * This method initializes jButtonCancel
96 * @return javax.swing.JButton
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);
105 return jButtonCancel
;
109 * This method initializes jButtonFinish
111 * @return javax.swing.JButton
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);
124 * This method initializes jTextArea1
126 * @return javax.swing.JTextArea
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
);
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);
139 return jTextAreaInstruction
;
143 * This method initializes jScrollPane
145 * @return javax.swing.JScrollPane
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());
157 * This method initializes jScrollPane1
159 * @return javax.swing.JScrollPane
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());
171 * This method initializes jScrollPane2
173 * @return javax.swing.JScrollPane
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());
185 * This method initializes jList
187 * @return javax.swing.JList
189 private JList
getJListPlatform() {
190 if (jListPlatform
== null) {
191 jListPlatform
= new JList();
192 jListPlatform
.setEnabled(false);
194 return jListPlatform
;
198 * This method initializes jList1
200 * @return javax.swing.JList
202 private JList
getJListPackage() {
203 if (jListPackage
== null) {
204 jListPackage
= new JList();
205 jListPackage
.setEnabled(false);
211 * This method initializes jButtonDetail
213 * @return javax.swing.JButton
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);
223 return jButtonDetail
;
227 * This method initializes jListFar
229 * @return javax.swing.JList
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);
243 * This is the default constructor
245 public DeleteStepOne(IFrame iFrame
, boolean modal
) {
246 super(iFrame
, modal
);
251 * This method initializes this
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);
264 * This method initializes jContentPane
266 * @return javax.swing.JPanel
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);
301 public void valueChanged(ListSelectionEvent e
) {
303 // Add logic for FAR list value changed
305 if (e
.getSource() == jListFar
) {
307 FarIdentification far
= (FarIdentification
) jListFar
.getSelectedValue();
308 WorkspaceTools wt
= new WorkspaceTools();
310 removePackages
= wt
.getPackagesByFar(far
);
311 jListPackage
.setListData(removePackages
);
312 removePlatforms
= wt
.getPlatformsByFar(far
);
313 jListPlatform
.setListData(removePlatforms
);
316 // Get Dependencies Info for current FAR
318 List
<PackageIdentification
> allPackages
= wt
.getAllPackages();
323 allPackages
.removeAll(removePackages
);
325 Iterator
<PackageIdentification
> iter
= allPackages
.iterator();
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) {
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);
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);
356 public void mouseClicked(MouseEvent e
) {
357 if (e
.getSource() == jButtonCancel
) {
358 this.setVisible(false);
359 } else if (e
.getSource() == jButtonNext
) {
361 // Add some logic process here
364 if (stepTwo
== null) {
365 stepTwo
= new DeleteStepTwo(this, true, this);
367 this.setVisible(false);
368 stepTwo
.setVisible(true);
372 public void mousePressed(MouseEvent e
) {
373 // TODO Auto-generated method stub
377 public void mouseReleased(MouseEvent e
) {
378 // TODO Auto-generated method stub
382 public void mouseEntered(MouseEvent e
) {
383 // TODO Auto-generated method stub
387 public void mouseExited(MouseEvent e
) {
388 // TODO Auto-generated method stub
392 public FarIdentification
getSelecedFar() {
393 return (FarIdentification
) jListFar
.getSelectedValue();