_plugin = plugin;
}
public void execute() throws BaseException
{
ISQLPanelAPI api = FrameWorkAcessor.getSQLPanelAPI(_session, _plugin);
int[] bounds = api.getSQLEntryPanel().getBoundsOfSQLToBeExecuted();
if(bounds[0] == bounds[1])
{
return;
}
String textToReformat = api.getSQLEntryPanel().getSQLToBeExecuted();
if (null == textToReformat)
{
return;
}
CommentSpec[] commentSpecs =
new CommentSpec[]
{
new CommentSpec("/*", "*/"),
new CommentSpec("--", StringUtilities.getEolStr())
};
String statementSep = _session.getQueryTokenizer().getSQLStatementSeparator();
CodeReformator cr = new CodeReformator(statementSep, commentSpecs);
String reformatedText = cr.reformat(textToReformat);
api.getSQLEntryPanel().setSelectionStart(bounds[0]);
api.getSQLEntryPanel().setSelectionEnd(bounds[1]);
api.getSQLEntryPanel().replaceSelection(reformatedText);
}