## org.eclipse.datatools.sqltools.sqleditor
Class SQLEditor

    java.lang.Object
      TextEditor
          org.eclipse.datatools.sqltools.sqleditor.SQLEditor

Direct Known Subclasses:
  RoutineEditor

public class SQLEditor
extends TextEditor

This class is responsible for configuring the SQL editor.

See Also:
  Serialized Form

Nested Class Summary
`class` `SQLEditor.AdaptedSourceViewer`

Field Summary
`static java.lang.String` `HELP_CONTEXT_ID`
`static java.lang.String` `PLUGIN_NAME`

Constructor Summary
`SQLEditor()` Constructs an instance of this class.

Method Summary
`void` `addConnectionProfileAttachListener(IConnectionProfileAttachListener listener)`
`void` `createPartControl(Composite parent)` Creates the SWT controls for the editor.
`void` `dispose()` Dispose of resources held by this editor.
`void` `doRevertToSaved()` Abandons all modifications applied to this text editor's input element's textual presentation since the last save operation.
`void` `doSave(IProgressMonitor monitor)` Saves the content of this editor.
`void` `doSaveAs()` Saves the contents of this editor to another object.
`void` `doSetInput(IEditorInput input)` Sets the input of the outline page after this class has set input.
`void` `fireConnectionProfileAttached()`
`java.lang.Object` `getAdapter(java.lang.Class classForWhichAdapterNeeded)` Gets an adapter for the given class.
`ISQLEditorConnectionInfo` `getConnectionInfo()` Gets the connection info object of the editor input of this editor.
`Database` `getDatabase()` Gets the `Database` object associated with this input.
`DatabaseIdentifier` `getDatabaseIdentifier()` Returns the DatabaseIdentifier associated with the connection info.
`ISQLDBProposalsService` `getDBProposalsService()` Gets the `DBProposalsService` object that provides content assist services for this editor.
`java.lang.String` `getDBType()`
`java.lang.String` `getDefaultSchemaName()` Gets the default schema name to use with the connection or database associated with this input.
`SQLEditorDocumentSetupParticipant` `getDocumentSetupParticipant()` Gets the document setup participant object associated with this editor.
`int` `getOrientation()`
`IEditorPart` `getParentEditor()` Gets the multipage editor to which this sql editor belongs
`ParsingResult` `getParsingResult()` Returns the parsing result no matter the "Enable syntax validation" is on or off.
`java.util.ResourceBundle` `getResourceBundle()` Gets the resource bundle associated with this editor.
`java.lang.String` `getSelectedText()` Returns the selected text.
`SQLColorProvider` `getSQLColorProvider()` Gets the color provider for colorizing SQL source code.
`int` `getSQLType()` Returns the outmost sql statement type that's allowed in this editor.
`ISourceViewer` `getSV()` Makes the source viewer public.
`java.lang.String` `getTargetText()`
`java.lang.String` `getText()` Returns the complete text in this editor.
`void` `init(IEditorSite site, IEditorInput input)`
`void` `insert(java.lang.String sqlText)` Insert the SQL text into editor
`boolean` `isConnected()` Utility methods to "getConnectionInfo().isConnected()"
`void` `outlinePageClosed()` Informs the editor that its outliner has been closed.
`void` `propertyChange(PropertyChangeEvent event)` Handles notifications to the object that a property has changed.
`void` `refreshConnectionStatus()` Refreshes the status area indicating the connection state.
`void` `removeConnectionProfileAttachListener(IConnectionProfileAttachListener listener)`
`void` `requestConnection()` Requests a connection.
`ISQLEditorConnectionInfo` `requestConnectionFromUser()` Prompts the user to select an existing connection or create a new one.
`void` `setConnectionInfo(ISQLEditorConnectionInfo connInfo)` Sets the connection info object of the editor input of this editor.
`void` `setDocumentSetupParticipant(SQLEditorDocumentSetupParticipant docSetupParticipant)` Sets the document setup participant object associated with this editor to the given object.
`void` `setFocus()` Asks this part to take focus within the workbench.
`void` `setParentEditor(IEditorPart editor)` Sets the multipage editor to which this sql editor belongs
`void` `setParsingResult(ParsingResult result)`
`void` `updatePartControl(IEditorInput input)`

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

Field Detail

### PLUGIN_NAME

    public static final java.lang.String PLUGIN_NAME

See Also:
  Constant Field Values

### HELP_CONTEXT_ID

    public static final java.lang.String HELP_CONTEXT_ID

See Also:
  Constant Field Values

Constructor Detail

### SQLEditor

    public SQLEditor()

  Constructs an instance of this class. This is the default constructor.

Method Detail

### init

    public void init(IEditorSite site,
                     IEditorInput input)
              throws PartInitException

  Throws:
    `PartInitException`

### createPartControl

    public void createPartControl(Composite parent)

  Creates the SWT controls for the editor.

  See Also:
    `org.eclipse.ui.texteditor.AbstractTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)`

### updatePartControl

    public void updatePartControl(IEditorInput input)

### dispose

    public void dispose()

  Dispose of resources held by this editor.

  See Also:
    `IWorkbenchPart#dispose()`

### getParentEditor

    public IEditorPart getParentEditor()

  Gets the multipage editor to which this sql editor belongs

### setParentEditor

    public void setParentEditor(IEditorPart editor)

  Sets the multipage editor to which this sql editor belongs

  Parameters:
    `editor` -

### doRevertToSaved

    public void doRevertToSaved()

  Abandons all modifications applied to this text editor's input element's textual presentation since the last save operation.

  See Also:
    `ITextEditor#doRevertToSaved()`

### doSave

    public void doSave(IProgressMonitor monitor)

  Saves the content of this editor.

  See Also:
    `org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)`

### doSaveAs

    public void doSaveAs()

  Saves the contents of this editor to another object.

  See Also:
    `org.eclipse.ui.ISaveablePart#doSaveAs()`

### doSetInput

    public void doSetInput(IEditorInput input)
                    throws CoreException

  Sets the input of the outline page after this class has set input.

  Parameters:
    `input` - the new input for the editor
  Throws:
    `CoreException`
  See Also:
    `org.eclipse.ui.editors.text.TextEditor#doSetInput(org.eclipse.ui.IEditorInput)`

### getAdapter

    public java.lang.Object getAdapter(java.lang.Class classForWhichAdapterNeeded)

  Gets an adapter for the given class. Returns the SQL content outline page if the get request is for an outline page. Otherwise returns a projection adapter if one hasn't already been created.

  See Also:
    `org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)`, `org.eclipse.jface.text.source.projection.ProjectionSupport#getAdapter(org.eclipse.jface.text.source.ISourceViewer, java.lang.Class)`

### getConnectionInfo

    public ISQLEditorConnectionInfo getConnectionInfo()

  Gets the connection info object of the editor input of this editor.

  Returns:
    the current connection info object if the editor has one, otherwise null

### setConnectionInfo

    public void setConnectionInfo(ISQLEditorConnectionInfo connInfo)

  Sets the connection info object of the editor input of this editor. Also updates connection related features such as actions, status line, syntax highlighting, and syntax validation, etc.

  Parameters:
    `connInfo` - the new connection info object

### requestConnection

    public void requestConnection()

  Requests a connection. Does not guarantee the connection is established. The default implementation does nothing.

### getDatabase

    public Database getDatabase()

  Gets the `Database` object associated with this input.

  Returns:
    the `Database` object associated with this input

### getDBProposalsService

    public ISQLDBProposalsService getDBProposalsService()

  Gets the `DBProposalsService` object that provides content assist services for this editor.

  Returns:
    the current `DBProposalsService` object

### getDefaultSchemaName

    public java.lang.String getDefaultSchemaName()

  Gets the default schema name to use with the connection or database associated with this input.

  Returns:
    the default schema name to use with this input, or null if none

### getDocumentSetupParticipant

    public SQLEditorDocumentSetupParticipant getDocumentSetupParticipant()

  Gets the document setup participant object associated with this editor. The setup participant sets the partitioning type for the document.

  Returns:
    the current document setup participant

### getResourceBundle

    public java.util.ResourceBundle getResourceBundle()

  Gets the resource bundle associated with this editor.

  Returns:
    the resource bundle associated with this editor.

### getSQLColorProvider

    public SQLColorProvider getSQLColorProvider()

  Gets the color provider for colorizing SQL source code.

  Returns:
    the SQL color provider

### propertyChange

    public void propertyChange(PropertyChangeEvent event)

  Handles notifications to the object that a property has changed.

  Parameters:
    `event` - the property change event object describing which property changed and how

### setDocumentSetupParticipant

    public void setDocumentSetupParticipant(SQLEditorDocumentSetupParticipant docSetupParticipant)

  Sets the document setup participant object associated with this editor to the given object. The setup participant sets the partitioning type for the document.

  Returns:
    the current document setup participant

### setFocus

    public void setFocus()

  Asks this part to take focus within the workbench.

  See Also:
    `org.eclipse.ui.IWorkbenchPart#setFocus()`

### requestConnectionFromUser

    public ISQLEditorConnectionInfo requestConnectionFromUser()

  Prompts the user to select an existing connection or create a new one. Returns a `ISQLEditorConnectionInfo` object for the chosen connection.

  Returns:
    the `ISQLEditorConnectionInfo` object for the selected connection or null if none selected

### getSV

    public ISourceViewer getSV()

  Makes the source viewer public.

  Returns:
    The source viewer used to create this editor

### outlinePageClosed

    public void outlinePageClosed()

  Informs the editor that its outliner has been closed.

### getParsingResult

    public ParsingResult getParsingResult()

  Returns the parsing result no matter the "Enable syntax validation" is on or off. If this option is on, we will always keep the parsing result up-to-date, if it is off, we will check if the parsing result is kept sync with the editor content, if not, we will parse it to get the synchronized parsing result

  Returns:
    the recent parsing result since the last modification, may only be null when parser can't be found

### setParsingResult

    public void setParsingResult(ParsingResult result)

### refreshConnectionStatus

    public void refreshConnectionStatus()

  Refreshes the status area indicating the connection state.

### getText

    public java.lang.String getText()

  Returns the complete text in this editor.

  Returns:
    the complete text.

### getSelectedText

    public java.lang.String getSelectedText()

  Returns the selected text.

### getOrientation

    public int getOrientation()

### getTargetText

    public java.lang.String getTargetText()

  Returns:
    the selected text or the whole text when there's no selection

### getSQLType

    public int getSQLType()

  Returns the outmost sql statement type that's allowed in this editor. The default sqlType is SQLParserConstants.TYPE_SQL_ROOT, which means any sql statements can occur.

  Returns:

### addConnectionProfileAttachListener

    public void addConnectionProfileAttachListener(IConnectionProfileAttachListener listener)

### removeConnectionProfileAttachListener

    public void removeConnectionProfileAttachListener(IConnectionProfileAttachListener listener)

### fireConnectionProfileAttached

    public void fireConnectionProfileAttached()

### getDatabaseIdentifier

    public DatabaseIdentifier getDatabaseIdentifier()

  Returns the DatabaseIdentifier associated with the connection info.

  Returns:
    might be null

### getDBType

    public java.lang.String getDBType()

### insert

    public void insert(java.lang.String sqlText)

  Insert the SQL text into editor

  Parameters:
    `sqlText` -

### isConnected

    public boolean isConnected()

  Utility methods to "getConnectionInfo().isConnected()"

  Returns:

Copyright © 2006 Actuate, IBM Corporation, Sybase, Inc. and others. All rights reserved.