diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:23:09 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 13:24:09 +0200 |
commit | c7da892cb23d50d4d85746c9a0b6b14bf570989d (patch) | |
tree | e7136073f386d6156f51766c498c52c30c8df85f /plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java | |
download | eclipse-poky-kepler-c7da892cb23d50d4d85746c9a0b6b14bf570989d.tar.gz |
initial commit for Enea Linux 4.0daisy
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java')
-rw-r--r-- | plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java new file mode 100644 index 0000000..9777396 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java | |||
@@ -0,0 +1,116 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010 Intel Corporation. | ||
3 | * All rights reserved. This program and the accompanying materials | ||
4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
5 | * which accompanies this distribution, and is available at | ||
6 | * http://www.eclipse.org/legal/epl-v10.html | ||
7 | * | ||
8 | * Contributors: | ||
9 | * Intel - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.ide; | ||
12 | |||
13 | import java.lang.reflect.InvocationTargetException; | ||
14 | |||
15 | import org.eclipse.core.resources.ResourcesPlugin; | ||
16 | import org.eclipse.core.runtime.CoreException; | ||
17 | import org.eclipse.core.runtime.IStatus; | ||
18 | import org.eclipse.core.runtime.Status; | ||
19 | import org.eclipse.core.runtime.preferences.InstanceScope; | ||
20 | import org.eclipse.jface.preference.IPreferenceStore; | ||
21 | import org.eclipse.swt.widgets.Shell; | ||
22 | import org.eclipse.ui.IWorkbenchWindow; | ||
23 | import org.eclipse.ui.plugin.AbstractUIPlugin; | ||
24 | import org.eclipse.ui.preferences.ScopedPreferenceStore; | ||
25 | import org.osgi.framework.BundleContext; | ||
26 | |||
27 | /** | ||
28 | * The activator class controls the plug-in life cycle | ||
29 | */ | ||
30 | public class YoctoSDKPlugin extends AbstractUIPlugin { | ||
31 | |||
32 | // The plug-in ID | ||
33 | public static final String PLUGIN_ID = "org.yocto.sdk.ide"; | ||
34 | |||
35 | // The shared instance | ||
36 | private static YoctoSDKPlugin plugin; | ||
37 | |||
38 | /** | ||
39 | * The constructor | ||
40 | */ | ||
41 | public YoctoSDKPlugin() { | ||
42 | } | ||
43 | |||
44 | /* | ||
45 | * (non-Javadoc) | ||
46 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) | ||
47 | */ | ||
48 | public void start(BundleContext context) throws Exception { | ||
49 | super.start(context); | ||
50 | plugin = this; | ||
51 | } | ||
52 | |||
53 | /* | ||
54 | * (non-Javadoc) | ||
55 | * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) | ||
56 | */ | ||
57 | public void stop(BundleContext context) throws Exception { | ||
58 | plugin = null; | ||
59 | super.stop(context); | ||
60 | } | ||
61 | |||
62 | /** | ||
63 | * Returns the shared instance | ||
64 | * | ||
65 | * @return the shared instance | ||
66 | */ | ||
67 | public static YoctoSDKPlugin getDefault() { | ||
68 | return plugin; | ||
69 | } | ||
70 | |||
71 | public static IPreferenceStore getProfilePreferenceStore(String profileName) { | ||
72 | int profileIdentifier = profileName.hashCode(); | ||
73 | |||
74 | return new ScopedPreferenceStore(InstanceScope.INSTANCE,getUniqueIdentifier() + "." + profileIdentifier); | ||
75 | } | ||
76 | |||
77 | public static void log(IStatus status) { | ||
78 | ResourcesPlugin.getPlugin().getLog().log(status); | ||
79 | } | ||
80 | |||
81 | public static void log(Throwable e) { | ||
82 | if (e instanceof InvocationTargetException) | ||
83 | e = ((InvocationTargetException) e).getTargetException(); | ||
84 | IStatus status = null; | ||
85 | if (e instanceof CoreException) | ||
86 | status = ((CoreException) e).getStatus(); | ||
87 | else | ||
88 | status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e); | ||
89 | log(status); | ||
90 | } | ||
91 | |||
92 | public static void logErrorMessage(String message) { | ||
93 | log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null)); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * Returns active shell. | ||
98 | */ | ||
99 | public static Shell getActiveWorkbenchShell() { | ||
100 | IWorkbenchWindow window = getDefault().getWorkbench().getActiveWorkbenchWindow(); | ||
101 | if (window != null) { | ||
102 | return window.getShell(); | ||
103 | } | ||
104 | return null; | ||
105 | } | ||
106 | |||
107 | public static String getUniqueIdentifier() { | ||
108 | if (getDefault() == null) { | ||
109 | // If the default instance is not yet initialized, | ||
110 | // return a static identifier. This identifier must | ||
111 | // match the plugin id defined in plugin.xml | ||
112 | return PLUGIN_ID; | ||
113 | } | ||
114 | return getDefault().getBundle().getSymbolicName(); | ||
115 | } | ||
116 | } | ||