From 5274aec543a29b44ac93139da839f6b7c25f5153 Mon Sep 17 00:00:00 2001 From: oburri Date: Tue, 5 Dec 2023 09:59:22 +0100 Subject: [PATCH] script name changes and fix for script location --- build.gradle | 2 +- .../ImageCombinerWarpyExtension.java | 57 +------------------ .../java/qupath/ext/warpy/WarpyExtension.java | 12 ++-- ...y => Transfer_TMA_to_current_entry.groovy} | 0 ...ns_and_detections_to_current_entry.groovy} | 0 5 files changed, 11 insertions(+), 60 deletions(-) rename src/main/resources/scripts/{Warpy_transfer_TMA_to_current_entry.groovy => Transfer_TMA_to_current_entry.groovy} (100%) rename src/main/resources/scripts/{Warpy_transfer_annotations_and_detections_to_current_entry.groovy => Transfer_annotations_and_detections_to_current_entry.groovy} (100%) diff --git a/build.gradle b/build.gradle index bc6785a..3d1f8a1 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { repositories { // Use this only for local development! - // mavenLocal() + mavenLocal() mavenCentral() maven{ diff --git a/src/main/java/qupath/ext/imagecombinerwarpy/ImageCombinerWarpyExtension.java b/src/main/java/qupath/ext/imagecombinerwarpy/ImageCombinerWarpyExtension.java index ffd98e2..b5d34de 100644 --- a/src/main/java/qupath/ext/imagecombinerwarpy/ImageCombinerWarpyExtension.java +++ b/src/main/java/qupath/ext/imagecombinerwarpy/ImageCombinerWarpyExtension.java @@ -1,23 +1,4 @@ -/*- - * #%L - * This file is part of QuPath. - * %% - * Copyright (C) 2018 - 2020 QuPath developers, The University of Edinburgh - * %% - * QuPath is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * QuPath 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with QuPath. If not, see . - * #L% - */ +package qupath.ext.imagecombinerwarpy; /********************************* * This file is part of ImageCombinerWarpy ... @@ -34,10 +15,8 @@ * Peter Haub (@phaub), Oct 2021 * *********************************/ -package qupath.ext.imagecombinerwarpy; import net.imglib2.realtransform.RealTransformSerializer; -import org.controlsfx.control.action.Action; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,10 +34,6 @@ import qupath.lib.io.GsonTools; import qupath.lib.io.GsonTools.SubTypeAdapterFactory; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; - /** * Extension to make more experimental commands present in the GUI. */ @@ -70,10 +45,6 @@ public class ImageCombinerWarpyExtension implements QuPathExtension, GitHubProje private static final Version minimumVersion = Version.parse("0.3.0-SNAPSHOT"); - private static final LinkedHashMap SCRIPTS = new LinkedHashMap<>() {{ - put("Warpy transfer annotations and detections to current entry", "scripts/Warpy_transfer_annotations_and_detections_to_current_entry.groovy"); - put("Warpy transfer TMA to current entry", "scripts/Warpy_transfer_TMA_to_current_entry.groovy"); - }}; @Override public void installExtension(QuPathGUI qupath) { if (alreadyInstalled || !checkCompatibility()) @@ -97,20 +68,6 @@ public void installExtension(QuPathGUI qupath) { MenuTools.addMenuItems(qupath.getMenu("Analyze", false), imageCombinerWarpy); - SCRIPTS.entrySet().forEach(entry -> { - String name = entry.getValue(); - String command = entry.getKey(); - try (InputStream stream = ImageCombinerWarpyExtension.class.getClassLoader().getResourceAsStream(name)) { - String script = new String(stream.readAllBytes(), StandardCharsets.UTF_8); - if (script != null) { - MenuTools.addMenuItems( - qupath.getMenu("Extensions>Cellpose", true), - new Action(command, e -> openScript(qupath, script))); - } - } catch (Exception e) { - logger.error(e.getLocalizedMessage(), e); - } - }); alreadyInstalled = true; } catch (Throwable t) { @@ -160,14 +117,4 @@ public GitHubRepo getRepository() { public Version getQuPathVersion() { return QuPathExtension.super.getQuPathVersion(); } - - private static void openScript(QuPathGUI qupath, String script) { - var editor = qupath.getScriptEditor(); - if (editor == null) { - logger.error("No script editor is available!"); - return; - } - qupath.getScriptEditor().showScript("Warpy", script); - } - -} +} \ No newline at end of file diff --git a/src/main/java/qupath/ext/warpy/WarpyExtension.java b/src/main/java/qupath/ext/warpy/WarpyExtension.java index 451335e..134eefc 100644 --- a/src/main/java/qupath/ext/warpy/WarpyExtension.java +++ b/src/main/java/qupath/ext/warpy/WarpyExtension.java @@ -26,13 +26,13 @@ public class WarpyExtension implements QuPathExtension, GitHubProject { private boolean isInstalled = false; private static final Map SCRIPTS = Map.of( - "Warpy transfer annotations and detections to current entry", "scripts/Warpy_transfer_annotations_and_detections_to_current_entry.groovy", - "Warpy transfer TMAs to current entry", "scripts/Warpy_transfer_TMA_to_current_entry.groovy" + "Warpy transfer annotations and detections to current entry", "scripts/Transfer_annotations_and_detections_to_current_entry.groovy", + "Warpy transfer TMAs to current entry", "scripts/Transfer_TMA_to_current_entry.groovy" ); @Override public GitHubRepo getRepository() { - return GitHubRepo.create("QuPath Warpy Extension", "biop", "qupath-extension-warpy"); + return GitHubRepo.create("Warpy Extension", "biop", "qupath-extension-warpy"); } @Override @@ -50,6 +50,9 @@ public void installExtension(QuPathGUI qupath) { qupath.getMenu("Extensions>Warpy", true), new Action(command, e -> openScript(qupath, script))); } + + isInstalled = true; + } catch (Exception e) { logger.error(e.getLocalizedMessage(), e); } @@ -77,6 +80,7 @@ public static String getWarpyVersion() { return Version.parse(packageVersion).toString(); } + private static void openScript(QuPathGUI qupath, String script) { var editor = qupath.getScriptEditor(); if (editor == null) { @@ -85,4 +89,4 @@ private static void openScript(QuPathGUI qupath, String script) { } qupath.getScriptEditor().showScript("Warpy", script); } -} +} \ No newline at end of file diff --git a/src/main/resources/scripts/Warpy_transfer_TMA_to_current_entry.groovy b/src/main/resources/scripts/Transfer_TMA_to_current_entry.groovy similarity index 100% rename from src/main/resources/scripts/Warpy_transfer_TMA_to_current_entry.groovy rename to src/main/resources/scripts/Transfer_TMA_to_current_entry.groovy diff --git a/src/main/resources/scripts/Warpy_transfer_annotations_and_detections_to_current_entry.groovy b/src/main/resources/scripts/Transfer_annotations_and_detections_to_current_entry.groovy similarity index 100% rename from src/main/resources/scripts/Warpy_transfer_annotations_and_detections_to_current_entry.groovy rename to src/main/resources/scripts/Transfer_annotations_and_detections_to_current_entry.groovy