01: package com.vividsolutions.jump.workbench.ui.plugin;
02:
03: import java.awt.BorderLayout;
04: import java.awt.Dimension;
05: import java.io.PrintStream;
06: import java.io.Reader;
07: import bsh.ConsoleInterface;
08: import bsh.EvalError;
09: import bsh.Interpreter;
10: import bsh.util.JConsole;
11:
12: import com.vividsolutions.jump.I18N;
13: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
14: import com.vividsolutions.jump.workbench.ui.MenuNames;
15: import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxDialog;
16: import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxPlugIn;
17:
18: public class BeanShellPlugIn extends ToolboxPlugIn {
19: public void initialize(PlugInContext context) throws Exception {
20: // [Michael Michaud 2007-03-23]
21: // Moves MenuNames.TOOLS/MenuNames.TOOLS_PROGRAMMING to MenuNames.CUSTOMIZE
22: createMainMenuItem(new String[] { MenuNames.CUSTOMIZE }, null,
23: context.getWorkbenchContext());
24: }
25:
26: public String getName() {
27: // [Michael Michaud 2007-03-23] Rename BeanShell to BeanShell Console to differentiate
28: // from BeanShell scripts menus
29: return "BeanShell Console";
30: }
31:
32: protected void initializeToolbox(ToolboxDialog toolbox) {
33: try {
34: final JConsole console = new JConsole();
35: console.setPreferredSize(new Dimension(430, 240));
36: console
37: .print(I18N
38: .get("ui.plugin.BeanShellPlugIn.the-workbenchcontext-may-be-referred-to-as-wc"));
39: console
40: .print(I18N
41: .get("ui.plugin.BeanShellPlugIn.warning-pasting-in-multiple-statements-may-cause-the-application-to-freeze"));
42: toolbox.getCenterPanel().add(console, BorderLayout.CENTER);
43: Interpreter interpreter = new Interpreter(console);
44: interpreter
45: .setClassLoader(toolbox.getContext().getWorkbench()
46: .getPlugInManager().getClassLoader());
47: interpreter.set("wc", toolbox.getContext());
48: interpreter.eval("setAccessibility(true)");
49: interpreter.eval("import com.vividsolutions.jts.geom.*");
50: interpreter
51: .eval("import com.vividsolutions.jump.feature.*");
52: new Thread(interpreter).start();
53: } catch (EvalError e) {
54: toolbox.getContext().getErrorHandler().handleThrowable(e);
55: }
56: }
57: }
|