Revision 49c6e8c3
Added by Cherian Mathew over 9 years ago
eu.etaxonomy.taxeditor.application/src/main/java/eu/etaxonomy/taxeditor/TaxonomicEditorPlugin.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.taxeditor; |
2 | 2 |
|
3 | 3 |
import org.apache.log4j.Logger; |
4 |
import org.eclipse.equinox.p2.core.IProvisioningAgent; |
|
5 |
import org.eclipse.equinox.p2.engine.IProfileRegistry; |
|
6 |
import org.eclipse.equinox.p2.operations.ProvisioningSession; |
|
7 |
import org.eclipse.equinox.p2.ui.Policy; |
|
8 |
import org.eclipse.equinox.p2.ui.ProvisioningUI; |
|
4 | 9 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
5 | 10 |
import org.osgi.framework.Bundle; |
6 | 11 |
import org.osgi.framework.BundleContext; |
... | ... | |
37 | 42 |
|
38 | 43 |
private ServiceRegistration policyRegistration; |
39 | 44 |
|
45 |
private ProvisioningSession session; |
|
46 |
private ProvisioningUI ui; |
|
47 |
|
|
40 | 48 |
// private CloudPolicy policy; |
41 |
|
|
49 |
|
|
42 | 50 |
/** |
43 | 51 |
* The constructor |
44 | 52 |
*/ |
... | ... | |
50 | 58 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
51 | 59 |
*/ |
52 | 60 |
/** {@inheritDoc} */ |
53 |
public void start(BundleContext context) throws Exception { |
|
61 |
@Override |
|
62 |
public void start(BundleContext context) throws Exception { |
|
54 | 63 |
super.start(context); |
55 |
|
|
64 |
|
|
56 | 65 |
plugin = this; |
57 | 66 |
bundleContext = context; |
58 |
|
|
67 |
|
|
59 | 68 |
packageAdminRef = bundleContext.getServiceReference(PackageAdmin.class.getName()); |
60 | 69 |
packageAdmin = (PackageAdmin) bundleContext.getService(packageAdminRef); |
61 |
|
|
70 |
|
|
62 | 71 |
logger.debug("Taxonomic Editor started."); |
63 | 72 |
} |
64 | 73 |
|
65 | 74 |
private Bundle getBundle(String symbolicName) { |
66 |
if (packageAdmin == null) |
|
67 |
return null; |
|
75 |
if (packageAdmin == null) { |
|
76 |
return null; |
|
77 |
} |
|
68 | 78 |
Bundle[] bundles = packageAdmin.getBundles(symbolicName, null); |
69 |
if (bundles == null) |
|
70 |
return null; |
|
79 |
if (bundles == null) { |
|
80 |
return null; |
|
81 |
} |
|
71 | 82 |
// Return the first bundle that is not installed or uninstalled |
72 | 83 |
for (int i = 0; i < bundles.length; i++) { |
73 | 84 |
if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) { |
... | ... | |
76 | 87 |
} |
77 | 88 |
return null; |
78 | 89 |
} |
79 |
|
|
90 |
|
|
80 | 91 |
/* |
81 | 92 |
* (non-Javadoc) |
82 | 93 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
83 | 94 |
*/ |
84 | 95 |
/** {@inheritDoc} */ |
96 |
@Override |
|
85 | 97 |
public void stop(BundleContext context) throws Exception { |
86 |
plugin = null;
|
|
87 |
super.stop(context);
|
|
88 |
MessagingUtils.info("Taxonomic Editor stopped.");
|
|
98 |
plugin = null;
|
|
99 |
super.stop(context);
|
|
100 |
MessagingUtils.info("Taxonomic Editor stopped.");
|
|
89 | 101 |
} |
90 | 102 |
|
91 | 103 |
/** |
... | ... | |
94 | 106 |
* @return the shared instance |
95 | 107 |
*/ |
96 | 108 |
public static TaxonomicEditorPlugin getDefault() { |
97 |
return plugin;
|
|
109 |
return plugin;
|
|
98 | 110 |
} |
99 |
|
|
100 |
|
|
101 |
|
|
111 |
|
|
112 |
public static BundleContext getContext() { |
|
113 |
return bundleContext; |
|
114 |
} |
|
115 |
|
|
116 |
public ProvisioningUI getProvisioningUI() { |
|
117 |
|
|
118 |
if (ui == null) { |
|
119 |
ServiceReference reference = bundleContext.getServiceReference(IProvisioningAgent.SERVICE_NAME); |
|
120 |
IProvisioningAgent agent = (IProvisioningAgent) bundleContext.getService(reference); |
|
121 |
session = new ProvisioningSession(agent); |
|
122 |
Policy policy = null;// = (Policy) ServiceHelper.getService(ProvUIActivator.getContext(), Policy.class.getName()); |
|
123 |
if (policy == null) { |
|
124 |
policy = new Policy(); |
|
125 |
} |
|
126 |
ui = new ProvisioningUI(session, IProfileRegistry.SELF, policy); |
|
127 |
} |
|
128 |
return ui; |
|
129 |
} |
|
130 |
|
|
131 |
|
|
102 | 132 |
} |
Also available in: Unified diff
P2 update implementation and editor version extraction
ApplicationWorkbenchAdvisor : clean up
ApplicationWorkbenchWindowAdvisor : added update of editor to startup
P2Util : replaced older class with a new one which handles background update of editor
UpdateHandler : handles modal update of editor when requested
InstallNewSoftwareHandler, PreloadingRepositoryHandler : handlers for installing new software and preloading repositories (not used yet)
ApplicationUtil : added new methods to retrieve editor version number
TaxonomicEditorPlugin : added new methods for retrieving provisioning elements
build.properties, pom.xml, plugin_en.properties, plugin.properties, plugin_de.properties : setup dynamic properties (version number , build date) to be replaced via maven
plugin.xml, MANIFEST.MF : added new dependencies for p2 update mechanism
p2.inf : deleted since we now setup update repositories programmatically