diff dwtx/jface/window/WindowManager.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 8a302fdb4140
children
line wrap: on
line diff
--- a/dwtx/jface/window/WindowManager.d	Sun Aug 03 17:01:51 2008 +0200
+++ b/dwtx/jface/window/WindowManager.d	Thu Aug 07 15:01:33 2008 +0200
@@ -14,12 +14,11 @@
 
 import dwtx.jface.window.Window;
 
-import tango.util.collection.ArraySeq;
-import tango.util.collection.model.Seq;
 
 import dwtx.core.runtime.Assert;
 
 import dwt.dwthelper.utils;
+import dwtx.dwtxhelper.Collection;
 
 /**
  * A manager for a group of windows. Window managers are an optional JFace
@@ -44,20 +43,20 @@
      * List of windows managed by this window manager
      * (element type: <code>Window</code>).
      */
-    private ArraySeq!(Window) windows;
+    private ArrayList windows;
 
     /**
      * List of window managers who have this window manager
      * as their parent (element type: <code>WindowManager</code>).
      */
-    private Seq!(WindowManager) subManagers;
+    private List subManagers;
 
     /**
      * Creates an empty window manager without a parent window
      * manager (that is, a root window manager).
      */
     public this() {
-        windows = new ArraySeq!(Window);
+        windows = new ArrayList();
     }
 
     /**
@@ -67,7 +66,7 @@
      * @param parent the parent window manager
      */
     public this(WindowManager parent) {
-        windows = new ArraySeq!(Window);
+        windows = new ArrayList();
         Assert.isNotNull(parent);
         parent.addWindowManager(this);
     }
@@ -81,7 +80,7 @@
      */
     public void add(Window window) {
         if (!windows.contains(window)) {
-            windows.append(window);
+            windows.add(window);
             window.setWindowManager(this);
         }
     }
@@ -94,10 +93,10 @@
      */
     private void addWindowManager(WindowManager wm) {
         if (subManagers is null) {
-            subManagers = new ArraySeq!(WindowManager);
+            subManagers = new ArrayList();
         }
         if (!subManagers.contains(wm)) {
-            subManagers.append(wm);
+            subManagers.add(wm);
         }
     }
 
@@ -109,15 +108,19 @@
      * and <code>false</code> if any window refused to close
      */
     public bool close() {
-        auto t = windows.dup(); // make iteration robust
-        foreach( window; t ){
+        List t = cast(List) windows.clone(); // make iteration robust
+        Iterator e = t.iterator();
+        while (e.hasNext()) {
+            Window window = cast(Window) e.next();
             bool closed = window.close();
             if (!closed) {
                 return false;
             }
         }
         if (subManagers !is null) {
-            foreach( wm; subManagers ){
+            e = subManagers.iterator();
+            while (e.hasNext()) {
+                WindowManager wm = cast(WindowManager) e.next();
                 bool closed = wm.close();
                 if (!closed) {
                     return false;
@@ -143,7 +146,7 @@
      * @return a possibly empty list of window
      */
     public Window[] getWindows() {
-        return windows.toArray();
+        return arraycast!(Window)(windows.toArray());
     }
 
     /**