Code cleanup
This commit is contained in:
parent
9037b525bd
commit
60826323f3
|
@ -24,7 +24,9 @@ import javafx.scene.layout.BorderPane;
|
||||||
|
|
||||||
public class DesktopIntegration {
|
public class DesktopIntegration {
|
||||||
|
|
||||||
private static final transient Logger LOG = LoggerFactory.getLogger(DesktopIntegration.class);
|
private DesktopIntegration() {}
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(DesktopIntegration.class);
|
||||||
|
|
||||||
private static SystemTray tray;
|
private static SystemTray tray;
|
||||||
private static TrayIcon trayIcon;
|
private static TrayIcon trayIcon;
|
||||||
|
@ -46,7 +48,7 @@ public class DesktopIntegration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// try external helpers
|
// try external helpers
|
||||||
String[] externalHelpers = {"kde-open5", "kde-open", "gnome-open", "xdg-open"};
|
String[] externalHelpers = { "kde-open5", "kde-open", "gnome-open", "xdg-open" };
|
||||||
Runtime rt = Runtime.getRuntime();
|
Runtime rt = Runtime.getRuntime();
|
||||||
for (String helper : externalHelpers) {
|
for (String helper : externalHelpers) {
|
||||||
try {
|
try {
|
||||||
|
@ -81,7 +83,7 @@ public class DesktopIntegration {
|
||||||
}
|
}
|
||||||
|
|
||||||
// try external helpers
|
// try external helpers
|
||||||
String[] externalHelpers = {"kde-open5", "kde-open", "gnome-open", "xdg-open"};
|
String[] externalHelpers = { "kde-open5", "kde-open", "gnome-open", "xdg-open" };
|
||||||
Runtime rt = Runtime.getRuntime();
|
Runtime rt = Runtime.getRuntime();
|
||||||
for (String helper : externalHelpers) {
|
for (String helper : externalHelpers) {
|
||||||
try {
|
try {
|
||||||
|
@ -108,11 +110,11 @@ public class DesktopIntegration {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void notification(String title, String header, String msg) {
|
public static void notification(String title, String header, String msg) {
|
||||||
if(OS.getOsType() == OS.TYPE.LINUX) {
|
if (OS.getOsType() == OS.TYPE.LINUX) {
|
||||||
notifyLinux(title, header, msg);
|
notifyLinux(title, header, msg);
|
||||||
} else if(OS.getOsType() == OS.TYPE.WINDOWS) {
|
} else if (OS.getOsType() == OS.TYPE.WINDOWS) {
|
||||||
notifyWindows(title, header, msg);
|
notifyWindows(title, header, msg);
|
||||||
} else if(OS.getOsType() == OS.TYPE.MAC) {
|
} else if (OS.getOsType() == OS.TYPE.MAC) {
|
||||||
notifyMac(title, header, msg);
|
notifyMac(title, header, msg);
|
||||||
} else {
|
} else {
|
||||||
// unknown system, try systemtray notification anyways
|
// unknown system, try systemtray notification anyways
|
||||||
|
@ -128,11 +130,11 @@ public class DesktopIntegration {
|
||||||
"-t", "5000",
|
"-t", "5000",
|
||||||
"-a", title,
|
"-a", title,
|
||||||
header,
|
header,
|
||||||
msg.replaceAll("-", "\\\\-").replaceAll("\\s", "\\\\ "),
|
msg.replace("-", "\\\\-").replace("\\s", "\\\\ "),
|
||||||
"--icon=dialog-information"
|
"--icon=dialog-information"
|
||||||
});
|
});
|
||||||
new Thread(new StreamRedirectThread(p.getInputStream(), System.out)).start();
|
new Thread(new StreamRedirectThread(p.getInputStream(), System.out)).start(); // NOSONAR
|
||||||
new Thread(new StreamRedirectThread(p.getErrorStream(), System.err)).start();
|
new Thread(new StreamRedirectThread(p.getErrorStream(), System.err)).start(); // NOSONAR
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
LOG.error("Notification failed", e1);
|
LOG.error("Notification failed", e1);
|
||||||
}
|
}
|
||||||
|
@ -146,9 +148,9 @@ public class DesktopIntegration {
|
||||||
notifySystemTray(title, header, msg);
|
notifySystemTray(title, header, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized static void notifySystemTray(String title, String header, String msg) {
|
private static synchronized void notifySystemTray(String title, String header, String msg) {
|
||||||
if(SystemTray.isSupported()) {
|
if (SystemTray.isSupported()) {
|
||||||
if(tray == null) {
|
if (tray == null) {
|
||||||
LOG.debug("Creating tray icon");
|
LOG.debug("Creating tray icon");
|
||||||
tray = SystemTray.getSystemTray();
|
tray = SystemTray.getSystemTray();
|
||||||
Image image = Toolkit.getDefaultToolkit().createImage(DesktopIntegration.class.getResource("/icon64.png"));
|
Image image = Toolkit.getDefaultToolkit().createImage(DesktopIntegration.class.getResource("/icon64.png"));
|
||||||
|
|
Loading…
Reference in New Issue