summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java
diff options
context:
space:
mode:
authorAdrian Dudau <adrian.dudau@enea.com>2013-12-12 13:36:50 +0100
committerAdrian Dudau <adrian.dudau@enea.com>2013-12-12 15:25:03 +0100
commit41ac47d732eed8392d60d0f6773e5a279d49b999 (patch)
treecf19d099db9cfdb8d73aa21c31e7aa1cc86ff860 /plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/YoctoSDKPlugin.java
downloadeclipse-poky-juno-master.tar.gz
initial commit of Enea Linux 3.1HEADmaster
Migrated from the internal git server on the dora-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.java116
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 *******************************************************************************/
11package org.yocto.sdk.ide;
12
13import java.lang.reflect.InvocationTargetException;
14
15import org.eclipse.core.resources.ResourcesPlugin;
16import org.eclipse.core.runtime.CoreException;
17import org.eclipse.core.runtime.IStatus;
18import org.eclipse.core.runtime.Status;
19import org.eclipse.core.runtime.preferences.InstanceScope;
20import org.eclipse.jface.preference.IPreferenceStore;
21import org.eclipse.swt.widgets.Shell;
22import org.eclipse.ui.IWorkbenchWindow;
23import org.eclipse.ui.plugin.AbstractUIPlugin;
24import org.eclipse.ui.preferences.ScopedPreferenceStore;
25import org.osgi.framework.BundleContext;
26
27/**
28 * The activator class controls the plug-in life cycle
29 */
30public 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}