/* XXX Workaround to configure jsyntaxpane */
JEditorPane e = new JEditorPane();
new JScrollPane(e);
e.setContentType("text/javascript");
if (e.getEditorKit() instanceof DefaultSyntaxKit) {
DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
}
}
/* Script area */
setLayout(new BorderLayout());
codeEditor = new JEditorPane();
logTextArea = new JTextArea(12,50);
logTextArea.setMargin(new Insets(5,5,5,5));
logTextArea.setEditable(true);
logTextArea.setCursor(null);
final JCheckBoxMenuItem activateMenuItem = new JCheckBoxMenuItem("Activate");
activateMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ev) {
try {
setScriptActive(!isActive());
} catch (Exception e) {
logger.fatal("Error: " + e.getMessage(), e);
}
}
});
runMenu.add(activateMenuItem);
final JMenuItem runTestMenuItem = new JMenuItem("Save simulation and run with script");
runMenu.add(runTestMenuItem);
runTestMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
exportAndRun();
}
});
doLayout();
centerPanel = new JSplitPane(
JSplitPane.VERTICAL_SPLIT,
new JScrollPane(codeEditor),
new JScrollPane(logTextArea)
);
MenuListener toggleMenuItems = new MenuListener() {
public void menuSelected(MenuEvent e) {
activateMenuItem.setSelected(isActive());
runTestMenuItem.setEnabled(!isActive());
examplesMenu.setEnabled(!isActive());
}
public void menuDeselected(MenuEvent e) {
}
public void menuCanceled(MenuEvent e) {
}
};
fileMenu.addMenuListener(toggleMenuItems);
editMenu.addMenuListener(toggleMenuItems);
runMenu.addMenuListener(toggleMenuItems);
codeEditor.setContentType("text/javascript");
if (codeEditor.getEditorKit() instanceof DefaultSyntaxKit) {
DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
}
JPopupMenu p = codeEditor.getComponentPopupMenu();
if (p != null) {
for (Component c: p.getComponents()) {