KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > quickassist > IQuickAssistAssistant


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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.quickassist;
12
13 import org.eclipse.swt.graphics.Color;
14
15 import org.eclipse.jface.text.IInformationControlCreator;
16 import org.eclipse.jface.text.contentassist.ICompletionListener;
17 import org.eclipse.jface.text.source.Annotation;
18 import org.eclipse.jface.text.source.ISourceViewer;
19 import org.eclipse.jface.text.source.ISourceViewerExtension3;
20
21
22 /**
23  * An <code>IQuickAssistAssistant</code> provides support for quick fixes and quick
24  * assists.
25  * The quick assist assistant is a {@link ISourceViewer} add-on. Its
26  * purpose is to propose, display, and insert quick assists and quick fixes
27  * available at the current source viewer's quick assist invocation context.
28  * <p>
29  * The quick assist assistant can be configured with a {@link IQuickAssistProcessor}
30  * which provides the possible quick assist and quick fix completions.
31  * </p>
32  * <p>
33  * The interface can be implemented by clients. By default, clients use
34  * {@link QuickAssistAssistant} as the standard
35  * implementer of this interface.
36  * </p>
37  *
38  * @see ISourceViewer
39  * @see IQuickAssistProcessor
40  * @since 3.2
41  */

42  public interface IQuickAssistAssistant {
43
44     /**
45      * Installs quick assist support on the given source viewer.
46      * <p>
47      * <strong>Note:</strong> This quick assist assistant will only be able to query the invocation context
48      * if <code>sourceViewer</code> also implements {@link ISourceViewerExtension3}.
49      * </p>
50      *
51      * @param sourceViewer the source viewer on which quick assist will work
52      */

53     void install(ISourceViewer sourceViewer);
54
55     /**
56      * Sets the information control creator for the additional information control.
57      *
58      * @param creator the information control creator for the additional information control
59      */

60     void setInformationControlCreator(IInformationControlCreator creator);
61
62     /**
63      * Uninstalls quick assist support from the source viewer it has
64      * previously be installed on.
65      */

66     void uninstall();
67
68     /**
69      * Shows all possible quick fixes and quick assists at the viewer's cursor position.
70      *
71      * @return an optional error message if no proposals can be computed
72      */

73     String JavaDoc showPossibleQuickAssists();
74     
75     /**
76      * Registers a given quick assist processor for a particular content type. If there is already
77      * a processor registered, the new processor is registered instead of the old one.
78      *
79      * @param processor the quick assist processor to register, or <code>null</code> to remove
80      * an existing one
81      */

82     void setQuickAssistProcessor(IQuickAssistProcessor processor);
83     
84     /**
85      * Returns the quick assist processor to be used for the given content type.
86      *
87      * @return the quick assist processor or <code>null</code> if none exists
88      */

89     IQuickAssistProcessor getQuickAssistProcessor();
90     
91     /**
92      * Tells whether this assistant has a fix for the given annotation.
93      * <p>
94      * <strong>Note:</strong> This test must be fast and optimistic i.e. it is OK to return
95      * <code>true</code> even though there might be no quick fix.
96      * </p>
97      *
98      * @param annotation the annotation
99      * @return <code>true</code> if the assistant has a fix for the given annotation
100      */

101     boolean canFix(Annotation annotation);
102     
103     /**
104      * Tells whether this assistant has assists for the given invocation context.
105      *
106      * @param invocationContext the invocation context
107      * @return <code>true</code> if the assistant has a fix for the given annotation
108      */

109     boolean canAssist(IQuickAssistInvocationContext invocationContext);
110     
111     /**
112      * Sets the proposal selector's background color.
113      *
114      * @param background the background color
115      */

116     void setProposalSelectorBackground(Color background);
117
118     /**
119      * Sets the proposal's foreground color.
120      *
121      * @param foreground the foreground color
122      */

123     void setProposalSelectorForeground(Color foreground);
124     
125     /**
126      * Adds a completion listener that will be informed before proposals are computed.
127      *
128      * @param listener the listener
129      */

130     void addCompletionListener(ICompletionListener listener);
131
132     /**
133      * Removes a completion listener.
134      *
135      * @param listener the listener to remove
136      */

137     void removeCompletionListener(ICompletionListener listener);
138     
139     /**
140      * Enables displaying a status line below the proposal popup. The default is not to show the
141      * status line. The contents of the status line may be set via {@link #setStatusMessage(String)}.
142      *
143      * @param show <code>true</code> to show a message line, <code>false</code> to not show one.
144      */

145     public void setStatusLineVisible(boolean show);
146
147     /**
148      * Sets the caption message displayed at the bottom of the completion proposal popup.
149      *
150      * @param message the message
151      */

152     public void setStatusMessage(String JavaDoc message);
153     
154 }
155
Popular Tags