org.eclipse.datatools.sqltools.schemaobjecteditor.ui.internal.ui
Class SQLSourceViewerService

java.lang.Object
  extended by org.eclipse.datatools.sqltools.schemaobjecteditor.ui.internal.ui.SQLSourceViewerService
All Implemented Interfaces:
ISQLSourceViewerService

public class SQLSourceViewerService
extends java.lang.Object
implements ISQLSourceViewerService

This is a common implementation of ISQLSourceViewerService . In this implementation, the document is divided into following partitions:

  • SQL code
  • SQL single line comment
  • SQL muli-line comment
  • SQL String
  • SQL double quoted identifier

    If user wants to support other partitions, user needs to subclass ISQLSourceViewerService directly and implement the method: setUpDocument().

    Author:
    Shi-feng Yu

    Constructor Summary
    SQLSourceViewerService()
               
     
    Method Summary
     void setUpDocument(org.eclipse.jface.text.IDocument document, java.lang.String dbType)
              This method is used for user to customize the document setting.
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    SQLSourceViewerService

    public SQLSourceViewerService()
    Method Detail

    setUpDocument

    public void setUpDocument(org.eclipse.jface.text.IDocument document,
                              java.lang.String dbType)
    Description copied from interface: ISQLSourceViewerService
    This method is used for user to customize the document setting.

    The document used by SQLStatementArea needs a PartitionSanner and Partitioner to compute the partitions. Through this method, user can set up customized PartitionSanner with customized rules.

    Sample code for setting up a document

     XXXPartitionScanner _xxxPartitionSanner = new XXXPartitionScanner();
       _xxxPartitionSanner.setCommentsScanner(SQLToolsFacade.getSQLSyntax(dbType));
       if (document instanceof IDocumentExtension3)
       {
           IDocumentExtension3 extension3 = (IDocumentExtension3) document;
           FastPartitioner _partitioner = new FastPartitioner(_sqlPartitionSanner, new String[]
           {
               XXXPartitionScanner.SQL_CODE, XXXPartitionScanner.SQL_COMMENT,
               XXXPartitionScanner.SQL_MULTILINE_COMMENT, XXXPartitionScanner.SQL_STRING,
               XXXPartitionScanner.SQL_DOUBLE_QUOTES_IDENTIFIER
           });
           _partitioner.connect(document);
           extension3.setDocumentPartitioner(ISQLPartitions.SQL_PARTITIONING, _partitioner);
       }
     

    Specified by:
    setUpDocument in interface ISQLSourceViewerService
    Parameters:
    document - the Document to be set up
    dbType - the Database type of the SQL Statement which is contained in the Document.