Mercurial > projects > dwt-addons
annotate dwtx/jface/text/projection/ProjectionDocumentEvent.d @ 146:75302ef3f92f
final
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 24 Aug 2008 22:34:04 +0200 |
parents | 7d818bd32d63 |
children | 1a5b8f8129df |
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 */ | |
146 | 55 public const static Object PROJECTION_CHANGE= new Object(); |
129 | 56 /** The change type indicating a content change */ |
146 | 57 public const static Object CONTENT_CHANGE= new Object(); |
129 | 58 |
59 /** The change type */ | |
60 private Object fChangeType; | |
61 /** The offset of the change in the master document */ | |
62 private int fMasterOffset= -1; | |
63 /** The length of the change in the master document */ | |
64 private int fMasterLength= -1; | |
65 | |
66 /** | |
67 * Creates a new content change event caused by the given master document | |
68 * change. Instances created using this constructor return <code>-1</code> | |
69 * when calling <code>getMasterOffset</code> or | |
70 * <code>getMasterLength</code>. This information can be obtained by | |
71 * accessing the master event. | |
72 * | |
73 * @param doc the changed projection document | |
74 * @param offset the offset in the projection document | |
75 * @param length the length in the projection document | |
76 * @param text the replacement text | |
77 * @param masterEvent the original master event | |
78 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
79 public this(IDocument doc, int offset, int length, String text, DocumentEvent masterEvent) { |
129 | 80 super(doc, offset, length, text, masterEvent); |
81 fChangeType= CONTENT_CHANGE; | |
82 } | |
83 | |
84 /** | |
85 * Creates a new projection change event for the given properties. Instances | |
86 * created with this constructor return the given master document offset and | |
87 * length but do not have an associated master document event. | |
88 * | |
89 * @param doc the projection document | |
90 * @param offset the offset in the projection document | |
91 * @param length the length in the projection document | |
92 * @param text the replacement text | |
93 * @param masterOffset the offset in the master document | |
94 * @param masterLength the length in the master document | |
95 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
96 public this(IDocument doc, int offset, int length, String text, int masterOffset, int masterLength) { |
129 | 97 super(doc, offset, length, text, null); |
98 fChangeType= PROJECTION_CHANGE; | |
99 fMasterOffset= masterOffset; | |
100 fMasterLength= masterLength; | |
101 } | |
102 | |
103 /** | |
104 * Creates a new projection document event for the given properties. The | |
105 * projection change is caused by a manipulation of the master document. In | |
106 * order to accommodate the master document change, the projection document | |
107 * had to change the projection. Instances created with this constructor | |
108 * return the given master document offset and length and also have an | |
109 * associated master document event. | |
110 * | |
111 * @param doc the projection document | |
112 * @param offset the offset in the projection document | |
113 * @param length the length in the projection document | |
114 * @param text the replacement text | |
115 * @param masterOffset the offset in the master document | |
116 * @param masterLength the length in the master document | |
117 * @param masterEvent the master document event | |
118 */ | |
133
7d818bd32d63
Fix ctors to this with gvim regexp
Frank Benoit <benoit@tionex.de>
parents:
131
diff
changeset
|
119 public this(IDocument doc, int offset, int length, String text, int masterOffset, int masterLength, DocumentEvent masterEvent) { |
129 | 120 super(doc, offset, length, text, masterEvent); |
121 fChangeType= PROJECTION_CHANGE; | |
122 fMasterOffset= masterOffset; | |
123 fMasterLength= masterLength; | |
124 } | |
125 | |
126 /** | |
127 * Returns the change type of this event. This is either {@link #PROJECTION_CHANGE} or | |
128 * {@link #CONTENT_CHANGE}. | |
129 * | |
130 * @return the change type of this event | |
131 */ | |
132 public Object getChangeType() { | |
133 return fChangeType; | |
134 } | |
135 | |
136 /** | |
137 * Returns the offset of the master document range that has been added or removed in case this | |
138 * event describes a projection change, otherwise it returns <code>-1</code>. | |
139 * | |
140 * @return the master document offset of the projection change or <code>-1</code> | |
141 */ | |
142 public int getMasterOffset() { | |
143 return fMasterOffset; | |
144 } | |
145 | |
146 /** | |
147 * Returns the length of the master document range that has been added or removed in case this event | |
148 * describes a projection changed, otherwise <code>-1</code>. | |
149 * | |
150 * @return the master document length of the projection change or <code>-1</code> | |
151 */ | |
152 public int getMasterLength() { | |
153 return fMasterLength; | |
154 } | |
155 } |