-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/java/de/mephisto/vpin/extensions/ServiceRunnerTray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package de.mephisto.vpin.extensions; | ||
|
||
import de.mephisto.vpin.VPinService; | ||
import de.mephisto.vpin.extensions.resources.ResourceLoader; | ||
import de.mephisto.vpin.extensions.util.Config; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class ServiceRunnerTray { | ||
private final static Logger LOG = LoggerFactory.getLogger(ServiceRunnerTray.class); | ||
|
||
public ServiceRunnerTray(VPinService service) { | ||
//Check the SystemTray is supported | ||
if (!SystemTray.isSupported()) { | ||
LOG.info("SystemTray is not supported"); | ||
return; | ||
} | ||
final PopupMenu popup = new PopupMenu(); | ||
final TrayIcon trayIcon = new TrayIcon(ResourceLoader.getResource("logo-small.png")); | ||
final SystemTray tray = SystemTray.getSystemTray(); | ||
MenuItem restartItem = new MenuItem("Restart"); | ||
restartItem.addActionListener(e -> { | ||
try { | ||
Config.reloadAll(); | ||
restartItem.setEnabled(false); | ||
service.restart(); | ||
} catch (Exception ex) { | ||
LOG.error("Failed to restart VPin Extension Service: " + ex.getMessage()); | ||
} | ||
finally { | ||
restartItem.setEnabled(true); | ||
} | ||
}); | ||
MenuItem logsItem = new MenuItem("Show Logs"); | ||
logsItem.addActionListener(e -> { | ||
try { | ||
File file = new File("./vpin-extensions.log"); | ||
if(file.exists()) { | ||
Desktop.getDesktop().open(file); | ||
} | ||
} catch (IOException ex) { | ||
LOG.error("Failed to open log file: " + ex.getMessage()); | ||
} | ||
}); | ||
MenuItem exitItem = new MenuItem("Terminate"); | ||
exitItem.addActionListener(e -> System.exit(0)); | ||
popup.add(restartItem); | ||
popup.add(logsItem); | ||
popup.addSeparator(); | ||
popup.add(exitItem); | ||
|
||
trayIcon.setPopupMenu(popup); | ||
try { | ||
tray.add(trayIcon); | ||
} catch (AWTException e) { | ||
LOG.error("TrayIcon could not be added: " + e.getMessage(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+1.06 KB
(100%)
src/main/resources/de/mephisto/vpin/extensions/resources/logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.