blob: 5d8254b310bdf1c32a19cd4e2aa2cd7b75e6e85c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*******************************************************************************
* Copyright (c) 2000, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jface.text;
/**
* Default document implementation. Uses a
* {@link org.eclipse.jface.text.GapTextStore}as default text store and a
* {@link org.eclipse.jface.text.SequentialRewriteTextStore}when in sequential
* rewrite mode.
* <p>
* The used line tracker considers the following strings as line delimiters
* "\n", "\r", "\r\n".
* <p>
* The document is ready to use. It has a default position category for which a
* default position updater is installed.
*
* @see org.eclipse.jface.text.GapTextStore
* @see org.eclipse.jface.text.SequentialRewriteTextStore
*/
public class Document extends AbstractDocument {
/**
* Creates a new empty document.
*/
public Document() {
super();
setTextStore(new GapTextStore(50, 300));
setLineTracker(new DefaultLineTracker());
completeInitialization();
}
/**
* Creates a new document with the given initial content.
*
* @param initialContent the document's initial content
*/
public Document(String initialContent) {
super();
setTextStore(new GapTextStore(50, 300));
setLineTracker(new DefaultLineTracker());
getStore().set(initialContent);
getTracker().set(initialContent);
completeInitialization();
}
/*
* @see org.eclipse.jface.text.IDocumentExtension#startSequentialRewrite(boolean)
* @since 2.0
*/
public void startSequentialRewrite(boolean normalized) {
ITextStore store= new SequentialRewriteTextStore(getStore());
setTextStore(store);
}
/*
* @see org.eclipse.jface.text.IDocumentExtension#stopSequentialRewrite()
* @since 2.0
*/
public void stopSequentialRewrite() {
if (getStore() instanceof SequentialRewriteTextStore) {
SequentialRewriteTextStore srws= (SequentialRewriteTextStore) getStore();
ITextStore source= srws.getSourceStore();
setTextStore(source);
srws.dispose();
}
}
}
|