File tree Expand file tree Collapse file tree
ome-zarr-fiji/src/main/java/ome/zarr/fiji Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,6 +156,7 @@ public Object openIJWithImage()
156156 final PyramidContents < ? > contents = getContents ();
157157 final PyramidalDataset dataset = new PyramidalDataset ( context , contents , preferredResolutionLevel );
158158 context .getService ( UIService .class ).show ( dataset );
159+ context .getService ( PyramidalService .class ).registerImageJDataset ( dataset );
159160 logger .info ( "Opened dataset in ImageJ: {}" , inputUri );
160161 return null ;
161162 },
@@ -191,6 +192,7 @@ public Object openIJWithImage( final int resolutionLevel )
191192 throw new NonExistingResolutionLevelException ( resolutionLevel , contents .numResolutionLevels () );
192193 final PyramidalDataset dataset = new PyramidalDataset ( context , contents , resolutionLevel );
193194 context .getService ( UIService .class ).show ( dataset );
195+ context .getService ( PyramidalService .class ).registerImageJDataset ( dataset );
194196 logger .info ( "Opened dataset at resolution level {} in ImageJ: {}" , resolutionLevel , inputUri );
195197 return null ;
196198 },
Original file line number Diff line number Diff line change @@ -168,10 +168,25 @@ public void unregisterBdvWindow( final Window window )
168168 }
169169
170170 /** Records {@code dataset} as the active pyramidal, replacing any previously active one. */
171- void notifyBdvWindowFocused ( final Pyramidal dataset )
171+ void notifyBdvWindowFocused ( final Pyramidal pyramidal )
172172 {
173- logger .trace ( "BDV window focused: {}" , dataset );
174- activePyramidal .set ( dataset );
173+ logger .trace ( "BDV window focused: {}" , pyramidal );
174+ activePyramidal .set ( pyramidal );
175+ logger .trace ( "Active pyramidal set to: {}" , activePyramidal .get () );
176+ }
177+
178+ /**
179+ * Records the given {@code pyramidal} as the active pyramidal immediately when it is opened in an
180+ * ImageJ window, without waiting for the asynchronous AWT {@code "activeWindow"} focus
181+ * event to arrive at the new {@link ImageWindow}. This mirrors the synchronous registration
182+ * that {@link #registerBdvWindow} performs for BDV windows. So a freshly opened pyramidal is
183+ * the active pyramidal as soon as the open call returns rather than only once the native
184+ * windowing system delivers focus (which may be delayed or never happen under load).
185+ */
186+ public void registerImageJDataset ( final Pyramidal pyramidal )
187+ {
188+ logger .trace ( "ImageJ dataset opened: {}" , pyramidal );
189+ activePyramidal .set ( pyramidal );
175190 logger .trace ( "Active pyramidal set to: {}" , activePyramidal .get () );
176191 }
177192
You can’t perform that action at this time.
0 commit comments