Package org.eclipse.jface.text.templates
Class TemplateProposal
java.lang.Object
org.eclipse.jface.text.templates.TemplateProposal
- All Implemented Interfaces:
- ICompletionProposal,- ICompletionProposalExtension,- ICompletionProposalExtension2,- ICompletionProposalExtension3
public class TemplateProposal
extends Object
implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3
A template completion proposal.
 
Clients may subclass.
- Since:
- 3.0
- 
Constructor SummaryConstructorsConstructorDescriptionTemplateProposal(Template template, TemplateContext context, IRegion region, Image image) Creates a template proposal with a template and its context.TemplateProposal(Template template, TemplateContext context, IRegion region, Image image, int relevance) Creates a template proposal with a template and its context.
- 
Method SummaryModifier and TypeMethodDescriptionfinal voidDeprecated.voidDeprecated.This method is no longer called by the framework and clients should overwriteapply(ITextViewer, char, int, int)insteadvoidapply(ITextViewer viewer, char trigger, int stateMask, int offset) Inserts the template offered by this proposal into the viewer's document and sets up aLinkedModeUIon the viewer to edit any of the template's unresolved variables.Returns optional additional information about the proposal.protected final TemplateContextReturns the context in which the template was requested.Returns optional context information associated with this proposal.intReturns the position to which the computed context information refers to or-1if no context information can be provided by this completion proposal.Returns the string to be displayed in the list of completion proposals.getImage()Returns the image to be displayed in the list of completion proposals.Returns the information control creator of this completion proposal.intgetPrefixCompletionStart(IDocument document, int completionOffset) Returns the document offset at which the receiver would insert its proposal.getPrefixCompletionText(IDocument document, int completionOffset) Returns the string that would be inserted at the position returned fromICompletionProposalExtension3.getPrefixCompletionStart(IDocument, int)if this proposal was applied.intReturns the relevance.protected final intReturns the end offset of the range in the document that will be replaced by applying this template.protected final intReturns the offset of the range in the document that will be replaced by applying this template.getSelection(IDocument document) Returns the new selection after the proposal has been applied to the given document in absolute document coordinates.protected final TemplateReturns the template of this proposal.char[]Returns the characters which trigger the application of this completion proposal.booleanisValidFor(IDocument document, int offset) Returns whether this completion proposal is valid for the given position in the given document.voidselected(ITextViewer viewer, boolean smartToggle) Called when the proposal is selected.final voidsetInformationControlCreator(IInformationControlCreator informationControlCreator) Sets the information control creator for this completion proposal.voidunselected(ITextViewer viewer) Called when the proposal is unselected.booleanvalidate(IDocument document, int offset, DocumentEvent event) Requests the proposal to be validated with respect to the document event.
- 
Constructor Details- 
TemplateProposalCreates a template proposal with a template and its context.- Parameters:
- template- the template
- context- the context in which the template was requested.
- region- the region this proposal is applied to
- image- the icon of the proposal.
 
- 
TemplateProposalpublic TemplateProposal(Template template, TemplateContext context, IRegion region, Image image, int relevance) Creates a template proposal with a template and its context.- Parameters:
- template- the template
- context- the context in which the template was requested.
- region- the region this proposal is applied to
- image- the icon of the proposal.
- relevance- the relevance of the proposal
 
 
- 
- 
Method Details- 
setInformationControlCreatorpublic final void setInformationControlCreator(IInformationControlCreator informationControlCreator) Sets the information control creator for this completion proposal.- Parameters:
- informationControlCreator- the information control creator
- Since:
- 3.1
 
- 
getTemplateReturns the template of this proposal.- Returns:
- the template of this proposal
- Since:
- 3.1
 
- 
getContextReturns the context in which the template was requested.- Returns:
- the context in which the template was requested
- Since:
- 3.1
 
- 
applyDeprecated.This method is no longer called by the framework and clients should overwriteapply(ITextViewer, char, int, int)insteadInserts the proposed completion into the given document.- Specified by:
- applyin interface- ICompletionProposal
- Parameters:
- document- the document into which to insert the proposed completion
 
- 
applyInserts the template offered by this proposal into the viewer's document and sets up aLinkedModeUIon the viewer to edit any of the template's unresolved variables.- Specified by:
- applyin interface- ICompletionProposalExtension2
- Parameters:
- viewer- the text viewer into which to insert the proposed completion
- trigger- the trigger to apply the completion
- stateMask- the state mask of the modifiers
- offset- the offset at which the trigger has been activated
 
- 
getReplaceOffsetprotected final int getReplaceOffset()Returns the offset of the range in the document that will be replaced by applying this template.- Returns:
- the offset of the range in the document that will be replaced by applying this template
- Since:
- 3.1
 
- 
getReplaceEndOffsetprotected final int getReplaceEndOffset()Returns the end offset of the range in the document that will be replaced by applying this template.- Returns:
- the end offset of the range in the document that will be replaced by applying this template
- Since:
- 3.1
 
- 
getSelectionDescription copied from interface:ICompletionProposalReturns the new selection after the proposal has been applied to the given document in absolute document coordinates. If it returnsnull, no new selection is set. A document change can trigger other document changes, which have to be taken into account when calculating the new selection. Typically, this would be done by installing a document listener or by using a document position duringICompletionProposal.apply(IDocument).- Specified by:
- getSelectionin interface- ICompletionProposal
- Parameters:
- document- the document into which the proposed completion has been inserted
- Returns:
- the new selection in absolute document coordinates
 
- 
getAdditionalProposalInfoDescription copied from interface:ICompletionProposalReturns optional additional information about the proposal. The additional information will be presented to assist the user in deciding if the selected proposal is the desired choice.If ICompletionProposalExtension5is implemented, this method should not be called any longer. This method may be deprecated in a future release.- Specified by:
- getAdditionalProposalInfoin interface- ICompletionProposal
- Returns:
- the additional information or null
 
- 
getDisplayStringDescription copied from interface:ICompletionProposalReturns the string to be displayed in the list of completion proposals.- Specified by:
- getDisplayStringin interface- ICompletionProposal
- Returns:
- the string to be displayed
- See Also:
 
- 
getImageDescription copied from interface:ICompletionProposalReturns the image to be displayed in the list of completion proposals. The image would typically be shown to the left of the display string.- Specified by:
- getImagein interface- ICompletionProposal
- Returns:
- the image to be shown or nullif no image is desired
 
- 
getContextInformationDescription copied from interface:ICompletionProposalReturns optional context information associated with this proposal. The context information will automatically be shown if the proposal has been applied.- Specified by:
- getContextInformationin interface- ICompletionProposal
- Returns:
- the context information for this proposal or null
 
- 
getRelevancepublic int getRelevance()Returns the relevance.- Returns:
- the relevance
 
- 
getInformationControlCreatorDescription copied from interface:ICompletionProposalExtension3Returns the information control creator of this completion proposal.- Specified by:
- getInformationControlCreatorin interface- ICompletionProposalExtension3
- Returns:
- the information control creator, or nullif no custom control creator is available
 
- 
selectedDescription copied from interface:ICompletionProposalExtension2Called when the proposal is selected.- Specified by:
- selectedin interface- ICompletionProposalExtension2
- Parameters:
- viewer- the text viewer.
- smartToggle- the smart toggle key was pressed
 
- 
unselectedDescription copied from interface:ICompletionProposalExtension2Called when the proposal is unselected.- Specified by:
- unselectedin interface- ICompletionProposalExtension2
- Parameters:
- viewer- the text viewer.
 
- 
validateDescription copied from interface:ICompletionProposalExtension2Requests the proposal to be validated with respect to the document event. If the proposal cannot be validated, the methods returnsfalse. If the document event wasnull, only the caret offset was changed, but not the document. This method replacesICompletionProposalExtension.isValidFor(IDocument, int)- Specified by:
- validatein interface- ICompletionProposalExtension2
- Parameters:
- document- the document
- offset- the caret offset
- event- the document event, may be- null
- Returns:
- boolean
 
- 
getPrefixCompletionTextDescription copied from interface:ICompletionProposalExtension3Returns the string that would be inserted at the position returned fromICompletionProposalExtension3.getPrefixCompletionStart(IDocument, int)if this proposal was applied. If the replacement string cannot be determined,nullmay be returned.- Specified by:
- getPrefixCompletionTextin interface- ICompletionProposalExtension3
- Parameters:
- document- the document that the receiver applies to
- completionOffset- the offset into- documentwhere the completion takes place
- Returns:
- the replacement string or nullif it cannot be determined
 
- 
getPrefixCompletionStartDescription copied from interface:ICompletionProposalExtension3Returns the document offset at which the receiver would insert its proposal.- Specified by:
- getPrefixCompletionStartin interface- ICompletionProposalExtension3
- Parameters:
- document- the document that the receiver applies to
- completionOffset- the offset into- documentwhere the completion takes place
- Returns:
- the offset at which the proposal would insert its proposal
 
- 
applyDeprecated.This method is no longer called by the framework and clients should overwriteapply(ITextViewer, char, int, int)insteadApplies the proposed completion to the given document. The insertion has been triggered by entering the given character at the given offset. This method assumes thatICompletionProposalExtension.isValidFor(IDocument, int)returnstrueif called foroffset.- Specified by:
- applyin interface- ICompletionProposalExtension
- Parameters:
- document- the document into which to insert the proposed completion
- trigger- the trigger to apply the completion
- offset- the offset at which the trigger has been activated
 
- 
isValidForDescription copied from interface:ICompletionProposalExtensionReturns whether this completion proposal is valid for the given position in the given document.- Specified by:
- isValidForin interface- ICompletionProposalExtension
- Parameters:
- document- the document for which the proposal is tested
- offset- the offset for which the proposal is tested
- Returns:
- trueiff valid
 
- 
getTriggerCharacterspublic char[] getTriggerCharacters()Description copied from interface:ICompletionProposalExtensionReturns the characters which trigger the application of this completion proposal.- Specified by:
- getTriggerCharactersin interface- ICompletionProposalExtension
- Returns:
- the completion characters for this completion proposal or nullif no completion other than the new line character is possible
 
- 
getContextInformationPositionpublic int getContextInformationPosition()Description copied from interface:ICompletionProposalExtensionReturns the position to which the computed context information refers to or-1if no context information can be provided by this completion proposal.- Specified by:
- getContextInformationPositionin interface- ICompletionProposalExtension
- Returns:
- the position to which the context information refers to or -1for no information
 
 
- 
apply(ITextViewer, char, int, int)instead