forked from tudor-malene/Easygrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEasygridGrailsPlugin.groovy
More file actions
82 lines (62 loc) · 3.01 KB
/
EasygridGrailsPlugin.groovy
File metadata and controls
82 lines (62 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import grails.util.Environment
import org.codehaus.groovy.grails.commons.GrailsApplication
import org.grails.plugin.easygrid.EasygridInitService
import org.grails.plugin.easygrid.JsUtils
class EasygridGrailsPlugin {
def version = "1.6.5"
def grailsVersion = "2.2 > *"
def loadAfter = ['services', 'controllers']
def pluginExcludes = [
'grails-app/controllers/org/grails/plugin/easygrid/TestDomainController.groovy',
'grails-app/domain/org/grails/plugin/easygrid/TestDomain.groovy',
'grails-app/domain/org/grails/plugin/easygrid/OwnerTest.groovy',
'grails-app/domain/org/grails/plugin/easygrid/PetTest.groovy',
'grails-app/services/org/grails/plugin/easygrid/grids/TestGridService.groovy',
'grails-app/views/templates/easygrid/_testGridRenderer.gsp',
]
// def dependsOn = [
// 'jquery-ui': "1.8.14 > *"
// ]
//the location of external grids config - to enable reloading
def watchedResources = "file:./src/groovy/grids/**/*.groovy"
def observe = ["controllers", "services"]
def title = "Easygrid Plugin"
def author = "Tudor Malene"
def authorEmail = "tudor.malene@gmail.com"
def description = '''
Provides a declarative way of defining Data Grids.
It works currently with jqGrid, google visualization and jquery dataTables.
Out of the box it provides sorting, filtering, exporting and inline edit just by declaring a grid in a controller and adding a tag to your gsp.
It also provides a powerful selection widget ( a direct replacement for drop-boxes )
'''
def documentation = "https://github.com/tudor-malene/Easygrid"
def license = "APACHE"
def issueManagement = [system: "GITHUB", url: "https://github.com/tudor-malene/Easygrid/issues"]
def scm = [url: "https://github.com/tudor-malene/Easygrid"]
def doWithDynamicMethods = { ctx ->
}
def doWithSpring = {
loadEasygridConfig(application)
}
def onChange = { event ->
event.ctx.getBean(EasygridInitService).initializeGrids()
}
def doWithApplicationContext = { appCtx ->
JsUtils.registerMarshallers()
appCtx.getBean(EasygridInitService).initializeGrids()
}
private ConfigObject loadEasygridConfig(GrailsApplication grailsApplication) {
def config = grailsApplication.config
GroovyClassLoader classLoader = new GroovyClassLoader(getClass().classLoader)
// Merging default Easygrid config into main application config
config.merge(new ConfigSlurper(Environment.current.name).parse(classLoader.loadClass('DefaultEasygridConfig')))
// Merging user-defined Easygrid config into main application config if provided
try {
config.merge(new ConfigSlurper(Environment.current.name).parse(classLoader.loadClass('EasygridConfig')))
} catch (any) {
println 'Could not process the EasygridConfig file '
// ignore, just use the defaults
}
return config
}
}