Skip to main content
summaryrefslogtreecommitdiffstats
blob: f68445b988ac15927b90297d3654f677d0a7f0e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package org.eclipse.mylar.bugzilla.ui;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugzilla.core.BugzillaPlugin;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskExternalizer;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskListActionContributor;
import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskListManager;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/**
 * The main plugin class to be used in the desktop.
 */
public class BugzillaUiPlugin extends AbstractUIPlugin implements IStartup {

	private BugzillaTaskListManager bugzillaTaskListManager;
    private static BugzillaUiPlugin plugin;
		
	
	/**
	 * The constructor.
	 */
	public BugzillaUiPlugin() {
		plugin = this;
	}

    public void earlyStartup() {
        final IWorkbench workbench = PlatformUI.getWorkbench();
        workbench.getDisplay().asyncExec(new Runnable() {
            public void run() {
        		BugzillaPlugin.setResultEditorMatchAdapter(new BugzillaResultMatchAdapter());
        		bugzillaTaskListManager = new BugzillaTaskListManager();
        		MylarTasksPlugin.getDefault().addPrimaryContributor(new BugzillaTaskListActionContributor());
        		
        		MylarTasksPlugin.getDefault().getTaskListExternalizer().addExternalizer(
        			new BugzillaTaskExternalizer()
        		);   
        		
            }
        });
    }
	
	/**
	 * This method is called upon plug-in activation
	 */
	public void start(BundleContext context) throws Exception {
		super.start(context);
	}

	/**
	 * This method is called when the plug-in is stopped
	 */
	public void stop(BundleContext context) throws Exception {
		super.stop(context);
		plugin = null;
		List<Job> list = new ArrayList<Job>();
		list.addAll(BugzillaTask.REFRESH_JOBS.keySet());
		for(Job j: list){
			j.cancel();
		}
	}

	/**
	 * Returns the shared instance.
	 */
	public static BugzillaUiPlugin getDefault() {
		return plugin;
	}

	/**
	 * Returns an image descriptor for the image file at the given
	 * plug-in relative path.
	 *
	 * @param path the path
	 * @return the image descriptor
	 */
	public static ImageDescriptor getImageDescriptor(String path) {
		return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.mylar.bugzilla.ui", path);
	}
	
	public BugzillaTaskListManager getBugzillaTaskListManager() {
		return bugzillaTaskListManager;
	}
}

Back to the top