From 1795f18c515b6e709dec612cc1dcbbef7dcb6301 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Thu, 25 Nov 2021 18:12:24 +0100 Subject: [PATCH] Added check for non-existing ResultsTable --- README.md | 8 +++---- .../igred/ij/plugin/OMEROMacroExtension.java | 22 +++++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 6bb969f..a3091e4 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,7 @@ A plugin for ImageJ to provide macro extensions to access OMERO. ## How to install -1. Install - the [OMERO.insight plugin for Fiji](https://omero-guides.readthedocs.io/en/latest/fiji/docs/installation.html) (if - you haven't already). +1. Install the [OMERO.insight plugin for Fiji](https://omero-guides.readthedocs.io/en/latest/fiji/docs/installation.html) (if you haven't already). 2. Download the JAR file for this [library](https://github.com/GReD-Clermont/simple-omero-client/releases/latest/). 3. Download the JAR file ([for this plugin](https://github.com/GReD-Clermont/omero_macro-extensions/releases/latest/)). 4. Place these JAR files in your plugins folder. @@ -193,8 +191,8 @@ imageplusID = Ext.getImage(imageIds[0]); ROIs from OMERO can also be added to the ROI manager (and the current image). ROIs composed of multiple shapes (eg 3D/4D) will share the same values in the "ROI" and "ROI_ID" properties in ImageJ. These can be optionnally changed with -the "property" parameter: local indices will be in "property" while OMERO IDs will be in "property + _ID". -This is achieved through: +the "property" parameter: local indices will be in "property" while OMERO IDs will be in "property + _ID". This is +achieved through: ``` nIJROIs = Ext.getROIs(imageIds[0], property); diff --git a/src/main/java/fr/igred/ij/plugin/OMEROMacroExtension.java b/src/main/java/fr/igred/ij/plugin/OMEROMacroExtension.java index e49dafc..8c3f698 100644 --- a/src/main/java/fr/igred/ij/plugin/OMEROMacroExtension.java +++ b/src/main/java/fr/igred/ij/plugin/OMEROMacroExtension.java @@ -243,16 +243,20 @@ public void deleteFile(long fileId) { public void addToTable(String tableName, ResultsTable results, Long imageId, List ijRois, String property) { TableWrapper table = tables.get(tableName); - try { - if (table == null) { - table = new TableWrapper(client, results, imageId, ijRois, property); - table.setName(tableName); - tables.put(tableName, table); - } else { - table.addRows(client, results, imageId, ijRois, property); + if(results == null) { + IJ.error("Results table does not exist."); + } else { + try { + if (table == null) { + table = new TableWrapper(client, results, imageId, ijRois, property); + table.setName(tableName); + tables.put(tableName, table); + } else { + table.addRows(client, results, imageId, ijRois, property); + } + } catch (ExecutionException | ServiceException | AccessException e) { + IJ.error("Could not add results to table: " + e.getMessage()); } - } catch (ExecutionException | ServiceException | AccessException e) { - IJ.error("Could not add results to table: " + e.getMessage()); } }