def __makeModule(name, code, path): module = _imp.addModule(name) builtins = _Py.getSystemState().builtins frame = _Frame(code, module.__dict__, module.__dict__, builtins) module.__file__ = path code.call(frame) # execute module code return module
def createMindMap( self ): import org.python.core.Py as Py system_state = Py.getSystemState() sscl = system_state.getClassLoader() try: try: ccl = java.lang.Thread.currentThread().getContextClassLoader() cpath = java.lang.System.getProperty( "java.class.path" ) import leoFreeMindView #Each of these 3 calls play a pivotal role in loading the system java.lang.System.setProperty( "java.class.path", "" ) java.lang.Thread.currentThread().setContextClassLoader( leoFreeMindView.mmcl ) system_state.setClassLoader( leoFreeMindView.mmcl ) self.mm = leoFreeMindView.mindmap( self.c ) self.mindmap = self.mm.mindmapview ml = MListener( self.mm._free_leo_mind.updateMenus ) self.mm._free_leo_mind.getMainMenu().addMenuListener( ml ) except java.lang.Exception, x: x.printStackTrace() swing.JOptionPane.showMessageDialog( None, "Cant Load MindMap View." ) finally: java.lang.System.setProperty( "java.class.path", cpath ) java.lang.Thread.currentThread().setContextClassLoader( ccl ) system_state.setClassLoader( sscl )
def getSystemState(self): from org.python.core import Py if not self.realInterp: return Py.getSystemState() return self.realInterp.getSystemState()
proppath = g.os_path_join( g.app.loadDir, "..", "plugins", "spellingdicts", "which.txt") #we start to determine which dictionary to use fis = io.FileInputStream(io.File(proppath)) properties = util.Properties() properties.load(fis) fis.close() fis = None lfile = properties.getProperty("dict") dpath = g.os_path_join(g.app.loadDir, "..", "plugins", "spellingdicts", lfile) dictionary = SpellDictionaryHashMap(io.File(dpath)) import org.python.core.Py as Py #now we descend into the Jython internals... sstate = Py.getSystemState() cloader = sstate.getClassLoader() sstate.setClassLoader( clb2 ) #we do this so the JyLeoSpellChecker class can implement SpellCheckListener, otherwise it fails except java.lang.Exception: load_ok = False if load_ok: #@ <<JyLeoSpellChecker>> #@+node:zorcanda!.20051111215311.1:<<JyLeoSpellChecker>> class JyLeoSpellChecker(SpellCheckListener): def __init__(self, editor): self.c = editor.c self.editor = editor.editor
def getSystemState(self): if not self.realInterp: return Py.getSystemState() return self.realInterp.getSystemState()
clb2.importClass( "SpellDictionaryHashMap", "com.swabunga.spell.engine.SpellDictionaryHashMap" ) #clb2.importClass( "SpellDictionaryCachedDichoDisk", "com.swabunga.spell.engine.SpellDictionaryCachedDichoDisk" ) clb2.importClass( "StringWordTokenizer", "com.swabunga.spell.event.StringWordTokenizer" ) proppath = g.os_path_join( g.app.loadDir, "..", "plugins", "spellingdicts", "which.txt" ) #we start to determine which dictionary to use fis = io.FileInputStream( io.File( proppath ) ) properties = util.Properties() properties.load( fis ) fis.close() fis = None lfile = properties.getProperty( "dict" ) dpath = g.os_path_join( g.app.loadDir, "..", "plugins", "spellingdicts", lfile ) dictionary = SpellDictionaryHashMap( io.File( dpath ) ) import org.python.core.Py as Py #now we descend into the Jython internals... sstate = Py.getSystemState() cloader = sstate.getClassLoader() sstate.setClassLoader( clb2 )#we do this so the JyLeoSpellChecker class can implement SpellCheckListener, otherwise it fails except java.lang.Exception: load_ok = False if load_ok: #@ <<JyLeoSpellChecker>> #@+node:zorcanda!.20051111215311.1:<<JyLeoSpellChecker>> class JyLeoSpellChecker( SpellCheckListener ): def __init__( self, editor ): self.c = editor.c self.editor = editor.editor self.foldprotection = editor.foldprotection