package org.csstudio.trends.databrowser;

import org.csstudio.platform.logging.CentralLogger;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

/** The main plugin class to be used in the desktop.
 *  @author Kay Kasemir
 */
public class Plugin extends AbstractUIPlugin
{
    public static final String ID = "org.csstudio.trends.databrowser"; //$NON-NLS-1$
    public static final String Version = "0.1"; //$NON-NLS-1$
    // The shared instance.
    private static Plugin plugin = null;

    /** The constructor. */
    public Plugin()
    {
        plugin = this;
    }

    /** This method is called upon plug-in activation */
    public void start(BundleContext context) throws Exception
    {
        super.start(context);
    }

    /** This method is called when the plug-in is stopped */
    public void stop(BundleContext context) throws Exception
    {
        super.stop(context);
        plugin = null;
    }

    /** Returns the shared instance. */
    public static Plugin getDefault()
    {   return plugin;   }

    /** Add info message to the plugin log. */
    public static void logInfo(String message)
    {
        CentralLogger.getInstance().info(getDefault(), message);
    }
    
    /** Add error message to the plugin log. */
    public static void logError(String message)
    {
        CentralLogger.getInstance().error(getDefault(), message);
    }

    /** Add an exception to the plugin log. */
    public static void logException(String message, Throwable e)
    {
        CentralLogger.getInstance().error(getDefault(), message, e);
    }

    /** Returns an image descriptor for the image file.
     *  <p>
     *  Usually, this is the image found via the the given plug-in
     *  relative path.
     *  But this implementation also supports a hack for testing:
     *  If no plugin is running, because for example this is an SWT-only
     *  test, the path is used as is, i.e. relative to the current
     *  directory.
     * 
     *  @param path the path
     *  @return the image descriptor
     */
    @SuppressWarnings("nls")
    public static ImageDescriptor getImageDescriptor(String path)
    {
        // If the plugin is running, get descriptor from the bundle
        if (plugin != null)
            return AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
        // ... otherwise, this is an SWT-only test without the plugin:
        try
        {
            Display display = Display.getCurrent();
            Image img = new Image(display, path);        
            return ImageDescriptor.createFromImage(img, display);
        }
        catch (Exception e)
        {
            logException("Cannot load image '" + path + "'", e);
        }
        return null;
    }
}

@@ -68,29 +68,111 @@
 orm.
-logging.CentralLogger
+ui.AbstractCssUiPlugin;%0Aimport org.eclipse.core.runtime.IStatus;%0Aimport org.eclipse.core.runtime.Status
 ;%0Aim
@@ -501,26 +501,29 @@
 nds Abstract
-UI
+CssUi
 Plugin%0A%7B%0A   
@@ -832,244 +832,270 @@
 /** 
-This method is called upon plug-in activation */%0A    public void start(BundleContext context) throws Exception%0A    %7B
+Returns the shared instance. */%0A    public static Plugin getDefault()%0A    %7B   return plugin;   %7D%0A
 %0A    
-    super.start(context);%0A    %7D%0A%0A    /** This method is called when the p
+/** @see AbstractCssUiPlugin */%0A    public String getPluginId()%0A    %7B   return ID;  %7D%0A    %0A    /** @see AbstractCssUiP
 lug
--
 in 
-is stopped */%0A    public void stop(
+*/%0A    protected void doStart(final 
 Bund
@@ -1139,168 +1139,149 @@
    %7B
+%7D%0A
 %0A    
-    super.stop(context);%0A        plugin = null;%0A    %7D%0A%0A    /** Returns the shared instance. */%0A    public static Plugin getDefault()
+/** @see AbstractCssUiPlugin */%0A    protected void doStop(final BundleContext context) throws Exception
 %0A    %7B
+%0A
    
-return
+    
  plugin
-;
+ = null;%0A 
    %7D
@@ -1394,53 +1394,37 @@
     
-CentralLogger.getInstance().info(getDefault()
+getDefault().log(IStatus.INFO
 , me
@@ -1420,32 +1420,38 @@
 us.INFO, message
+, null
 );%0A    %7D%0A    %0A  
@@ -1562,54 +1562,38 @@
     
-CentralLogger.getInstance().error(getDefault()
+getDefault().log(IStatus.ERROR
 , me
@@ -1597,16 +1597,22 @@
  message
+, null
 );%0A    %7D
@@ -1743,54 +1743,311 @@
     
-CentralLogger.getInstance().error(getDefault()
+getDefault().log(IStatus.ERROR, message, e);%0A    %7D%0A%0A    /** Add a message to the log.%0A     *  @param type%0A     *  @param message%0A     *  @param e Exception or %3Ccode%3Enull%3C/code%3E%0A     */%0A    private void log(int type, String message, Throwable e)%0A    %7B%0A        getLog().log(new Status(type, ID, IStatus.OK
 , me
@@ -2051,32 +2051,33 @@
  message, e)
+)
 ;%0A    %7D%0A
 %0A    /** Ret
@@ -2056,32 +2056,36 @@
 age, e));%0A    %7D%0A
+    
 %0A    /** Returns

Use AbstractCssUiPlugin