Script Editor and Interpreter for SciJava script languages.
mvn -Pexec,editor
mvn -Pexec,interp
Script Editor and Interpreter for SciJava script languages
Home Page: http://imagej.net/Script_Editor
License: BSD 2-Clause "Simplified" License
To allow running scripts in batch from the script editor, we should have a Batch
button next to the Run
and Kill
buttons in the script editor.
I did some initial work on the batch-processing-draft
branch, but it would be much better if we had a way to provide this functionality in an extensible way, much the same as SearchActionFactory
plugins in scijava-search
.
How about creating a ScriptAction
plugin type, so that the batch-processor
project can provide a BatchScriptAction
that results in a Batch button being added, and the script is run with the batch processor upon click?!
There's a subset of keyboard shortcuts for the Fiji script editor that I can't get working. I'm sure this is a non-exhaustive list, but the biggest annoyances are:
I can use these shortcuts with no trouble:
System details:
Mac High Sierra, 10.13.5
Fiji version: 2.0.0-rc-67/1.52d
Build 1762a07c5c
Date: 2018-06-04T18:22:47+0000
$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
When using Save As... from the script editor, the script title in the tab doesn't get updated. Only after saving one more time (Ctrl+S), the tab title reflects the script name correctly.
In the script editor, it's currently not possible to install macro tool defined by the macro "XY Tool" { }
construct.
Let's add a menu entry Install Macros that acts the same as the one in IJ1's Editor
.
This might have to live in imagej-legacy
though...
Running Edit > Tab sizes > Other... in the script editor throws the following exception:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.scijava.command.DynamicCommandInfo.populateItems(DynamicCommandInfo.java:303)
at org.scijava.command.DynamicCommandInfo.<init>(DynamicCommandInfo.java:73)
at org.scijava.command.DynamicCommand.getInfo(DynamicCommand.java:74)
at org.scijava.command.DynamicCommand.getInfo(DynamicCommand.java:52)
at org.scijava.module.DefaultModuleService.assignInputs(DefaultModuleService.java:460)
at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:241)
at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:210)
at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:199)
at org.scijava.module.DefaultModuleService.run(DefaultModuleService.java:184)
at org.scijava.command.DefaultCommandService.run(DefaultCommandService.java:186)
at org.scijava.command.DefaultCommandService.run(DefaultCommandService.java:169)
at org.scijava.ui.swing.script.TextEditor.actionPerformed(TextEditor.java:1101)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
at java.awt.Container.dispatchEventImpl(Container.java:2280)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Hi @acardona ,
when hitting CTRL+Space behind a single line containing "Views", a BadLocationException pops up:
javax.swing.text.BadLocationException: No such line
at javax.swing.JTextArea.getLineStartOffset(JTextArea.java:409)
at org.scijava.ui.swing.script.autocompletion.JythonAutoCompletion.insertCompletion(JythonAutoCompletion.java:74)
at org.fife.ui.autocomplete.AutoCompletion.insertCompletion(AutoCompletion.java:609)
at org.fife.ui.autocomplete.AutoCompletion.lambda$refreshPopupWindow$1(AutoCompletion.java:881)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Let me know if I can help fixing it!
Cheers,
Robert
[ERROR]: Cannot locate JRE jar in /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
[ERROR] Cannot create plugin: class='org.scijava.ui.swing.script.languagesupport.JavaLanguageSupportPlugin', priority=0.0, enabled=true, pluginType=LanguageSupportPlugin
java.lang.IllegalArgumentException: info cannot be null
at org.fife.rsta.ac.java.JarManager.addClassFileSource(JarManager.java:157)
at org.fife.rsta.ac.java.JarManager.addCurrentJreClassFileSource(JarManager.java:193)
at org.scijava.ui.swing.script.languagesupport.JavaLanguageSupportPlugin.<init>(JavaLanguageSupportPlugin.java:56)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
at java.base/java.lang.Class.newInstance(Class.java:560)
at org.scijava.plugin.PluginInfo.createInstance(PluginInfo.java:306)
at org.scijava.plugin.DefaultPluginService.createInstance(DefaultPluginService.java:237)
at org.scijava.plugin.DefaultPluginService.createInstances(DefaultPluginService.java:226)
at org.scijava.plugin.DefaultPluginService.createInstancesOfType(DefaultPluginService.java:217)
at org.scijava.plugin.AbstractSingletonService.initInstances(AbstractSingletonService.java:138)
at org.scijava.plugin.AbstractSingletonService.getInstances(AbstractSingletonService.java:77)
at org.scijava.plugin.SingletonService.lambda$initialize$0(SingletonService.java:97)
at org.scijava.object.ObjectIndex.resolvePending(ObjectIndex.java:388)
at org.scijava.object.ObjectIndex.get(ObjectIndex.java:133)
at org.scijava.object.DefaultObjectService.getObjects(DefaultObjectService.java:87)
at org.scijava.display.DefaultDisplayService.getDisplays(DefaultDisplayService.java:166)
at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:159)
at org.scijava.ui.DefaultUIService.showUI(DefaultUIService.java:142)
at org.scijava.AbstractGateway.launch(AbstractGateway.java:104)
at net.imagej.Main.main(Main.java:55)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at net.imagej.launcher.ClassLauncher.launch(ClassLauncher.java:291)
at net.imagej.launcher.ClassLauncher.run(ClassLauncher.java:198)
at net.imagej.launcher.ClassLauncher.main(ClassLauncher.java:89)
ScriptEditor
is CloseConfirmable
so it should present the save dialog for its scripts before being hidden. The fact that it isn't suggests it may be getting picked up by the IJ1 close mechanism first.
My first guess is that there could be a parent/child problem where the editor window is being hidden even though child windows aren't ready yet.. so it could just be a traversal order problem
Running the following code with IJ1 as selected language
# @File myFile
print(myFile)
does pop-up a window to select a file but after "ok", the editor returns an error like below.
Statement cannot begin with '#' in line 3.
<#> @ File myFile
In the new FileSystemTree
(the left panel listing folders and files), at the top, there should be a text field next to the [+] and [-] buttons to enable filtering folder contents by file name extension.
As suggested by Daniela https://twitter.com/happifocus/status/1118917974142914560
The Script Editor minimises into the bottom left corner of the screen. To reproduce:
Running macOS Mojave 10.14.4
and script-editor-0.5.1
I think this is related to the workaround in commit 9a52e0b?
Hi,
I updated Fiji ((Fiji Is Just) ImageJ 2.3.0/1.53f51; Java 1.8.0_172 [64-bit]; Windows 10 10.0;) When typing in editor in jython, error poped up like following.
javax.swing.text.BadLocationException: Position not represented by view
at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.modelToView(WrappedSyntaxView.java:770)
at javax.swing.plaf.basic.BasicTextUI$RootView.modelToView(BasicTextUI.java:1509)
at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1047)
at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:1022)
at javax.swing.text.JTextComponent.modelToView(JTextComponent.java:1377)
at org.fife.ui.rtextarea.RTextAreaBase.possiblyUpdateCurrentLineHighlightLocation(RTextAreaBase.java:754)
at org.fife.ui.rtextarea.RTextArea.fireCaretUpdate(RTextArea.java:611)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.fireCaretUpdate(RSyntaxTextArea.java:873)
at javax.swing.text.JTextComponent$MutableCaretEvent.fire(JTextComponent.java:4394)
at javax.swing.text.JTextComponent$MutableCaretEvent.stateChanged(JTextComponent.java:4416)
at javax.swing.text.DefaultCaret.fireStateChanged(DefaultCaret.java:802)
at javax.swing.text.DefaultCaret.changeCaretPosition(DefaultCaret.java:1274)
at javax.swing.text.DefaultCaret.handleSetDot(DefaultCaret.java:1173)
at javax.swing.text.DefaultCaret$DefaultFilterBypass.setDot(DefaultCaret.java:1913)
at javax.swing.text.NavigationFilter.setDot(NavigationFilter.java:64)
at org.fife.ui.rtextarea.ConfigurableCaret$FoldAwareNavigationFilter.setDot(ConfigurableCaret.java:724)
at javax.swing.text.DefaultCaret.setDot(DefaultCaret.java:1151)
at javax.swing.text.DefaultCaret$Handler.insertUpdate(DefaultCaret.java:1723)
at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:201)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.fireInsertUpdate(RSyntaxDocument.java:187)
at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:748)
at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:707)
at javax.swing.text.PlainDocument.insertString(PlainDocument.java:130)
at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:669)
at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1328)
at org.fife.ui.rtextarea.RTextArea.handleReplaceSelection(RTextArea.java:887)
at org.fife.ui.rtextarea.RTextArea.replaceSelection(RTextArea.java:1261)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit$InsertBreakAction.insertNewlineWithAutoIndent(RSyntaxTextAreaEditorKit.java:1539)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit$InsertBreakAction.handleInsertBreak(RSyntaxTextAreaEditorKit.java:1497)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit$InsertBreakAction.actionPerformedImpl(RSyntaxTextAreaEditorKit.java:1447)
at org.fife.ui.rtextarea.RecordableTextAction.actionPerformed(RecordableTextAction.java:106)
at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1668)
at javax.swing.JComponent.processKeyBinding(JComponent.java:2882)
at javax.swing.JComponent.processKeyBindings(JComponent.java:2929)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2845)
at java.awt.Component.processEvent(Component.java:6316)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:835)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1103)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:974)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:800)
at java.awt.Component.dispatchEventImpl(Component.java:4760)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
I would appreciate if you repaire the issue.
I noticed that the persistence set up an unexpected value (actually 0) when the value entered by the user is the one defined as default.
ex:
#@ int (label="delta", min=-5, value=10) delta
print delta
The persisted value is indeed recovered in every case, except if the user enters 10, then the next time the script is launched the value is 0 !
Tested on 2 different fiji installations, with Jython and the IJ macro language.
Associated post on the forum
In VNC sessions, opening a Script Editor larger than the dimensions of the desktop can segfault the JVM 8.0 in a way that it takes down the VNC server too, meaning, the X11 window manager system crashes as well.
One way to avoid this would be to check, when opening a Script Editor window, if the dimensions stored in the preferences are larger than the desktop dimensions, and constrain them not to be. That would be desirable anyway.
Sometimes, when I open a script, an error message pops up. This only happens some times when I open a sript. I have not been able to find any pattern. If I open and close the same file several times, some times I will get an error, and some times I won't.
Here is an example from opening a Python script:
Exception in thread "Thread-5" java.lang.Error: Error: could not match input
at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.zzScanError(PythonTokenMaker.java:881)
at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.yylex(PythonTokenMaker.java:1081)
at org.fife.ui.rsyntaxtextarea.modes.PythonTokenMaker.getTokenList(PythonTokenMaker.java:705)
at org.fife.ui.rsyntaxtextarea.TokenMakerBase.getLastTokenTypeOnLine(TokenMakerBase.java:225)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.updateSyntaxHighlightingInformation(RSyntaxDocument.java:666)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.setSyntaxStyle(RSyntaxDocument.java:548)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.setSyntaxEditingStyle(RSyntaxTextArea.java:2909)
at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:501)
at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:445)
at org.scijava.ui.swing.script.EditorPane.setLanguageByFileName(EditorPane.java:433)
at org.scijava.ui.swing.script.TextEditor.stateChanged(TextEditor.java:1221)
at javax.swing.JTabbedPane.fireStateChanged(JTabbedPane.java:416)
at javax.swing.JTabbedPane$ModelListener.stateChanged(JTabbedPane.java:270)
at javax.swing.DefaultSingleSelectionModel.fireStateChanged(DefaultSingleSelectionModel.java:132)
at javax.swing.DefaultSingleSelectionModel.setSelectedIndex(DefaultSingleSelectionModel.java:67)
at javax.swing.JTabbedPane.setSelectedIndexImpl(JTabbedPane.java:616)
at javax.swing.JTabbedPane.setSelectedIndex(JTabbedPane.java:591)
at org.scijava.ui.swing.script.TextEditor.switchTo(TextEditor.java:2155)
at org.scijava.ui.swing.script.TextEditor.open(TextEditor.java:1382)
at org.scijava.ui.swing.script.TextEditor$15.run(TextEditor.java:1045)
Here is another example from opening an IJ1 macro:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Error: could not match input
at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.zzScanError(ImageJMacroTokenMaker.java:2619)
at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.yylex(ImageJMacroTokenMaker.java:2878)
at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.getTokenList(ImageJMacroTokenMaker.java:2469)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.getTokenListForLine(RSyntaxDocument.java:431)
at org.fife.ui.rsyntaxtextarea.SyntaxView.paint(SyntaxView.java:728)
at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1434)
at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:737)
at org.fife.ui.rtextarea.RTextAreaUI.paintSafely(RTextAreaUI.java:539)
at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:881)
at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:860)
at org.fife.ui.rtextarea.RTextAreaBase.paintComponent(RTextAreaBase.java:735)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.paintComponent(RSyntaxTextArea.java:2072)
at javax.swing.JComponent.paint(JComponent.java:1056)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JViewport.paint(JViewport.java:728)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintChildren(JComponent.java:889)
at javax.swing.JComponent.paint(JComponent.java:1065)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:306)
at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Here is another example, form opening the same IJ1 macro. (exactly the same)
Exception in thread "Thread-9" java.lang.Error: Error: could not match input
at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.zzScanError(ImageJMacroTokenMaker.java:2619)
at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.yylex(ImageJMacroTokenMaker.java:2878)
at org.scijava.ui.swing.script.highliters.ImageJMacroTokenMaker.getTokenList(ImageJMacroTokenMaker.java:2469)
at org.fife.ui.rsyntaxtextarea.TokenMakerBase.getLastTokenTypeOnLine(TokenMakerBase.java:225)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.updateSyntaxHighlightingInformation(RSyntaxDocument.java:666)
at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.setSyntaxStyle(RSyntaxDocument.java:548)
at org.fife.ui.rsyntaxtextarea.RSyntaxTextArea.setSyntaxEditingStyle(RSyntaxTextArea.java:2909)
at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:501)
at org.scijava.ui.swing.script.EditorPane.setLanguage(EditorPane.java:445)
at org.scijava.ui.swing.script.EditorPane.setLanguageByFileName(EditorPane.java:433)
at org.scijava.ui.swing.script.EditorPane.setFileName(EditorPane.java:379)
at org.scijava.ui.swing.script.TextEditor.setEditorPaneFileName(TextEditor.java:1683)
at org.scijava.ui.swing.script.TextEditor.open(TextEditor.java:1386)
at org.scijava.ui.swing.script.TextEditor$15.run(TextEditor.java:1045)
Most of the time, these errors don't seem to represent any actual problem -- the only unexpected behavior is that an error popped up. Sometimes, however, the syntax parser actually fails. For me, this always manifests itself in the same way: starting from some line in the middle of the file, every line below it is highlighted as a comment. I can fix this by going to the last line that isn't highlighted as a comment, commenting it out, and then uncommenting it. This always corrects the syntax highlighting for the rest of the file.
ImageJ 1.51t, Fiji Distribution, Java 1.8.0_66 (64-bit)
From @rasband:
Eclipse and NetBeans can be overwhelming to a scientist who wants to develop a simple plugin or who wants to install a plugin only available in source form. The Script Editor should have an Install command similar to the Plugins>Compile and Run command, which no longer works in Fiji. Fiji's Plugins>Install Plugin command is not the solution since the installed plugin appears to be compiled every time you run it.
See also discussion at Fiji bug #1074.
Hi all,
as reported in the forum, setting the language to "None" after it was ImageJ Macro, for example causes an exception:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.scijava.ui.swing.script.TextEditor.setLanguage(TextEditor.java:1860)
at org.scijava.ui.swing.script.TextEditor.lambda$new$3(TextEditor.java:428)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:308)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:842)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:886)
at java.awt.Component.processMouseEvent(Component.java:6539)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
When trying to run IJ1 macro code in the script interpreter, e.g. run("Blobs (25K)");
, the following exception is thrown:
java.lang.IllegalStateException: Cannot run macro from the EDT!
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:977)
at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1035)
at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:97)
at org.scijava.script.DefaultScriptInterpreter.eval(DefaultScriptInterpreter.java:139)
at org.scijava.script.DefaultScriptInterpreter.interpret(DefaultScriptInterpreter.java:198)
at org.scijava.script.ScriptREPL.evaluate(ScriptREPL.java:182)
at org.scijava.ui.swing.script.PromptPane.execute(PromptPane.java:157)
at org.scijava.ui.swing.script.PromptPane.access$100(PromptPane.java:55)
at org.scijava.ui.swing.script.PromptPane$1.keyPressed(PromptPane.java:80)
at java.awt.Component.processKeyEvent(Component.java:6493)
at javax.swing.JComponent.processKeyEvent(JComponent.java:2832)
at java.awt.Component.processEvent(Component.java:6312)
at java.awt.Container.processEvent(Container.java:2236)
at java.awt.Component.dispatchEventImpl(Component.java:4891)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1954)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:806)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:1074)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:945)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:771)
at java.awt.Component.dispatchEventImpl(Component.java:4762)
at java.awt.Container.dispatchEventImpl(Container.java:2294)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4713)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
See snapshot here (EditorPane under dark theme while popup completion remains under light theme):
https://forum.image.sc/t/python-syntax-highlighting-stopped-working-in-fiji-script-editor/83615/11
Hey @acardona ,
I'm happy about your efforts on the auto-completion side. Just please be careful. I just downloaded and compiled the master branch of script-editor. It breaks the auto-completion of CLIJ. This is how it worked before:
And now, there is no pulldown opening anymore behind otsu (also not when hitting CTRL+Space).
However, what works now, is auto-completion of static methods (thanks to your great work!):
Do you think it would be possible to combine your implementation with mine? E.g. could we integrate this class in your implementation to receive custom completions including documentation?
Thanks for your support!
Cheers,
Robert
It would be helpful to have a tool to quickly search for a specific script template in the Templates menu, as well as locating its source (i.e. from which jar file, from which update site).
Maybe some code of the ImageJ CommandFinder
can be re-used for this, at it provides the same functionality for menu commands?
Stepping through script execution is a nice feature. In particular, the ImageJ1 text editor supports single-stepping through macros; therefore, it would be nice to also support that in the Script Editor, since it is supposed to be a drop-in replacement for that text editor.
@rasband was recently kind enough to extract an interface to make this feasible. Leveraging it will probably require changes in both this component as well as in imagej-legacy. Possibly also in SciJava Common's org.scijava.script
package.
Currently, the script editor defaults to courier. Since we allow font size adjustments it would make sense to have a font selector as well.
This was pointed on the forum by @imagejan
#@ PrefService prefs
retrievedValue = prefs.getBoolean(None, "persistedBool", False)
retrievedString = prefs.get(None, "persistedString", "abcdefghijklmnopqrstuvwxyz")
print retrievedValue # always prints False
print retrievedString
prefs.put(None, "persistedBool", not retrievedValue)
prefs.put(None, "persistedString", retrievedString[0:-1])
While it works with getInt
#@ PrefService prefs
retrievedValue = prefs.getInt(None, "persistedBool", False) # <-- see change here
retrievedString = prefs.get(None, "persistedString", "abcdefghijklmnopqrstuvwxyz")
print retrievedValue # now it works as expected
print retrievedString
prefs.put(None, "persistedBool", not retrievedValue)
prefs.put(None, "persistedString", retrievedString[0:-1])
I am very new to Java and Fiji, so I am not sure if this is the right place to report this bug.
Jython auto-completions fail to load on a fresh Fiji installation with warining: WARNING did not load JythonAutoCompletions
.
I am triggering this message window by trying to run "find class" function.
I am running:
(Fiji is Just) ImageJ 2.3.0/1.53f51
Java 1.8.0_172 [64-bit]
on Ubuntu 20.04.3
I would really appreciate help with this, since I have failed to setup eclipse with auto-completions for all Fiji classes.
Users new to programming often are not aware of the difference between straight quotes ("
) and typographic curly quotes (“”
). See for example this, this and this forum post.
It might be useful to warn users if they try running scripts that contain those wrong quotation characters, instead of letting the respective script engine throw cryptic error messages.
Instead of in the script editor, we could also think about detecting this kind of error when interpreting the scripts, but usually it is something that only happens when you actively edit a script...
This relates to scijava/pom-scijava#191
The new RSyntaxTextArea components have built-in support for Kotlin and Markdown syntax (see release notes). Would be awesome to add support for those here.
@imagejan, @haesleinhuepf: You guys implemented LanguageSupports in the past. I'm confident it would be trivial for you to tackle this, so pinging you in 😉
I guess one could also make available syntaxes for common stuff like XML or JSON, that once in a while are present in Fiji. @ctrueden , agree?
I worked really hard on getting ImageJ2's script editor into a shape where we can use it also in Fiji. It is time to switch.
When auto-generating Maven projects, we should inspect the explicit import <class>;
statements and build the dependencies accordingly (ClassUtils.getLocation()
followed by POM
class magic).
This might not be necessary, however, if scripting-java
makes the complete class path available anyway. But it would still be nice: when exporting a .jar
file, it would contain a perfect pom.xml
automatically.
The Ctrl+/ (⌘+/ on Mac) shortcut is useful for (un-)commenting out a line of code. Let's make it more discoverable:
For other Eclipse-like shortcuts (like e.g. Ctrl+D to delete an entire line), we should also provide menu commands with shortcut labels.
Turns out the file reload dialog keeps popping up repeatedly when dismissed.
Hey all, hey @acardona,
I think the following bug is related to the new script editor which was just released. I have a single folder with macro files in the treeview on the left and opened one of the files by double-clicking. Then, I saved that file under a new name in the same folder. I guess the tree on the left tried to refresh then. While/after saving, this exception pops up:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 29 >= 29
at java.util.Vector.elementAt(Vector.java:477)
at javax.swing.tree.DefaultMutableTreeNode.getChildAt(DefaultMutableTreeNode.java:245)
at org.scijava.ui.swing.script.FileSystemTree$Node.getChildAt(FileSystemTree.java:182)
at org.scijava.ui.swing.script.FileSystemTree$Node.getChildAt(FileSystemTree.java:93)
at javax.swing.tree.DefaultTreeModel.getChild(DefaultTreeModel.java:174)
at javax.swing.plaf.basic.BasicTreeUI.getLastChildPath(BasicTreeUI.java:1721)
at javax.swing.plaf.basic.BasicTreeUI.paintVerticalPartOfLeg(BasicTreeUI.java:1429)
at javax.swing.plaf.metal.MetalTreeUI.paintVerticalPartOfLeg(MetalTreeUI.java:211)
at javax.swing.plaf.basic.BasicTreeUI.paint(BasicTreeUI.java:1203)
at javax.swing.plaf.metal.MetalTreeUI.paint(MetalTreeUI.java:169)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:161)
at javax.swing.JComponent.paintComponent(JComponent.java:780)
at javax.swing.JComponent.paint(JComponent.java:1056)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1579)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1502)
at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
I'm running on a recently updated Fiji on Windows 10, 64 bit. I'm happy to help fixing it, but I have no time right now.
Cheers,
Robert
With the new IJ1 Macro auto-completion implemented by @haesleinhuepf, we get nice completions for all currently implemented macro functions, but not all of them are recognized by the syntax highlighter, because syntax highlighting relies on ImageJMacroTokenMaker
in this repository.
To illustrate this, paste the following lines in the script editor:
getTitle() // is highlighted
Table.applyMacro(code) // is not highlighted
Let's migrate IJ1MacroHighlighter
to imagej-legacy
and unify the way how macro tokens are recognized, such that all functions that can be auto-completed will also be shown with a dedicated syntax color.
Currently, the [ shortcut is used to start up the script editor. We should consider changing this to something that works from most keyboard layouts, not only US keyboards.
Also, it would help if that shortcut is displayed next to the command in the menu, so it is easily discoverable.
The ImageJ 1.x macro editor has a Debug menu with some useful debugging features.
It would be great if the Script Editor had these features as well.
See these discussions:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.