From 3994af2b15dc8a41d91eda143dd6dbe56dc64df3 Mon Sep 17 00:00:00 2001 From: Mark Nellemann Date: Wed, 9 Aug 2023 16:17:17 +0200 Subject: [PATCH] Copy to clipboard on select. --- build.gradle | 2 +- .../nellemann/mdexpl/NetworkServiceCell.java | 21 +++++++++++++++---- .../mdexpl/service/DiscoveryService.java | 15 ++++++++++++- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 9c1ebd6..67b8839 100644 --- a/build.gradle +++ b/build.gradle @@ -63,7 +63,7 @@ gluonfx { attachConfig { version = "4.0.18" - services 'storage', 'display', 'lifecycle', 'statusbar', 'cache' + services 'storage', 'display', 'lifecycle', 'statusbar' } reflectionList = [ diff --git a/src/main/java/biz/nellemann/mdexpl/NetworkServiceCell.java b/src/main/java/biz/nellemann/mdexpl/NetworkServiceCell.java index 4b1ae7f..296b7b7 100644 --- a/src/main/java/biz/nellemann/mdexpl/NetworkServiceCell.java +++ b/src/main/java/biz/nellemann/mdexpl/NetworkServiceCell.java @@ -1,19 +1,27 @@ package biz.nellemann.mdexpl; import biz.nellemann.mdexpl.model.NetworkService; +import com.gluonhq.attach.util.impl.ClipboardUtils; import com.gluonhq.charm.glisten.control.CharmListCell; import com.gluonhq.charm.glisten.control.ListTile; -import javafx.scene.Node; -import javafx.scene.paint.Color; +import javafx.scene.input.ClipboardContent; import javafx.scene.shape.Rectangle; +import javafx.scene.input.Clipboard; + +import java.util.Optional; public class NetworkServiceCell extends CharmListCell { private final ListTile tile; - //private final ImageView imageView; private final Rectangle icon; + private final Clipboard clipboard; + private final ClipboardContent clipboardContent; + public NetworkServiceCell() { + clipboard = Clipboard.getSystemClipboard(); + clipboardContent = new ClipboardContent(); + this.tile = new ListTile(); //imageView = new ImageView(); //imageView.setFitHeight(15); @@ -23,7 +31,12 @@ public class NetworkServiceCell extends CharmListCell { icon.setHeight(25); icon.setWidth(25); tile.setPrimaryGraphic(icon); - tile.setOnMouseClicked(e -> { System.out.println("Selected -> " + itemProperty().get().getName() ); }); + tile.setOnMouseClicked(e -> { + System.out.println("Selected -> " + itemProperty().get().getName() ); + clipboardContent.putString(itemProperty().get().getUrl()); + clipboard.setContent(clipboardContent); + // TODO: Copy to iOS / Android clipboard + }); setText(null); } diff --git a/src/main/java/biz/nellemann/mdexpl/service/DiscoveryService.java b/src/main/java/biz/nellemann/mdexpl/service/DiscoveryService.java index 7f6e8c2..e4dd045 100644 --- a/src/main/java/biz/nellemann/mdexpl/service/DiscoveryService.java +++ b/src/main/java/biz/nellemann/mdexpl/service/DiscoveryService.java @@ -32,26 +32,39 @@ public class DiscoveryService { "googlecast", "sonos", "airplay", "smartenergy", "skype", "bittorrent" );*/ - // From: http://www.dns-sd.org/serviceTypes.html + some guesses + // From: http://www.dns-sd.org/serviceTypes.html + + // https://jonathanmumm.com/tech-it/mdns-bonjour-bible-common-service-strings-for-various-vendors/ + some guesses private final Map services = new HashMap<>() {{ put("http", Color.BLUE); put("https", Color.DARKBLUE); put("googlecast", Color.RED); + //put("googlezone", Color.RED); + put("googlerpc", Color.RED); put("airplay", Color.SLATEGRAY); put("sonos", Color.SANDYBROWN); + //put("spotify-connect", Color.SANDYBROWN); + + put("ssh", Color.GOLD); + put("rdp", Color.GOLD); + put("teamviewer", Color.GOLD); put("ipp", Color.LIGHTGRAY); put("ipps", Color.LIGHTGRAY); + put("printer", Color.LIGHTGRAY); put("nfs", Color.CORAL); put("smb", Color.CORAL); put("cifs", Color.CORAL); + put("webdav", Color.CORAL); put("smartenergy", Color.LIGHTGREEN); + put("homekit", Color.LIGHTGREEN); put("sip", Color.YELLOW); put("skype", Color.YELLOW); + + //put("rdlink", Color.KHAKI); }};