Skip to content

Commit 4e572d7

Browse files
authored
Merge pull request #16 from cryptomator/feature/reveal-files-service
Feature/reveal files service
2 parents 4addcad + c08b8a7 commit 4e572d7

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/main/java/module-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import org.cryptomator.integrations.mount.MountService;
2+
import org.cryptomator.integrations.revealpath.RevealPathService;
23
import org.cryptomator.integrations.tray.TrayMenuController;
34
import org.cryptomator.integrations.autostart.AutoStartProvider;
45
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
@@ -14,12 +15,14 @@
1415
exports org.cryptomator.integrations.common;
1516
exports org.cryptomator.integrations.keychain;
1617
exports org.cryptomator.integrations.mount;
18+
exports org.cryptomator.integrations.revealpath;
1719
exports org.cryptomator.integrations.tray;
1820
exports org.cryptomator.integrations.uiappearance;
1921

2022
uses AutoStartProvider;
2123
uses KeychainAccessProvider;
2224
uses MountService;
25+
uses RevealPathService;
2326
uses TrayIntegrationProvider;
2427
uses TrayMenuController;
2528
uses UiAppearanceProvider;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.cryptomator.integrations.revealpath;
2+
3+
public class RevealFailedException extends Exception {
4+
5+
public RevealFailedException(String msg) {
6+
super(msg);
7+
}
8+
9+
public RevealFailedException(Exception cause) {
10+
super(cause);
11+
}
12+
13+
public RevealFailedException(String msg, Exception cause) {
14+
super(msg, cause);
15+
}
16+
17+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package org.cryptomator.integrations.revealpath;
2+
3+
import org.cryptomator.integrations.common.IntegrationsLoader;
4+
5+
import java.nio.file.Path;
6+
import java.util.stream.Stream;
7+
8+
public interface RevealPathService {
9+
10+
/**
11+
* Loads all supported service providers.
12+
*
13+
* @return Stream of supported RevealPathService implementations (may be empty)
14+
*/
15+
static Stream<RevealPathService> get() {
16+
return IntegrationsLoader.loadAll(RevealPathService.class).filter(RevealPathService::isSupported);
17+
}
18+
19+
/**
20+
* Reveal the path in the system default file manager.
21+
* <p>
22+
* If the path points to a file, the parent of the file is opened and the file is selected in the file manager window.
23+
* If the path points to a directory, the directory is opened and its content shown in the file manager window.
24+
*
25+
* @param p Path to reveal
26+
* @throws RevealFailedException if revealing the path failed
27+
*/
28+
void reveal(Path p) throws RevealFailedException;
29+
30+
/**
31+
* Indicates, if this provider can be used.
32+
*
33+
* @return true, if this provider is supported in the current OS environment
34+
* @implSpec This check needs to return fast and in constant time
35+
*/
36+
boolean isSupported();
37+
38+
}

0 commit comments

Comments
 (0)