Skip to content

Commit

Permalink
GUI: Add (minor) convenience access to Spot Spine
Browse files Browse the repository at this point in the history
  • Loading branch information
tferr committed Sep 16, 2024
1 parent 05eb7f4 commit 9ee87e6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/main/java/sc/fiji/snt/BookmarkManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ private JPopupMenu exportMenu() {
JMenuItem jmi = new JMenuItem("To CSV File...");
menu.add(jmi);
jmi.addActionListener(e -> {
if (noBookmarksError()) return;
final File saveFile = sntui.saveFile("Export Bookmarks to CSV...",
"SNT_Bookmarks.csv", "csv");
if (saveFile != null) {
Expand Down Expand Up @@ -251,7 +250,9 @@ private JPanel assembleButtonPanel() {
impButton.addActionListener(e -> impMenu.show(impButton, impButton.getWidth() / 2, impButton.getHeight() / 2));
final JButton expButton = new JButton("Export...");
final JPopupMenu expMenu = exportMenu();
expButton.addActionListener(e -> expMenu.show(expButton, expButton.getWidth() / 2, expButton.getHeight() / 2));
expButton.addActionListener(e -> {
if (!noBookmarksError()) expMenu.show(expButton, expButton.getWidth() / 2, expButton.getHeight() / 2);
});
final JPanel buttonPanel = new JPanel(new GridLayout(0, 2));
buttonPanel.setBorder(new EmptyBorder(SNTUI.InternalUtils.MARGIN, 0, SNTUI.InternalUtils.MARGIN, 0));
buttonPanel.add(impButton);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/sc/fiji/snt/PathManagerUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ private JMenu getSpineUtilsMenu(final MultiPathActionListener multiPathListener)
jmi.addActionListener(multiPathListener);
menu.add(jmi);
menu.addSeparator();
jmi = new JMenuItem("Start Spot Spine...");
jmi.addActionListener(e -> {
plugin.getContext().getService(CommandService.class).run(SpotSpineLoaderCmd.class, true, new HashMap<>());
});
menu.add(jmi);
menu.addSeparator();
jmi = GuiUtils.menuItemTriggeringHelpURL("Spine/Varicosity Utilities Help",
"https://imagej.net/plugins/snt/step-by-step-instructions#spinevaricosity-analysis");
menu.add(jmi);
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/sc/fiji/snt/gui/DemoRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
package sc.fiji.snt.gui;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import org.scijava.Context;
import org.scijava.command.CommandService;
import org.scijava.plugin.Parameter;

import ij.ImagePlus;
Expand All @@ -34,6 +36,7 @@
import sc.fiji.snt.SNTService;
import sc.fiji.snt.SNTUI;
import sc.fiji.snt.Tree;
import sc.fiji.snt.gui.cmds.SpotSpineLoaderCmd;

public class DemoRunner {

Expand Down Expand Up @@ -340,13 +343,14 @@ public void load() {
snt.getUI().runCommand("Display/Rebuild ZY/XZ Views");
if (!snt.getDrawDiameters())
snt.getUI().runCommand("Draw diameters");
snt.getContext().getService(CommandService.class).run(SpotSpineLoaderCmd.class, true, new HashMap<>());
}
}
};

entry.summary = "Downloads the test dataset of the Spot Spine software (image stack and traced dendrite).";
entry.data = "Image (3D; 0.7MB) and tracings (160KB)";
entry.source = "Spot Spine (https://imagej.net/plugins/spot-spine) manuscript, doi:10.12688/f1000research" +
entry.source = "Spot Spine (https://imagej.net/plugins/spot-spine) manuscript, doi:10.12688/f1000research.146327.2" +
".146327.1";
entry.online = true;
entry.tracingsURL = "https://raw.githubusercontent.com/morphonets/misc/master/dataset-demos/SpotSpine/SpotSpine_ImageStack_Test.swc";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* #L%
*/
import net.imagej.legacy.LegacyService;
import org.scijava.command.Command;
import org.scijava.command.CommandInfo;
import org.scijava.command.CommandService;
Expand Down Expand Up @@ -51,9 +52,12 @@ public class EnableSciViewUpdateSiteCmd implements Command {
@Parameter
private CommandService cmdService;

@Parameter
LegacyService legacyService;

@Override
public void run() {
final UpdateSite updateSite = updateService.getUpdateSite("SciView"); // this may be outdated
final UpdateSite updateSite = updateService.getUpdateSite("sciview");
if (updateSite != null && updateSite.isActive()) {
SNTUtils.log("sciview subscription detected");
return;
Expand All @@ -64,7 +68,7 @@ public void run() {
if (prompts[0])
runUpdater();
if (prompts[1])
ij.IJ.runPlugIn("ij.plugin.BrowserLauncher", "https://docs.scenery.graphics/sciview");
legacyService.runLegacyCommand("ij.plugin.BrowserLauncher","https://docs.scenery.graphics/sciview");
}

private void runUpdater() {
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/sc/fiji/snt/gui/cmds/SpotSpineLoaderCmd.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package sc.fiji.snt.gui.cmds;

import net.imagej.legacy.LegacyService;
import org.scijava.command.Command;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.util.Types;
import sc.fiji.snt.gui.GuiUtils;

/**
* Implements the 'Open Spot Spine...' command.
*
* @author Tiago Ferreira
*/
@Plugin(type = Command.class, visible = false)
public class SpotSpineLoaderCmd implements Command {

private static final String DOC_PAGE = "https://imagej.net/plugins/spot-spine#installation";
private static final String CLASS = "spine_sources.Spine3D_All";

@Parameter
LegacyService legacyService;

@Override
public void run() {
if (Types.load(CLASS) != null) {
legacyService.runLegacyCommand(CLASS, "");
return;
}
final boolean openDoc = new GuiUtils().getConfirmation("Spot Spine does not seem to be available. Please " +
"install it by following the installation details on imagej.net. Open documentation page now?",
"Spot Spine Not Installed", "Yes. Open In Browser", "No. Dismiss");
if (openDoc)
legacyService.runLegacyCommand("ij.plugin.BrowserLauncher", DOC_PAGE);
}

}

0 comments on commit 9ee87e6

Please sign in to comment.