KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > search > dependencies > UnusedDependenciesJob


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.search.dependencies;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
14
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.core.runtime.IStatus;
17 import org.eclipse.core.runtime.Status;
18 import org.eclipse.core.runtime.jobs.Job;
19 import org.eclipse.jface.action.Action;
20 import org.eclipse.pde.core.plugin.IPluginModelBase;
21 import org.eclipse.pde.internal.ui.PDEPlugin;
22 import org.eclipse.pde.internal.ui.PDEUIMessages;
23 import org.eclipse.swt.widgets.Display;
24
25
26 public class UnusedDependenciesJob extends Job {
27     
28
29     private IPluginModelBase fModel;
30     private boolean fReadOnly;
31
32     public UnusedDependenciesJob(String JavaDoc name, IPluginModelBase model, boolean readOnly) {
33         super(name);
34         fModel = model;
35         fReadOnly = readOnly;
36     }
37
38     /* (non-Javadoc)
39      * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
40      */

41     protected IStatus run(IProgressMonitor monitor) {
42         try {
43             GatherUnusedDependenciesOperation udo = new GatherUnusedDependenciesOperation(fModel);
44             udo.run(monitor);
45             // List can contain IPluginImports or ImportPackageObjects
46
showResults(udo.getList().toArray());
47         } catch (InvocationTargetException JavaDoc e) {
48         } catch (InterruptedException JavaDoc e) {
49         } finally {
50             monitor.done();
51         }
52         return new Status(IStatus.OK, PDEPlugin.getPluginId(), IStatus.OK, PDEUIMessages.UnusedDependenciesJob_viewResults, null);
53     }
54     
55
56     
57     private Action getShowResultsAction(Object JavaDoc[] unused) {
58         return new ShowResultsAction(fModel, unused, fReadOnly);
59     }
60     
61     protected void showResults(final Object JavaDoc[] unused) {
62         Display.getDefault().asyncExec(new Runnable JavaDoc() {
63            public void run() {
64               getShowResultsAction(unused).run();
65            }
66         });
67      }
68 }
69
Popular Tags