← 返回首页
ADD: SelfShowableContent - a new kind of opening outcome by xulman · Pull Request #473 · scijava/scijava-common · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus

ADD: SelfShowableContent - a new kind of opening outcome#473

Open
xulman wants to merge 1 commit into
scijava:masterfrom
xulman:SelfShowableContent
Open

ADD: SelfShowableContent - a new kind of opening outcome#473
xulman wants to merge 1 commit into
scijava:masterfrom
xulman:SelfShowableContent

Conversation

Copy link
Copy Markdown

xulman commented Oct 18, 2023

It is often used in conjuction with openers that do load-and-show on their own,
as opposed to load-only-and-have-Fiji-to-show pattern.

Requires a patch on the imagej-legacy side... will PR there too.

Example code

package sc.fiji.ome.zarr.fiji.ui; import net.imagej.ImageJ; import org.scijava.io.AbstractIOPlugin; import org.scijava.io.IOPlugin; import org.scijava.io.location.Location; import org.scijava.plugin.Attr; import org.scijava.plugin.Plugin; import org.scijava.ui.SelfShowableContent; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @Plugin(type = IOPlugin.class, attrs = @Attr(name = "eager")) public class MinimalFolderOpeningExample extends AbstractIOPlugin<Object> { @Override public boolean supportsOpen(Location source) { System.out.println(this.getClass().getName() + " is considering the file "+source); // final Path filePath = Paths.get(source.getURI()); boolean canOpen = Files.isDirectory(filePath) && filePath.toString().endsWith(".xyz"); System.out.println(this.getClass().getName() + " says canOpen = " + canOpen); return canOpen; } @Override public Object open(Location source) throws IOException { final String message = this.getClass().getName() + " is opening the file "+source; return new SelfShowableContent<>( source.toString(), m -> System.out.println("I just took care of the .xyz folder: "+m) ); } @Override public Class<Object> getDataType() { return Object.class; } public static void main(String[] args) { ImageJ ij = new ImageJ(); ij.ui().showUI(); } }

Copy link
Copy Markdown
Author

xulman commented Oct 18, 2023

this PR becomes useful only in conjunction with imagej/imagej-legacy#302

It is often used in conjuction with openers that do load-and-show on their own, as opposite to load-only-and-have-Fiji-to-show pattern.
xulman force-pushed the SelfShowableContent branch from cdc04ef to 13626d1 Compare March 4, 2024 12:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Footer

© 2026 GitHub, Inc.