diff dwtx/jface/resource/JFaceResources.d @ 104:04b47443bb01

Reworked the collection uses to make use of a wrapper collection that is compatible to the Java Collections. These new wrappers now use the tango.util.containers instead of the tango.util.collections.
author Frank Benoit <benoit@tionex.de>
date Thu, 07 Aug 2008 15:01:33 +0200
parents 7ffeace6c47f
children 46b175eeced4
line wrap: on
line diff
--- a/dwtx/jface/resource/JFaceResources.d	Sun Aug 03 17:01:51 2008 +0200
+++ b/dwtx/jface/resource/JFaceResources.d	Thu Aug 07 15:01:33 2008 +0200
@@ -20,8 +20,6 @@
 import dwtx.jface.resource.DeviceResourceManager;
 import dwtx.jface.resource.ImageDescriptor;
 
-import tango.util.collection.HashMap;
-import tango.util.collection.model.Map;
 
 import dwt.graphics.Font;
 import dwt.graphics.Image;
@@ -34,6 +32,7 @@
 import dwtx.jface.wizard.Wizard;
 
 import dwt.dwthelper.utils;
+import dwtx.dwtxhelper.Collection;
 import dwt.dwthelper.Runnable;
 import dwt.dwthelper.ResourceBundle;
 import tango.text.convert.Format;
@@ -66,11 +65,11 @@
      * Map of Display onto DeviceResourceManager. Holds all the resources for
      * the associated display.
      */
-    private static Map!(Display,ResourceManager) registries;
+    private static Map registries;
     private static void init_registries(){
         if( registries is null ){
             synchronized if( registries is null ){
-                registries = new HashMap!(Display,ResourceManager);
+                registries = new HashMap();
             }
         }
     }
@@ -219,28 +218,21 @@
      */
     public static ResourceManager getResources(Display toQuery) {
         init_registries();
-        ResourceManager reg = registries.containsKey(toQuery) ? cast(ResourceManager) registries.get(toQuery) : null;
+        ResourceManager reg = cast(ResourceManager) registries.get(toQuery);
 
         if (reg is null) {
-            toQuery.disposeExec(new class(toQuery) Runnable {
-                DeviceResourceManager mgr;
-                Display toQuery_;
-                this(Display d){
-                    mgr = new DeviceResourceManager(d);
-                    reg = mgr;
-                    toQuery_ = d;
-                    registries.add(d, reg);
-                }
+            DeviceResourceManager mgr = new DeviceResourceManager(toQuery);
+            reg = mgr;
+            registries.put(toQuery, reg);
+            toQuery.disposeExec( dgRunnable( (DeviceResourceManager mgr_, Display toQuery_){
                 /*
                  * (non-Javadoc)
                  *
                  * @see java.lang.Runnable#run()
                  */
-                public void run() {
-                    mgr.dispose();
-                    registries.removeKey(toQuery_);
-                }
-            });
+                mgr_.dispose();
+                registries.remove(toQuery_);
+            }, mgr, toQuery ));
         }
 
         return reg;