Skip to content

Commit 8cab531

Browse files
stefanhahmannclaude
andcommitted
Expose backend selection in the drag-and-drop settings UI
Adds a reader-backend choice field to DragAndDropBehaviorSettings so users can pick the OME-Zarr reader (N5 vs zarr-java) from Plugins > OME-Zarr > Drag & Drop Behavior Settings, and updates the neighboring help text to reflect support for OME-Zarr v0.4 and v0.5. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent d5d208d commit 8cab531

1 file changed

Lines changed: 32 additions & 4 deletions

File tree

src/main/java/sc/fiji/ome/zarr/plugins/DragAndDropBehaviorSettings.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
* %%
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions are met:
9-
*
9+
*
1010
* 1. Redistributions of source code must retain the above copyright notice,
1111
* this list of conditions and the following disclaimer.
1212
* 2. Redistributions in binary form must reproduce the above copyright notice,
1313
* this list of conditions and the following disclaimer in the documentation
1414
* and/or other materials provided with the distribution.
15-
*
15+
*
1616
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1717
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1818
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -44,6 +44,7 @@
4444

4545
import sc.fiji.ome.zarr.settings.ZarrDragAndDropOpenSettings;
4646
import sc.fiji.ome.zarr.settings.ZarrOpenBehavior;
47+
import sc.fiji.ome.zarr.settings.ZarrReaderBackend;
4748

4849
/**
4950
* A FIJI/ImageJ command to select what to do when an OME-Zarr image is Drag &amp; Dropped into Fiji.
@@ -86,15 +87,29 @@ public class DragAndDropBehaviorSettings extends DynamicCommand
8687
+ "</body>"
8788
+ "</html>";
8889

90+
@SuppressWarnings( "all" )
91+
@Parameter( label = "Reader backend", description = "Choose which library is used to read OME-Zarr datasets", initializer = "initZarrReaderBackends" )
92+
private String readerBackendChoice;
93+
94+
@SuppressWarnings( "all" )
95+
@Parameter( visibility = ItemVisibility.MESSAGE, required = false, persist = false )
96+
private String readerBackendInfo = "<html>"
97+
+ "<body width=" + WIDTH + "cm align=left>"
98+
+ "N5 supports OME-Zarr v0.4 (Zarr v2) - v0.5 (Zarr v3).<br>"
99+
+ "zarr-java supports OME-Zarr v0.4 (Zarr v2) - v0.3 (Zarr v3)."
100+
+ "</body>"
101+
+ "</html>";
102+
89103
private ZarrDragAndDropOpenSettings settings;
90104

91105
@Override
92106
public void run()
93107
{
94108
settings.setCurrentChoice( ZarrOpenBehavior.getByDescription( defaultZarrOpenBehavior ) );
95109
settings.setPreferredMaxWidth( preferredWidth );
96-
logger.debug( "Now saving OME-Zarr Drag & Drop settings to user preferences. Behavior: {}, preferredWidth: {}",
97-
settings.getOpenBehavior(), preferredWidth );
110+
settings.setReaderBackend( ZarrReaderBackend.getByDescription( readerBackendChoice ) );
111+
logger.debug( "Now saving OME-Zarr Drag & Drop settings to user preferences. Behavior: {}, preferredWidth: {}, readerBackend: {}",
112+
settings.getOpenBehavior(), preferredWidth, settings.getReaderBackend() );
98113
settings.saveSettingsToPreferences( prefService );
99114
}
100115

@@ -104,6 +119,7 @@ private void init()
104119
settings = ZarrDragAndDropOpenSettings.loadSettingsFromPreferences( prefService );
105120
defaultZarrOpenBehavior = settings.getOpenBehavior().getDescription();
106121
preferredWidth = settings.getPreferredMaxWidth();
122+
readerBackendChoice = settings.getReaderBackend().getDescription();
107123
}
108124

109125
@SuppressWarnings( "unused" )
@@ -112,8 +128,20 @@ private void initZarrOpenBehaviors()
112128
getInfo().getMutableInput( "defaultZarrOpenBehavior", String.class ).setChoices( enumNamesAsList( ZarrOpenBehavior.values() ) );
113129
}
114130

131+
@SuppressWarnings( "unused" )
132+
private void initZarrReaderBackends()
133+
{
134+
getInfo().getMutableInput( "readerBackendChoice", String.class )
135+
.setChoices( readerBackendDescriptions( ZarrReaderBackend.values() ) );
136+
}
137+
115138
static List< String > enumNamesAsList( final ZarrOpenBehavior[] values )
116139
{
117140
return Arrays.stream( values ).map( ZarrOpenBehavior::getDescription ).collect( Collectors.toList() );
118141
}
142+
143+
static List< String > readerBackendDescriptions( final ZarrReaderBackend[] values )
144+
{
145+
return Arrays.stream( values ).map( ZarrReaderBackend::getDescription ).collect( Collectors.toList() );
146+
}
119147
}

0 commit comments

Comments
 (0)