Skip to content

Add the user-interface independent part of a generic script interpreter#127

Merged
dscho merged 16 commits into
masterfrom
interpreter
Oct 15, 2014
Merged

Add the user-interface independent part of a generic script interpreter#127
dscho merged 16 commits into
masterfrom
interpreter

Conversation

@dscho
Copy link
Copy Markdown
Contributor

@dscho dscho commented Oct 7, 2014

Fiji introduced interpreters for the script languages it supported. When ImageJ2 overhauled the idea of Fiji's scripting framework, reimplementing it cleanly on top of the SciJava common framework, the interpreters were dropped due to a misconception how widely in use they are. For example, Pavel Tomancak – the father of Fiji – pointed out that he uses the interpreter quite heavily.

Therefore, let's introduce a clean rewrite of the script interpreters. This topic branch adds the backend that is not visible to users; a corresponding Pull Request will be opened in the imagej-ui-swing project in a moment.

@dscho
Copy link
Copy Markdown
Contributor Author

dscho commented Oct 7, 2014

There is an open problem with this PR, still: command histories are not persisted correctly. To test this, start the ScriptInterpreterTestDrive in imagej/imagej-ui-swing#24, execute a command (e.g. in BeanShell: addClassPath("/path/to/Fiji.app/jars/ij-1.49h.jar"); and then ij.IJ.log("Hello");), then close the interpreter, restart it, and press the cursor up key (and see that the previous commands are not shown).

@hinerm
Copy link
Copy Markdown
Member

hinerm commented Oct 9, 2014

Also, it looks like before this can be merged, the changes to Prefs should be reconciled with PrefService.

@dscho
Copy link
Copy Markdown
Contributor Author

dscho commented Oct 10, 2014

it looks like before this can be merged, the changes to Prefs should be reconciled with PrefService.

@hinerm see d93ef83 ;-)

dscho added 4 commits October 11, 2014 20:22
Once the test ran successfully, bar is distinctively different from 0...

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The most generic way to provide a bunch of Strings to persist is by
passing an Iterable<String> for writing and handling an Iterable<String>
when reading.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Copy Markdown
Contributor Author

dscho commented Oct 11, 2014

command histories are not persisted correctly

The problem was actually in the imagej-ui-swing part: it did not dispose on close previously, and hence the saveState() method that triggered the persistence was never called. All is good now.

dscho and others added 12 commits October 14, 2014 16:14
This is similar to the LinkedHashMap structure, except that an
already-existing item can be easily put to the front of the list, or the
back.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The newly-introduced History class maintains the history of most recently
executed statements and has functionality to persist and retrieve the list
from the preferences.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The newly-introduced ScriptInterpreter class provides all the
functionality of a script interpreter sans the graphical user interface.
It can execute statements and persists a history of most recently
executed statements.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
It simplifies things downstream to be able to query the associated
ScriptLanguage later, since it is known at construction time anyway.

This does *not* persist the most recently used interpreter language!
The 'current command' is the command that is not yet in the history. It
is very convenient to be able to go back in history, just to have a
look, before continuing to craft the current command (and it would be
annoying if it was lost when going back in history). Of course, if the
user decides to execute a different command from the history instead,
the edits to the 'current command' are lost.

This behavior is most in line with the Unix shell behavior power users
might be used to.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit that referenced this pull request Oct 15, 2014
Add the user-interface independent part of a generic script interpreter
@dscho dscho merged commit a571896 into master Oct 15, 2014
@dscho dscho deleted the interpreter branch October 15, 2014 23:27
@hinerm
Copy link
Copy Markdown
Member

hinerm commented Oct 15, 2014

yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants