Mercurial > projects > dwt-addons
annotate dwtx/text/edits/UndoEdit.d @ 153:f70d9508c95c
Fix java Collection imports
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 25 Aug 2008 00:27:31 +0200 |
parents | 6dcb0baaa031 |
children |
rev | line source |
---|---|
129 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.text.edits.UndoEdit; | |
14 | |
131 | 15 import dwtx.text.edits.MultiTextEdit; // packageimport |
16 import dwtx.text.edits.CopySourceEdit; // packageimport | |
17 import dwtx.text.edits.MoveSourceEdit; // packageimport | |
18 import dwtx.text.edits.CopyingRangeMarker; // packageimport | |
19 import dwtx.text.edits.ReplaceEdit; // packageimport | |
20 import dwtx.text.edits.EditDocument; // packageimport | |
21 import dwtx.text.edits.UndoCollector; // packageimport | |
22 import dwtx.text.edits.DeleteEdit; // packageimport | |
23 import dwtx.text.edits.MoveTargetEdit; // packageimport | |
24 import dwtx.text.edits.CopyTargetEdit; // packageimport | |
25 import dwtx.text.edits.TextEditCopier; // packageimport | |
26 import dwtx.text.edits.ISourceModifier; // packageimport | |
27 import dwtx.text.edits.TextEditMessages; // packageimport | |
28 import dwtx.text.edits.TextEditProcessor; // packageimport | |
29 import dwtx.text.edits.MalformedTreeException; // packageimport | |
30 import dwtx.text.edits.TreeIterationInfo; // packageimport | |
31 import dwtx.text.edits.TextEditVisitor; // packageimport | |
32 import dwtx.text.edits.TextEditGroup; // packageimport | |
33 import dwtx.text.edits.TextEdit; // packageimport | |
34 import dwtx.text.edits.RangeMarker; // packageimport | |
35 import dwtx.text.edits.InsertEdit; // packageimport | |
36 | |
37 | |
129 | 38 import dwt.dwthelper.utils; |
39 | |
153
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
136
diff
changeset
|
40 import dwtx.dwtxhelper.Collection; |
f70d9508c95c
Fix java Collection imports
Frank Benoit <benoit@tionex.de>
parents:
136
diff
changeset
|
41 |
129 | 42 |
43 import dwtx.jface.text.BadLocationException; | |
44 import dwtx.jface.text.IDocument; | |
45 | |
46 | |
47 /** | |
48 * This class encapsulates the reverse changes of an executed text | |
49 * edit tree. To apply an undo memento to a document use method | |
50 * <code>apply(IDocument)</code>. | |
51 * <p> | |
52 * Clients can't add additional children to an undo edit nor can they | |
53 * add an undo edit as a child to another edit. Doing so results in | |
54 * both cases in a <code>MalformedTreeException<code>. | |
55 * | |
56 * @since 3.0 | |
57 * @noinstantiate This class is not intended to be instantiated by clients. | |
58 */ | |
59 public final class UndoEdit : TextEdit { | |
60 | |
130 | 61 this() { |
129 | 62 super(0, Integer.MAX_VALUE); |
63 } | |
64 | |
130 | 65 private this(UndoEdit other) { |
129 | 66 super(other); |
67 } | |
68 | |
69 /* | |
70 * @see dwtx.text.edits.TextEdit#internalAdd(dwtx.text.edits.TextEdit) | |
71 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
72 void internalAdd(TextEdit child) { |
129 | 73 throw new MalformedTreeException(null, this, TextEditMessages.getString("UndoEdit.no_children")); //$NON-NLS-1$ |
74 } | |
75 | |
76 /* | |
77 * @see dwtx.text.edits.MultiTextEdit#aboutToBeAdded(dwtx.text.edits.TextEdit) | |
78 */ | |
79 void aboutToBeAdded(TextEdit parent) { | |
80 throw new MalformedTreeException(parent, this, TextEditMessages.getString("UndoEdit.can_not_be_added")); //$NON-NLS-1$ | |
81 } | |
82 | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
83 UndoEdit dispatchPerformEdits(TextEditProcessor processor) { |
129 | 84 return processor.executeUndo(); |
85 } | |
86 | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
87 void dispatchCheckIntegrity(TextEditProcessor processor) { |
129 | 88 processor.checkIntegrityUndo(); |
89 } | |
90 | |
91 /* | |
92 * @see dwtx.text.edits.TextEdit#doCopy() | |
93 */ | |
94 protected TextEdit doCopy() { | |
95 return new UndoEdit(this); | |
96 } | |
97 | |
98 /* | |
99 * @see TextEdit#accept0 | |
100 */ | |
101 protected void accept0(TextEditVisitor visitor) { | |
102 bool visitChildren= visitor.visit(this); | |
103 if (visitChildren) { | |
104 acceptChildren(visitor); | |
105 } | |
106 } | |
107 | |
108 /* | |
109 * @see TextEdit#performDocumentUpdating | |
110 */ | |
136
6dcb0baaa031
Regex removal of throws decls, some instanceof
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
111 int performDocumentUpdating(IDocument document) { |
129 | 112 fDelta= 0; |
113 return fDelta; | |
114 } | |
115 | |
116 void add(ReplaceEdit edit) { | |
117 List children= internalGetChildren(); | |
118 if (children is null) { | |
119 children= new ArrayList(2); | |
120 internalSetChildren(children); | |
121 } | |
122 children.add(edit); | |
123 } | |
124 | |
125 void defineRegion(int offset, int length) { | |
126 internalSetOffset(offset); | |
127 internalSetLength(length); | |
128 } | |
129 | |
130 bool deleteChildren() { | |
131 return false; | |
132 } | |
133 } | |
134 |