@Autowired public TabService( final ApplicationController controller, final WebviewService webviewService, final EditorService editorService, final PathResolverService pathResolver, final ThreadService threadService, final Current current, final DirectoryService directoryService) { this.controller = controller; this.webviewService = webviewService; this.editorService = editorService; this.pathResolver = pathResolver; this.threadService = threadService; this.current = current; this.directoryService = directoryService; final Consumer<Path> openFileConsumer = path -> { if (Files.isDirectory(path)) { directoryService.changeWorkigDir( path.equals(directoryService.workingDirectory()) ? path.getParent() : path); } else if (pathResolver.isImage(path)) { addImageTab(path); } else if (pathResolver.isHTML(path) || pathResolver.isAsciidoc(path) || pathResolver.isMarkdown(path)) { addTab(path); } else if (pathResolver.isEpub(path)) { controller .getHostServices() .showDocument( String.format( "http://localhost:%d/epub/viewer?path=%s", controller.getPort(), path.toString())); } else { List<String> supportedModes = controller.getSupportedModes(); String extension = FilenameUtils.getExtension(path.toString()); if ("".equals(extension) || supportedModes.contains(extension)) { addTab(path); controller.hidePreviewPanel(); } else { controller.getHostServices().showDocument(path.toUri().toString()); } } }; directoryService.setOpenFileConsumer(openFileConsumer); }