blob: 5d2735431f3f1e46177063fd539e4f0861fc77af (
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
|
package org.eclipse.equinox.p2.examples.rcp.cloud;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
import org.eclipse.equinox.internal.provisional.p2.engine.IProfileRegistry;
import org.eclipse.equinox.internal.provisional.p2.ui.ProfileFactory;
import org.eclipse.equinox.internal.provisional.p2.ui.ProvUI;
import org.eclipse.equinox.internal.provisional.p2.ui.operations.ProvisioningUtil;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IProfileChooser;
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.statushandlers.StatusManager;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.equinox.p2.examples.rcp.cloud";
// The shared instance
private static Activator plugin;
// The update site used for this product
private static final String CLOUD_UPDATE_SITE = "http://www.eclipse.org/equinox/p2/testing/updateSite";
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
/// XXX initialize the p2 UI policy
initializeP2Policies();
initializeP2Repositories();
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator 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 imageDescriptorFromPlugin(PLUGIN_ID, path);
}
private void initializeP2Policies() {
Policy policy = Policy.getDefault();
// XXX Where a profile must be chosen, use the running profile
policy.setProfileChooser(new IProfileChooser() {
public String getProfileId(Shell shell) {
return ProfileFactory.makeProfile("Canned").getProfileId();
}
});
// XXX User has no access to manipulate repositories
policy.setRepositoryManipulator(null);
}
// This should really be done at product build time
private void initializeP2Repositories() {
try {
URI uri = URIUtil.fromString(CLOUD_UPDATE_SITE);
ProvisioningUtil.addMetadataRepository(uri, false);
ProvisioningUtil.addArtifactRepository(uri, false);
} catch (ProvisionException e) {
ProvUI.handleException(e, null, StatusManager.SHOW | StatusManager.LOG);
} catch (URISyntaxException e) {
ProvUI.handleException(e, null, StatusManager.SHOW | StatusManager.LOG);
}
}
}
|