Skip to content

Commit

Permalink
script name changes and fix for script location
Browse files Browse the repository at this point in the history
  • Loading branch information
lacan committed Dec 5, 2023
1 parent 409181d commit 5274aec
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 60 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {

repositories {
// Use this only for local development!
// mavenLocal()
mavenLocal()
mavenCentral()

maven{
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <https://www.gnu.org/licenses/>.
* #L%
*/
package qupath.ext.imagecombinerwarpy;

/*********************************
* This file is part of ImageCombinerWarpy ...
Expand All @@ -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;

Expand All @@ -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.
*/
Expand All @@ -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<String, String> 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())
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}

}
}
12 changes: 8 additions & 4 deletions src/main/java/qupath/ext/warpy/WarpyExtension.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ public class WarpyExtension implements QuPathExtension, GitHubProject {
private boolean isInstalled = false;

private static final Map<String, String> 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
Expand All @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand All @@ -85,4 +89,4 @@ private static void openScript(QuPathGUI qupath, String script) {
}
qupath.getScriptEditor().showScript("Warpy", script);
}
}
}

0 comments on commit 5274aec

Please sign in to comment.