-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow testing of scripts in the Experimental module
- Loading branch information
Showing
4 changed files
with
128 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
resolvers += "SCI Java Releases" at "https://maven.scijava.org/content/repositories/thirdparty/" | ||
|
||
libraryDependencies ++= Seq( | ||
"org.scijava" % "script-editor" % "1.1.0", | ||
"org.scijava" % "scripting-groovy" % "1.0.0", | ||
"org.scijava" % "scripting-java" % "0.4.1", | ||
"org.scijava" % "scripting-scala" % "0.3.2", | ||
"org.scijava" % "script-editor-scala" % "0.2.1", | ||
"org.scijava" % "script-editor-jython" % "1.1.0", | ||
// "org.scijava" % "scripting-javascript" % "1.0.0", | ||
|
||
// not needed for script editor | ||
"org.python" % "jython-slim" % "2.7.3", | ||
|
||
// dependency overrides to pull bug fixes in transitive dependencies | ||
"org.scijava" % "scijava-optional" % "1.0.1", | ||
"org.scijava" % "scijava-table" % "1.0.2", | ||
"org.scijava" % "scijava-ui-swing" % "1.0.1" | ||
// "org.codehaus.groovy" % "groovy" % "3.0.17" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
experimental/src/main/scala/ij_plugins/javacv/experimental/ScriptEditorRunner.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Image/J Plugins | ||
* Copyright (C) 2002-2023 Jarek Sacha | ||
* Author's email: jpsacha at gmail dot com | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* Latest release available at http://sourceforge.net/projects/ij-plugins/ | ||
*/ | ||
|
||
package ij_plugins.javacv.experimental | ||
|
||
import ij.plugin.PlugIn | ||
import org.scijava.Context | ||
import org.scijava.script.{ScriptLanguage, ScriptService} | ||
import org.scijava.ui.DefaultUIService | ||
import org.scijava.ui.swing.script.{Helper, Main, ScriptEditor, TextEditor} | ||
|
||
import java.awt.event.{WindowAdapter, WindowEvent} | ||
import javax.swing.{SwingUtilities, WindowConstants} | ||
|
||
object ScriptEditorRunner { | ||
// private lazy val context = new org.scijava.Context() | ||
def main(args: Array[String]): Unit = { | ||
Helper.launch("Groovy", true) | ||
// Main.launch("Groovy") | ||
} | ||
} | ||
|
||
class ScriptEditorRunner extends PlugIn { | ||
|
||
import org.scijava.util.VersionUtils | ||
|
||
VersionUtils.getVersion(classOf[VersionUtils]) | ||
|
||
// import ScriptEditorRunner.* | ||
override def run(arg: String): Unit = { | ||
Helper.launch("Groovy", false) | ||
// Main.launch("Groovy") | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
experimental/src/main/scala/org/scijava/ui/swing/script/Helper.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Image/J Plugins | ||
* Copyright (C) 2002-2023 Jarek Sacha | ||
* Author's email: jpsacha at gmail dot com | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
* | ||
* Latest release available at http://sourceforge.net/projects/ij-plugins/ | ||
*/ | ||
|
||
package org.scijava.ui.swing.script | ||
|
||
import org.scijava.Context | ||
import org.scijava.script.{ScriptLanguage, ScriptService} | ||
import org.scijava.ui.DefaultUIService | ||
import org.scijava.ui.swing.script.TextEditor | ||
|
||
import java.awt.event.{WindowAdapter, WindowEvent} | ||
import javax.swing.{SwingUtilities, WindowConstants} | ||
|
||
object Helper { | ||
def launch(language: String, exitOnClose: Boolean): Unit = { | ||
val context = new Context() | ||
val defaultUIService = context.getService(classOf[DefaultUIService]) | ||
defaultUIService.showUI() | ||
val editor = new TextEditor(context) | ||
val scriptService = context.getService(classOf[ScriptService]) | ||
val lang = scriptService.getLanguageByName(language) | ||
if (lang == null) throw new IllegalArgumentException("Script language '" + language + "' not found") | ||
editor.setLanguage(lang) | ||
editor.addWindowListener(new WindowAdapter() { | ||
override def windowClosed(e: WindowEvent): Unit = { | ||
defaultUIService.dispose() | ||
SwingUtilities.invokeLater(() => { context.dispose() }) | ||
} | ||
}) | ||
if (exitOnClose) editor.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE) | ||
editor.setVisible(true) | ||
// Main.launch(language) | ||
} | ||
} |