01: /*******************************************************************************
02: * Copyright (c) 2005, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.search.dependencies;
11:
12: import java.lang.reflect.InvocationTargetException;
13:
14: import org.eclipse.core.runtime.IProgressMonitor;
15: import org.eclipse.core.runtime.IStatus;
16: import org.eclipse.core.runtime.Status;
17: import org.eclipse.core.runtime.jobs.Job;
18: import org.eclipse.jface.action.Action;
19: import org.eclipse.pde.core.plugin.IPluginModelBase;
20: import org.eclipse.pde.internal.ui.PDEPlugin;
21: import org.eclipse.pde.internal.ui.PDEUIMessages;
22: import org.eclipse.swt.widgets.Display;
23:
24: public class UnusedDependenciesJob extends Job {
25:
26: private IPluginModelBase fModel;
27: private boolean fReadOnly;
28:
29: public UnusedDependenciesJob(String name, IPluginModelBase model,
30: boolean readOnly) {
31: super (name);
32: fModel = model;
33: fReadOnly = readOnly;
34: }
35:
36: /* (non-Javadoc)
37: * @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
38: */
39: protected IStatus run(IProgressMonitor monitor) {
40: try {
41: GatherUnusedDependenciesOperation udo = new GatherUnusedDependenciesOperation(
42: fModel);
43: udo.run(monitor);
44: // List can contain IPluginImports or ImportPackageObjects
45: showResults(udo.getList().toArray());
46: } catch (InvocationTargetException e) {
47: } catch (InterruptedException e) {
48: } finally {
49: monitor.done();
50: }
51: return new Status(IStatus.OK, PDEPlugin.getPluginId(),
52: IStatus.OK,
53: PDEUIMessages.UnusedDependenciesJob_viewResults, null);
54: }
55:
56: private Action getShowResultsAction(Object[] unused) {
57: return new ShowResultsAction(fModel, unused, fReadOnly);
58: }
59:
60: protected void showResults(final Object[] unused) {
61: Display.getDefault().asyncExec(new Runnable() {
62: public void run() {
63: getShowResultsAction(unused).run();
64: }
65: });
66: }
67: }
|