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 java
.awt
.Color
;
17 import java
.awt
.Dimension
;
18 import java
.awt
.Toolkit
;
19 import java
.awt
.event
.ActionEvent
;
20 import java
.util
.Iterator
;
21 import java
.util
.List
;
22 import java
.util
.Vector
;
24 import javax
.swing
.ImageIcon
;
25 import javax
.swing
.JButton
;
26 import javax
.swing
.JLabel
;
27 import javax
.swing
.JList
;
28 import javax
.swing
.JPanel
;
29 import javax
.swing
.JScrollPane
;
30 import javax
.swing
.JTextArea
;
31 import javax
.swing
.event
.ListSelectionEvent
;
32 import javax
.swing
.event
.ListSelectionListener
;
34 import org
.tianocore
.frameworkwizard
.common
.ui
.IDialog
;
35 import org
.tianocore
.frameworkwizard
.common
.ui
.IFrame
;
36 import org
.tianocore
.frameworkwizard
.far
.AggregationOperation
;
37 import org
.tianocore
.frameworkwizard
.far
.FarIdentification
;
38 import org
.tianocore
.frameworkwizard
.far
.PackageQuery
;
39 import org
.tianocore
.frameworkwizard
.far
.PackageQueryInterface
;
40 import org
.tianocore
.frameworkwizard
.packaging
.PackageIdentification
;
41 import org
.tianocore
.frameworkwizard
.platform
.PlatformIdentification
;
42 import org
.tianocore
.frameworkwizard
.workspace
.WorkspaceTools
;
44 public class DeleteStepOne
extends IDialog
implements ListSelectionListener
{
49 private static final long serialVersionUID
= 636773964435618476L;
51 private JPanel jContentPane
= null;
53 private JButton jButtonCancel
= null;
55 private JButton jButtonNext
= null;
57 private JTextArea jTextAreaInstruction
= null;
59 private JLabel jLabel
= null;
61 private JScrollPane jScrollPane
= null;
63 private JLabel jLabel2
= null;
65 private JLabel jLabel3
= null;
67 private JScrollPane jScrollPane1
= null;
69 private JScrollPane jScrollPane2
= null;
71 private JList jListPlatform
= null;
73 private JList jListPackage
= null;
75 private JLabel jLabel4
= null;
77 private JButton jButtonDetail
= null;
79 private JList jListFar
= null;
81 private JLabel jLabelImage
= null;
83 private Vector
<FarIdentification
> farVector
= null;
85 Vector
<PackageIdentification
> removePackages
= null;
87 Vector
<PlatformIdentification
> removePlatforms
= null;
89 private DeleteStepTwo stepTwo
= null;
92 * This method initializes jButtonCancel
94 * @return javax.swing.JButton
96 private JButton
getJButtonCancel() {
97 if (jButtonCancel
== null) {
98 jButtonCancel
= new JButton();
99 jButtonCancel
.setBounds(new java
.awt
.Rectangle(570, 330, 90, 20));
100 jButtonCancel
.setText("Cancel");
101 jButtonCancel
.addActionListener(this);
103 return jButtonCancel
;
107 * This method initializes jButtonFinish
109 * @return javax.swing.JButton
111 private JButton
getJButtonNext() {
112 if (jButtonNext
== null) {
113 jButtonNext
= new JButton();
114 jButtonNext
.setBounds(new java
.awt
.Rectangle(470, 330, 90, 20));
115 jButtonNext
.setText("Next");
116 jButtonNext
.setEnabled(false);
117 jButtonNext
.addActionListener(this);
123 * This method initializes jTextArea1
125 * @return javax.swing.JTextArea
127 private JTextArea
getJTextArea1() {
128 if (jTextAreaInstruction
== null) {
129 jTextAreaInstruction
= new JTextArea();
130 jTextAreaInstruction
.setBounds(new java
.awt
.Rectangle(30, 7, 642, 50));
131 jTextAreaInstruction
.setText("Step 1: Choose FAR from framework database. \n");
132 jTextAreaInstruction
.setCaretColor(Color
.RED
);
134 .append("After choose FAR, the packages and platforms which belong to the FAR will display. \n");
135 jTextAreaInstruction
.append("Picture \"Okay\" or \"No\" indicates whether FAR can be removed or not. ");
136 jTextAreaInstruction
.setEditable(false);
138 return jTextAreaInstruction
;
142 * This method initializes jScrollPane
144 * @return javax.swing.JScrollPane
146 private JScrollPane
getJScrollPane() {
147 if (jScrollPane
== null) {
148 jScrollPane
= new JScrollPane();
149 jScrollPane
.setBounds(new java
.awt
.Rectangle(140, 65, 530, 100));
150 jScrollPane
.setViewportView(getJListFar());
156 * This method initializes jScrollPane1
158 * @return javax.swing.JScrollPane
160 private JScrollPane
getJScrollPane1() {
161 if (jScrollPane1
== null) {
162 jScrollPane1
= new JScrollPane();
163 jScrollPane1
.setBounds(new java
.awt
.Rectangle(30, 195, 300, 115));
164 jScrollPane1
.setViewportView(getJListPackage());
170 * This method initializes jScrollPane2
172 * @return javax.swing.JScrollPane
174 private JScrollPane
getJScrollPane2() {
175 if (jScrollPane2
== null) {
176 jScrollPane2
= new JScrollPane();
177 jScrollPane2
.setBounds(new java
.awt
.Rectangle(360, 195, 310, 115));
178 jScrollPane2
.setViewportView(getJListPlatform());
184 * This method initializes jList
186 * @return javax.swing.JList
188 private JList
getJListPlatform() {
189 if (jListPlatform
== null) {
190 jListPlatform
= new JList();
191 jListPlatform
.setEnabled(false);
193 return jListPlatform
;
197 * This method initializes jList1
199 * @return javax.swing.JList
201 private JList
getJListPackage() {
202 if (jListPackage
== null) {
203 jListPackage
= new JList();
204 jListPackage
.setEnabled(false);
210 * This method initializes jButtonDetail
212 * @return javax.swing.JButton
214 private JButton
getJButtonDetail() {
215 if (jButtonDetail
== null) {
216 jButtonDetail
= new JButton();
217 jButtonDetail
.setBounds(new java
.awt
.Rectangle(367, 325, 69, 20));
218 jButtonDetail
.setText("Detail");
219 jButtonDetail
.setVisible(false);
221 return jButtonDetail
;
225 * This method initializes jListFar
227 * @return javax.swing.JList
229 private JList
getJListFar() {
230 if (jListFar
== null) {
231 jListFar
= new JList();
232 WorkspaceTools wt
= new WorkspaceTools();
233 farVector
= wt
.getAllFars();
234 jListFar
.setListData(farVector
);
235 jListFar
.addListSelectionListener(this);
241 * This is the default constructor
243 public DeleteStepOne(IFrame iFrame
, boolean modal
) {
244 super(iFrame
, modal
);
249 * This method initializes this
253 private void initialize() {
254 this.setSize(700, 400);
255 this.setContentPane(getJContentPane());
256 this.setTitle("Delete Framework Archive(FAR) - Step 1: Choose FAR from framework database");
257 Dimension d
= Toolkit
.getDefaultToolkit().getScreenSize();
258 this.setLocation((d
.width
- this.getSize().width
) / 2, (d
.height
- this.getSize().height
) / 2);
262 * This method initializes jContentPane
264 * @return javax.swing.JPanel
266 private JPanel
getJContentPane() {
267 if (jContentPane
== null) {
268 jLabelImage
= new JLabel();
269 jLabelImage
.setBounds(new java
.awt
.Rectangle(30, 319, 36, 36));
270 jLabel4
= new JLabel();
271 jLabel4
.setBounds(new java
.awt
.Rectangle(71, 325, 289, 20));
272 jLabel3
= new JLabel();
273 jLabel3
.setBounds(new java
.awt
.Rectangle(360, 170, 113, 20));
274 jLabel3
.setText("FAR's Platforms");
275 jLabel2
= new JLabel();
276 jLabel2
.setBounds(new java
.awt
.Rectangle(30, 170, 113, 20));
277 jLabel2
.setText("FAR's Packages");
278 jLabel
= new JLabel();
279 jLabel
.setBounds(new java
.awt
.Rectangle(30, 65, 100, 20));
280 jLabel
.setText("Select one FAR: ");
281 jContentPane
= new JPanel();
282 jContentPane
.setLayout(null);
283 jContentPane
.add(getJButtonCancel(), null);
284 jContentPane
.add(getJButtonNext(), null);
285 jContentPane
.add(getJTextArea1(), null);
286 jContentPane
.add(jLabel
, null);
287 jContentPane
.add(getJScrollPane(), null);
288 jContentPane
.add(jLabel2
, null);
289 jContentPane
.add(jLabel3
, null);
290 jContentPane
.add(getJScrollPane1(), null);
291 jContentPane
.add(getJScrollPane2(), null);
292 jContentPane
.add(jLabel4
, null);
293 jContentPane
.add(getJButtonDetail(), null);
294 jContentPane
.add(jLabelImage
, null);
299 public void valueChanged(ListSelectionEvent e
) {
301 // Add logic for FAR list value changed
303 if (e
.getSource() == jListFar
) {
305 FarIdentification far
= (FarIdentification
) jListFar
.getSelectedValue();
306 WorkspaceTools wt
= new WorkspaceTools();
308 removePackages
= wt
.getPackagesByFar(far
);
309 jListPackage
.setListData(removePackages
);
310 removePlatforms
= wt
.getPlatformsByFar(far
);
311 jListPlatform
.setListData(removePlatforms
);
314 // Get Dependencies Info for current FAR
316 List
<PackageIdentification
> allPackages
= wt
.getAllPackages();
321 allPackages
.removeAll(removePackages
);
323 Iterator
<PackageIdentification
> iter
= allPackages
.iterator();
325 PackageQueryInterface pq
= new PackageQuery();
326 while (iter
.hasNext()) {
327 PackageIdentification item
= iter
.next();
328 List
<PackageIdentification
> list
= pq
.getPackageDependencies(item
.getSpdFile());
329 List
<PackageIdentification
> result
= AggregationOperation
.minus(list
, allPackages
);
330 if (result
.size() > 0) {
331 if (AggregationOperation
.intersection(result
, removePackages
).size() > 0) {
339 jLabelImage
.setIcon(new ImageIcon(getClass().getResource("/resources/images/Yes.JPG")));
340 jLabel4
.setText("Without any remain packages depend on this FAR. ");
341 jButtonDetail
.setVisible(false);
342 jButtonNext
.setEnabled(true);
344 jLabelImage
.setIcon(new ImageIcon(getClass().getResource("/resources/images/No.JPG")));
345 jLabel4
.setText("Some remain packages still depend on this FAR. ");
346 // jButtonDetail.setVisible(true);
347 jButtonNext
.setEnabled(false);
352 public void actionPerformed(ActionEvent e
) {
353 if (e
.getSource() == jButtonCancel
) {
354 this.setVisible(false);
355 } else if (e
.getSource() == jButtonNext
) {
357 // Add some logic process here
360 if (stepTwo
== null) {
361 stepTwo
= new DeleteStepTwo(this, true, this);
363 this.setVisible(false);
364 stepTwo
.setVisible(true);
369 public FarIdentification
getSelecedFar() {
370 return (FarIdentification
) jListFar
.getSelectedValue();