CodeEditor Exec tool
March 25, 2009 at 10:57 pm Leave a comment
In Grails there are two main environments which are development and production. Development mode is able to reload changes dynamically but it is slow when it is compared with production mode since for every file it checks whether it has changed or not. Therefore, most commonly a real life applications will be deployed in production mode. If this is correct why do we need CodeEditor? For this purpose (To make CodeEditor a benefical tool for users
) I decided to add capability to add actions to reload selective parts of application such as controllers, views, filters and etc. Action can be added and configured from CodeEditorActionService and the visibility of each of this tool from ui will be dependent configuration of the tools in the configuration section of the service. In configuration section user will be able to add tools and should specify displayName of the tool and the regular expression which will be evaluated by javascript code to find files which this tool will be shown.
As an example scenario think that you changed the code of controller and you want to apply this change to application. The only thing you should do is that executing Reload Controllers from Exec menu (See below image). The current file name will be passed to CodeEditorActionService corresponding tool method and since I developed reloading controllers, the change you made to controller will be loaded.

public class CodeEditorActionService
{
boolean transactional = false
def actionConfigurationMap = [
reloadControllers:[displayName:"Reload Controllers", filters:[".*controllers/.*\\.groovy"]],
reloadFilters:[displayName:"Reload Filters", filters:[".*/grails-app/conf/.*Filters\\.groovy"]],
reloadViews:[displayName:"Reload Views", filters:[".*\\.gsp"]]
]
def reloadControllers(params){
PluginManagerHolder.getPluginManager().getGrailsPlugin("controllers").checkForChanges()
}
def reloadFilters(params){
PluginManagerHolder.getPluginManager().getGrailsPlugin("filters").checkForChanges()
}
def reloadViews(params){
GroovyPagesTemplateEngine.pageCache.clear();
}
}
Entry filed under: CodeEditor. Tags: CodeEditor, Grails, ide, plugin.
Trackback this post | Subscribe to the comments via RSS Feed