diff --git a/build.xml b/build.xml
index 45d8fe1..1f1df10 100644
--- a/build.xml
+++ b/build.xml
@@ -69,5 +69,16 @@
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
+
-->
+
+
+
+
+
+
+
+
+
+
diff --git a/app/putty.exe b/resources/app/putty.exe
similarity index 100%
rename from app/putty.exe
rename to resources/app/putty.exe
diff --git a/app/winbox.exe b/resources/app/winbox.exe
similarity index 100%
rename from app/winbox.exe
rename to resources/app/winbox.exe
diff --git a/config.properties b/resources/config.properties
similarity index 100%
rename from config.properties
rename to resources/config.properties
diff --git a/img/add.png b/resources/img/add.png
similarity index 100%
rename from img/add.png
rename to resources/img/add.png
diff --git a/img/app.png b/resources/img/app.png
similarity index 100%
rename from img/app.png
rename to resources/img/app.png
diff --git a/img/browser.png b/resources/img/browser.png
similarity index 100%
rename from img/browser.png
rename to resources/img/browser.png
diff --git a/img/connect.png b/resources/img/connect.png
similarity index 100%
rename from img/connect.png
rename to resources/img/connect.png
diff --git a/img/flag_gray.png b/resources/img/flag_gray.png
similarity index 100%
rename from img/flag_gray.png
rename to resources/img/flag_gray.png
diff --git a/img/flag_green.png b/resources/img/flag_green.png
similarity index 100%
rename from img/flag_green.png
rename to resources/img/flag_green.png
diff --git a/img/flag_orange.png b/resources/img/flag_orange.png
similarity index 100%
rename from img/flag_orange.png
rename to resources/img/flag_orange.png
diff --git a/img/flag_red.png b/resources/img/flag_red.png
similarity index 100%
rename from img/flag_red.png
rename to resources/img/flag_red.png
diff --git a/img/lock.png b/resources/img/lock.png
similarity index 100%
rename from img/lock.png
rename to resources/img/lock.png
diff --git a/img/log.png b/resources/img/log.png
similarity index 100%
rename from img/log.png
rename to resources/img/log.png
diff --git a/img/no.png b/resources/img/no.png
similarity index 100%
rename from img/no.png
rename to resources/img/no.png
diff --git a/img/online_clients.png b/resources/img/online_clients.png
similarity index 100%
rename from img/online_clients.png
rename to resources/img/online_clients.png
diff --git a/img/ping.png b/resources/img/ping.png
similarity index 100%
rename from img/ping.png
rename to resources/img/ping.png
diff --git a/img/platform_android.png b/resources/img/platform_android.png
similarity index 100%
rename from img/platform_android.png
rename to resources/img/platform_android.png
diff --git a/img/platform_pc.png b/resources/img/platform_pc.png
similarity index 100%
rename from img/platform_pc.png
rename to resources/img/platform_pc.png
diff --git a/img/server_connected.png b/resources/img/server_connected.png
similarity index 100%
rename from img/server_connected.png
rename to resources/img/server_connected.png
diff --git a/img/server_not_connected.png b/resources/img/server_not_connected.png
similarity index 100%
rename from img/server_not_connected.png
rename to resources/img/server_not_connected.png
diff --git a/img/server_settings.png b/resources/img/server_settings.png
similarity index 100%
rename from img/server_settings.png
rename to resources/img/server_settings.png
diff --git a/img/settings.png b/resources/img/settings.png
similarity index 100%
rename from img/settings.png
rename to resources/img/settings.png
diff --git a/img/ssh.png b/resources/img/ssh.png
similarity index 100%
rename from img/ssh.png
rename to resources/img/ssh.png
diff --git a/img/trash.png b/resources/img/trash.png
similarity index 100%
rename from img/trash.png
rename to resources/img/trash.png
diff --git a/img/unlock.png b/resources/img/unlock.png
similarity index 100%
rename from img/unlock.png
rename to resources/img/unlock.png
diff --git a/img/winbox.png b/resources/img/winbox.png
similarity index 100%
rename from img/winbox.png
rename to resources/img/winbox.png
diff --git a/img/yes.png b/resources/img/yes.png
similarity index 100%
rename from img/yes.png
rename to resources/img/yes.png
diff --git a/sound/schema1/all_online.wav b/resources/sound/schema1/all_online.wav
similarity index 100%
rename from sound/schema1/all_online.wav
rename to resources/sound/schema1/all_online.wav
diff --git a/sound/schema1/first_offline.wav b/resources/sound/schema1/first_offline.wav
similarity index 100%
rename from sound/schema1/first_offline.wav
rename to resources/sound/schema1/first_offline.wav
diff --git a/sound/schema1/next_offline.wav b/resources/sound/schema1/next_offline.wav
similarity index 100%
rename from sound/schema1/next_offline.wav
rename to resources/sound/schema1/next_offline.wav
diff --git a/sound/schema1/one_online.wav b/resources/sound/schema1/one_online.wav
similarity index 100%
rename from sound/schema1/one_online.wav
rename to resources/sound/schema1/one_online.wav
diff --git a/src/jnet/client/Client.java b/src/jnet/client/Client.java
index ba9365e..45db454 100644
--- a/src/jnet/client/Client.java
+++ b/src/jnet/client/Client.java
@@ -1,11 +1,11 @@
package jnet.client;
-import jnet.client.gui.Tray;
import jnet.client.gui.Window;
import jnet.client.network.NettyClient;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import jnet.client.gui.Tray;
import jnet.lib.BuilddDate;
import jnet.lib.LogFile;
import jnet.lib.PropertiesManager;
@@ -17,6 +17,7 @@ import jnet.lib.object.ServerConfig;
import jnet.lib.object.SnmpProfile;
import jnet.lib.object.User;
+
public class Client {
// verze serveru
diff --git a/src/jnet/client/ClientMessageParser.java b/src/jnet/client/ClientMessageParser.java
index d7dd237..9148a48 100644
--- a/src/jnet/client/ClientMessageParser.java
+++ b/src/jnet/client/ClientMessageParser.java
@@ -182,6 +182,7 @@ public class ClientMessageParser {
for (int i = 0; i < map.getObjects().size(); i++) {
if (map.getObjects().get(i).getId() == mo.getId()) {
map.getObjects().set(i, mo);
+ UIUpdater.updateMapView();
break;
}
}
diff --git a/src/jnet/client/gui/MenuPanel.java b/src/jnet/client/gui/MenuPanel.java
index 0ed1a59..b7a0cc2 100644
--- a/src/jnet/client/gui/MenuPanel.java
+++ b/src/jnet/client/gui/MenuPanel.java
@@ -22,7 +22,7 @@ class MenuPanel extends JPanel {
// tlacitko pripojit / odpojit
try {
- BufferedImage buttonIcon = ImageIO.read(new File("img/connect.png"));
+ BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/connect.png"));
JButton bLogin = new JButton(new ImageIcon(buttonIcon));
bLogin.setFocusPainted(false);
bLogin.setContentAreaFilled(false);
@@ -44,7 +44,7 @@ class MenuPanel extends JPanel {
// tlacitko nastaveni
try {
- BufferedImage buttonIcon = ImageIO.read(new File("img/settings.png"));
+ BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/settings.png"));
JButton bSettings = new JButton(new ImageIcon(buttonIcon));
bSettings.setFocusPainted(false);
bSettings.setContentAreaFilled(false);
@@ -62,7 +62,7 @@ class MenuPanel extends JPanel {
// tlacitko log
try {
- BufferedImage buttonIcon = ImageIO.read(new File("img/log.png"));
+ BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/log.png"));
JButton bLog = new JButton(new ImageIcon(buttonIcon));
bLog.setFocusPainted(false);
bLog.setContentAreaFilled(false);
@@ -80,7 +80,7 @@ class MenuPanel extends JPanel {
// tlacitko server settings
try {
- BufferedImage buttonIcon = ImageIO.read(new File("img/server_settings.png"));
+ BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/server_settings.png"));
JButton bServerSettings = new JButton(new ImageIcon(buttonIcon));
bServerSettings.setFocusPainted(false);
bServerSettings.setContentAreaFilled(false);
diff --git a/src/jnet/client/gui/StatusBar.java b/src/jnet/client/gui/StatusBar.java
index d1cee95..46b0001 100644
--- a/src/jnet/client/gui/StatusBar.java
+++ b/src/jnet/client/gui/StatusBar.java
@@ -36,7 +36,7 @@ public class StatusBar extends JPanel {
// tlacitko zobrazujici klienty
try {
- BufferedImage buttonIcon = ImageIO.read(new File("img/online_clients.png"));
+ BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/online_clients.png"));
btnOnline = new JButton(new ImageIcon(buttonIcon));
btnOnline.setFocusPainted(false);
btnOnline.setContentAreaFilled(false);
diff --git a/src/jnet/client/gui/Tray.java b/src/jnet/client/gui/Tray.java
index 28824e3..c67f6d1 100644
--- a/src/jnet/client/gui/Tray.java
+++ b/src/jnet/client/gui/Tray.java
@@ -1,82 +1,67 @@
package jnet.client.gui;
-import jnet.client.Client;
-import java.awt.AWTException;
-import java.awt.MenuItem;
-import java.awt.PopupMenu;
-import java.awt.SystemTray;
-import java.awt.TrayIcon;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.*;
import java.awt.image.BufferedImage;
-import java.io.File;
import java.io.IOException;
-import java.util.Iterator;
import javax.imageio.ImageIO;
+import jnet.client.Client;
import jnet.lib.LogFile;
import jnet.lib.Status;
import jnet.lib.object.Map;
-import jnet.lib.object.MapObject;
public class Tray {
- private SystemTray tray = SystemTray.getSystemTray();
+ private SystemTray tray;
private static TrayIcon trayIcon;
private static PopupMenu menu = new PopupMenu();
public void createAndShowTray() {
try {
-
- //Check the SystemTray is supported
+ // Ověření, zda je SystemTray podporován
if (!SystemTray.isSupported()) {
LogFile.printErr("SystemTray is not supported");
return;
}
- // tray menu
+ // Menu pro tray ikonu
MenuItem exitItem = new MenuItem("Ukončit");
- exitItem.addActionListener(new ActionListener() {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- LogFile.printInfo("Exit appliaction from tray icon");
- System.exit(0);
- }
+ exitItem.addActionListener(e -> {
+ LogFile.printInfo("Exit application from tray icon");
+ System.exit(0);
});
menu.add(exitItem);
- trayIcon = new TrayIcon(ImageIO.read(new File("img/flag_gray.png")), Client.APP_NAME, menu);
- trayIcon.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- //Double click - obnovit/minimalizovat
- if (Client.okno.isVisible()) {
- Client.okno.setVisible(false);
- } else {
- Client.okno.setVisible(true);
- }
- }
- }
- );
+ // Načtení výchozí ikony ze zdrojů
+ trayIcon = new TrayIcon(loadImage("/img/flag_gray.png"), Client.APP_NAME, menu);
+ trayIcon.setImageAutoSize(true);
+ trayIcon.addActionListener(e -> {
+ // Dvojklik - obnovit/minimalizovat okno
+ Client.okno.setVisible(!Client.okno.isVisible());
+ });
tray = SystemTray.getSystemTray();
tray.add(trayIcon);
- } catch (IOException ex) {
- LogFile.printErr("TrayIcon error: " + ex.getMessage());
- } catch (AWTException ex) {
+ } catch (IOException | AWTException ex) {
LogFile.printErr("TrayIcon error: " + ex.getMessage());
}
}
+ private static BufferedImage loadImage(String path) throws IOException {
+ try (var input = Tray.class.getResourceAsStream(path)) {
+ if (input == null) {
+ throw new IOException("Soubor nenalezen: " + path);
+ }
+ return ImageIO.read(input);
+ }
+ }
+
public static void setIcon(String icon) {
try {
- BufferedImage image = ImageIO.read(new File("img/" + icon));
- trayIcon.setImage(image);
+ trayIcon.setImage(loadImage("/img/" + icon));
} catch (IOException ex) {
LogFile.printErr("TrayIcon error: " + ex.getMessage());
}
-
}
public static void setStatusOffline() {
@@ -100,13 +85,12 @@ public class Tray {
for (Map map : Client.maps) {
int status = map.getStatus();
-
if (status == Status.OFFLINE) {
- setStatusOffline(); // OFFLINE má nejvyšší prioritu
+ setStatusOffline();
return;
}
if (status == Status.WARNING) {
- setStatusWarning(); // Možná varování, ale pokračujeme
+ setStatusWarning();
}
}
}
diff --git a/src/jnet/client/gui/UIUpdater.java b/src/jnet/client/gui/UIUpdater.java
index 389c76e..e618c9e 100644
--- a/src/jnet/client/gui/UIUpdater.java
+++ b/src/jnet/client/gui/UIUpdater.java
@@ -1,7 +1,6 @@
package jnet.client.gui;
import javax.swing.SwingUtilities;
-import jnet.lib.object.Map;
public class UIUpdater {
diff --git a/src/jnet/client/gui/Window.java b/src/jnet/client/gui/Window.java
index 2cef743..28b152b 100644
--- a/src/jnet/client/gui/Window.java
+++ b/src/jnet/client/gui/Window.java
@@ -40,7 +40,6 @@ public class Window extends JFrame {
} catch (IOException ex) {
LogFile.printErr("APP icon exception");
}
-
this.addWindowListener(new WindowAdapter() {
@Override