From: <bc...@wo...> - 2000-12-04 23:15:10
|
[Boudewijn Rempt] >I've got the console working - even if I still have to hack Actions.py >to be able to switch back to strong security, so now I've started to >integrate my application interface in the console. However, this is a >first for me, and I'm not an experienced Java developer, so I wanted to >ask you all to look at my solution, and give criticism (like: this is >a hack! It's unsupported! Don't do it! ;-). I hope you can make use of: This is cool! It is intended to used this way! Just do it! >What I've done is this: > >All functionality to the core application goes via an adapter. There's >already a Swing gui, so that was easy. > >I've added an extra parameter to the constructor of the console, where >I put the adapter object: > >class Console (Object): > def __init__(self, adapter=None, adapterName=""): > "@sig public Console(Object adapter, java.lang.String adapterName)" > self.locals = {} > if adapter!=None: > self.locals[adapterName]=adapter > >I've given the signature Object, so I can reuse the console for other >adapters - this is the point where I'm not sure. If you take a look at at org/python/util/PythonInterpreter and its set() method you will see that it too takes an Object as a generic value. public void set(String name, Object value) { ... } This method is solving exactly the same problem of setting a local variable in a python namespace. >I can access the >interface from the Jython prompt, that's true. > >From Java I call it like this: > > Console console=new Console(managementGuiAdapter, "managementAdapter"); > JScrollPane pane=new JScrollPane(console.getTextPane()); > console.write("Tryllian AFC 1.5 Habitat Management Console\n" + > "Uses Jython technology.\n" > ,"output"); > console.capturePythonOutput(); > console.getTextPane().requestFocus(); > console.newInput(); > getContentPane().add(pane); > >And everything seems nice - but is it, really? Yes. Very nice. regards, finn |