diff --git a/components/blitz/src/ome/formats/importer/ImportCandidates.java b/components/blitz/src/ome/formats/importer/ImportCandidates.java index 88170124c8f..f67e2b42533 100644 --- a/components/blitz/src/ome/formats/importer/ImportCandidates.java +++ b/components/blitz/src/ome/formats/importer/ImportCandidates.java @@ -424,7 +424,7 @@ protected ImportContainer singleFile(File file, ImportConfig config) String configImageName = config.userSpecifiedName.get(); if (configImageName == null) { - ic.setUserSpecifiedName(path); + ic.setUserSpecifiedName(file.getName()); } else { @@ -567,8 +567,7 @@ private void safeUpdate(ImportEvent event) { * @param depth - depth of scan * @param collection */ - @SuppressWarnings("unchecked") - @Override + @Override public void handleFile(File file, int depth, Collection collection) { count++; diff --git a/components/blitz/src/ome/formats/model/PixelsProcessor.java b/components/blitz/src/ome/formats/model/PixelsProcessor.java index efa2b17aa09..083d6fd0e77 100644 --- a/components/blitz/src/ome/formats/model/PixelsProcessor.java +++ b/components/blitz/src/ome/formats/model/PixelsProcessor.java @@ -157,32 +157,36 @@ public void process(IObjectContainerStore store) // Ensure that the Image name is set String userSpecifiedName = store.getUserSpecifiedName(); + if (userSpecifiedName != null) { + userSpecifiedName = userSpecifiedName.trim(); + if (userSpecifiedName.isEmpty()) { + userSpecifiedName = null; + } + } String saveName = ""; - if (image.getName() == null - || image.getName().getValue().trim().length() == 0 - || userSpecifiedName != null) - { + String imageName; + if (image.getName() != null && image.getName().getValue() != null) { + imageName = image.getName().getValue().trim(); + if (imageName.isEmpty()) { + imageName = null; + } + } else { + imageName = null; + } + if (userSpecifiedName != null) { saveName = userSpecifiedName; - if (reader.getSeriesCount() > 1) - { - if (image.getName() == null) - { - saveName += " [" + imageIndex + "]"; - } - else if (image.getName().getValue().trim().length() != 0) - { - saveName += " [" + image.getName().getValue() + "]"; - } - else - { - saveName += " [" + imageIndex + "]"; + if (reader.getSeriesCount() > 1) { + if (imageName == null) { + imageName = Integer.toString(imageIndex); } + saveName += " [" + imageName + "]"; } + } else { + saveName = imageName; } - else - { - saveName = image.getName().getValue(); + if (saveName != null && saveName.length() > 255) { + saveName = '…' + saveName.substring(saveName.length() - 254); } image.setName(rstring(saveName));