author | dadubrow |
Fri, 16 Jul 2010 15:39:47 -0500 | |
changeset 1634 | c8405758cfd4 |
parent 1378 | 9a387b0094c7 |
child 1637 | 06fc2fdd1ac4 |
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 |
||
1634 | 19 |
import java.io.File; |
20 |
import java.io.FileInputStream; |
|
21 |
import java.io.IOException; |
|
22 |
import java.io.InputStream; |
|
23 |
import java.net.URL; |
|
24 |
import java.text.MessageFormat; |
|
25 |
import java.util.Properties; |
|
26 |
||
27 |
import org.eclipse.core.runtime.IPath; |
|
1363 | 28 |
import org.eclipse.core.runtime.IStatus; |
1634 | 29 |
import org.eclipse.core.runtime.Path; |
30 |
import org.eclipse.core.runtime.Platform; |
|
1363 | 31 |
import org.eclipse.core.runtime.Status; |
1360 | 32 |
import org.eclipse.jface.resource.ImageDescriptor; |
1634 | 33 |
import org.eclipse.osgi.service.datalocation.Location; |
1360 | 34 |
import org.eclipse.ui.plugin.AbstractUIPlugin; |
35 |
import org.osgi.framework.BundleContext; |
|
36 |
||
37 |
/** |
|
38 |
* The activator class controls the plug-in life cycle |
|
39 |
*/ |
|
40 |
public class Activator extends AbstractUIPlugin { |
|
41 |
// The plug-in ID |
|
42 |
public static final String PLUGIN_ID = "com.nokia.carbide.discovery.ui"; //$NON-NLS-1$ |
|
43 |
||
44 |
// The shared instance |
|
45 |
private static Activator plugin; |
|
46 |
||
47 |
/** |
|
48 |
* The constructor |
|
49 |
*/ |
|
50 |
public Activator() { |
|
51 |
} |
|
52 |
||
53 |
/* |
|
54 |
* (non-Javadoc) |
|
55 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) |
|
56 |
*/ |
|
57 |
public void start(BundleContext context) throws Exception { |
|
58 |
super.start(context); |
|
59 |
} |
|
60 |
||
61 |
/* |
|
62 |
* (non-Javadoc) |
|
63 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) |
|
64 |
*/ |
|
65 |
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
|
66 |
super.stop(context); |
1360 | 67 |
plugin = null; |
68 |
} |
|
69 |
||
70 |
/** |
|
71 |
* Returns the shared instance |
|
72 |
* |
|
73 |
* @return the shared instance |
|
74 |
*/ |
|
75 |
public static Activator getDefault() { |
|
76 |
return plugin; |
|
77 |
} |
|
78 |
||
79 |
/** |
|
80 |
* Returns an image descriptor for the image file at the given |
|
81 |
* plug-in relative path |
|
82 |
* |
|
83 |
* @param path the path |
|
84 |
* @return the image descriptor |
|
85 |
*/ |
|
86 |
public static ImageDescriptor getImageDescriptor(String path) { |
|
87 |
return imageDescriptorFromPlugin(PLUGIN_ID, path); |
|
88 |
} |
|
1363 | 89 |
|
90 |
/** |
|
91 |
* Log to error log |
|
92 |
* @param message |
|
93 |
* @param t |
|
94 |
*/ |
|
95 |
public static void logError(String message, Throwable t) { |
|
96 |
getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, message, t)); |
|
97 |
} |
|
1634 | 98 |
|
99 |
/** |
|
100 |
* Get a value from the server.properties file |
|
101 |
* @param key |
|
102 |
* @return |
|
103 |
*/ |
|
104 |
public static String getFromServerProperties(String key) { |
|
105 |
Location installLocation = Platform.getInstallLocation(); |
|
106 |
URL url = installLocation.getURL(); |
|
107 |
IPath path = new Path(url.getPath()); |
|
108 |
path = path.append("configuration/server.properties"); //$NON-NLS-1$ |
|
109 |
File file = path.toFile(); |
|
110 |
Properties properties = new Properties(); |
|
111 |
try { |
|
112 |
InputStream is = new FileInputStream(file); |
|
113 |
properties.load(is); |
|
114 |
is.close(); |
|
115 |
} catch (IOException e) { |
|
116 |
String message = |
|
117 |
MessageFormat.format("Could not find URL in configuration/server.properties file for key={0}", key); |
|
118 |
Activator.logError(message, e); |
|
119 |
} |
|
120 |
return (String) properties.get(key); |
|
121 |
} |
|
122 |
||
1360 | 123 |
} |