]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/deleteui/DeleteStepOne.java
1. Adjust UI for far operations
[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 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;
23
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;
33
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;
43
44 public class DeleteStepOne extends IDialog implements ListSelectionListener {
45
46 /**
47 *
48 */
49 private static final long serialVersionUID = 636773964435618476L;
50
51 private JPanel jContentPane = null;
52
53 private JButton jButtonCancel = null;
54
55 private JButton jButtonNext = null;
56
57 private JTextArea jTextAreaInstruction = null;
58
59 private JLabel jLabel = null;
60
61 private JScrollPane jScrollPane = null;
62
63 private JLabel jLabel2 = null;
64
65 private JLabel jLabel3 = null;
66
67 private JScrollPane jScrollPane1 = null;
68
69 private JScrollPane jScrollPane2 = null;
70
71 private JList jListPlatform = null;
72
73 private JList jListPackage = null;
74
75 private JLabel jLabel4 = null;
76
77 private JButton jButtonDetail = null;
78
79 private JList jListFar = null;
80
81 private JLabel jLabelImage = null;
82
83 private Vector<FarIdentification> farVector = null;
84
85 Vector<PackageIdentification> removePackages = null;
86
87 Vector<PlatformIdentification> removePlatforms = null;
88
89 private DeleteStepTwo stepTwo = null;
90
91 /**
92 * This method initializes jButtonCancel
93 *
94 * @return javax.swing.JButton
95 */
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);
102 }
103 return jButtonCancel;
104 }
105
106 /**
107 * This method initializes jButtonFinish
108 *
109 * @return javax.swing.JButton
110 */
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);
118 }
119 return jButtonNext;
120 }
121
122 /**
123 * This method initializes jTextArea1
124 *
125 * @return javax.swing.JTextArea
126 */
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);
133 jTextAreaInstruction
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);
137 }
138 return jTextAreaInstruction;
139 }
140
141 /**
142 * This method initializes jScrollPane
143 *
144 * @return javax.swing.JScrollPane
145 */
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());
151 }
152 return jScrollPane;
153 }
154
155 /**
156 * This method initializes jScrollPane1
157 *
158 * @return javax.swing.JScrollPane
159 */
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());
165 }
166 return jScrollPane1;
167 }
168
169 /**
170 * This method initializes jScrollPane2
171 *
172 * @return javax.swing.JScrollPane
173 */
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());
179 }
180 return jScrollPane2;
181 }
182
183 /**
184 * This method initializes jList
185 *
186 * @return javax.swing.JList
187 */
188 private JList getJListPlatform() {
189 if (jListPlatform == null) {
190 jListPlatform = new JList();
191 jListPlatform.setEnabled(false);
192 }
193 return jListPlatform;
194 }
195
196 /**
197 * This method initializes jList1
198 *
199 * @return javax.swing.JList
200 */
201 private JList getJListPackage() {
202 if (jListPackage == null) {
203 jListPackage = new JList();
204 jListPackage.setEnabled(false);
205 }
206 return jListPackage;
207 }
208
209 /**
210 * This method initializes jButtonDetail
211 *
212 * @return javax.swing.JButton
213 */
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);
220 }
221 return jButtonDetail;
222 }
223
224 /**
225 * This method initializes jListFar
226 *
227 * @return javax.swing.JList
228 */
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);
236 }
237 return jListFar;
238 }
239
240 /**
241 * This is the default constructor
242 */
243 public DeleteStepOne(IFrame iFrame, boolean modal) {
244 super(iFrame, modal);
245 initialize();
246 }
247
248 /**
249 * This method initializes this
250 *
251 * @return void
252 */
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);
259 }
260
261 /**
262 * This method initializes jContentPane
263 *
264 * @return javax.swing.JPanel
265 */
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);
295 }
296 return jContentPane;
297 }
298
299 public void valueChanged(ListSelectionEvent e) {
300 //
301 // Add logic for FAR list value changed
302 //
303 if (e.getSource() == jListFar) {
304 boolean flag = true;
305 FarIdentification far = (FarIdentification) jListFar.getSelectedValue();
306 WorkspaceTools wt = new WorkspaceTools();
307
308 removePackages = wt.getPackagesByFar(far);
309 jListPackage.setListData(removePackages);
310 removePlatforms = wt.getPlatformsByFar(far);
311 jListPlatform.setListData(removePlatforms);
312
313 //
314 // Get Dependencies Info for current FAR
315 //
316 List<PackageIdentification> allPackages = wt.getAllPackages();
317
318 //
319 // Remain packages
320 //
321 allPackages.removeAll(removePackages);
322
323 Iterator<PackageIdentification> iter = allPackages.iterator();
324
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) {
332 flag = false;
333 break;
334 }
335 }
336 }
337
338 if (flag) {
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);
343 } else {
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);
348 }
349 }
350 }
351
352 public void actionPerformed(ActionEvent e) {
353 if (e.getSource() == jButtonCancel) {
354 this.setVisible(false);
355 } else if (e.getSource() == jButtonNext) {
356 //
357 // Add some logic process here
358 //
359
360 if (stepTwo == null) {
361 stepTwo = new DeleteStepTwo(this, true, this);
362 }
363 this.setVisible(false);
364 stepTwo.setVisible(true);
365 }
366
367 }
368
369 public FarIdentification getSelecedFar() {
370 return (FarIdentification) jListFar.getSelectedValue();
371 }
372
373 }