## org.eclipse.datatools.sqltools.sqlbuilder
Class SQLBuilder

    java.lang.Object
      org.eclipse.datatools.sqltools.sqlbuilder.SQLBuilder

All Implemented Interfaces:
  java.util.Observer, IContentChangeListener, org.eclipse.emf.edit.domain.IEditingDomainProvider, org.eclipse.jface.action.IMenuListener

    public class SQLBuilder

extends java.lang.Object
implements org.eclipse.emf.edit.domain.IEditingDomainProvider, java.util.Observer, IContentChangeListener, org.eclipse.jface.action.IMenuListener

UI Component of SQL Query Builder content editor. This can be hosted in an editor (e.g. `SQLBuilderEditor`) or a dialog.

Constructor Summary
`SQLBuilder()` Constructor for `SQLBuilder`.
`SQLBuilder(org.eclipse.ui.IEditorPart ed)` Constructor for `SQLBuilder`.

Method Summary
`void` `addContentChangeListener(IContentChangeListener listener)`
`void` `addExecuteSQLListener(IExecuteSQLListener listener)`
`void` `changeStatementType(int statementType)` Changes the statement type in the SQLBuilder by using the statement template for the specified type.
`void` `connectIfNeeded(org.eclipse.ui.IWorkbenchPart part)` Tries to make sure that we have a database connection so that the SQL model will be populated when we need it.
`void` `createClient(org.eclipse.swt.widgets.Composite parent)` Creates the UI component for the `SQLBuilder`.
`org.eclipse.jface.action.MenuManager` `createContextMenuFor(org.eclipse.jface.viewers.Viewer viewer)` Creates context menu for a viewer.
`void` `doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor)` Saves the current statement in the file resource associated with this `SQLBuilder`.
`SQLBuilderActionBarContributor` `getActionBarContributor()` Returns the `SQLBuilderActionBarContributor` belonging to this `SQLBuilder`.
`ISQLEditorConnectionInfo` `getConnectionInfo()` Gets the `ISQLEditorConnectionInfo` object associated with this SQLBuilder's statement.
`org.eclipse.ui.views.contentoutline.IContentOutlinePage` `getContentOutlinePage(org.eclipse.swt.widgets.Composite composite)` Returns the content outline page.
`DesignViewer` `getDesignViewer()` Returns the DesignViewer.
`SQLDomainModel` `getDomainModel()` Returns the `SQLDomainModel` belonging to this `SQLBuilder`.
`org.eclipse.emf.edit.domain.EditingDomain` `getEditingDomain()` Returns the `EditingDomain` belonging to this `SQLBuilder`
`ISQLBuilderEditorInputUsageOptions` `getEditorInputUsageOptions()` Returns the current editorInputusageOptions of the `SQLBuilder`.
`org.eclipse.core.resources.IFile` `getFile()` Returns the `IFile` belonging to this `SQLBuilder`, which may be null.
`GraphControl` `getGraphViewer()` Returns the GraphViewer.
`IOmitSchemaInfo` `getOmitSchemaInfo()` Gets the `OmitSchemaInfo` object associated with this statement
`SQLSourceViewer` `getSourceViewer()` Returns the SourceViewer.
`java.lang.String` `getSQL()`
`ISQLBuilderEditorInput` `getSQLBuilderEditorInput()` Returns the `ISQLBuilderEditorInput` belonging to this `SQLBuilder`.
`SQLTreeViewer` `getSQLTreeViewer()` Returns the SQLTreeViewer.
`IWindowStateInfo` `getWindowStateInfo()` Returns the current window state of the `SQLBuilder`.
`void` `handleContentOutlineSelection(org.eclipse.jface.viewers.ISelection selection, boolean fromEvent)` This deals with how we want selection in the outliner to affect the other views.
`boolean` `inValidateEditCall()` Returns whether the `SQLBuilder` is currently validating the SQL.
`boolean` `isContentOutlineRootSelected()` Returns whether the root of the content outline view is selected.
`boolean` `isDirty()` Returns whether the contents of this `SQLBuilder` have changed since the last save operation.
`static boolean` `isStatementProper(SQLDomainModel domainModel)` Tests whether the current SQL is valid.
`void` `menuAboutToShow(org.eclipse.jface.action.IMenuManager menuManager)`
`void` `notifyContentChange()` Called when content has changed.
`void` `notifySQLExecuted()` Called when SQL statement has been executed.
`void` `reloadFromModel()` Reloads the SourceViewer from the SQL Model.
`void` `removeContentChangeListener(IContentChangeListener listener)`
`void` `removeExecuteSQLListener(IExecuteSQLListener listener)`
`void` `reparseIfRequired()` Reparses the SQL in the SourceViewer if it has changed.
`void` `saveOmitSchemaInfo(org.eclipse.core.resources.IFile file)` Saves the current OmitSchemaInfo for IFile parameter
`void` `setActionBarContributor(SQLBuilderActionBarContributor contributor)` Sets the `SQLBuilderActionBarContributor` for this `SQLBuilder`.
`void` `setDirty(boolean dirty)` Marks this SQLBuilder's statement as "dirty" (has unsaved changes).
`void` `setInput(ISQLBuilderEditorInput sqlBuilderEditorInput)` Sets the input for the `SQLBuilder`.
`void` `setLoadOnConnection(boolean loadOnConnection)` Tells the SQLBuilder to load the input SQL only after a database connection has been obtained.
`void` `update(java.util.Observable ob, java.lang.Object arg)` Implementation of Observer interface.
`void` `updateProperStatement(boolean isValid)` Enables / disables SQLBuilder controls and actions depending on whether the current SQL is valid or not.

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

Constructor Detail

### SQLBuilder

    public SQLBuilder()

  Constructor for `SQLBuilder`. This constructor should be called when a component other than an editor is being created.

### SQLBuilder

    public SQLBuilder(org.eclipse.ui.IEditorPart ed)

  Constructor for `SQLBuilder`. This constructor should be called when an Editor is being created.

  Parameters:
    `ed` - the editor that is creating this `SQLBuilder`.

Method Detail

### addContentChangeListener

    public void addContentChangeListener(IContentChangeListener listener)

### removeContentChangeListener

    public void removeContentChangeListener(IContentChangeListener listener)

### addExecuteSQLListener

    public void addExecuteSQLListener(IExecuteSQLListener listener)

### removeExecuteSQLListener

    public void removeExecuteSQLListener(IExecuteSQLListener listener)

### createClient

    public void createClient(org.eclipse.swt.widgets.Composite parent)

  Creates the UI component for the `SQLBuilder`. This method should be called after `setInput(ISQLBuilderEditorInput)`.

  Parameters:
    `parent` - the parent composite.

### setLoadOnConnection

    public void setLoadOnConnection(boolean loadOnConnection)

  Tells the SQLBuilder to load the input SQL only after a database connection has been obtained.

### setInput

    public void setInput(ISQLBuilderEditorInput sqlBuilderEditorInput)
                  throws org.eclipse.ui.PartInitException,
                         ParseException

  Sets the input for the `SQLBuilder`. This method should be called before `createClient(Composite)`. The `waitForConnection` parameter indicates that the SQLBuilder should delay opening the input until a connection to the database has been obtained.

  Parameters:
    `sqlBuilderEditorInput` -
    `bWaitForConnection` -
  Throws:
    `org.eclipse.ui.PartInitException`
    `ParseException`

### saveOmitSchemaInfo

    public void saveOmitSchemaInfo(org.eclipse.core.resources.IFile file)

  Saves the current OmitSchemaInfo for IFile parameter

### getSourceViewer

    public SQLSourceViewer getSourceViewer()

  Returns the SourceViewer.

  Returns:
    SQLSourceViewer the SourceViewer.

### getGraphViewer

    public GraphControl getGraphViewer()

  Returns the GraphViewer.

  Returns:
    GraphControl the GraphViewer.

### getDesignViewer

    public DesignViewer getDesignViewer()

  Returns the DesignViewer.

  Returns:
    DesignViewer the DesignViewer.

### getSQLTreeViewer

    public SQLTreeViewer getSQLTreeViewer()

  Returns the SQLTreeViewer.

  Returns:
    SQLTreeViewer the SQLTreeViewer.

### getContentOutlinePage

    public org.eclipse.ui.views.contentoutline.IContentOutlinePage getContentOutlinePage(org.eclipse.swt.widgets.Composite composite)

  Returns the content outline page.

  Returns:
    IContentOutlinePage the content outline page.

### handleContentOutlineSelection

    public void handleContentOutlineSelection(org.eclipse.jface.viewers.ISelection selection,
                                              boolean fromEvent)

  This deals with how we want selection in the outliner to affect the other views.

  Parameters:
    `selection` - selection passed to `handleContentOutlineSelection`.
    `fromEvent` - not used.

### isContentOutlineRootSelected

    public boolean isContentOutlineRootSelected()

  Returns whether the root of the content outline view is selected.

  Returns:
    boolean true if the root is selected, otherwise false.

### changeStatementType

    public void changeStatementType(int statementType)

  Changes the statement type in the SQLBuilder by using the statement template for the specified type. Statement type must be a constant from the StatementHelper class

  Parameters:
    `statementType` -

### updateProperStatement

    public void updateProperStatement(boolean isValid)

  Enables / disables SQLBuilder controls and actions depending on whether the current SQL is valid or not.

  Parameters:
    `isValid` - whether the current SQL is valid.

### isStatementProper

    public static boolean isStatementProper(SQLDomainModel domainModel)

  Tests whether the current SQL is valid.

  Parameters:
    `domainModel` - the domain model for the SQL.
  Returns:
    boolean true if the SQL is valid, otherwise false.

### reparseIfRequired

    public void reparseIfRequired()

  Reparses the SQL in the SourceViewer if it has changed.

### reloadFromModel

    public void reloadFromModel()

  Reloads the SourceViewer from the SQL Model.

### getEditingDomain

    public org.eclipse.emf.edit.domain.EditingDomain getEditingDomain()

  Returns the `EditingDomain` belonging to this `SQLBuilder`

  Specified by:
    `getEditingDomain` in interface `org.eclipse.emf.edit.domain.IEditingDomainProvider`

### update

    public void update(java.util.Observable ob,
                       java.lang.Object arg)

  Implementation of Observer interface. This method is called when user changes the omit schema settings.

  Specified by:
    `update` in interface `java.util.Observer`
  Parameters:
    `ob` - the object calling this method
    `arg` - the argument passed to the notifyObservers method

### getDomainModel

    public SQLDomainModel getDomainModel()

  Returns the `SQLDomainModel` belonging to this `SQLBuilder`.

### getSQLBuilderEditorInput

    public ISQLBuilderEditorInput getSQLBuilderEditorInput()

  Returns the `ISQLBuilderEditorInput` belonging to this `SQLBuilder`.

### getEditorInputUsageOptions

    public ISQLBuilderEditorInputUsageOptions getEditorInputUsageOptions()

  Returns the current editorInputusageOptions of the `SQLBuilder`.

  Returns:

### getFile

    public org.eclipse.core.resources.IFile getFile()

  Returns the `IFile` belonging to this `SQLBuilder`, which may be null.

### inValidateEditCall

    public boolean inValidateEditCall()

  Returns whether the `SQLBuilder` is currently validating the SQL.

### getActionBarContributor

    public SQLBuilderActionBarContributor getActionBarContributor()

  Returns the `SQLBuilderActionBarContributor` belonging to this `SQLBuilder`.

### setActionBarContributor

    public void setActionBarContributor(SQLBuilderActionBarContributor contributor)

  Sets the `SQLBuilderActionBarContributor` for this `SQLBuilder`.

### doSave

    public void doSave(org.eclipse.core.runtime.IProgressMonitor progressMonitor)

  Saves the current statement in the file resource associated with this `SQLBuilder`. This method should be called by editors which consume the `SQLBuilder`. If the SQLBuilder has an input which is not file based, the SQL is not saved. In this case, it is the responsibility of the consumer of the `SQLBuilder` to save the SQL.

  Parameters:
    `progressMonitor` - progressMonitor used during save.

### isDirty

    public boolean isDirty()

  Returns whether the contents of this `SQLBuilder` have changed since the last save operation.

  Returns:
    `true` if the contents have been modified and need saving, and `false` if they have not changed since the last save

### setDirty

    public void setDirty(boolean dirty)

  Marks this SQLBuilder's statement as "dirty" (has unsaved changes).

  Parameters:
    `dirty` - true when there are unsaved changes, otherwise false

### getWindowStateInfo

    public IWindowStateInfo getWindowStateInfo()

  Returns the current window state of the `SQLBuilder`.

  Returns:

### notifyContentChange

    public void notifyContentChange()

  Called when content has changed. This can be a change to the SQL or the OmitSchemaInfo.

  Specified by:
    `notifyContentChange` in interface `IContentChangeListener`
  See Also:
    `IContentChangeListener.notifyContentChange()`

### notifySQLExecuted

    public void notifySQLExecuted()

  Called when SQL statement has been executed.

### menuAboutToShow

    public void menuAboutToShow(org.eclipse.jface.action.IMenuManager menuManager)

  Specified by:
    `menuAboutToShow` in interface `org.eclipse.jface.action.IMenuListener`
  See Also:
    `IMenuListener.menuAboutToShow(IMenuManager)`

### createContextMenuFor

    public org.eclipse.jface.action.MenuManager createContextMenuFor(org.eclipse.jface.viewers.Viewer viewer)

  Creates context menu for a viewer.

  Parameters:
    `viewer` - the viewer.
  Returns:
    MenuManager the context menu created.

### getSQL

    public java.lang.String getSQL()

### getConnectionInfo

    public ISQLEditorConnectionInfo getConnectionInfo()

  Gets the `ISQLEditorConnectionInfo` object associated with this SQLBuilder's statement.

  Returns:
    ISQLEditorConnectionInfo the SQLBuilder's SQLEditorConnectionInfo object.

### getOmitSchemaInfo

    public IOmitSchemaInfo getOmitSchemaInfo()

  Gets the `OmitSchemaInfo` object associated with this statement

  Returns:
    OmitSchemaInfo the SQLBuilder's OmitSchemaInfo object.

### connectIfNeeded

    public void connectIfNeeded(org.eclipse.ui.IWorkbenchPart part)

  Tries to make sure that we have a database connection so that the SQL model will be populated when we need it. This allows us to delay connecting so that the user won't get prompted when the Workbench is coming up. This function should be called by editors based on SQLBuilder when the Workbench opens with the editor having been open when the workbench last closed.