improved workaround to disable the code editor pane's built in run functionality: remove keyboard shortcut instead of

disabling action
This commit is contained in:
Fredrik Osterlind 2012-06-05 13:39:21 +02:00
parent afcc7559a5
commit 5c2ecd1def

View file

@ -75,7 +75,6 @@ import javax.swing.filechooser.FileFilter;
import jsyntaxpane.DefaultSyntaxKit; import jsyntaxpane.DefaultSyntaxKit;
import jsyntaxpane.actions.DefaultSyntaxAction; import jsyntaxpane.actions.DefaultSyntaxAction;
import jsyntaxpane.actions.ScriptRunnerAction;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
@ -169,6 +168,7 @@ public class ScriptRunner extends VisPlugin {
DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit(); DefaultSyntaxKit kit = (DefaultSyntaxKit) e.getEditorKit();
kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile"); kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName()); 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(); DefaultSyntaxKit kit = (DefaultSyntaxKit) codeEditor.getEditorKit();
kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile"); kit.setProperty("PopupMenu", "copy-to-clipboard,-,find,find-next,goto-line,-,linkfile");
kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName()); kit.setProperty("Action.linkfile", JSyntaxLinkFile.class.getName());
kit.setProperty("Action.execute-script", "jsyntaxpane.actions.ScriptRunnerAction");
} }
JPopupMenu p = codeEditor.getComponentPopupMenu(); JPopupMenu p = codeEditor.getComponentPopupMenu();
@ -242,13 +243,9 @@ public class ScriptRunner extends VisPlugin {
} }
Action a = ((JMenuItem) c).getAction(); Action a = ((JMenuItem) c).getAction();
if (a instanceof JSyntaxLinkFile) { if (a instanceof JSyntaxLinkFile) {
actionLinkFile = (JSyntaxLinkFile)(((JMenuItem) c).getAction()); actionLinkFile = (JSyntaxLinkFile) a;
actionLinkFile.setMenuText("Link script to disk file"); actionLinkFile.setMenuText("Link script to disk file");
actionLinkFile.putValue("ScriptRunner", this); actionLinkFile.putValue("ScriptRunner", this);
} else if (a instanceof ScriptRunnerAction) {
/* XXX Disable run action */
ScriptRunnerAction sra = (ScriptRunnerAction) ((JMenuItem) c).getAction();
sra.setEnabled(false);
} }
} }
} }