View Javadoc

1   /*
2    WSMO Studio - a Semantic Web Service Editor
3    Copyright (c) 2004-2006, OntoText Lab. / SIRMA Group
4    
5    This library is free software; you can redistribute it and/or modify it under
6    the terms of the GNU Lesser General Public License as published by the Free
7    Software Foundation; either version 2.1 of the License, or (at your option)
8    any later version.
9    This library is distributed in the hope that it will be useful, but WITHOUT
10   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   details.
13   You should have received a copy of the GNU Lesser General Public License along
14   with this library; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16   */
17  
18  /***
19   * <p>Title: WSMO Studio</p>
20   * <p>Description: Semantic Web Service Editor</p>
21   * <p>Copyright:  Copyright (c) 2004-2006</p>
22   * <p>Company: OntoText Lab. / SIRMA </p>
23   */
24  
25  package org.wsmostudio.runtime;
26  
27  import org.eclipse.ui.plugin.*;
28  import org.osgi.framework.BundleContext;
29  import org.wsmostudio.runtime.cache.WSMLResourceListener;
30  import org.eclipse.core.resources.*;
31  
32  import java.util.*;
33  
34  /***
35   * The main Runtime plugin class which represents the base of the WSMO Studio.
36   *
37   * @author not attributable
38   * @version $Revision: 469 $ $Date: 2006-01-09 14:51:14 +0200 $
39   */
40  
41  public class RuntimePlugin extends AbstractUIPlugin {
42  	//The shared instance.
43  	private static RuntimePlugin plugin;
44  	//Resource bundle.
45  	private ResourceBundle resourceBundle;
46  	
47  	public static final String PLUGIN_ID = "org.wsmostudio.runtime";
48  	
49  	/***
50  	 * The constructor.
51  	 */
52  	public RuntimePlugin() {
53  		super();
54  		plugin = this;
55  		try {
56  			resourceBundle = ResourceBundle.getBundle("org.wsmostudio.runtime.RuntimePluginResources");
57  		} catch (MissingResourceException x) {
58  			resourceBundle = null;
59  		}
60  	}
61  
62  	/***
63  	 * This method is called upon plug-in activation
64  	 */
65  	public void start(BundleContext context) throws Exception {
66  	    super.start(context);
67  	    
68  		// add a resource listener and parse all wsmo headers
69  		WSMLResourceListener resourceListener = new WSMLResourceListener();
70  		ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener);
71  		WSMORuntime.getCache().reinit();
72  	}
73  
74  	/***
75  	 * This method is called when the plug-in is stopped
76  	 */
77  	public void stop(BundleContext context) throws Exception {
78  		super.stop(context);
79  	}
80  
81  	/***
82  	 * Returns the shared instance.
83  	 */
84  	public static RuntimePlugin getDefault() {
85  		return plugin;
86  	}
87  
88  	/***
89  	 * Returns the string from the plugin's resource bundle,
90  	 * or 'key' if not found.
91  	 */
92  	public static String getResourceString(String key) {
93  		ResourceBundle bundle = RuntimePlugin.getDefault().getResourceBundle();
94  		try {
95  			return (bundle != null) ? bundle.getString(key) : key;
96  		} catch (MissingResourceException e) {
97  			return key;
98  		}
99  	}
100 
101 	/***
102 	 * Returns the plugin's resource bundle,
103 	 */
104 	public ResourceBundle getResourceBundle() {
105 		return resourceBundle;
106 	}	
107 }
108 
109 /*
110  * $Log$
111  * Revision 1.5  2006/01/09 12:51:12  alex_simov
112  * Copyright message in header updated
113  *
114  * Revision 1.4  2005/07/21 14:44:40  alex_simov
115  * added javadoc: class description, footer
116  *
117  */