Mercurial > projects > dwt-addons
annotate dwtx/jface/text/projection/ProjectionDocumentEvent.d @ 162:1a5b8f8129df
...
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 08 Sep 2008 00:51:37 +0200 |
parents | 75302ef3f92f |
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.jface.text.projection.ProjectionDocumentEvent; | |
14 | |
131 | 15 import dwtx.jface.text.projection.ProjectionMapping; // packageimport |
16 import dwtx.jface.text.projection.ChildDocumentManager; // packageimport | |
17 import dwtx.jface.text.projection.SegmentUpdater; // packageimport | |
18 import dwtx.jface.text.projection.Segment; // packageimport | |
19 import dwtx.jface.text.projection.ProjectionDocument; // packageimport | |
20 import dwtx.jface.text.projection.FragmentUpdater; // packageimport | |
21 import dwtx.jface.text.projection.ChildDocument; // packageimport | |
22 import dwtx.jface.text.projection.IMinimalMapping; // packageimport | |
23 import dwtx.jface.text.projection.Fragment; // packageimport | |
24 import dwtx.jface.text.projection.ProjectionTextStore; // packageimport | |
25 import dwtx.jface.text.projection.ProjectionDocumentManager; // packageimport | |
26 | |
27 | |
129 | 28 import dwt.dwthelper.utils; |
29 | |
30 import dwtx.jface.text.DocumentEvent; | |
31 import dwtx.jface.text.IDocument; | |
32 import dwtx.jface.text.SlaveDocumentEvent; | |
33 | |
34 | |
35 /** | |
36 * This event is sent out by an | |
37 * {@link dwtx.jface.text.projection.ProjectionDocument}when it is | |
38 * manipulated. The manipulation is either a content manipulation or a change of | |
39 * the projection between the master and the slave. Clients can determine the | |
40 * type of change by asking the projection document event for its change type | |
41 * (see {@link #getChangeType()}) and comparing it with the predefined types | |
42 * {@link #PROJECTION_CHANGE}and {@link #CONTENT_CHANGE}. | |
43 * <p> | |
44 * Clients are not supposed to create instances of this class. Instances are | |
45 * created by {@link dwtx.jface.text.projection.ProjectionDocument} | |
46 * instances. This class is not intended to be subclassed.</p> | |
47 * | |
48 * @since 3.0 | |
49 * @noinstantiate This class is not intended to be instantiated by clients. | |
50 * @noextend This class is not intended to be subclassed by clients. | |
51 */ | |
52 public class ProjectionDocumentEvent : SlaveDocumentEvent { | |
53 | |
54 /** The change type indicating a projection change */ | |
162 | 55 private static Object PROJECTION_CHANGE_; |
56 public static Object PROJECTION_CHANGE(){ | |
57 if( PROJECTION_CHANGE_ is null ) { | |
58 synchronized( ProjectionDocumentEvent.classinfo ) { | |
59 if( PROJECTION_CHANGE_ is null ) { | |
60 PROJECTION_CHANGE_ = new Object(); | |
61 } | |
62 } | |
63 } | |
64 return PROJECTION_CHANGE_; | |
65 } | |
129 | 66 /** The change type indicating a content change */ |
162 | 67 private static Object CONTENT_CHANGE_; |
68 public static Object CONTENT_CHANGE(){ | |
69 if( CONTENT_CHANGE_ is null ) { | |
70 synchronized( ProjectionDocumentEvent.classinfo ) { | |
71 if( CONTENT_CHANGE_ is null ) { | |
72 CONTENT_CHANGE_ = new Object(); | |
73 } | |
74 } | |
75 } | |
76 return CONTENT_CHANGE_; | |
77 } | |
129 | 78 |
79 /** The change type */ | |
80 private Object fChangeType; | |
81 /** The offset of the change in the master document */ | |
82 private int fMasterOffset= -1; | |
83 /** The length of the change in the master document */ | |
84 private int fMasterLength= -1; | |
85 | |
86 /** | |
87 * Creates a new content change event caused by the given master document | |
88 * change. Instances created using this constructor return <code>-1</code> | |
89 * when calling <code>getMasterOffset</code> or | |
90 * <code>getMasterLength</code>. This information can be obtained by | |
91 * accessing the master event. | |
92 * | |
93 * @param doc the changed projection document | |
94 * @param offset the offset in the projection document | |
95 * @param length the length in the projection document | |
96 * @param text the replacement text | |
97 * @param masterEvent the original master event | |
98 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
99 public this(IDocument doc, int offset, int length, String text, DocumentEvent masterEvent) { |
129 | 100 super(doc, offset, length, text, masterEvent); |
101 fChangeType= CONTENT_CHANGE; | |
102 } | |
103 | |
104 /** | |
105 * Creates a new projection change event for the given properties. Instances | |
106 * created with this constructor return the given master document offset and | |
107 * length but do not have an associated master document event. | |
108 * | |
109 * @param doc the projection document | |
110 * @param offset the offset in the projection document | |
111 * @param length the length in the projection document | |
112 * @param text the replacement text | |
113 * @param masterOffset the offset in the master document | |
114 * @param masterLength the length in the master document | |
115 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
116 public this(IDocument doc, int offset, int length, String text, int masterOffset, int masterLength) { |
129 | 117 super(doc, offset, length, text, null); |
118 fChangeType= PROJECTION_CHANGE; | |
119 fMasterOffset= masterOffset; | |
120 fMasterLength= masterLength; | |
121 } | |
122 | |
123 /** | |
124 * Creates a new projection document event for the given properties. The | |
125 * projection change is caused by a manipulation of the master document. In | |
126 * order to accommodate the master document change, the projection document | |
127 * had to change the projection. Instances created with this constructor | |
128 * return the given master document offset and length and also have an | |
129 * associated master document event. | |
130 * | |
131 * @param doc the projection document | |
132 * @param offset the offset in the projection document | |
133 * @param length the length in the projection document | |
134 * @param text the replacement text | |
135 * @param masterOffset the offset in the master document | |
136 * @param masterLength the length in the master document | |
137 * @param masterEvent the master document event | |
138 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
139 public this(IDocument doc, int offset, int length, String text, int masterOffset, int masterLength, DocumentEvent masterEvent) { |
129 | 140 super(doc, offset, length, text, masterEvent); |
141 fChangeType= PROJECTION_CHANGE; | |
142 fMasterOffset= masterOffset; | |
143 fMasterLength= masterLength; | |
144 } | |
145 | |
146 /** | |
147 * Returns the change type of this event. This is either {@link #PROJECTION_CHANGE} or | |
148 * {@link #CONTENT_CHANGE}. | |
149 * | |
150 * @return the change type of this event | |
151 */ | |
152 public Object getChangeType() { | |
153 return fChangeType; | |
154 } | |
155 | |
156 /** | |
157 * Returns the offset of the master document range that has been added or removed in case this | |
158 * event describes a projection change, otherwise it returns <code>-1</code>. | |
159 * | |
160 * @return the master document offset of the projection change or <code>-1</code> | |
161 */ | |
162 public int getMasterOffset() { | |
163 return fMasterOffset; | |
164 } | |
165 | |
166 /** | |
167 * Returns the length of the master document range that has been added or removed in case this event | |
168 * describes a projection changed, otherwise <code>-1</code>. | |
169 * | |
170 * @return the master document length of the projection change or <code>-1</code> | |
171 */ | |
172 public int getMasterLength() { | |
173 return fMasterLength; | |
174 } | |
175 } |