author | dadubrow |
Thu, 20 May 2010 11:40:37 -0500 | |
changeset 1377 | 40401ea8b1fd |
parent 1363 | dfbd4576cd61 |
child 1378 | 9a387b0094c7 |
permissions | -rw-r--r-- |
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
1 |
/* |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
3 |
* All rights reserved. |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
4 |
* This component and the accompanying materials are made available |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
5 |
* under the terms of the License "Eclipse Public License v1.0" |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
6 |
* which accompanies this distribution, and is available |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
8 |
* |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
9 |
* Initial Contributors: |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
10 |
* Nokia Corporation - initial contribution. |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
11 |
* |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
12 |
* Contributors: |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
13 |
* |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
14 |
* Description: |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
15 |
* |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
16 |
*/ |
1360 | 17 |
package com.nokia.carbide.discovery.ui; |
18 |
||
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
19 |
import java.util.Collections; |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
20 |
import java.util.Hashtable; |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
21 |
import java.util.Map; |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
22 |
|
1363 | 23 |
import org.eclipse.core.runtime.IStatus; |
24 |
import org.eclipse.core.runtime.Status; |
|
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
25 |
import org.eclipse.equinox.p2.ui.Policy; |
1360 | 26 |
import org.eclipse.jface.resource.ImageDescriptor; |
27 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
|
28 |
import org.osgi.framework.BundleContext; |
|
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
29 |
import org.osgi.framework.ServiceRegistration; |
1360 | 30 |
|
31 |
/** |
|
32 |
* The activator class controls the plug-in life cycle |
|
33 |
*/ |
|
34 |
public class Activator extends AbstractUIPlugin { |
|
35 |
// The plug-in ID |
|
36 |
public static final String PLUGIN_ID = "com.nokia.carbide.discovery.ui"; //$NON-NLS-1$ |
|
37 |
||
38 |
// The shared instance |
|
39 |
private static Activator plugin; |
|
40 |
||
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
41 |
private ServiceRegistration policyRegistration; |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
42 |
|
1360 | 43 |
/** |
44 |
* The constructor |
|
45 |
*/ |
|
46 |
public Activator() { |
|
47 |
} |
|
48 |
||
49 |
/* |
|
50 |
* (non-Javadoc) |
|
51 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
|
52 |
*/ |
|
53 |
public void start(BundleContext context) throws Exception { |
|
54 |
super.start(context); |
|
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
55 |
Policy policy = new Policy(); |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
56 |
policy.setRestartPolicy(Policy.RESTART_POLICY_PROMPT); |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
57 |
Map<String, Integer> map = Collections.singletonMap("service.ranking", 100); |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
58 |
policyRegistration = context.registerService(Policy.class.getName(), policy, new Hashtable<Object, Object>(map)); |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
59 |
System.setProperty("eclipse.p2.unsignedPolicy", "allow"); |
1360 | 60 |
} |
61 |
||
62 |
/* |
|
63 |
* (non-Javadoc) |
|
64 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
|
65 |
*/ |
|
66 |
public void stop(BundleContext context) throws Exception { |
|
1377
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
67 |
policyRegistration.unregister(); |
40401ea8b1fd
move p2 policy code to discovery plugin for now + add system property for disabling unsigned check
dadubrow
parents:
1363
diff
changeset
|
68 |
super.stop(context); |
1360 | 69 |
plugin = null; |
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Returns the shared instance |
|
74 |
* |
|
75 |
* @return the shared instance |
|
76 |
*/ |
|
77 |
public static Activator getDefault() { |
|
78 |
return plugin; |
|
79 |
} |
|
80 |
||
81 |
/** |
|
82 |
* Returns an image descriptor for the image file at the given |
|
83 |
* plug-in relative path |
|
84 |
* |
|
85 |
* @param path the path |
|
86 |
* @return the image descriptor |
|
87 |
*/ |
|
88 |
public static ImageDescriptor getImageDescriptor(String path) { |
|
89 |
return imageDescriptorFromPlugin(PLUGIN_ID, path); |
|
90 |
} |
|
1363 | 91 |
|
92 |
/** |
|
93 |
* Log to error log |
|
94 |
* @param message |
|
95 |
* @param t |
|
96 |
*/ |
|
97 |
public static void logError(String message, Throwable t) { |
|
98 |
getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, t)); |
|
99 |
} |
|
1360 | 100 |
} |