forked from Qortal/qortal
Add ZH translations for SysTray pop-up menu.
Reduce log spam when SysTray can't open Node UI in browser, e.g. no browser installed, or no association for URLs.
This commit is contained in:
parent
0d85a60c54
commit
6942c02700
@ -7,7 +7,6 @@ import java.awt.SystemTray;
|
|||||||
import java.awt.TrayIcon;
|
import java.awt.TrayIcon;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
@ -15,6 +14,7 @@ import javax.swing.SwingWorker;
|
|||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.qora.controller.Controller;
|
import org.qora.controller.Controller;
|
||||||
|
import org.qora.globalization.Translator;
|
||||||
import org.qora.settings.Settings;
|
import org.qora.settings.Settings;
|
||||||
import org.qora.utils.URLViewer;
|
import org.qora.utils.URLViewer;
|
||||||
|
|
||||||
@ -59,19 +59,19 @@ public class SysTray {
|
|||||||
private PopupMenu createPopupMenu() {
|
private PopupMenu createPopupMenu() {
|
||||||
PopupMenu menu = new PopupMenu();
|
PopupMenu menu = new PopupMenu();
|
||||||
|
|
||||||
MenuItem openUi = new MenuItem("Open UI");
|
MenuItem openUi = new MenuItem(Translator.INSTANCE.translate("SysTray", "OPEN_NODE_UI"));
|
||||||
openUi.addActionListener(new ActionListener() {
|
openUi.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
try {
|
try {
|
||||||
URLViewer.openWebpage(new URL("http://localhost:" + Settings.getInstance().getUiPort()));
|
URLViewer.openWebpage(new URL("http://localhost:" + Settings.getInstance().getUiPort()));
|
||||||
} catch (MalformedURLException e1) {
|
} catch (Exception e1) {
|
||||||
LOGGER.error(e1.getMessage(),e1);
|
LOGGER.error("Unable to open node UI in browser");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
menu.add(openUi);
|
menu.add(openUi);
|
||||||
|
|
||||||
MenuItem exit = new MenuItem("Exit");
|
MenuItem exit = new MenuItem(Translator.INSTANCE.translate("SysTray", "EXIT"));
|
||||||
exit.addActionListener(new ActionListener() {
|
exit.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
new ClosingWorker().execute();
|
new ClosingWorker().execute();
|
||||||
|
@ -12,23 +12,18 @@ public class URLViewer {
|
|||||||
|
|
||||||
private static final Logger LOGGER = LogManager.getLogger(URLViewer.class);
|
private static final Logger LOGGER = LogManager.getLogger(URLViewer.class);
|
||||||
|
|
||||||
public static void openWebpage(URI uri) {
|
public static void openWebpage(URI uri) throws Exception {
|
||||||
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
|
Desktop desktop = Desktop.isDesktopSupported() ? Desktop.getDesktop() : null;
|
||||||
|
|
||||||
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
|
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE))
|
||||||
try {
|
|
||||||
desktop.browse(uri);
|
desktop.browse(uri);
|
||||||
} catch (Exception e) {
|
|
||||||
LOGGER.error(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openWebpage(URL url) {
|
public static void openWebpage(URL url) throws Exception {
|
||||||
try {
|
try {
|
||||||
openWebpage(url.toURI());
|
openWebpage(url.toURI());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
LOGGER.error(e.getMessage(), e);
|
LOGGER.error(String.format("Invalid URL: %s", url.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# SysTray pop-up menu
|
||||||
|
OPEN_NODE_UI=Open Node UI
|
||||||
|
EXIT=Exit
|
||||||
|
|
||||||
# Nagging about lack of NTP time sync
|
# Nagging about lack of NTP time sync
|
||||||
NTP_NAG_CAPTION=No connections?
|
NTP_NAG_CAPTION=No connections?
|
||||||
NTP_NAG_TEXT=Please enable Windows automatic time synchronization
|
NTP_NAG_TEXT=Please enable Windows automatic time synchronization
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
# SysTray pop-up menu
|
||||||
|
OPEN_NODE_UI=开启界面
|
||||||
|
EXIT=退出软件
|
||||||
|
|
||||||
# Nagging about lack of NTP time sync
|
# Nagging about lack of NTP time sync
|
||||||
NTP_NAG_CAPTION=No connections?
|
NTP_NAG_CAPTION=没有连接上节点?
|
||||||
NTP_NAG_TEXT=Please enable Windows automatic time synchronization
|
NTP_NAG_TEXT=请启用Windows自动时间同步。
|
||||||
|
Loading…
x
Reference in New Issue
Block a user