upravena kompilace presun do složky resurces

main
Michal 2025-02-15 10:26:37 +01:00
parent 16bbf9ee0f
commit fb09049516
39 changed files with 47 additions and 52 deletions

View File

@ -69,5 +69,16 @@
properties which you can use, check the target you are overriding in the properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
--> -->
<target name="-post-compile">
<copy todir="${build.classes.dir}">
<fileset dir="resources"/>
</copy>
</target>
<target name="-post-jar">
<copy todir="${dist.jar.dir}">
<fileset dir="resources"/>
</copy>
</target>
</project> </project>

View File

Before

Width:  |  Height:  |  Size: 424 B

After

Width:  |  Height:  |  Size: 424 B

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 725 B

After

Width:  |  Height:  |  Size: 725 B

View File

Before

Width:  |  Height:  |  Size: 644 B

After

Width:  |  Height:  |  Size: 644 B

View File

Before

Width:  |  Height:  |  Size: 634 B

After

Width:  |  Height:  |  Size: 634 B

View File

Before

Width:  |  Height:  |  Size: 679 B

After

Width:  |  Height:  |  Size: 679 B

View File

Before

Width:  |  Height:  |  Size: 769 B

After

Width:  |  Height:  |  Size: 769 B

View File

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

Before

Width:  |  Height:  |  Size: 188 B

After

Width:  |  Height:  |  Size: 188 B

View File

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 362 B

After

Width:  |  Height:  |  Size: 362 B

View File

Before

Width:  |  Height:  |  Size: 312 B

After

Width:  |  Height:  |  Size: 312 B

View File

Before

Width:  |  Height:  |  Size: 659 B

After

Width:  |  Height:  |  Size: 659 B

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

Before

Width:  |  Height:  |  Size: 397 B

After

Width:  |  Height:  |  Size: 397 B

View File

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 313 B

View File

Before

Width:  |  Height:  |  Size: 802 B

After

Width:  |  Height:  |  Size: 802 B

View File

Before

Width:  |  Height:  |  Size: 1023 B

After

Width:  |  Height:  |  Size: 1023 B

View File

Before

Width:  |  Height:  |  Size: 177 B

After

Width:  |  Height:  |  Size: 177 B

View File

@ -1,11 +1,11 @@
package jnet.client; package jnet.client;
import jnet.client.gui.Tray;
import jnet.client.gui.Window; import jnet.client.gui.Window;
import jnet.client.network.NettyClient; import jnet.client.network.NettyClient;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import jnet.client.gui.Tray;
import jnet.lib.BuilddDate; import jnet.lib.BuilddDate;
import jnet.lib.LogFile; import jnet.lib.LogFile;
import jnet.lib.PropertiesManager; import jnet.lib.PropertiesManager;
@ -17,6 +17,7 @@ import jnet.lib.object.ServerConfig;
import jnet.lib.object.SnmpProfile; import jnet.lib.object.SnmpProfile;
import jnet.lib.object.User; import jnet.lib.object.User;
public class Client { public class Client {
// verze serveru // verze serveru

View File

@ -182,6 +182,7 @@ public class ClientMessageParser {
for (int i = 0; i < map.getObjects().size(); i++) { for (int i = 0; i < map.getObjects().size(); i++) {
if (map.getObjects().get(i).getId() == mo.getId()) { if (map.getObjects().get(i).getId() == mo.getId()) {
map.getObjects().set(i, mo); map.getObjects().set(i, mo);
UIUpdater.updateMapView();
break; break;
} }
} }

View File

@ -22,7 +22,7 @@ class MenuPanel extends JPanel {
// tlacitko pripojit / odpojit // tlacitko pripojit / odpojit
try { 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)); JButton bLogin = new JButton(new ImageIcon(buttonIcon));
bLogin.setFocusPainted(false); bLogin.setFocusPainted(false);
bLogin.setContentAreaFilled(false); bLogin.setContentAreaFilled(false);
@ -44,7 +44,7 @@ class MenuPanel extends JPanel {
// tlacitko nastaveni // tlacitko nastaveni
try { 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)); JButton bSettings = new JButton(new ImageIcon(buttonIcon));
bSettings.setFocusPainted(false); bSettings.setFocusPainted(false);
bSettings.setContentAreaFilled(false); bSettings.setContentAreaFilled(false);
@ -62,7 +62,7 @@ class MenuPanel extends JPanel {
// tlacitko log // tlacitko log
try { 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)); JButton bLog = new JButton(new ImageIcon(buttonIcon));
bLog.setFocusPainted(false); bLog.setFocusPainted(false);
bLog.setContentAreaFilled(false); bLog.setContentAreaFilled(false);
@ -80,7 +80,7 @@ class MenuPanel extends JPanel {
// tlacitko server settings // tlacitko server settings
try { 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)); JButton bServerSettings = new JButton(new ImageIcon(buttonIcon));
bServerSettings.setFocusPainted(false); bServerSettings.setFocusPainted(false);
bServerSettings.setContentAreaFilled(false); bServerSettings.setContentAreaFilled(false);

View File

@ -36,7 +36,7 @@ public class StatusBar extends JPanel {
// tlacitko zobrazujici klienty // tlacitko zobrazujici klienty
try { 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 = new JButton(new ImageIcon(buttonIcon));
btnOnline.setFocusPainted(false); btnOnline.setFocusPainted(false);
btnOnline.setContentAreaFilled(false); btnOnline.setContentAreaFilled(false);

View File

@ -1,82 +1,67 @@
package jnet.client.gui; package jnet.client.gui;
import jnet.client.Client; import java.awt.*;
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.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import jnet.client.Client;
import jnet.lib.LogFile; import jnet.lib.LogFile;
import jnet.lib.Status; import jnet.lib.Status;
import jnet.lib.object.Map; import jnet.lib.object.Map;
import jnet.lib.object.MapObject;
public class Tray { public class Tray {
private SystemTray tray = SystemTray.getSystemTray(); private SystemTray tray;
private static TrayIcon trayIcon; private static TrayIcon trayIcon;
private static PopupMenu menu = new PopupMenu(); private static PopupMenu menu = new PopupMenu();
public void createAndShowTray() { public void createAndShowTray() {
try { try {
// Ověření, zda je SystemTray podporován
//Check the SystemTray is supported
if (!SystemTray.isSupported()) { if (!SystemTray.isSupported()) {
LogFile.printErr("SystemTray is not supported"); LogFile.printErr("SystemTray is not supported");
return; return;
} }
// tray menu // Menu pro tray ikonu
MenuItem exitItem = new MenuItem("Ukončit"); MenuItem exitItem = new MenuItem("Ukončit");
exitItem.addActionListener(new ActionListener() { exitItem.addActionListener(e -> {
LogFile.printInfo("Exit application from tray icon");
@Override
public void actionPerformed(ActionEvent e) {
LogFile.printInfo("Exit appliaction from tray icon");
System.exit(0); System.exit(0);
}
}); });
menu.add(exitItem); menu.add(exitItem);
trayIcon = new TrayIcon(ImageIO.read(new File("img/flag_gray.png")), Client.APP_NAME, menu); // Načtení výchozí ikony ze zdrojů
trayIcon.addActionListener(new ActionListener() { trayIcon = new TrayIcon(loadImage("/img/flag_gray.png"), Client.APP_NAME, menu);
@Override trayIcon.setImageAutoSize(true);
public void actionPerformed(ActionEvent e) { trayIcon.addActionListener(e -> {
//Double click - obnovit/minimalizovat // Dvojklik - obnovit/minimalizovat okno
if (Client.okno.isVisible()) { Client.okno.setVisible(!Client.okno.isVisible());
Client.okno.setVisible(false); });
} else {
Client.okno.setVisible(true);
}
}
}
);
tray = SystemTray.getSystemTray(); tray = SystemTray.getSystemTray();
tray.add(trayIcon); tray.add(trayIcon);
} catch (IOException ex) { } catch (IOException | AWTException ex) {
LogFile.printErr("TrayIcon error: " + ex.getMessage());
} catch (AWTException ex) {
LogFile.printErr("TrayIcon error: " + ex.getMessage()); 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) { public static void setIcon(String icon) {
try { try {
BufferedImage image = ImageIO.read(new File("img/" + icon)); trayIcon.setImage(loadImage("/img/" + icon));
trayIcon.setImage(image);
} catch (IOException ex) { } catch (IOException ex) {
LogFile.printErr("TrayIcon error: " + ex.getMessage()); LogFile.printErr("TrayIcon error: " + ex.getMessage());
} }
} }
public static void setStatusOffline() { public static void setStatusOffline() {
@ -100,13 +85,12 @@ public class Tray {
for (Map map : Client.maps) { for (Map map : Client.maps) {
int status = map.getStatus(); int status = map.getStatus();
if (status == Status.OFFLINE) { if (status == Status.OFFLINE) {
setStatusOffline(); // OFFLINE má nejvyšší prioritu setStatusOffline();
return; return;
} }
if (status == Status.WARNING) { if (status == Status.WARNING) {
setStatusWarning(); // Možná varování, ale pokračujeme setStatusWarning();
} }
} }
} }

View File

@ -1,7 +1,6 @@
package jnet.client.gui; package jnet.client.gui;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import jnet.lib.object.Map;
public class UIUpdater { public class UIUpdater {

View File

@ -40,7 +40,6 @@ public class Window extends JFrame {
} catch (IOException ex) { } catch (IOException ex) {
LogFile.printErr("APP icon exception"); LogFile.printErr("APP icon exception");
} }
this.addWindowListener(new WindowAdapter() { this.addWindowListener(new WindowAdapter() {
@Override @Override