2
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.sdt.symbian.ui;
|
|
18 |
|
|
19 |
import com.nokia.cpp.internal.api.utils.core.Logging;
|
|
20 |
|
|
21 |
import org.eclipse.ui.plugin.*;
|
|
22 |
import org.eclipse.core.runtime.IStatus;
|
|
23 |
import org.eclipse.jface.resource.ImageDescriptor;
|
|
24 |
import org.osgi.framework.BundleContext;
|
|
25 |
|
|
26 |
import java.util.*;
|
|
27 |
|
|
28 |
/**
|
|
29 |
* The main plugin class to be used in the desktop.
|
|
30 |
*/
|
|
31 |
public class UIPlugin extends AbstractUIPlugin {
|
|
32 |
|
|
33 |
public static String PLUGIN_ID = "com.nokia.sdt.symbian.ui"; //$NON-NLS-1$
|
|
34 |
|
|
35 |
//The shared instance.
|
|
36 |
private static UIPlugin plugin;
|
|
37 |
|
|
38 |
// Resource bundle.
|
|
39 |
private ResourceBundle resourceBundle;
|
|
40 |
|
|
41 |
/**
|
|
42 |
* The constructor.
|
|
43 |
*/
|
|
44 |
public UIPlugin() {
|
|
45 |
plugin = this;
|
|
46 |
try {
|
|
47 |
resourceBundle = ResourceBundle.getBundle("com.nokia.sdt.symbian.ui.messages");
|
|
48 |
} catch (MissingResourceException x) {
|
|
49 |
resourceBundle = null;
|
|
50 |
}
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
* This method is called upon plug-in activation
|
|
55 |
*/
|
|
56 |
public void start(BundleContext context) throws Exception {
|
|
57 |
super.start(context);
|
|
58 |
}
|
|
59 |
|
|
60 |
/**
|
|
61 |
* This method is called when the plug-in is stopped
|
|
62 |
*/
|
|
63 |
public void stop(BundleContext context) throws Exception {
|
|
64 |
super.stop(context);
|
|
65 |
plugin = null;
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Returns the shared instance.
|
|
70 |
*/
|
|
71 |
public static UIPlugin getDefault() {
|
|
72 |
return plugin;
|
|
73 |
}
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Returns the string from the plugin's resource bundle, or 'key' if not
|
|
77 |
* found.
|
|
78 |
*/
|
|
79 |
public static String getResourceString(String key) {
|
|
80 |
ResourceBundle bundle = UIPlugin.getDefault().getResourceBundle();
|
|
81 |
try {
|
|
82 |
return (bundle != null) ? bundle.getString(key) : key;
|
|
83 |
} catch (MissingResourceException e) {
|
|
84 |
return key;
|
|
85 |
}
|
|
86 |
}
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Returns the plugin's resource bundle,
|
|
90 |
*/
|
|
91 |
public ResourceBundle getResourceBundle() {
|
|
92 |
return resourceBundle;
|
|
93 |
}
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Returns an image descriptor for the image file at the given
|
|
97 |
* plug-in relative path.
|
|
98 |
*
|
|
99 |
* @param path the path
|
|
100 |
* @return the image descriptor
|
|
101 |
*/
|
|
102 |
public static ImageDescriptor getImageDescriptor(String path) {
|
|
103 |
return AbstractUIPlugin.imageDescriptorFromPlugin("com.nokia.sdt.uidesigner.wizard", path);
|
|
104 |
}
|
|
105 |
|
|
106 |
static public void log(IStatus status) {
|
|
107 |
Logging.log(plugin, status);
|
|
108 |
}
|
|
109 |
|
|
110 |
static public void log(Throwable thr) {
|
|
111 |
Logging.log(plugin, Logging.newStatus(plugin, thr));
|
|
112 |
}
|
|
113 |
|
|
114 |
static public void log(Throwable thr, String msg) {
|
|
115 |
Logging.log(plugin, Logging.newStatus(plugin, IStatus.ERROR, msg, thr));
|
|
116 |
}
|
|
117 |
}
|