001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.so6.plugin;
034:
035: import org.eclipse.ui.plugin.AbstractUIPlugin;
036:
037: import org.osgi.framework.BundleContext;
038:
039: import java.util.MissingResourceException;
040: import java.util.ResourceBundle;
041:
042: /**
043: * The main plugin class to be used in the desktop.
044: */
045: public class Plugin extends AbstractUIPlugin {
046: //The shared instance.
047: private static Plugin plugin;
048:
049: /** DOCUMENT ME! */
050: public static String ID = "org.libresource.so6.plugin";
051:
052: //Resource bundle.
053: private ResourceBundle resourceBundle;
054:
055: /**
056: * The constructor.
057: */
058: public Plugin() {
059: super ();
060: plugin = this ;
061:
062: try {
063: resourceBundle = ResourceBundle
064: .getBundle("org.libresource.so6.plugin.PluginResources");
065: } catch (MissingResourceException x) {
066: resourceBundle = null;
067: }
068: }
069:
070: /**
071: * Returns the shared instance.
072: *
073: * @return DOCUMENT ME!
074: */
075: public static Plugin getDefault() {
076: return plugin;
077: }
078:
079: /**
080: * Returns the string from the plugin's resource bundle, or 'key' if not
081: * found.
082: *
083: * @param key DOCUMENT ME!
084: *
085: * @return DOCUMENT ME!
086: */
087: public static String getResourceString(String key) {
088: ResourceBundle bundle = Plugin.getDefault().getResourceBundle();
089:
090: try {
091: return (bundle != null) ? bundle.getString(key) : key;
092: } catch (MissingResourceException e) {
093: return key;
094: }
095: }
096:
097: /**
098: * Returns the plugin's resource bundle,
099: *
100: * @return DOCUMENT ME!
101: */
102: public ResourceBundle getResourceBundle() {
103: return resourceBundle;
104: }
105:
106: /**
107: * This method is called upon plug-in activation
108: *
109: * @param context DOCUMENT ME!
110: *
111: * @throws Exception DOCUMENT ME!
112: */
113: public void start(BundleContext context) throws Exception {
114: super .start(context);
115: }
116:
117: /**
118: * This method is called when the plug-in is stopped
119: *
120: * @param context DOCUMENT ME!
121: *
122: * @throws Exception DOCUMENT ME!
123: */
124: public void stop(BundleContext context) throws Exception {
125: super.stop(context);
126: }
127: }
|