comparison dwtx/core/commands/operations/ObjectUndoContext.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
comparison
equal deleted inserted replaced
103:2d6540440fe6 104:04b47443bb01
10 * Port to the D programming language: 10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de> 11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/ 12 *******************************************************************************/
13 module dwtx.core.commands.operations.ObjectUndoContext; 13 module dwtx.core.commands.operations.ObjectUndoContext;
14 14
15 import tango.util.collection.ArraySeq;
16 import tango.util.collection.model.Seq;
17
18 import dwtx.core.commands.operations.UndoContext; 15 import dwtx.core.commands.operations.UndoContext;
19 import dwtx.core.commands.operations.IUndoContext; 16 import dwtx.core.commands.operations.IUndoContext;
20 17
21 import dwt.dwthelper.utils; 18 import dwt.dwthelper.utils;
19 import dwtx.dwtxhelper.Collection;
22 20
23 /** 21 /**
24 * <p> 22 * <p>
25 * An undo context that can be used to represent any given object. Clients 23 * An undo context that can be used to represent any given object. Clients
26 * can add matching contexts to this context. This class may be instantiated 24 * can add matching contexts to this context. This class may be instantiated
33 31
34 private Object object; 32 private Object object;
35 33
36 private String label; 34 private String label;
37 35
38 private Seq!(IUndoContext) children; 36 private List children;
39 37
40 /** 38 /**
41 * Construct an operation context that represents the given object. 39 * Construct an operation context that represents the given object.
42 * 40 *
43 * @param object 41 * @param object
57 * the label for the context 55 * the label for the context
58 */ 56 */
59 public this(Object object, String label) { 57 public this(Object object, String label) {
60 this.object = object; 58 this.object = object;
61 this.label = label; 59 this.label = label;
62 children = new ArraySeq!(IUndoContext); 60 children = new ArrayList();
63 } 61 }
64 62
65 /* 63 /*
66 * (non-Javadoc) 64 * (non-Javadoc)
67 * 65 *
96 * 94 *
97 * @param context 95 * @param context
98 * the context to be added as a match of this context 96 * the context to be added as a match of this context
99 */ 97 */
100 public void addMatch(IUndoContext context) { 98 public void addMatch(IUndoContext context) {
101 children.append(context); 99 children.add(cast(Object)context);
102 } 100 }
103 101
104 /** 102 /**
105 * Remove the specified context as a match of this context. The context will 103 * Remove the specified context as a match of this context. The context will
106 * no longer be interpreted as a match of this context when the history is 104 * no longer be interpreted as a match of this context when the history is
110 * @param context 108 * @param context
111 * the context to be removed from the list of matches for this 109 * the context to be removed from the list of matches for this
112 * context 110 * context
113 */ 111 */
114 public void removeMatch(IUndoContext context) { 112 public void removeMatch(IUndoContext context) {
115 children.remove(context); 113 children.remove(cast(Object)context);
116 } 114 }
117 115
118 /* 116 /*
119 * (non-Javadoc) 117 * (non-Javadoc)
120 * 118 *
121 * @see dwtx.core.commands.operations.IUndoContext#matches(IUndoContext 119 * @see dwtx.core.commands.operations.IUndoContext#matches(IUndoContext
122 * context) 120 * context)
123 */ 121 */
124 public override bool matches(IUndoContext context) { 122 public override bool matches(IUndoContext context) {
125 // Check first for explicit matches that have been assigned. 123 // Check first for explicit matches that have been assigned.
126 if (children.contains(context)) { 124 if (children.contains(cast(Object)context)) {
127 return true; 125 return true;
128 } 126 }
129 // Contexts for equal objects are considered matching 127 // Contexts for equal objects are considered matching
130 if ( null !is cast(ObjectUndoContext)context && getObject() !is null) { 128 if ( null !is cast(ObjectUndoContext)context && getObject() !is null) {
131 return getObject().opEquals((cast(ObjectUndoContext)context).getObject()) !is 0; 129 return getObject().opEquals((cast(ObjectUndoContext)context).getObject()) !is 0;