annotate dwtx/text/edits/MoveTargetEdit.d @ 129:eb30df5ca28b

Added JFace Text sources
author Frank Benoit <benoit@tionex.de>
date Sat, 23 Aug 2008 19:10:48 +0200
parents
children b56e9be9fe88
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
129
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
1 /*******************************************************************************
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module dwtx.text.edits.MoveTargetEdit;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15 import dwt.dwthelper.utils;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 import java.util.ArrayList;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 import java.util.List;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 import dwtx.jface.text.BadLocationException;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21 import dwtx.jface.text.IDocument;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 /**
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24 * A move target edit denotes the target of a move operation. Move
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 * target edits are only valid inside an edit tree if they have a
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 * corresponding source edit. Furthermore a target edit can't
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 * can't be a direct or indirect child of its associated source edit.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 * Violating one of two requirements will result in a <code>
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 * MalformedTreeException</code> when executing the edit tree.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 * <p>
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 * Move target edits can't be used as a parent for other edits.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 * Trying to add an edit to a move target edit results in a <code>
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 * MalformedTreeException</code> as well.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 * @see dwtx.text.edits.MoveSourceEdit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 * @see dwtx.text.edits.CopyTargetEdit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 * @since 3.0
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 public final class MoveTargetEdit : TextEdit {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 private MoveSourceEdit fSource;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 /**
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 * Constructs a new move target edit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 * @param offset the edit's offset
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
49 public MoveTargetEdit(int offset) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
50 super(offset, 0);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
51 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
52
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
53 /**
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
54 * Constructs an new move target edit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
55 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
56 * @param offset the edit's offset
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
57 * @param source the corresponding source edit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
58 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
59 public MoveTargetEdit(int offset, MoveSourceEdit source) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
60 this(offset);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
61 setSourceEdit(source);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
62 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
63
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
64 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
65 * Copy constructor
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
66 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
67 private MoveTargetEdit(MoveTargetEdit other) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
68 super(other);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
69 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
70
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
71 /**
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
72 * Returns the associated source edit or <code>null</code>
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
73 * if no source edit is associated yet.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
74 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
75 * @return the source edit or <code>null</code>
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
76 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
77 public MoveSourceEdit getSourceEdit() {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
78 return fSource;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
79 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
80
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
81 /**
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
82 * Sets the source edit.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
83 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
84 * @param edit the source edit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
85 *
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
86 * @exception MalformedTreeException is thrown if the target edit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
87 * is a direct or indirect child of the source edit
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
88 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
89 public void setSourceEdit(MoveSourceEdit edit) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
90 if (fSource !is edit) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
91 fSource= edit;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
92 fSource.setTargetEdit(this);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
93 TextEdit parent= getParent();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
94 while (parent !is null) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
95 if (parent is fSource)
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
96 throw new MalformedTreeException(parent, this, TextEditMessages.getString("MoveTargetEdit.wrong_parent")); //$NON-NLS-1$
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
97 parent= parent.getParent();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
98 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
99 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
100 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
101
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
102 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
103 * @see TextEdit#doCopy
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
104 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
105 protected TextEdit doCopy() {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
106 return new MoveTargetEdit(this);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
107 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
108
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
109 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
110 * @see TextEdit#postProcessCopy
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
111 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
112 protected void postProcessCopy(TextEditCopier copier) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
113 if (fSource !is null) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
114 MoveTargetEdit target= (MoveTargetEdit)copier.getCopy(this);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
115 MoveSourceEdit source= (MoveSourceEdit)copier.getCopy(fSource);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
116 if (target !is null && source !is null)
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
117 target.setSourceEdit(source);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
118 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
119 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
120
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
121 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
122 * @see TextEdit#accept0
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
123 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
124 protected void accept0(TextEditVisitor visitor) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
125 bool visitChildren= visitor.visit(this);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
126 if (visitChildren) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
127 acceptChildren(visitor);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
128 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
129 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
130
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
131 //---- consistency check ----------------------------------------------------------
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
132
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
133 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
134 * @see TextEdit#traverseConsistencyCheck
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
135 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
136 int traverseConsistencyCheck(TextEditProcessor processor, IDocument document, List sourceEdits) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
137 return super.traverseConsistencyCheck(processor, document, sourceEdits) + 1;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
138 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
139
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
140 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
141 * @see TextEdit#performConsistencyCheck
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
142 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
143 void performConsistencyCheck(TextEditProcessor processor, IDocument document) throws MalformedTreeException {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
144 if (fSource is null)
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
145 throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.no_source")); //$NON-NLS-1$
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
146 if (fSource.getTargetEdit() !is this)
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
147 throw new MalformedTreeException(getParent(), this, TextEditMessages.getString("MoveTargetEdit.different_target")); //$NON-NLS-1$
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
148 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
149
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
150 //---- document updating ----------------------------------------------------------------
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
151
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
152 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
153 * @see TextEdit#performDocumentUpdating
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
154 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
155 int performDocumentUpdating(IDocument document) throws BadLocationException {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
156 String source= fSource.getContent();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
157 document.replace(getOffset(), getLength(), source);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
158 fDelta= source.length() - getLength();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
159
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
160 MultiTextEdit sourceRoot= fSource.getSourceRoot();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
161 if (sourceRoot !is null) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
162 sourceRoot.internalMoveTree(getOffset());
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
163 TextEdit[] sourceChildren= sourceRoot.removeChildren();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
164 List children= new ArrayList(sourceChildren.length);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
165 for (int i= 0; i < sourceChildren.length; i++) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
166 TextEdit child= sourceChildren[i];
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
167 child.internalSetParent(this);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
168 children.add(child);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
169 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
170 internalSetChildren(children);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
171 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
172 fSource.clearContent();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
173 return fDelta;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
174 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
175
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
176 //---- region updating --------------------------------------------------------------
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
177
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
178 /*
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
179 * @see dwtx.text.edits.TextEdit#traversePassThree
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
180 */
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
181 int traverseRegionUpdating(TextEditProcessor processor, IDocument document, int accumulatedDelta, bool delete) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
182 // the children got already updated / normalized while they got removed
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
183 // from the source edit. So we only have to adjust the offset computed to
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
184 // far.
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
185 if (delete) {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
186 deleteTree();
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
187 } else {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
188 internalMoveTree(accumulatedDelta);
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
189 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
190 return accumulatedDelta + fDelta;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
191 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
192
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
193 bool deleteChildren() {
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
194 return false;
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
195 }
eb30df5ca28b Added JFace Text sources
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
196 }