From 5c2ecd1def46764eec87a339e87f11aa22f69964 Mon Sep 17 00:00:00 2001 From: Fredrik Osterlind Date: Tue, 5 Jun 2012 13:39:21 +0200 Subject: [PATCH] improved workaround to disable the code editor pane's built in run functionality: remove keyboard shortcut instead of disabling action --- tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java index f7db90b55..96dc544fd 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java +++ b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java @@ -75,7 +75,6 @@ import javax.swing.filechooser.FileFilter; import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.actions.DefaultSyntaxAction; -import jsyntaxpane.actions.ScriptRunnerAction; import org.apache.log4j.Logger; import org.jdom.Element; @@ -169,6 +168,7 @@ public class ScriptRunner extends VisPlugin { 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"); } } @@ -229,6 +229,7 @@ public class ScriptRunner extends VisPlugin { 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(); @@ -242,13 +243,9 @@ public class ScriptRunner extends VisPlugin { } Action a = ((JMenuItem) c).getAction(); if (a instanceof JSyntaxLinkFile) { - actionLinkFile = (JSyntaxLinkFile)(((JMenuItem) c).getAction()); + actionLinkFile = (JSyntaxLinkFile) a; actionLinkFile.setMenuText("Link script to disk file"); actionLinkFile.putValue("ScriptRunner", this); - } else if (a instanceof ScriptRunnerAction) { - /* XXX Disable run action */ - ScriptRunnerAction sra = (ScriptRunnerAction) ((JMenuItem) c).getAction(); - sra.setEnabled(false); } } }