KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > contentassist > ICompletionProposalExtension2


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.contentassist;
12
13 import org.eclipse.jface.text.DocumentEvent;
14 import org.eclipse.jface.text.IDocument;
15 import org.eclipse.jface.text.ITextViewer;
16
17
18 /**
19  * Extends {@link org.eclipse.jface.text.contentassist.ICompletionProposal}
20  * with the following functions:
21  * <ul>
22  * <li>handling of trigger characters with modifiers</li>
23  * <li>visual indication for selection of a proposal</li>
24  * </ul>
25  *
26  * @since 2.1
27  */

28 public interface ICompletionProposalExtension2 {
29
30     /**
31      * Applies the proposed completion to the given document. The insertion
32      * has been triggered by entering the given character with a modifier at the given offset.
33      * This method assumes that {@link #validate(IDocument, int, DocumentEvent)}
34      * returns <code>true</code> if called for <code>offset</code>.
35      *
36      * @param viewer the text viewer into which to insert the proposed completion
37      * @param trigger the trigger to apply the completion
38      * @param stateMask the state mask of the modifiers
39      * @param offset the offset at which the trigger has been activated
40      */

41     void apply(ITextViewer viewer, char trigger, int stateMask, int offset);
42
43     /**
44      * Called when the proposal is selected.
45      *
46      * @param viewer the text viewer.
47      * @param smartToggle the smart toggle key was pressed
48      */

49     void selected(ITextViewer viewer, boolean smartToggle);
50
51     /**
52      * Called when the proposal is unselected.
53      *
54      * @param viewer the text viewer.
55      */

56     void unselected(ITextViewer viewer);
57
58     /**
59      * Requests the proposal to be validated with respect to the document event.
60      * If the proposal cannot be validated, the methods returns <code>false</code>.
61      * If the document event was <code>null</code>, only the caret offset was changed, but not the document.
62      *
63      * This method replaces {@link ICompletionProposalExtension#isValidFor(IDocument, int)}
64      *
65      * @param document the document
66      * @param offset the caret offset
67      * @param event the document event, may be <code>null</code>
68      * @return boolean
69      */

70     boolean validate(IDocument document, int offset, DocumentEvent event);
71
72 }
73
Popular Tags