blob: 9107c5229c8f6fab1bf1948f91d7c3b41d57e932 (
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/*******************************************************************************
* Copyright (c) 2004 - 2005 University Of British Columbia and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* University Of British Columbia - initial API and implementation
*******************************************************************************/
package org.eclipse.mylar.bugs;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.mylar.bugs.search.BugzillaReferencesProvider;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchWindow;
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.
*
* @author Mik Kersten
* @author Shawn Minto
*/
public class MylarBugsPlugin extends AbstractUIPlugin {
public static ImageDescriptor EDGE_REF_BUGZILLA = getImageDescriptor("icons/elcl16/edge-ref-bug.gif");
private BugzillaEditingMonitor bugzillaEditingMonitor;
private static BugzillaSearchManager bridge = null;
private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider();
private static MylarBugsPlugin plugin;
private BugzillaReportCache cache;
public MylarBugsPlugin() {
plugin = this;
}
/**
* This method is called upon plug-in activation
*/
public void start(BundleContext context) throws Exception {
super.start(context);
cache = new BugzillaReportCache();
cache.readCacheFile();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
// create a new bridge and initialize it
bridge = new BugzillaSearchManager();
}
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {
bugzillaEditingMonitor = new BugzillaEditingMonitor();
MylarPlugin.getDefault().getSelectionMonitors().add(bugzillaEditingMonitor);
}
});
}
/**
* This method is called when the plug-in is stopped
*/
public void stop(BundleContext context) throws Exception {
super.stop(context);
plugin = null;
MylarPlugin.getDefault().getSelectionMonitors().remove(bugzillaEditingMonitor);
// List<AbstractRelationProvider> providers = structureBridge.getProviders();
// if(providers != null){
// for(AbstractRelationProvider provider: providers){
// provider.stopAllRunningJobs();
// }
// }
}
/**
* Returns the shared instance.
*/
public static MylarBugsPlugin 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.bugs.bridge", path);
}
public static BugzillaSearchManager getBridge() {
// make sure that the bridge initialized, if not, make a new one
if (bridge == null) {
bridge = new BugzillaSearchManager();
}
return bridge;
}
public static BugzillaReferencesProvider getReferenceProvider() {
return referencesProvider;
}
public BugzillaReportCache getCache() {
return cache;
}
}
|