Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #10175, #10953: shorten image name #1710

Merged
merged 6 commits into from
Nov 14, 2013
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
46 changes: 25 additions & 21 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)
{
saveName = userSpecifiedName;
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.trim();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it only me, or is the trim() method called twice on the userSpecifiedName object, in this code path (cf. line 161)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thank you, the latter preceded the former. (-:


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