0
|
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 "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.s60tools.symbianfoundationtemplates;
|
|
18 |
|
|
19 |
import java.io.File;
|
|
20 |
import java.io.IOException;
|
|
21 |
import java.net.URL;
|
|
22 |
|
|
23 |
import org.eclipse.core.runtime.FileLocator;
|
|
24 |
import org.eclipse.core.runtime.IStatus;
|
|
25 |
import org.eclipse.core.runtime.Status;
|
|
26 |
import org.eclipse.jface.dialogs.ErrorDialog;
|
|
27 |
import org.eclipse.swt.widgets.Display;
|
|
28 |
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
|
29 |
import org.osgi.framework.BundleContext;
|
|
30 |
|
|
31 |
import com.nokia.s60tools.symbianfoundationtemplates.resources.Messages;
|
|
32 |
|
|
33 |
/**
|
|
34 |
* The activator class controls the plug-in life cycle
|
|
35 |
*/
|
|
36 |
public class SymbianFoundationTemplates extends AbstractUIPlugin {
|
|
37 |
|
|
38 |
// The plug-in ID
|
|
39 |
public static final String PLUGIN_ID = "com.nokia.s60tools.symbianfoundationtemplates"; //$NON-NLS-1$
|
|
40 |
|
|
41 |
// The shared instance
|
|
42 |
private static SymbianFoundationTemplates plugin;
|
|
43 |
|
|
44 |
/**
|
|
45 |
* The constructor
|
|
46 |
*/
|
|
47 |
public SymbianFoundationTemplates() {
|
|
48 |
plugin = this;
|
|
49 |
}
|
|
50 |
|
|
51 |
/*
|
|
52 |
* (non-Javadoc)
|
|
53 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
|
|
54 |
*/
|
|
55 |
public void start(BundleContext context) throws Exception {
|
|
56 |
super.start(context);
|
|
57 |
}
|
|
58 |
|
|
59 |
/*
|
|
60 |
* (non-Javadoc)
|
|
61 |
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
|
|
62 |
*/
|
|
63 |
public void stop(BundleContext context) throws Exception {
|
|
64 |
plugin = null;
|
|
65 |
super.stop(context);
|
|
66 |
}
|
|
67 |
|
|
68 |
/**
|
|
69 |
* Returns the shared instance
|
|
70 |
*
|
|
71 |
* @return the shared instance
|
|
72 |
*/
|
|
73 |
public static SymbianFoundationTemplates getDefault() {
|
|
74 |
return plugin;
|
|
75 |
}
|
|
76 |
|
|
77 |
/**
|
|
78 |
* Show the error dialog.
|
|
79 |
*
|
|
80 |
* @param error the error message.
|
|
81 |
* @param reason the reason of the error.
|
|
82 |
*/
|
|
83 |
public void showErrorDialog(String error, String reason) {
|
|
84 |
IStatus status = new Status(IStatus.ERROR, SymbianFoundationTemplates.PLUGIN_ID, -1, reason, null);
|
|
85 |
|
|
86 |
ErrorDialog.openError(Display.getCurrent().getActiveShell(),
|
|
87 |
Messages.getString("ErrorMessageTitle"), //$NON-NLS-1$
|
|
88 |
error, status);
|
|
89 |
}
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Get the location of the templates associated with this plugin.
|
|
93 |
*
|
|
94 |
* @return the location of templates
|
|
95 |
*/
|
|
96 |
public String getTemplatesPath() {
|
|
97 |
return getRootPath() + "templates"; //$NON-NLS-1$
|
|
98 |
}
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Get the location of the images associated with this plugin.
|
|
102 |
*
|
|
103 |
* @return the location of images
|
|
104 |
*/
|
|
105 |
public String getImagesPath() {
|
|
106 |
return getRootPath() + "images"; //$NON-NLS-1$
|
|
107 |
}
|
|
108 |
|
|
109 |
/**
|
|
110 |
* Get the plugin root path of this plugin
|
|
111 |
* @return the plugin installation path
|
|
112 |
*/
|
|
113 |
private String getRootPath() {
|
|
114 |
URL relativeURL = getBundle().getEntry("/"); //$NON-NLS-1$
|
|
115 |
|
|
116 |
URL localURL = null;
|
|
117 |
try {
|
|
118 |
localURL = FileLocator.toFileURL(relativeURL);
|
|
119 |
} catch(IOException ioe) {
|
|
120 |
}
|
|
121 |
|
|
122 |
if(localURL == null)
|
|
123 |
return null;
|
|
124 |
|
|
125 |
File f = new File(localURL.getPath());
|
|
126 |
|
|
127 |
return f.getAbsolutePath() + File.separator;
|
|
128 |
}
|
|
129 |
}
|