-
-
Save tyama/2348225 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab('com.gmongo:gmongo:0.9.5') | |
@GrabConfig(systemClassLoader=true) | |
import com.gmongo.GMongo | |
import com.mongodb.* | |
import javax.swing.UIManager | |
import groovy.ui.Console | |
import org.codehaus.groovy.control.CompilerConfiguration | |
import org.codehaus.groovy.control.customizers.ImportCustomizer | |
import groovy.transform.* | |
def mongoMenu = { | |
menu('Mongo') { | |
menu('Templates') { | |
menuItem('group') | |
} | |
} | |
} | |
Console.metaClass.newScript = { ClassLoader parent, Binding binding -> | |
def config = new CompilerConfiguration() | |
def importCustomizer = new ImportCustomizer() | |
importCustomizer.addImports('com.gmongo.GMongo') | |
config.addCompilationCustomizers(importCustomizer) | |
binding.mongo = new GMongo() | |
delegate.shell = new GroovyShell(parent, binding, config) | |
} | |
UIManager.lookAndFeel = UIManager.systemLookAndFeelClassName | |
new Console(Console.class.classLoader.getRootLoader()).run( | |
Console.frameConsoleDelegates << [menuBarDelegate: {arg-> | |
current.JMenuBar = build(arg) | |
current.JMenuBar.add(build(mongoMenu)) | |
}] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment