## org.eclipse.datatools.sqltools.sqleditor.internal.templates
Class SQLTemplateProposal

    java.lang.Object
      org.eclipse.datatools.sqltools.sqleditor.internal.templates.SQLTemplateProposal

All Implemented Interfaces:
  ISQLCompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposalExtension, org.eclipse.jface.text.contentassist.ICompletionProposalExtension2, org.eclipse.jface.text.contentassist.ICompletionProposalExtension3

    public class SQLTemplateProposal

extends java.lang.Object
implements org.eclipse.jface.text.contentassist.ICompletionProposal, org.eclipse.jface.text.contentassist.ICompletionProposalExtension, org.eclipse.jface.text.contentassist.ICompletionProposalExtension2, org.eclipse.jface.text.contentassist.ICompletionProposalExtension3, ISQLCompletionProposal

This class is refactored from TemplateProposal to support intelligence template.

Author:
  lihuang

Field Summary
`static java.lang.String` `KEY_SQLEDITOR`

Constructor Summary
`SQLTemplateProposal(SQLEditor editor, org.eclipse.jface.text.templates.Template template, org.eclipse.jface.text.templates.TemplateContext context, org.eclipse.jface.text.IRegion region, org.eclipse.swt.graphics.Image image)` Creates a SQL template proposal with a template and its context.
`SQLTemplateProposal(SQLEditor editor, org.eclipse.jface.text.templates.Template template, org.eclipse.jface.text.templates.TemplateContext context, org.eclipse.jface.text.IRegion region, org.eclipse.swt.graphics.Image image, int relevance)` Creates a template proposal with a template and its context.

Method Summary
`void` `apply(org.eclipse.jface.text.IDocument document)`
`void` `apply(org.eclipse.jface.text.IDocument document, char trigger, int offset)`
`void` `apply(org.eclipse.jface.text.ITextViewer viewer, char trigger, int stateMask, int offset)` Inserts the template offered by this proposal into the viewer's document and sets up a `LinkedModeUI` on the viewer to edit any of the template's unresolved variables.
`java.lang.String` `getAdditionalProposalInfo()`
`org.eclipse.jface.text.contentassist.IContextInformation` `getContextInformation()`
`int` `getContextInformationPosition()`
`java.lang.String` `getDisplayString()`
`org.eclipse.swt.graphics.Image` `getImage()`
`org.eclipse.jface.text.IInformationControlCreator` `getInformationControlCreator()`
`int` `getPrefixCompletionStart(org.eclipse.jface.text.IDocument document, int completionOffset)`
`java.lang.CharSequence` `getPrefixCompletionText(org.eclipse.jface.text.IDocument document, int completionOffset)`
`int` `getRelevance()` Returns the relevance.
`org.eclipse.swt.graphics.Point` `getSelection(org.eclipse.jface.text.IDocument document)`
`char[]` `getTriggerCharacters()`
`boolean` `isValidFor(org.eclipse.jface.text.IDocument document, int offset)`
`void` `selected(org.eclipse.jface.text.ITextViewer viewer, boolean smartToggle)`
`void` `setInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator informationControlCreator)` Sets the information control creator for this completion proposal.
`void` `unselected(org.eclipse.jface.text.ITextViewer viewer)`
`boolean` `validate(org.eclipse.jface.text.IDocument document, int offset, org.eclipse.jface.text.DocumentEvent event)`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### KEY_SQLEDITOR

    public static final java.lang.String KEY_SQLEDITOR

See Also:
  Constant Field Values

Constructor Detail

### SQLTemplateProposal

    public SQLTemplateProposal(SQLEditor editor,
                               org.eclipse.jface.text.templates.Template template,
                               org.eclipse.jface.text.templates.TemplateContext context,
                               org.eclipse.jface.text.IRegion region,
                               org.eclipse.swt.graphics.Image image)

  Creates a SQL 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.

### SQLTemplateProposal

    public SQLTemplateProposal(SQLEditor editor,
                               org.eclipse.jface.text.templates.Template template,
                               org.eclipse.jface.text.templates.TemplateContext context,
                               org.eclipse.jface.text.IRegion region,
                               org.eclipse.swt.graphics.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.
    `image` - the icon of the proposal.
    `region` - the region this proposal is applied to
    `relevance` - the relevance of the proposal

Method Detail

### setInformationControlCreator

    public final void setInformationControlCreator(org.eclipse.jface.text.IInformationControlCreator informationControlCreator)

  Sets the information control creator for this completion proposal.

  Parameters:
    `informationControlCreator` - the information control creator
  Since:
    3.1

### apply

    public final void apply(org.eclipse.jface.text.IDocument document)

  Specified by:
    `apply` in interface `org.eclipse.jface.text.contentassist.ICompletionProposal`

### apply

    public void apply(org.eclipse.jface.text.ITextViewer viewer,
                      char trigger,
                      int stateMask,
                      int offset)

  Inserts the template offered by this proposal into the viewer's document and sets up a `LinkedModeUI` on the viewer to edit any of the template's unresolved variables.

  Specified by:
    `apply` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension2`
  Parameters:
    `viewer` -
    `trigger` -
    `stateMask` -
    `offset` -

### getSelection

    public org.eclipse.swt.graphics.Point getSelection(org.eclipse.jface.text.IDocument document)

  Specified by:
    `getSelection` in interface `org.eclipse.jface.text.contentassist.ICompletionProposal`

### getAdditionalProposalInfo

    public java.lang.String getAdditionalProposalInfo()

  Specified by:
    `getAdditionalProposalInfo` in interface `org.eclipse.jface.text.contentassist.ICompletionProposal`

### getDisplayString

    public java.lang.String getDisplayString()

  Specified by:
    `getDisplayString` in interface `org.eclipse.jface.text.contentassist.ICompletionProposal`

### getImage

    public org.eclipse.swt.graphics.Image getImage()

  Specified by:
    `getImage` in interface `org.eclipse.jface.text.contentassist.ICompletionProposal`

### getContextInformation

    public org.eclipse.jface.text.contentassist.IContextInformation getContextInformation()

  Specified by:
    `getContextInformation` in interface `org.eclipse.jface.text.contentassist.ICompletionProposal`

### getRelevance

    public int getRelevance()

  Returns the relevance.

  Specified by:
    `getRelevance` in interface `ISQLCompletionProposal`
  Returns:
    the relevance

### getInformationControlCreator

    public org.eclipse.jface.text.IInformationControlCreator getInformationControlCreator()

  Specified by:
    `getInformationControlCreator` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension3`

### selected

    public void selected(org.eclipse.jface.text.ITextViewer viewer,
                         boolean smartToggle)

  Specified by:
    `selected` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension2`

### unselected

    public void unselected(org.eclipse.jface.text.ITextViewer viewer)

  Specified by:
    `unselected` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension2`

### validate

    public boolean validate(org.eclipse.jface.text.IDocument document,
                            int offset,
                            org.eclipse.jface.text.DocumentEvent event)

  Specified by:
    `validate` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension2`

### getPrefixCompletionText

    public java.lang.CharSequence getPrefixCompletionText(org.eclipse.jface.text.IDocument document,
                                                          int completionOffset)

  Specified by:
    `getPrefixCompletionText` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension3`

### getPrefixCompletionStart

    public int getPrefixCompletionStart(org.eclipse.jface.text.IDocument document,
                                        int completionOffset)

  Specified by:
    `getPrefixCompletionStart` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension3`

### apply

    public void apply(org.eclipse.jface.text.IDocument document,
                      char trigger,
                      int offset)

  Specified by:
    `apply` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension`

### isValidFor

    public boolean isValidFor(org.eclipse.jface.text.IDocument document,
                              int offset)

  Specified by:
    `isValidFor` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension`

### getTriggerCharacters

    public char[] getTriggerCharacters()

  Specified by:
    `getTriggerCharacters` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension`

### getContextInformationPosition

    public int getContextInformationPosition()

  Specified by:
    `getContextInformationPosition` in interface `org.eclipse.jface.text.contentassist.ICompletionProposalExtension`