Skip to content
Permalink
Browse files

Add batch processing

  • Loading branch information...
imagejan authored and ctrueden committed Jun 25, 2017
1 parent a55380b commit 9b3667d6392e1557a8c931753f95410c0ebe09a0
@@ -5,7 +5,7 @@
<parent>
<groupId>org.scijava</groupId>
<artifactId>pom-scijava</artifactId>
<version>17.1.1</version>
<version>22.3.0</version>
<relativePath />
</parent>

@@ -180,6 +180,10 @@ Genetics, and others.</license.copyrightOwners>
<artifactId>miglayout</artifactId>
<classifier>swing</classifier>
</dependency>
<dependency>
<groupId>org.scijava</groupId>
<artifactId>batch-processor</artifactId>
</dependency>

<!-- Test scope dependencies -->
<dependency>
@@ -56,6 +56,7 @@
import java.io.PipedOutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StringReader;
import java.io.Writer;
import java.net.URL;
import java.util.ArrayList;
@@ -104,6 +105,7 @@
import org.fife.ui.rsyntaxtextarea.TokenMakerFactory;
import org.scijava.Context;
import org.scijava.app.AppService;
import org.scijava.batch.BatchService;
import org.scijava.command.CommandService;
import org.scijava.event.ContextDisposingEvent;
import org.scijava.event.EventHandler;
@@ -218,6 +220,8 @@
private PrefService prefService;
@Parameter
private AppService appService;
@Parameter
private BatchService batchService;

private Map<ScriptLanguage, JRadioButtonMenuItem> languageMenuItems;
private JRadioButtonMenuItem noneLanguageItem;
@@ -1917,6 +1921,18 @@ public void runText(final boolean selectionOnly) {
}
}

/**
* Run current script with the batch processor
*/
public void runBatch() {
// get script from current tab
String script = getTab().getEditorPane().getText();
ScriptInfo scriptInfo = new ScriptInfo(context, "dummy."
+ getCurrentLanguage().getExtensions().get(0),
new StringReader(script));
batchService.run(scriptInfo);
}

/** Invoke in the context of the event dispatch thread. */
private void execute(final boolean selectionOnly) throws IOException {
final TextEditorTab tab = getTab();
@@ -60,7 +60,7 @@
protected final JScrollPane scroll;
protected boolean showingErrors;
private Executer executer;
private final JButton runit, killit, toggleErrors;
private final JButton runit, batchit, killit, toggleErrors;

private final TextEditor textEditor;

@@ -96,6 +96,17 @@ public void actionPerformed(final ActionEvent ae) {
bottom.add(runit, bc);

bc.gridx = 1;
batchit = new JButton("Batch");
batchit.addActionListener(new ActionListener() {

@Override
public void actionPerformed(final ActionEvent ae) {
textEditor.runBatch();
}
});
bottom.add(batchit, bc);

bc.gridx = 2;
killit = new JButton("Kill");
killit.setEnabled(false);
killit.addActionListener(new ActionListener() {
@@ -107,12 +118,12 @@ public void actionPerformed(final ActionEvent ae) {
});
bottom.add(killit, bc);

bc.gridx = 2;
bc.gridx = 3;
bc.fill = GridBagConstraints.HORIZONTAL;
bc.weightx = 1;
bottom.add(new JPanel(), bc);

bc.gridx = 3;
bc.gridx = 4;
bc.fill = GridBagConstraints.NONE;
bc.weightx = 0;
bc.anchor = GridBagConstraints.NORTHEAST;
@@ -126,7 +137,7 @@ public void actionPerformed(final ActionEvent e) {
});
bottom.add(toggleErrors, bc);

bc.gridx = 4;
bc.gridx = 5;
bc.fill = GridBagConstraints.NONE;
bc.weightx = 0;
bc.anchor = GridBagConstraints.NORTHEAST;
@@ -146,7 +157,7 @@ public void actionPerformed(final ActionEvent ae) {
bc.fill = GridBagConstraints.BOTH;
bc.weightx = 1;
bc.weighty = 1;
bc.gridwidth = 5;
bc.gridwidth = 6;
screen.setEditable(false);
screen.setLineWrap(true);
final Font font = new Font("Courier", Font.PLAIN, 12);

0 comments on commit 9b3667d

Please sign in to comment.
You can’t perform that action at this time.