net.sourceforge.squirrel_sql.plugins.refactoring.commands
Class AbstractRefactoringCommand

java.lang.Object
  extended by net.sourceforge.squirrel_sql.plugins.refactoring.commands.AbstractRefactoringCommand
All Implemented Interfaces:
ICommand
Direct Known Subclasses:
AddAutoIncrementCommand, AddColumnCommand, AddForeignKeyCommand, AddIndexCommand, AddLookupTableCommand, AddPrimaryKeyCommand, AddSequenceCommand, AddUniqueConstraintCommand, AddViewCommand, DropColumnCommand, DropForeignKeyCommand, DropIndexTableCommand, DropPrimaryKeyCommand, DropSequenceCommand, DropTablesCommand, DropUniqueConstraintCommand, DropViewCommand, MergeColumnCommand, MergeTableCommand, ModifyColumnCommand, ModifySequenceCommand, RenameTableCommand, RenameViewCommand

public abstract class AbstractRefactoringCommand
extends Object
implements ICommand


Nested Class Summary
protected  class AbstractRefactoringCommand.CommandExecHandler
           
protected  class AbstractRefactoringCommand.EditSQLListener
          An ActionListener for the Edit SQL button that appends the sql statement to the sql panel, disposes the specified dialog and switches to the sql panel.
protected  class AbstractRefactoringCommand.ExecuteListener
          An ActionListener for the Execute button that delegates the execution of the sql statement to the subclass.
protected  class AbstractRefactoringCommand.ShowSQLListener
          An ActionListener for the Show SQL button that opens the sql statement in a dialog.
 
Field Summary
protected  HibernateDialect _dialect
          HibernateDialect to use for this refactoring.
protected  IDatabaseObjectInfo[] _info
          Selected database object(s)
protected  DatabaseObjectQualifier _qualifier
          qualifier object to use in qualifying identifiers.
protected  ISession _session
          Current session
protected  SqlGenerationPreferences _sqlPrefs
          User preferences regarding the generation of SQL scripts.
 
Constructor Summary
AbstractRefactoringCommand(ISession session, IDatabaseObjectInfo[] info)
           
 
Method Summary
 void execute()
          Does general execution work that every refactoring command needs (e.g.
protected abstract  void executeScript(String script)
          The subclass should implement this so that the ExecuteListener can delegate the execution of the sql script to the subclass.
protected abstract  String[] generateSQLStatements()
          The subclass should implement this so that getSQLStatements can generate the actual statements.
protected  void getSQLStatements(SQLResultListener listener)
          Adds a new task to the ThreadPool that generates the SQL statements and notifies the listener when the statements were successfully generated.
protected abstract  boolean isRefactoringSupportedForDialect(HibernateDialect dialectExt)
          Returns a boolean value indicating whether or not this refactoring is supported for the specified dialect.
protected abstract  void onExecute()
          The subclass should implement this method with it's refactoring specific execution code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_session

protected final ISession _session
Current session


_info

protected final IDatabaseObjectInfo[] _info
Selected database object(s)


_dialect

protected HibernateDialect _dialect
HibernateDialect to use for this refactoring.


_sqlPrefs

protected final SqlGenerationPreferences _sqlPrefs
User preferences regarding the generation of SQL scripts.


_qualifier

protected final DatabaseObjectQualifier _qualifier
qualifier object to use in qualifying identifiers.

Constructor Detail

AbstractRefactoringCommand

public AbstractRefactoringCommand(ISession session,
                                  IDatabaseObjectInfo[] info)
Method Detail

execute

public void execute()
Does general execution work that every refactoring command needs (e.g. HibernateDialect) and then calls the onExecute method for the subclass's specific execution implementation.

Specified by:
execute in interface ICommand

isRefactoringSupportedForDialect

protected abstract boolean isRefactoringSupportedForDialect(HibernateDialect dialectExt)
Returns a boolean value indicating whether or not this refactoring is supported for the specified dialect.

Parameters:
dialectExt - the HibernateDialect to check
Returns:
true if this refactoring is supported; false otherwise.

onExecute

protected abstract void onExecute()
                           throws Exception
The subclass should implement this method with it's refactoring specific execution code.

Throws:
Exception - if something goes wrong while executing the command

generateSQLStatements

protected abstract String[] generateSQLStatements()
                                           throws Exception
The subclass should implement this so that getSQLStatements can generate the actual statements.

Returns:
the sql statements
Throws:
Exception - if something goes wrong while generating the sql statements

getSQLStatements

protected void getSQLStatements(SQLResultListener listener)
Adds a new task to the ThreadPool that generates the SQL statements and notifies the listener when the statements were successfully generated.

Parameters:
listener - the listener to notify when the statments are ready

executeScript

protected abstract void executeScript(String script)
The subclass should implement this so that the ExecuteListener can delegate the execution of the sql script to the subclass.

Parameters:
script - the sql script that should be executed


Copyright © 2001-2010. All Rights Reserved.