1
+ /*-
2
+ * #%L
3
+ * BigDataViewer core classes with minimal dependencies.
4
+ * %%
5
+ * Copyright (C) 2012 - 2025 BigDataViewer developers.
6
+ * %%
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice,
11
+ * this list of conditions and the following disclaimer.
12
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ * this list of conditions and the following disclaimer in the documentation
14
+ * and/or other materials provided with the distribution.
15
+ *
16
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
+ * POSSIBILITY OF SUCH DAMAGE.
27
+ * #L%
28
+ */
29
+ import bdv .util .Bdv ;
30
+ import bdv .util .BdvFunctions ;
31
+ import bdv .util .BdvOptions ;
32
+ import bdv .util .BdvStackSource ;
33
+ import net .imglib2 .RandomAccessibleInterval ;
34
+ import net .imglib2 .img .array .ArrayImgs ;
35
+ import net .imglib2 .type .numeric .integer .UnsignedByteType ;
36
+ import org .janelia .saalfeldlab .n5 .N5Reader ;
37
+ import org .scijava .links .AbstractLinkHandler ;
38
+ import org .scijava .links .LinkHandler ;
39
+ import org .scijava .plugin .Parameter ;
40
+ import org .scijava .plugin .Plugin ;
41
+ import org .scijava .ui .UIService ;
42
+ import org .slf4j .Logger ;
43
+ import org .slf4j .LoggerFactory ;
44
+
45
+ import com .google .gson .JsonParseException ;
46
+
47
+ import javax .swing .*;
48
+
49
+ import java .io .UnsupportedEncodingException ;
50
+ import java .net .URI ;
51
+ import java .net .URLDecoder ;
52
+ import java .nio .charset .StandardCharsets ;
53
+
54
+ @ Plugin (type = LinkHandler .class )
55
+ public class BDVLinkHandlerPlugin extends AbstractLinkHandler {
56
+
57
+ private static final Logger LOG = LoggerFactory .getLogger ( LinkActions .class );
58
+
59
+ public static final String PLUGIN_NAME = "BDV" ;
60
+
61
+ @ Parameter
62
+ private UIService uiService ;
63
+
64
+ @ Override
65
+ public void handle (final URI uri ){
66
+ if (!supports (uri )) throw new UnsupportedOperationException ("" + uri );
67
+ String query = uri .getQuery ();
68
+ if (query == null || query .isEmpty ()) {
69
+ // TODO open an empty BDV window
70
+ throw new UnsupportedOperationException ("Not implemented yet" );
71
+ } else {
72
+ String decoded_query ;
73
+ try {
74
+ decoded_query = URLDecoder .decode (query , StandardCharsets .UTF_8 .name ());
75
+ } catch (UnsupportedEncodingException e ) {
76
+ LOG .error ("Failed to decode JSON from URI: {}" , uri , e );
77
+ return ;
78
+ }
79
+ try
80
+ {
81
+ // TODO handle the decoded JSON query
82
+ // Links.paste( decoded_query, panel, converterSetups, pasteSettings, resources );
83
+ throw new UnsupportedOperationException ("Not implemented yet" );
84
+ }
85
+ catch ( final JsonParseException | IllegalArgumentException e )
86
+ {
87
+ LOG .debug ( "pasted JSON is malformed:\n \" {}\" " , pastedText , e );
88
+ }
89
+ }
90
+
91
+ }
92
+
93
+
94
+
95
+ @ Override
96
+ public boolean supports (final URI uri ) {
97
+ return super .supports (uri ) && PLUGIN_NAME .equals (org .scijava .links .Links .operation (uri ));
98
+ }
99
+
100
+
101
+ }
0 commit comments