diff org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.d @ 105:bbe49769ec18

...
author Frank Benoit <benoit@tionex.de>
date Sun, 08 Nov 2009 12:42:30 +0100
parents bc29606a740c
children
line wrap: on
line diff
--- a/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.d	Sat May 02 11:27:24 2009 +0200
+++ b/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/RuntimeLog.d	Sun Nov 08 12:42:30 2009 +0100
@@ -4,33 +4,35 @@
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- *
+ * 
  * Contributors:
  *     IBM Corporation - initial API and implementation
  *     Julian Chen - fix for bug #92572, jclRM
- * Port to the D programming language:
- *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
-module org.eclipse.core.internal.runtime.RuntimeLog;
+// Port to the D programming language:
+//     Frank Benoit <benoit@tionex.de>
+module org.eclipse.core.internal.runtimeRuntimeLog;
 
 import java.lang.all;
+
+import org.eclipse.core.internal.runtimeIRuntimeConstants; // packageimport
+
 import java.util.ArrayList;
 import java.util.Iterator;
 
 import org.eclipse.core.runtime.ILogListener;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.internal.runtime.IRuntimeConstants;
 
 /**
  * NOT API!!!  This log infrastructure was split from the InternalPlatform.
- *
+ * 
  * @since org.eclipse.equinox.common 3.2
  */
 // XXX this must be removed and replaced with something more reasonable
 public final class RuntimeLog {
 
-    private static ArrayList logListeners;
+    private static ArrayList logListeners = new ArrayList(5);
 
     /**
      * Keep the messages until the first log listener is registered.
@@ -38,12 +40,7 @@
      * all status messages accumulated during the period when no log
      * listener was available.
      */
-    private static ArrayList queuedMessages;
-
-    static this(){
-        logListeners = new ArrayList(5);
-        queuedMessages = new ArrayList(5);
-    }
+    private static ArrayList queuedMessages = new ArrayList(5);
 
     /**
      * See org.eclipse.core.runtime.Platform#addLogListener(ILogListener)
@@ -53,8 +50,8 @@
             bool firstListener = (logListeners.size() is 0);
             // replace if already exists (Set behaviour but we use an array
             // since we want to retain order)
-            logListeners.remove(cast(Object)listener);
-            logListeners.add(cast(Object)listener);
+            logListeners.remove(listener);
+            logListeners.add(listener);
             if (firstListener) {
                 for (Iterator i = queuedMessages.iterator(); i.hasNext();) {
                     try {
@@ -62,9 +59,8 @@
                         listener.logging(recordedMessage, IRuntimeConstants.PI_RUNTIME);
                     } catch (Exception e) {
                         handleException(e);
-// SWT Fixme
-//                     } catch (LinkageError e) {
-//                         handleException(e);
+                    } catch (LinkageError e) {
+                        handleException(e);
                     }
                 }
                 queuedMessages.clear();
@@ -77,7 +73,7 @@
      */
     public static void removeLogListener(ILogListener listener) {
         synchronized (logListeners) {
-            logListeners.remove(cast(Object)listener);
+            logListeners.remove(listener);
         }
     }
 
@@ -86,20 +82,20 @@
      */
     public static bool contains(ILogListener listener) {
         synchronized (logListeners) {
-            return logListeners.contains(cast(Object)listener);
+            return logListeners.contains(listener);
         }
     }
 
     /**
      * Notifies all listeners of the platform log.
      */
-    public static void log(IStatus status) {
+    public static void log(final IStatus status) {
         // create array to avoid concurrent access
         ILogListener[] listeners;
         synchronized (logListeners) {
-            listeners = arraycast!(ILogListener)( logListeners.toArray());
+            listeners = (ILogListener[]) logListeners.toArray(new ILogListener[logListeners.size()]);
             if (listeners.length is 0) {
-                queuedMessages.add(cast(Object)status);
+                queuedMessages.add(status);
                 return;
             }
         }
@@ -108,17 +104,16 @@
                 listeners[i].logging(status, IRuntimeConstants.PI_RUNTIME);
             } catch (Exception e) {
                 handleException(e);
-// SWT Fixme
-//             } catch (LinkageError e) {
-//                 handleException(e);
+            } catch (LinkageError e) {
+                handleException(e);
             }
         }
     }
 
-    private static void handleException(Exception e) {
-        if (!(cast(OperationCanceledException)e )) {
-            // Got a error while logging. Don't try to log again, just put it into stderr
-            ExceptionPrintStackTrace(e);
+    private static void handleException(Throwable e) {
+        if (!( null !is cast(OperationCanceledException)e )) {
+            // Got a error while logging. Don't try to log again, just put it into stderr 
+            e.printStackTrace();
         }
     }