KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > ITextViewerExtension


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  *******************************************************************************/

11
12 package org.eclipse.jface.text;
13
14
15 import org.eclipse.swt.custom.VerifyKeyListener;
16 import org.eclipse.swt.widgets.Control;
17
18
19 /**
20  * Extension interface for {@link org.eclipse.jface.text.ITextViewer}.
21  * <p>
22  * This extension interface replaces the event consumer mechanism (
23  * {@link org.eclipse.jface.text.ITextViewer#setEventConsumer(IEventConsumer)})
24  * with a set of methods that allow to manage a sequence of
25  * {@link org.eclipse.swt.custom.VerifyKeyListener}objects. It also adds
26  * <ul>
27  * <li>access to the control of this viewer</li>
28  * <li>marked region support as in emacs</li>
29  * <li>control of the viewer's redraw behavior by introducing
30  * <code>setRedraw(boolean)</code>
31  * <li>access to the viewer's rewrite target.
32  * </ul>
33  *
34  * A rewrite target ({@link org.eclipse.jface.text.IRewriteTarget}) represents
35  * an facade offering the necessary methods to manipulate a document that is the
36  * input document of a text viewer.
37  *
38  * @since 2.0
39  */

40 public interface ITextViewerExtension {
41
42     /**
43      * Inserts the verify key listener at the beginning of the viewer's list of
44      * verify key listeners. If the listener is already registered with the
45      * viewer this call moves the listener to the beginning of the list.
46      *
47      * @param listener the listener to be inserted
48      */

49     void prependVerifyKeyListener(VerifyKeyListener listener);
50
51     /**
52      * Appends a verify key listener to the viewer's list of verify key
53      * listeners. If the listener is already registered with the viewer this
54      * call moves the listener to the end of the list.
55      *
56      * @param listener the listener to be added
57      */

58     void appendVerifyKeyListener(VerifyKeyListener listener);
59
60     /**
61      * Removes the verify key listener from the viewer's list of verify key listeners.
62      * If the listener is not registered with this viewer, this call has no effect.
63      *
64      * @param listener the listener to be removed
65      */

66     void removeVerifyKeyListener(VerifyKeyListener listener);
67
68     /**
69      * Returns the control of this viewer.
70      *
71      * @return the control of this viewer
72      */

73     Control getControl();
74
75     /**
76      * Sets a mark at the given offset or clears the mark if the specified
77      * offset is <code>-1</code>. If a mark is set and the selection is
78      * empty, cut and copy actions performed on this text viewer work on the
79      * region described by the positions of the mark and the cursor.
80      *
81      * @param offset the offset of the mark
82      */

83     void setMark(int offset);
84
85     /**
86      * Returns the position of the mark, <code>-1</code> if the mark is not set.
87      *
88      * @return the position of the mark or <code>-1</code> if no mark is set
89      */

90     int getMark();
91
92     /**
93      * Enables/disables the redrawing of this text viewer. This temporarily
94      * disconnects the viewer from its underlying
95      * {@link org.eclipse.swt.custom.StyledText}widget. While being
96      * disconnected only the viewer's selection may be changed using
97      * <code>setSelectedRange</code>. Any direct manipulation of the widget
98      * as well as calls to methods that change the viewer's presentation state
99      * (such as enabling the segmented view) are not allowed. When redrawing is
100      * disabled the viewer does not send out any selection or view port change
101      * notification. When redrawing is enabled again, a selection change
102      * notification is sent out for the selected range and this range is
103      * revealed causing a view port changed notification.
104      *
105      * @param redraw <code>true</code> to enable redrawing, <code>false</code>
106      * otherwise
107      */

108     void setRedraw(boolean redraw);
109
110     /**
111      * Returns the viewer's rewrite target.
112      *
113      * @return the viewer's rewrite target
114      */

115     IRewriteTarget getRewriteTarget();
116 }
117
Popular Tags