diff dwtx/core/commands/operations/TriggeredOperations.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 ea8ff534f622
children
line wrap: on
line diff
--- a/dwtx/core/commands/operations/TriggeredOperations.d	Sun Aug 03 17:01:51 2008 +0200
+++ b/dwtx/core/commands/operations/TriggeredOperations.d	Thu Aug 07 15:01:33 2008 +0200
@@ -12,9 +12,6 @@
  *******************************************************************************/
 module dwtx.core.commands.operations.TriggeredOperations;
 
-import tango.util.collection.ArraySeq;
-import tango.util.collection.model.Seq;
-
 import dwtx.core.commands.ExecutionException;
 import dwtx.core.runtime.IAdaptable;
 import dwtx.core.runtime.IProgressMonitor;
@@ -32,6 +29,7 @@
 import dwtx.core.commands.operations.OperationHistoryEvent;
 
 import dwt.dwthelper.utils;
+import dwtx.dwtxhelper.Collection;
 
 /**
  * Triggered operations are a specialized implementation of a composite
@@ -56,7 +54,7 @@
 
     private IOperationHistory history;
 
-    private Seq!(IUndoableOperation) children;
+    private List children;
 
     /**
      * Construct a composite triggered operations using the specified undoable
@@ -71,7 +69,7 @@
     public this(IUndoableOperation operation,
             IOperationHistory history) {
         super(operation.getLabel());
-        children = new ArraySeq!(IUndoableOperation);
+        children = new ArrayList();
         triggeringOperation = operation;
         recomputeContexts();
         this.history = history;
@@ -83,7 +81,7 @@
      * @see dwtx.core.commands.operations.IUndoableOperation#add(dwtx.core.commands.operations.IUndoableOperation)
      */
     public void add(IUndoableOperation operation) {
-        children.append(operation);
+        children.add(cast(Object)operation);
         recomputeContexts();
     }
 
@@ -101,14 +99,14 @@
             // operation will be disposed as part of replacing it. We don't want
             // the children to be disposed since they are to replace this
             // operation.
-            Seq!(IUndoableOperation) childrenToRestore = children.dup;
-            children = new ArraySeq!(IUndoableOperation);
+            List childrenToRestore = new ArrayList(children);
+            children = new ArrayList(0);
             recomputeContexts();
             operation.dispose();
             // now replace the triggering operation
-            history.replaceOperation(this, childrenToRestore.toArray());
+            history.replaceOperation(this, arraycast!(IUndoableOperation)(childrenToRestore.toArray()));
         } else {
-            children.remove(operation);
+            children.remove(cast(Object)operation);
             operation.dispose();
             recomputeContexts();
         }
@@ -142,12 +140,12 @@
             recompute = true;
         }
         // the triggering operation remains, check all the children
-        auto toBeRemoved = new ArraySeq!(IUndoableOperation);
+        auto toBeRemoved = new ArrayList();
         for (int i = 0; i < children.size(); i++) {
             IUndoableOperation child = cast(IUndoableOperation) children.get(i);
             if (child.hasContext(context)) {
                 if (child.getContexts().length is 1) {
-                    toBeRemoved.append(child);
+                    toBeRemoved.add(cast(Object)child);
                 } else {
                     child.removeContext(context);
                 }
@@ -197,7 +195,7 @@
     public override IStatus redo(IProgressMonitor monitor, IAdaptable info) {
         if (triggeringOperation !is null) {
             history.openOperation(this, IOperationHistory.REDO);
-            Seq!(IUndoableOperation) childrenToRestore = children.dup;
+            List childrenToRestore = new ArrayList(children);
             try {
                 removeAllChildren();
                 IStatus status = triggeringOperation.redo(monitor, info);
@@ -229,7 +227,7 @@
     public override IStatus undo(IProgressMonitor monitor, IAdaptable info) {
         if (triggeringOperation !is null) {
             history.openOperation(this, IOperationHistory.UNDO);
-            auto childrenToRestore = children.dup;
+            List childrenToRestore = new ArrayList(children);
             try {
                 removeAllChildren();
                 IStatus status = triggeringOperation.undo(monitor, info);
@@ -293,7 +291,7 @@
      */
     public override void dispose() {
         for (int i = 0; i < children.size(); i++) {
-            children.get(i).dispose();
+            (cast(IUndoableOperation)children.get(i)).dispose();
         }
         if (triggeringOperation !is null) {
             triggeringOperation.dispose();
@@ -304,18 +302,19 @@
      * Recompute contexts in light of some change in the children
      */
     private void recomputeContexts() {
-        auto allContexts = new ArraySeq!(IUndoContext);
+        ArrayList allContexts = new ArrayList();
         if (triggeringOperation !is null) {
             IUndoContext[] contexts = triggeringOperation.getContexts();
             for (int i = 0; i < contexts.length; i++) {
-                allContexts.append(contexts[i]);
+                allContexts.add(cast(Object)contexts[i]);
             }
         }
         for (int i = 0; i < children.size(); i++) {
-            IUndoContext[] contexts = children.get(i).getContexts();
+            IUndoContext[] contexts = (cast(IUndoableOperation)children.get(i))
+                    .getContexts();
             for (int j = 0; j < contexts.length; j++) {
-                if (!allContexts.contains(contexts[j])) {
-                    allContexts.append(contexts[j]);
+                if (!allContexts.contains(cast(Object)contexts[j])) {
+                    allContexts.add(cast(Object)contexts[j]);
                 }
             }
         }
@@ -327,9 +326,10 @@
      * Remove all non-triggering children
      */
     private void removeAllChildren() {
-        IUndoableOperation[] nonTriggers = children.toArray();
+        IUndoableOperation[] nonTriggers = arraycast!(IUndoableOperation)(children
+                .toArray());
         for (int i = 0; i < nonTriggers.length; i++) {
-            children.remove(nonTriggers[i]);
+            children.remove(cast(Object)nonTriggers[i]);
             nonTriggers[i].dispose();
         }
     }
@@ -431,7 +431,7 @@
         }
         // Now check all the children
         for (int i = 0; i < children.size(); i++) {
-            IUndoableOperation child = children.get(i);
+            IUndoableOperation child = cast(IUndoableOperation)children.get(i);
             if (child.hasContext(original)) {
                 if ( auto c = cast(IContextReplacingOperation)child ) {
                     c.replaceContext(