129
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2000, 2005 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.IDocumentExtension3;
|
|
14
|
|
15 import dwt.dwthelper.utils;
|
|
16
|
|
17 /**
|
|
18 * Extension interface for {@link dwtx.jface.text.IDocument}.
|
|
19 * <p>
|
|
20 * Adds the concept of multiple partitionings and the concept of zero-length
|
|
21 * partitions in conjunction with open and delimited partitions. A delimited
|
|
22 * partition has a well defined start delimiter and a well defined end
|
|
23 * delimiter. Between two delimited partitions there may be an open partition of
|
|
24 * length zero.
|
|
25 * <p>
|
|
26 *
|
|
27 * In order to fulfill the contract of this interface, the document must be
|
|
28 * configured with a document partitioner implementing
|
|
29 * {@link dwtx.jface.text.IDocumentPartitionerExtension2}.
|
|
30 *
|
|
31 * @see dwtx.jface.text.IDocumentPartitionerExtension2
|
|
32 * @since 3.0
|
|
33 */
|
|
34 public interface IDocumentExtension3 {
|
|
35
|
|
36 /**
|
|
37 * The identifier of the default partitioning.
|
|
38 */
|
|
39 final static String DEFAULT_PARTITIONING= "__dftl_partitioning"; //$NON-NLS-1$
|
|
40
|
|
41
|
|
42 /**
|
|
43 * Returns the existing partitionings for this document. This includes
|
|
44 * the default partitioning.
|
|
45 *
|
|
46 * @return the existing partitionings for this document
|
|
47 */
|
|
48 String[] getPartitionings();
|
|
49
|
|
50 /**
|
|
51 * Returns the set of legal content types of document partitions for the given partitioning
|
|
52 * This set can be empty. The set can contain more content types than contained by the
|
|
53 * result of <code>getPartitioning(partitioning, 0, getLength())</code>.
|
|
54 *
|
|
55 * @param partitioning the partitioning for which to return the legal content types
|
|
56 * @return the set of legal content types
|
|
57 * @exception BadPartitioningException if partitioning is invalid for this document
|
|
58 */
|
|
59 String[] getLegalContentTypes(String partitioning) throws BadPartitioningException;
|
|
60
|
|
61
|
|
62 /**
|
|
63 * Returns the type of the document partition containing the given offset
|
|
64 * for the given partitioning. This is a convenience method for
|
|
65 * <code>getPartition(partitioning, offset, bool).getType()</code>.
|
|
66 * <p>
|
|
67 * If <code>preferOpenPartitions</code> is <code>true</code>,
|
|
68 * precedence is given to an open partition ending at <code>offset</code>
|
|
69 * over a delimited partition starting at <code>offset</code>. If it is
|
|
70 * <code>false</code>, precedence is given to the partition that does not
|
|
71 * end at <code>offset</code>.
|
|
72 * </p>
|
|
73 * This is only supported if the connected <code>IDocumentPartitioner</code>
|
|
74 * supports it, i.e. implements <code>IDocumentPartitionerExtension2</code>.
|
|
75 * Otherwise, <code>preferOpenPartitions</code> is ignored.
|
|
76 * </p>
|
|
77 *
|
|
78 * @param partitioning the partitioning
|
|
79 * @param offset the document offset
|
|
80 * @param preferOpenPartitions <code>true</code> if precedence should be
|
|
81 * given to a open partition ending at <code>offset</code> over a
|
|
82 * closed partition starting at <code>offset</code>
|
|
83 * @return the partition type
|
|
84 * @exception BadLocationException if offset is invalid in this document
|
|
85 * @exception BadPartitioningException if partitioning is invalid for this document
|
|
86 */
|
|
87 String getContentType(String partitioning, int offset, bool preferOpenPartitions) throws BadLocationException, BadPartitioningException;
|
|
88
|
|
89 /**
|
|
90 * Returns the document partition of the given partitioning in which the
|
|
91 * given offset is located.
|
|
92 * <p>
|
|
93 * If <code>preferOpenPartitions</code> is <code>true</code>,
|
|
94 * precedence is given to an open partition ending at <code>offset</code>
|
|
95 * over a delimited partition starting at <code>offset</code>. If it is
|
|
96 * <code>false</code>, precedence is given to the partition that does not
|
|
97 * end at <code>offset</code>.
|
|
98 * </p>
|
|
99 * This is only supported if the connected <code>IDocumentPartitioner</code>
|
|
100 * supports it, i.e. implements <code>IDocumentPartitionerExtension2</code>.
|
|
101 * Otherwise, <code>preferOpenPartitions</code> is ignored.
|
|
102 * </p>
|
|
103 *
|
|
104 * @param partitioning the partitioning
|
|
105 * @param offset the document offset
|
|
106 * @param preferOpenPartitions <code>true</code> if precedence should be
|
|
107 * given to a open partition ending at <code>offset</code> over a
|
|
108 * closed partition starting at <code>offset</code>
|
|
109 * @return a specification of the partition
|
|
110 * @exception BadLocationException if offset is invalid in this document
|
|
111 * @exception BadPartitioningException if partitioning is invalid for this document
|
|
112 */
|
|
113 ITypedRegion getPartition(String partitioning, int offset, bool preferOpenPartitions) throws BadLocationException, BadPartitioningException;
|
|
114
|
|
115 /**
|
|
116 * Computes the partitioning of the given document range based on the given
|
|
117 * partitioning type.
|
|
118 * <p>
|
|
119 * If <code>includeZeroLengthPartitions</code> is <code>true</code>, a
|
|
120 * zero-length partition of an open partition type (usually the default
|
|
121 * partition) is included between two closed partitions. If it is
|
|
122 * <code>false</code>, no zero-length partitions are included.
|
|
123 * </p>
|
|
124 * This is only supported if the connected <code>IDocumentPartitioner</code>
|
|
125 * supports it, i.e. implements <code>IDocumentPartitionerExtension2</code>.
|
|
126 * Otherwise, <code>includeZeroLengthPartitions</code> is ignored.
|
|
127 * </p>
|
|
128 *
|
|
129 * @param partitioning the document's partitioning type
|
|
130 * @param offset the document offset at which the range starts
|
|
131 * @param length the length of the document range
|
|
132 * @param includeZeroLengthPartitions <code>true</code> if zero-length
|
|
133 * partitions should be returned as part of the computed partitioning
|
|
134 * @return a specification of the range's partitioning
|
|
135 * @exception BadLocationException if the range is invalid in this document$
|
|
136 * @exception BadPartitioningException if partitioning is invalid for this document
|
|
137 */
|
|
138 ITypedRegion[] computePartitioning(String partitioning, int offset, int length, bool includeZeroLengthPartitions) throws BadLocationException, BadPartitioningException;
|
|
139
|
|
140 /**
|
|
141 * Sets this document's partitioner. The caller of this method is responsible for
|
|
142 * disconnecting the document's old partitioner from the document and to
|
|
143 * connect the new partitioner to the document. Informs all document partitioning
|
|
144 * listeners about this change.
|
|
145 *
|
|
146 * @param partitioning the partitioning for which to set the partitioner
|
|
147 * @param partitioner the document's new partitioner
|
|
148 * @see IDocumentPartitioningListener
|
|
149 */
|
|
150 void setDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner);
|
|
151
|
|
152 /**
|
|
153 * Returns the partitioner for the given partitioning or <code>null</code> if
|
|
154 * no partitioner is registered.
|
|
155 *
|
|
156 * @param partitioning the partitioning for which to set the partitioner
|
|
157 * @return the partitioner for the given partitioning
|
|
158 */
|
|
159 IDocumentPartitioner getDocumentPartitioner(String partitioning);
|
|
160 }
|