org.eclipse.datatools.sqltools.sqleditor
Class SQLEditor

java.lang.Object
  extended by org.eclipse.core.commands.common.EventManager
      extended by org.eclipse.ui.part.WorkbenchPart
          extended by org.eclipse.ui.part.EditorPart
              extended by org.eclipse.ui.texteditor.AbstractTextEditor
                  extended by org.eclipse.ui.texteditor.StatusTextEditor
                      extended by org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
                          extended by org.eclipse.ui.editors.text.TextEditor
                              extended by org.eclipse.datatools.sqltools.sqleditor.SQLEditor
All Implemented Interfaces:
java.util.EventListener, org.eclipse.core.runtime.IAdaptable, org.eclipse.core.runtime.IExecutableExtension, org.eclipse.jface.util.IPropertyChangeListener, org.eclipse.ui.IEditorPart, org.eclipse.ui.INavigationLocationProvider, org.eclipse.ui.IPersistable, org.eclipse.ui.IPersistableEditor, org.eclipse.ui.IReusableEditor, org.eclipse.ui.ISaveablePart, org.eclipse.ui.ISaveablesSource, org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.IWorkbenchPart2, org.eclipse.ui.IWorkbenchPart3, org.eclipse.ui.part.IWorkbenchPartOrientation, org.eclipse.ui.texteditor.ITextEditor, org.eclipse.ui.texteditor.ITextEditorExtension, org.eclipse.ui.texteditor.ITextEditorExtension2, org.eclipse.ui.texteditor.ITextEditorExtension3, org.eclipse.ui.texteditor.ITextEditorExtension4
Direct Known Subclasses:
RoutineEditor

public class SQLEditor
extends org.eclipse.ui.editors.text.TextEditor
implements org.eclipse.jface.util.IPropertyChangeListener

This class is responsible for configuring the SQL editor.


Nested Class Summary
 class SQLEditor.AdaptedSourceViewer
           
 
Nested classes/interfaces inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
org.eclipse.ui.texteditor.ITextEditorExtension3.InsertMode
 
Field Summary
static java.lang.String HELP_CONTEXT_ID
           
static java.lang.String PLUGIN_NAME
           
 
Fields inherited from class org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
DEFAULT_OVERVIEW_RULER_CONTEXT_MENU_ID
 
Fields inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
DEFAULT_EDITOR_CONTEXT_MENU_ID, DEFAULT_RULER_CONTEXT_MENU_ID, PREFERENCE_COLOR_BACKGROUND, PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_FIND_SCOPE, PREFERENCE_COLOR_FOREGROUND, PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_BACKGROUND, PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT, PREFERENCE_COLOR_SELECTION_FOREGROUND, PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, PREFERENCE_FONT, PREFERENCE_HOVER_ENRICH_MODE, PREFERENCE_HYPERLINK_KEY_MODIFIER, PREFERENCE_HYPERLINK_KEY_MODIFIER_MASK, PREFERENCE_HYPERLINKS_ENABLED, PREFERENCE_NAVIGATION_SMART_HOME_END, PREFERENCE_RULER_CONTRIBUTIONS, PREFERENCE_SHOW_WHITESPACE_CHARACTERS, PREFERENCE_TEXT_DRAG_AND_DROP_ENABLED, PREFERENCE_USE_CUSTOM_CARETS, PREFERENCE_WIDE_CARET
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Fields inherited from interface org.eclipse.ui.IEditorPart
PROP_DIRTY, PROP_INPUT
 
Fields inherited from interface org.eclipse.ui.IWorkbenchPart
PROP_TITLE
 
Fields inherited from interface org.eclipse.ui.texteditor.ITextEditorExtension3
INSERT, SMART_INSERT
 
Constructor Summary
SQLEditor()
          Constructs an instance of this class.
 
Method Summary
 void addConnectionProfileAttachListener(IConnectionProfileAttachListener listener)
           
 void createPartControl(org.eclipse.swt.widgets.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(org.eclipse.core.runtime.IProgressMonitor monitor)
          Saves the content of this editor.
 void doSaveAs()
          Saves the contents of this editor to another object.
 void doSetInput(org.eclipse.ui.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.
 org.eclipse.datatools.sqltools.core.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()
           
 org.eclipse.ui.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.
 org.eclipse.jface.text.source.ISourceViewer getSV()
          Makes the source viewer public.
 java.lang.String getTargetText()
           
 java.lang.String getText()
          Returns the complete text in this editor.
 void gotoMatchingToken()
          Going to matching token.
 void init(org.eclipse.ui.IEditorSite site, org.eclipse.ui.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(org.eclipse.jface.util.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(org.eclipse.ui.IEditorPart editor)
          Sets the multipage editor to which this sql editor belongs
 void setParsingResult(ParsingResult result)
           
 void updatePartControl(org.eclipse.ui.IEditorInput input)
           
 
Methods inherited from class org.eclipse.ui.editors.text.TextEditor
isSaveAsAllowed
 
Methods inherited from class org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
getDocumentProvider, gotoAnnotation, gotoMarker, isChangeInformationShowing, isEditable, showChangeInformation, showRevisionInformation, validateEditorInputState
 
Methods inherited from class org.eclipse.ui.texteditor.AbstractTextEditor
addRulerContextMenuListener, close, createEmptyNavigationLocation, createNavigationLocation, getAction, getActiveSaveables, getHighlightRange, getInsertMode, getSaveables, getSelectionProvider, isDirty, isEditorInputModifiable, isEditorInputReadOnly, markAsContentDependentAction, markAsPropertyDependentAction, markAsSelectionDependentAction, markAsStateDependentAction, removeActionActivationCode, removeRulerContextMenuListener, resetHighlightRange, restoreState, saveState, selectAndReveal, setAction, setActionActivationCode, setHighlightRange, setInput, setInsertMode, setStatusField, showHighlightRangeOnly, showsHighlightRangeOnly
 
Methods inherited from class org.eclipse.ui.part.EditorPart
getEditorInput, getEditorSite, getTitleToolTip, isSaveOnCloseNeeded, setInitializationData
 
Methods inherited from class org.eclipse.ui.part.WorkbenchPart
addPartPropertyListener, addPropertyListener, getContentDescription, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, removePartPropertyListener, removePropertyListener, setPartProperty, showBusy
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
 
Methods inherited from interface org.eclipse.ui.IEditorPart
getEditorInput, getEditorSite
 
Methods inherited from interface org.eclipse.ui.IWorkbenchPart
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
 
Methods inherited from interface org.eclipse.ui.ISaveablePart
isSaveOnCloseNeeded
 

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(org.eclipse.ui.IEditorSite site,
                 org.eclipse.ui.IEditorInput input)
          throws org.eclipse.ui.PartInitException
Specified by:
init in interface org.eclipse.ui.IEditorPart
Overrides:
init in class org.eclipse.ui.texteditor.AbstractTextEditor
Throws:
org.eclipse.ui.PartInitException

createPartControl

public void createPartControl(org.eclipse.swt.widgets.Composite parent)
Creates the SWT controls for the editor.

Specified by:
createPartControl in interface org.eclipse.ui.IWorkbenchPart
Overrides:
createPartControl in class org.eclipse.ui.texteditor.AbstractDecoratedTextEditor
See Also:
AbstractTextEditor.createPartControl(org.eclipse.swt.widgets.Composite)

updatePartControl

public void updatePartControl(org.eclipse.ui.IEditorInput input)
Overrides:
updatePartControl in class org.eclipse.ui.texteditor.StatusTextEditor

dispose

public void dispose()
Dispose of resources held by this editor.

Specified by:
dispose in interface org.eclipse.ui.IWorkbenchPart
Overrides:
dispose in class org.eclipse.ui.editors.text.TextEditor
See Also:
IWorkbenchPart.dispose()

getParentEditor

public org.eclipse.ui.IEditorPart getParentEditor()
Gets the multipage editor to which this sql editor belongs

Parameters:
editor -

setParentEditor

public void setParentEditor(org.eclipse.ui.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.

Specified by:
doRevertToSaved in interface org.eclipse.ui.texteditor.ITextEditor
Overrides:
doRevertToSaved in class org.eclipse.ui.texteditor.StatusTextEditor
See Also:
ITextEditor.doRevertToSaved()

doSave

public void doSave(org.eclipse.core.runtime.IProgressMonitor monitor)
Saves the content of this editor.

Specified by:
doSave in interface org.eclipse.ui.ISaveablePart
Overrides:
doSave in class org.eclipse.ui.texteditor.AbstractTextEditor
Parameters:
progressMonitor - the progress monitor for communicating result state or null
See Also:
ISaveablePart.doSave(org.eclipse.core.runtime.IProgressMonitor)

doSaveAs

public void doSaveAs()
Saves the contents of this editor to another object.

Specified by:
doSaveAs in interface org.eclipse.ui.ISaveablePart
Overrides:
doSaveAs in class org.eclipse.ui.texteditor.AbstractTextEditor
See Also:
ISaveablePart.doSaveAs()

doSetInput

public void doSetInput(org.eclipse.ui.IEditorInput input)
                throws org.eclipse.core.runtime.CoreException
Sets the input of the outline page after this class has set input.

Overrides:
doSetInput in class org.eclipse.ui.editors.text.TextEditor
Parameters:
input - the new input for the editor
Throws:
org.eclipse.core.runtime.CoreException
See Also:
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.

Specified by:
getAdapter in interface org.eclipse.core.runtime.IAdaptable
Overrides:
getAdapter in class org.eclipse.ui.editors.text.TextEditor
See Also:
IAdaptable.getAdapter(java.lang.Class), 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(org.eclipse.jface.util.PropertyChangeEvent event)
Handles notifications to the object that a property has changed.

Specified by:
propertyChange in interface org.eclipse.jface.util.IPropertyChangeListener
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.


setFocus

public void setFocus()
Asks this part to take focus within the workbench.

Specified by:
setFocus in interface org.eclipse.ui.IWorkbenchPart
Overrides:
setFocus in class org.eclipse.ui.texteditor.AbstractTextEditor
See Also:
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 org.eclipse.jface.text.source.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)
Parameters:
node - the new parsing 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()
Specified by:
getOrientation in interface org.eclipse.ui.part.IWorkbenchPartOrientation
Overrides:
getOrientation in class org.eclipse.ui.part.WorkbenchPart

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 org.eclipse.datatools.sqltools.core.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:

gotoMatchingToken

public void gotoMatchingToken()
Going to matching token.