KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.eclipse.jface.text;
12
13
14 import org.eclipse.swt.graphics.Point;
15
16
17 /**
18  * Defines the target for finding and replacing strings.
19  * <p>
20  * The two main methods are <code>findAndSelect</code> and
21  * <code>replaceSelection</code>. The target does not provide any way to
22  * modify the content other than replacing the selection.
23  * <p>
24  *
25  * In order to provide backward compatibility for clients of
26  * <code>IFindReplaceTarget</code>, extension interfaces are used as a means
27  * of evolution. The following extension interfaces exist:
28  * <ul>
29  * <li>{@link org.eclipse.jface.text.IFindReplaceTargetExtension} since version
30  * 2.0 introducing the notion of find/replace session and of a find/replace
31  * scope. In additions, in allows clients to replace all occurrences of a given
32  * find query.</li>
33  * <li>{@link org.eclipse.jface.text.IFindReplaceTargetExtension3} since
34  * version 3.0 allowing clients to specify search queries as regular
35  * expressions.</li>
36  * </ul>
37  * <p>
38  * Clients of a <code>IFindReplaceTarget</code> that also implements the
39  * <code>IFindReplaceTargetExtension</code> have to indicate the start of a find/replace
40  * session before using the target and to indicate the end of the session when the
41  * target is no longer used.
42  *
43  * @see org.eclipse.jface.text.IFindReplaceTargetExtension
44  * @see org.eclipse.jface.text.IFindReplaceTargetExtension3
45  */

46 public interface IFindReplaceTarget {
47
48     /**
49      * Returns whether a find operation can be performed.
50      *
51      * @return whether a find operation can be performed
52      */

53     boolean canPerformFind();
54
55     /**
56      * Searches for a string starting at the given widget offset and using the specified search
57      * directives. If a string has been found it is selected and its start offset is
58      * returned.
59      * <p>
60      * Replaced by {@link IFindReplaceTargetExtension3#findAndSelect(int, String, boolean, boolean, boolean, boolean)}.
61      *
62      * @param widgetOffset the widget offset at which searching starts
63      * @param findString the string which should be found
64      * @param searchForward <code>true</code> searches forward, <code>false</code> backwards
65      * @param caseSensitive <code>true</code> performs a case sensitive search, <code>false</code> an insensitive search
66      * @param wholeWord if <code>true</code> only occurrences are reported in which the findString stands as a word by itself
67      * @return the position of the specified string, or -1 if the string has not been found
68      */

69     int findAndSelect(int widgetOffset, String JavaDoc findString, boolean searchForward, boolean caseSensitive, boolean wholeWord);
70
71     /**
72      * Returns the currently selected range of characters as a offset and length in widget coordinates.
73      *
74      * @return the currently selected character range in widget coordinates
75      */

76     Point getSelection();
77
78     /**
79      * Returns the currently selected characters as a string.
80      *
81      * @return the currently selected characters
82      */

83     String JavaDoc getSelectionText();
84
85     /**
86      * Returns whether this target can be modified.
87      *
88      * @return <code>true</code> if target can be modified
89      */

90     boolean isEditable();
91
92     /**
93      * Replaces the currently selected range of characters with the given text.
94      * This target must be editable. Otherwise nothing happens.
95      * <p>
96      * Replaced by {@link IFindReplaceTargetExtension3#replaceSelection(String, boolean)}.
97      *
98      * @param text the substitution text
99      */

100     void replaceSelection(String JavaDoc text);
101 }
102
Popular Tags