File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed
src/main/java/org/scijava/links Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change 2828 */
2929package org .scijava .links ;
3030
31+ import org .scijava .event .ContextCreatedEvent ;
32+ import org .scijava .event .EventHandler ;
3133import org .scijava .plugin .AbstractHandlerService ;
3234import org .scijava .plugin .Plugin ;
3335import org .scijava .service .Service ;
3436
37+ import java .awt .Desktop ;
3538import java .net .URI ;
3639
3740/**
4144 */
4245@ Plugin (type = Service .class )
4346public class DefaultLinkService extends AbstractHandlerService <URI , LinkHandler > implements LinkService {
44- // NB: No implementation needed.
47+
48+ @ EventHandler
49+ private void onEvent (final ContextCreatedEvent evt ) {
50+ // Register URI handler with the desktop system, if possible.
51+ if (!Desktop .isDesktopSupported ()) return ;
52+ final Desktop desktop = Desktop .getDesktop ();
53+ if (!desktop .isSupported (Desktop .Action .APP_OPEN_URI )) return ;
54+ desktop .setOpenURIHandler (event -> handle (event .getURI ()));
55+ }
56+
4557}
Original file line number Diff line number Diff line change 3232import org .scijava .plugin .HandlerService ;
3333import org .scijava .service .SciJavaService ;
3434
35- import java .awt .*;
3635import java .net .URI ;
3736import java .util .Optional ;
3837
@@ -68,18 +67,6 @@ default Class<LinkHandler> getPluginType() {
6867 return LinkHandler .class ;
6968 }
7069
71- // -- Service methods --
72-
73- @ Override
74- default void initialize () {
75- HandlerService .super .initialize ();
76- // Register URI handler with the desktop system, if possible.
77- if (!Desktop .isDesktopSupported ()) return ;
78- final Desktop desktop = Desktop .getDesktop ();
79- if (!desktop .isSupported (Desktop .Action .APP_OPEN_URI )) return ;
80- desktop .setOpenURIHandler (event -> handle (event .getURI ()));
81- }
82-
8370 // -- Typed methods --
8471
8572 @ Override
You can’t perform that action at this time.
0 commit comments