Skip to content

Commit

Permalink
Merge pull request #1710 from mtbc/trac-10175-long-image-path
Browse files Browse the repository at this point in the history
fix #10175, #10953: shorten image name
  • Loading branch information
joshmoore committed Nov 14, 2013
2 parents d279094 + 9df5564 commit 0a414bf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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++;
Expand Down
44 changes: 24 additions & 20 deletions components/blitz/src/ome/formats/model/PixelsProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit 0a414bf

Please sign in to comment.