Sebastian Stenzel 9 yıl önce
ebeveyn
işleme
807fdae3b9

+ 3 - 0
main/frontend-api/src/main/java/org/cryptomator/frontend/Frontend.java

@@ -23,4 +23,7 @@ public interface Frontend extends AutoCloseable {
 
 	void reveal() throws CommandFailedException;
 
+	// For now let's assume every single frontend knows what a WebDAV url is ;-)
+	String getWebDavUrl();
+
 }

+ 5 - 0
main/frontend-webdav/src/main/java/org/cryptomator/frontend/webdav/WebDavFrontend.java

@@ -62,4 +62,9 @@ class WebDavFrontend implements Frontend {
 		}
 	}
 
+	@Override
+	public String getWebDavUrl() {
+		return uri.toString();
+	}
+
 }

+ 9 - 0
main/ui/src/main/java/org/cryptomator/ui/controllers/UnlockedController.java

@@ -39,6 +39,8 @@ import javafx.scene.chart.XYChart.Series;
 import javafx.scene.control.ContextMenu;
 import javafx.scene.control.Label;
 import javafx.scene.control.ToggleButton;
+import javafx.scene.input.Clipboard;
+import javafx.scene.input.ClipboardContent;
 import javafx.stage.PopupWindow.AnchorLocation;
 import javafx.stage.Stage;
 import javafx.util.Duration;
@@ -155,6 +157,13 @@ public class UnlockedController extends AbstractFXMLViewController {
 		});
 	}
 
+	@FXML
+	private void didClickCopyUrl(ActionEvent event) {
+		ClipboardContent clipboardContent = new ClipboardContent();
+		clipboardContent.putUrl(vault.get().getWebDavUrl());
+		Clipboard.getSystemClipboard().setContent(clipboardContent);
+	}
+
 	// ****************************************
 	// MAC Auth Warnings
 	// ****************************************

+ 4 - 0
main/ui/src/main/java/org/cryptomator/ui/model/Vault.java

@@ -176,6 +176,10 @@ public class Vault implements Serializable, CryptoFileSystemDelegate {
 	// Getter/Setter
 	// *******************************************************************************/
 
+	public String getWebDavUrl() {
+		return filesystemFrontend.get().map(Frontend::getWebDavUrl).orElseThrow(IllegalStateException::new);
+	}
+
 	public Path getPath() {
 		return path;
 	}

+ 1 - 1
main/ui/src/main/resources/fxml/unlocked.fxml

@@ -30,7 +30,7 @@
 			<items>
 				<MenuItem text="%unlocked.moreOptions.reveal" onAction="#didClickRevealVault"/>
 				<!-- Future use: -->
-				<MenuItem text="%unlocked.moreOptions.copyUrl" disable="true"/>
+				<MenuItem text="%unlocked.moreOptions.copyUrl" onAction="#didClickCopyUrl"/>
 			</items>
 		</ContextMenu>
 	</fx:define>