Commits

Anonymous committed 0ca052f

Preferences now use common logging plugin.

  • Participants
  • Parent commits 8d3b39e

Comments (0)

Files changed (6)

File org.lispdev.preferences/META-INF/MANIFEST.MF

 Bundle-Activator: org.lispdev.preferences.PreferencesPlugin
 Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
- org.eclipse.core.resources;bundle-version="3.5.0"
+ org.eclipse.core.resources;bundle-version="3.5.0",
+ org.lispdev.log;bundle-version="1.0.0"
 Bundle-ActivationPolicy: lazy
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Export-Package: org.lispdev.preferences,

File org.lispdev.preferences/src/org/lispdev/preferences/Log.java

-package org.lispdev.preferences;
-
-import java.lang.management.ManagementFactory;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- * <h1>Logging Facility</h1>
- * <h2>How to log in code</h2>
- * To log a message use one of the four functions: {@link EtLog#logInfo},
- * {@link EtLog#logWarning}, {@link EtLog#logError},
- * or {@link EtLog#logException}.
- */
-public class Log
-{
-  public static void appendCallInformation(StringBuilder sb, int lvl, String tag)
-  {
-    final StackTraceElement ste = Thread.currentThread().getStackTrace()[lvl];
-    sb.append('(');
-    sb.append(ste.getFileName());
-    sb.append(':');
-    sb.append(ste.getLineNumber());
-    sb.append(')');
-    sb.append('<');
-    sb.append(tag);
-    sb.append(':');
-    sb.append(ste.getMethodName());
-    sb.append(':');
-    sb.append(ManagementFactory.getRuntimeMXBean().getUptime());
-    sb.append('>');
-  }
-
-  /**
-   * Throws exception with custom message.
-   * @param message Message that assigned to the exception
-   * @param e a low-level exception or <tt>null</tt> if not applicable
-   * @throws CoreException
-   *
-   * <p>
-   * This is a convenience function to throw an exception with custom
-   * message.
-   */
-  public static void abort(String message, Throwable e) throws CoreException
-  {
-    throw new CoreException(new Status(IStatus.ERROR, PreferencesPlugin.ID,
-        0, message, e));
-  }
-
-  /**
-   * @param message
-   * @param severity
-   *          Integer constant from {@org.eclipse.core.runtime.IStatus}
-   */
-  private static void log(String message, int severity, Throwable e)
-  {
-    StringBuilder sb = new StringBuilder();
-    appendCallInformation(sb, 4, "");
-    sb.append(" ");
-    sb.append(message);
-    PreferencesPlugin.get().getLog().log(
-        new Status(severity, PreferencesPlugin.ID, 0, sb.toString(), e));
-  }
-
-
-  public static void logInfo(String message)
-  {
-    log(message, IStatus.INFO, null);
-  }
-
-  public static void logWarning(String message)
-  {
-    log(message, IStatus.WARNING, null);
-  }
-
-  public static void logError(String message)
-  {
-    log(message, IStatus.ERROR, null);
-  }
-
-  public static void logException(String message, Throwable e)
-  {
-    log(message, IStatus.ERROR, e);
-  }
-
-}

File org.lispdev.preferences/src/org/lispdev/preferences/PreferencesPlugin.java

   public Color colorGreenish;
   public Color colorLightGray;
 
-
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
-   * )
-   */
   @Override
   public void start(BundleContext context) throws Exception
   {
     colorLightGray = new Color(null, 224, 223, 226);
   }
 
-  /*
-   * (non-Javadoc)
-   *
-   * @see
-   * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
-   * )
-   */
   @Override
   public void stop(BundleContext context) throws Exception
   {

File org.lispdev.preferences/src/org/lispdev/preferences/PreferencesService.java

 import org.eclipse.core.runtime.Platform;
 import org.eclipse.core.runtime.preferences.DefaultScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
 import org.eclipse.core.runtime.preferences.IPreferencesService;
 import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.lispdev.log.Log;
 import org.osgi.service.prefs.BackingStoreException;
 
 /**
   /**
    * workspace scope
    */
-  private InstanceScope instanceScope = new InstanceScope();
+  private final InstanceScope instanceScope = new InstanceScope();
   /**
    * default values scope
    */
-  private DefaultScope defaultScope = new DefaultScope();
+  private final DefaultScope defaultScope = new DefaultScope();
 
   /**
    * Create preferences service associated with this language

File org.lispdev.preferences/src/org/lispdev/preferences/fields/BooleanItemEditor.java

 import org.eclipse.jface.preference.BooleanFieldEditor;
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
-import org.lispdev.preferences.Log;
+import org.lispdev.log.Log;
 import org.lispdev.preferences.PreferenceItem;
 import org.lispdev.preferences.PreferenceType;
 import org.lispdev.preferences.PreferencesService;
 
 public class BooleanItemEditor extends BooleanFieldEditor implements ItemField
 {
-  private PreferencesService service;
-  private Composite parent;
-  private PreferenceItem item;
+  private final PreferencesService service;
+  private final Composite parent;
+  private final PreferenceItem item;
 
   public BooleanItemEditor(PreferenceItem item, Composite parent,
       PreferencesService service)

File org.lispdev.preferences/src/org/lispdev/preferences/fields/FontItemEditor.java

 import org.eclipse.jface.preference.FontFieldEditor;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swt.widgets.Composite;
-import org.lispdev.preferences.Log;
+import org.lispdev.log.Log;
 import org.lispdev.preferences.PreferenceItem;
 import org.lispdev.preferences.PreferenceType;
 import org.lispdev.preferences.PreferencesService;