Compare commits
No commits in common. "main" and "verze3" have entirely different histories.
|
|
@ -1 +0,0 @@
|
||||||
*.log
|
|
||||||
84
build.xml
84
build.xml
|
|
@ -1,84 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!-- You may freely edit this file. See commented blocks below for -->
|
|
||||||
<!-- some examples of how to customize the build. -->
|
|
||||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
|
||||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
|
||||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
|
||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
|
||||||
<project name="jNetClient" default="default" basedir=".">
|
|
||||||
<description>Builds, tests, and runs the project jNetClient.</description>
|
|
||||||
<import file="nbproject/build-impl.xml"/>
|
|
||||||
<!--
|
|
||||||
|
|
||||||
There exist several targets which are by default empty and which can be
|
|
||||||
used for execution of your tasks. These targets are usually executed
|
|
||||||
before and after some main targets. They are:
|
|
||||||
|
|
||||||
-pre-init: called before initialization of project properties
|
|
||||||
-post-init: called after initialization of project properties
|
|
||||||
-pre-compile: called before javac compilation
|
|
||||||
-post-compile: called after javac compilation
|
|
||||||
-pre-compile-single: called before javac compilation of single file
|
|
||||||
-post-compile-single: called after javac compilation of single file
|
|
||||||
-pre-compile-test: called before javac compilation of JUnit tests
|
|
||||||
-post-compile-test: called after javac compilation of JUnit tests
|
|
||||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
|
||||||
-pre-jar: called before JAR building
|
|
||||||
-post-jar: called after JAR building
|
|
||||||
-post-clean: called after cleaning build products
|
|
||||||
|
|
||||||
(Targets beginning with '-' are not intended to be called on their own.)
|
|
||||||
|
|
||||||
Example of inserting an obfuscator after compilation could look like this:
|
|
||||||
|
|
||||||
<target name="-post-compile">
|
|
||||||
<obfuscate>
|
|
||||||
<fileset dir="${build.classes.dir}"/>
|
|
||||||
</obfuscate>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
For list of available properties check the imported
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
|
|
||||||
Another way to customize the build is by overriding existing main targets.
|
|
||||||
The targets of interest are:
|
|
||||||
|
|
||||||
-init-macrodef-javac: defines macro for javac compilation
|
|
||||||
-init-macrodef-junit: defines macro for junit execution
|
|
||||||
-init-macrodef-debug: defines macro for class debugging
|
|
||||||
-init-macrodef-java: defines macro for class execution
|
|
||||||
-do-jar: JAR building
|
|
||||||
run: execution of project
|
|
||||||
-javadoc-build: Javadoc generation
|
|
||||||
test-report: JUnit report generation
|
|
||||||
|
|
||||||
An example of overriding the target for project execution could look like this:
|
|
||||||
|
|
||||||
<target name="run" depends="jNetClient-impl.jar">
|
|
||||||
<exec dir="bin" executable="launcher.exe">
|
|
||||||
<arg file="${dist.jar}"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
Notice that the overridden target depends on the jar target and not only on
|
|
||||||
the compile target as the regular run target does. Again, for a list of available
|
|
||||||
properties which you can use, check the target you are overriding in the
|
|
||||||
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>
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
autoconnect = true
|
|
||||||
debug = true
|
|
||||||
port = 1225
|
|
||||||
server = localhost
|
|
||||||
user = michal
|
|
||||||
volume = 75
|
|
||||||
start_minimalized = false
|
|
||||||
password = Michal2407
|
|
||||||
sound = true
|
|
||||||
debuger = true
|
|
||||||
sound_one_online=sound/schema1/one_online.wav
|
|
||||||
sound_next_offline=sound/schema1/next_offline.wav
|
|
||||||
sound_all_online = sound/schema1/all_online.wav
|
|
||||||
sound_first_offline=sound/schema1/first_offline.wav
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,164 @@
|
||||||
|
25.08.26 23:45:18 I ---------------------------------------------
|
||||||
|
25.08.26 23:45:18 I jNet Client
|
||||||
|
25.08.26 23:45:18 I Version: 1 (Tue Aug 25 22:22:02 CEST 2026)
|
||||||
|
25.08.26 23:45:18 I ---------------------------------------------
|
||||||
|
25.08.26 23:45:18 I
|
||||||
|
25.08.26 23:45:18 I Loading config ...
|
||||||
|
25.08.26 23:45:18 I successfully
|
||||||
|
25.08.26 23:45:18 I Debug mode
|
||||||
|
25.08.26 23:45:18 I Nalezen putty.exe v: C:\Users\cucky\Documents\NetBeansProjects\jNet\jNetClient\src\main\resources\app\putty.exe
|
||||||
|
25.08.26 23:45:18 I Nalezen winbox.exe v: C:\Users\cucky\Documents\NetBeansProjects\jNet\jNetClient\src\main\resources\app\winbox.exe
|
||||||
|
25.08.26 23:45:18 I Nalezen smsc_sdv.exe v: C:\Users\cucky\Documents\NetBeansProjects\jNet\jNetClient\src\main\resources\app\smsc_sdv.exe
|
||||||
|
25.08.26 23:45:18 I Nalezen smsc_bth.exe v: C:\Users\cucky\Documents\NetBeansProjects\jNet\jNetClient\src\main\resources\app\smsc_bth.exe
|
||||||
|
25.08.26 23:45:18 I Nalezen smsc_bt.exe v: C:\Users\cucky\Documents\NetBeansProjects\jNet\jNetClient\src\main\resources\app\smsc_bt.exe
|
||||||
|
25.08.26 23:45:18 I RemoteAdminTools inicializovan, app dir: C:\Users\cucky\Documents\NetBeansProjects\jNet\jNetClient\src\main\resources\app
|
||||||
|
25.08.26 23:45:19 I Connected to server
|
||||||
|
25.08.26 23:45:19 D Received message ID: 102
|
||||||
|
25.08.26 23:45:19 D Received message ID: 103
|
||||||
|
25.08.26 23:45:19 D Received message ID: 111
|
||||||
|
25.08.26 23:45:19 D Received message ID: 105
|
||||||
|
25.08.26 23:45:19 D Received message ID: 109
|
||||||
|
25.08.26 23:45:19 D Received message ID: 113
|
||||||
|
25.08.26 23:45:19 D Received message ID: 112
|
||||||
|
25.08.26 23:45:19 D Received message ID: 116
|
||||||
|
25.08.26 23:45:19 D Received message ID: 106
|
||||||
|
25.08.26 23:45:19 D Received message ID: 124
|
||||||
|
25.08.26 23:45:19 D Received message ID: 131
|
||||||
|
25.08.26 23:45:19 D Received message ID: 132
|
||||||
|
25.08.26 23:45:23 D Received message ID: 134
|
||||||
|
25.08.26 23:45:26 D Received message ID: 133
|
||||||
|
25.08.26 23:45:27 D Received message ID: 134
|
||||||
|
25.08.26 23:45:33 D Received message ID: 134
|
||||||
|
25.08.26 23:45:37 D Received message ID: 134
|
||||||
|
25.08.26 23:45:43 D Received message ID: 134
|
||||||
|
25.08.26 23:45:47 D Received message ID: 134
|
||||||
|
25.08.26 23:45:53 D Received message ID: 134
|
||||||
|
25.08.26 23:45:56 D Received message ID: 133
|
||||||
|
25.08.26 23:45:57 D Received message ID: 134
|
||||||
|
25.08.26 23:46:03 D Received message ID: 134
|
||||||
|
25.08.26 23:46:07 D Received message ID: 134
|
||||||
|
25.08.26 23:46:13 D Received message ID: 134
|
||||||
|
25.08.26 23:46:17 D Received message ID: 134
|
||||||
|
25.08.26 23:46:23 D Received message ID: 134
|
||||||
|
25.08.26 23:46:26 D Received message ID: 133
|
||||||
|
25.08.26 23:46:27 D Received message ID: 134
|
||||||
|
25.08.26 23:46:33 D Received message ID: 134
|
||||||
|
25.08.26 23:46:37 D Received message ID: 134
|
||||||
|
25.08.26 23:46:43 D Received message ID: 134
|
||||||
|
25.08.26 23:46:47 D Received message ID: 134
|
||||||
|
25.08.26 23:46:51 D Received message ID: 134
|
||||||
|
25.08.26 23:46:53 D Received message ID: 134
|
||||||
|
25.08.26 23:46:56 D Received message ID: 133
|
||||||
|
25.08.26 23:46:57 D Received message ID: 134
|
||||||
|
25.08.26 23:47:03 D Received message ID: 134
|
||||||
|
25.08.26 23:47:07 D Received message ID: 134
|
||||||
|
25.08.26 23:47:13 D Received message ID: 134
|
||||||
|
25.08.26 23:47:17 D Received message ID: 134
|
||||||
|
25.08.26 23:47:23 D Received message ID: 134
|
||||||
|
25.08.26 23:47:26 D Received message ID: 133
|
||||||
|
25.08.26 23:47:27 D Received message ID: 134
|
||||||
|
25.08.26 23:47:33 D Received message ID: 134
|
||||||
|
25.08.26 23:47:37 D Received message ID: 134
|
||||||
|
25.08.26 23:47:43 D Received message ID: 134
|
||||||
|
25.08.26 23:47:47 D Received message ID: 134
|
||||||
|
25.08.26 23:47:53 D Received message ID: 134
|
||||||
|
25.08.26 23:47:56 D Received message ID: 133
|
||||||
|
25.08.26 23:47:57 D Received message ID: 134
|
||||||
|
25.08.26 23:48:03 D Received message ID: 134
|
||||||
|
25.08.26 23:48:07 D Received message ID: 134
|
||||||
|
25.08.26 23:48:13 D Received message ID: 134
|
||||||
|
25.08.26 23:48:17 D Received message ID: 134
|
||||||
|
25.08.26 23:48:23 D Received message ID: 134
|
||||||
|
25.08.26 23:48:28 D Received message ID: 130
|
||||||
|
25.08.26 23:48:28 D Received message ID: 133
|
||||||
|
25.08.26 23:48:28 D Received message ID: 134
|
||||||
|
25.08.26 23:48:28 D Received message ID: 117
|
||||||
|
25.08.26 23:48:28 D Received message ID: 108
|
||||||
|
25.08.26 23:48:33 D Received message ID: 134
|
||||||
|
25.08.26 23:48:36 D Received message ID: 118
|
||||||
|
25.08.26 23:48:36 D Received message ID: 108
|
||||||
|
25.08.26 23:48:37 D Received message ID: 134
|
||||||
|
25.08.26 23:48:43 D Received message ID: 134
|
||||||
|
25.08.26 23:48:47 D Received message ID: 134
|
||||||
|
25.08.26 23:48:53 D Received message ID: 134
|
||||||
|
25.08.26 23:48:56 D Received message ID: 133
|
||||||
|
25.08.26 23:48:57 D Received message ID: 134
|
||||||
|
25.08.26 23:49:03 D Received message ID: 134
|
||||||
|
25.08.26 23:49:07 D Received message ID: 134
|
||||||
|
25.08.26 23:49:13 D Received message ID: 134
|
||||||
|
25.08.26 23:49:17 D Received message ID: 134
|
||||||
|
25.08.26 23:49:23 D Received message ID: 134
|
||||||
|
25.08.26 23:49:26 D Received message ID: 133
|
||||||
|
25.08.26 23:49:27 D Received message ID: 134
|
||||||
|
25.08.26 23:49:33 D Received message ID: 134
|
||||||
|
25.08.26 23:49:37 D Received message ID: 134
|
||||||
|
25.08.26 23:49:43 D Received message ID: 134
|
||||||
|
25.08.26 23:49:47 D Received message ID: 134
|
||||||
|
25.08.26 23:49:53 D Received message ID: 134
|
||||||
|
25.08.26 23:49:56 D Received message ID: 133
|
||||||
|
25.08.26 23:49:57 D Received message ID: 134
|
||||||
|
25.08.26 23:50:03 D Received message ID: 134
|
||||||
|
25.08.26 23:50:07 D Received message ID: 134
|
||||||
|
25.08.26 23:50:13 D Received message ID: 134
|
||||||
|
25.08.26 23:50:17 D Received message ID: 134
|
||||||
|
25.08.26 23:50:21 D Received message ID: 134
|
||||||
|
25.08.26 23:50:23 D Received message ID: 134
|
||||||
|
25.08.26 23:50:26 D Received message ID: 133
|
||||||
|
25.08.26 23:50:27 D Received message ID: 134
|
||||||
|
25.08.26 23:50:33 D Received message ID: 134
|
||||||
|
25.08.26 23:50:37 D Received message ID: 134
|
||||||
|
25.08.26 23:50:43 D Received message ID: 134
|
||||||
|
25.08.26 23:50:47 D Received message ID: 134
|
||||||
|
25.08.26 23:50:53 D Received message ID: 134
|
||||||
|
25.08.26 23:50:56 D Received message ID: 133
|
||||||
|
25.08.26 23:50:57 D Received message ID: 134
|
||||||
|
25.08.26 23:51:03 D Received message ID: 134
|
||||||
|
25.08.26 23:51:07 D Received message ID: 134
|
||||||
|
25.08.26 23:51:13 D Received message ID: 134
|
||||||
|
25.08.26 23:51:17 D Received message ID: 134
|
||||||
|
25.08.26 23:51:23 D Received message ID: 134
|
||||||
|
25.08.26 23:51:26 D Received message ID: 133
|
||||||
|
25.08.26 23:51:27 D Received message ID: 134
|
||||||
|
25.08.26 23:51:33 D Received message ID: 134
|
||||||
|
25.08.26 23:51:37 D Received message ID: 134
|
||||||
|
25.08.26 23:51:43 D Received message ID: 134
|
||||||
|
25.08.26 23:51:47 D Received message ID: 134
|
||||||
|
25.08.26 23:51:53 D Received message ID: 134
|
||||||
|
25.08.26 23:51:56 D Received message ID: 133
|
||||||
|
25.08.26 23:51:57 D Received message ID: 134
|
||||||
|
25.08.26 23:52:01 D Received message ID: 134
|
||||||
|
25.08.26 23:52:03 D Received message ID: 134
|
||||||
|
25.08.26 23:52:07 D Received message ID: 134
|
||||||
|
25.08.26 23:52:13 D Received message ID: 134
|
||||||
|
25.08.26 23:52:17 D Received message ID: 134
|
||||||
|
25.08.26 23:52:23 D Received message ID: 134
|
||||||
|
25.08.26 23:52:26 D Received message ID: 133
|
||||||
|
25.08.26 23:52:27 D Received message ID: 134
|
||||||
|
25.08.26 23:52:33 D Received message ID: 134
|
||||||
|
25.08.26 23:52:37 D Received message ID: 134
|
||||||
|
25.08.26 23:52:43 D Received message ID: 134
|
||||||
|
25.08.26 23:52:47 D Received message ID: 134
|
||||||
|
25.08.26 23:52:53 D Received message ID: 134
|
||||||
|
25.08.26 23:52:56 D Received message ID: 133
|
||||||
|
25.08.26 23:52:57 D Received message ID: 134
|
||||||
|
25.08.26 23:53:03 D Received message ID: 134
|
||||||
|
25.08.26 23:53:07 D Received message ID: 134
|
||||||
|
25.08.26 23:53:13 D Received message ID: 134
|
||||||
|
25.08.26 23:53:17 D Received message ID: 134
|
||||||
|
25.08.26 23:53:23 D Received message ID: 134
|
||||||
|
25.08.26 23:53:26 D Received message ID: 133
|
||||||
|
25.08.26 23:53:27 D Received message ID: 134
|
||||||
|
25.08.26 23:53:33 D Received message ID: 134
|
||||||
|
25.08.26 23:53:37 D Received message ID: 134
|
||||||
|
25.08.26 23:53:43 D Received message ID: 134
|
||||||
|
25.08.26 23:53:47 D Received message ID: 134
|
||||||
|
25.08.26 23:53:53 D Received message ID: 134
|
||||||
|
25.08.26 23:53:56 D Received message ID: 133
|
||||||
|
25.08.26 23:53:57 D Received message ID: 134
|
||||||
|
25.08.26 23:54:03 D Received message ID: 134
|
||||||
|
25.08.26 23:54:07 D Received message ID: 134
|
||||||
|
25.08.26 23:54:13 D Received message ID: 134
|
||||||
|
25.08.26 23:54:17 D Received message ID: 134
|
||||||
|
25.08.26 23:54:23 D Received message ID: 134
|
||||||
|
25.08.26 23:54:23 I Connection reset by server
|
||||||
|
25.08.26 23:54:23 I Connection inactive ..... reconnect initiated
|
||||||
756
log.log
756
log.log
|
|
@ -1,756 +0,0 @@
|
||||||
04.02.25 17:54:36 I ---------------------------------------------
|
|
||||||
04.02.25 17:54:36 I jNet Client
|
|
||||||
04.02.25 17:54:36 I Version: 1 (Tue Feb 04 17:54:07 CET 2025)
|
|
||||||
04.02.25 17:54:36 I ---------------------------------------------
|
|
||||||
04.02.25 17:54:36 I
|
|
||||||
04.02.25 17:54:36 I Loading config ...
|
|
||||||
04.02.25 17:54:36 I successfully
|
|
||||||
04.02.25 17:54:36 D Debug mode on
|
|
||||||
04.02.25 17:54:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:54:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:54:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:54:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:54:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:54:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:54:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:54:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:54:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:55:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:55:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:56:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:56:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:57:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:57:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:58:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:58:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 17:59:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 17:59:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:0:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:0:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:1:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:1:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:2:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:2:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:3:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:3:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:4:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:4:57 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:02 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:02 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:07 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:07 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:12 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:12 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:17 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:17 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:22 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:22 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:27 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:27 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:32 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:37 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:37 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:42 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:42 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:47 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:47 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:52 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:52 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:5:57 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:5:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:08 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:13 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:18 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:18 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:23 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:23 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:28 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:28 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:33 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:33 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:38 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:38 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:43 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:43 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:48 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:48 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:53 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:53 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:6:58 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:6:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:08 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:13 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:18 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:18 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:23 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:23 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:28 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:28 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:33 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:33 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:38 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:38 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:43 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:43 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:48 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:48 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:53 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:53 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:7:58 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:7:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:08 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:13 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:18 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:18 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:23 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:23 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:28 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:28 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:33 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:33 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:38 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:38 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:43 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:43 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:48 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:48 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:53 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:53 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:8:58 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:8:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:08 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:13 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:18 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:18 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:23 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:23 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:28 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:28 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:33 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:33 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:38 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:38 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:43 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:43 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:48 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:48 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:53 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:53 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:9:58 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:9:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:08 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:13 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:18 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:18 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:23 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:23 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:28 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:28 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:33 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:33 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:38 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:38 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:43 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:43 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:48 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:48 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:53 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:53 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:10:58 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:10:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:08 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:13 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:18 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:18 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:23 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:23 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:28 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:28 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:33 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:33 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:38 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:38 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:43 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:43 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:48 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:48 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:53 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:53 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:11:58 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:11:58 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:12:03 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:12:03 E Pripojeni selhalo: Connection refused: getsockopt: localhost/127.0.0.1:1225
|
|
||||||
04.02.25 18:12:08 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:12:08 D -> Message type: 1
|
|
||||||
04.02.25 18:12:08 D <- Message type: 1
|
|
||||||
04.02.25 18:12:08 D -> Message type: 3
|
|
||||||
04.02.25 18:12:08 D <- Message type: 4
|
|
||||||
04.02.25 18:12:08 D -> Message type: 5
|
|
||||||
04.02.25 18:12:08 I Log in to server
|
|
||||||
04.02.25 18:12:08 D -> Message type: 9
|
|
||||||
04.02.25 18:12:08 D -> Message type: 7
|
|
||||||
04.02.25 18:12:08 D -> Message type: 13
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 8
|
|
||||||
04.02.25 18:12:08 D -> Message type: 11
|
|
||||||
04.02.25 18:12:08 D -> Message type: 11
|
|
||||||
04.02.25 18:12:08 D -> Message type: 100
|
|
||||||
04.02.25 18:12:08 D -> Message type: 100
|
|
||||||
04.02.25 18:12:08 D -> Message type: 100
|
|
||||||
04.02.25 18:12:08 D -> Message type: 100
|
|
||||||
04.02.25 18:12:08 D -> Message type: 100
|
|
||||||
04.02.25 18:12:08 D -> Message type: 100
|
|
||||||
04.02.25 18:12:08 D -> Message type: 14
|
|
||||||
04.02.25 18:12:08 D -> Message type: 110
|
|
||||||
04.02.25 18:12:08 D -> Message type: 107
|
|
||||||
04.02.25 18:12:08 D -> Message type: 107
|
|
||||||
04.02.25 18:12:28 D -> Message type: 101
|
|
||||||
04.02.25 18:12:35 D -> Message type: 108
|
|
||||||
04.02.25 18:12:35 D -> Message type: 101
|
|
||||||
04.02.25 18:12:54 E Spojeni bylo ukonceno
|
|
||||||
04.02.25 18:12:59 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:12:59 D -> Message type: 1
|
|
||||||
04.02.25 18:12:59 D <- Message type: 1
|
|
||||||
04.02.25 18:12:59 D -> Message type: 3
|
|
||||||
04.02.25 18:12:59 D <- Message type: 4
|
|
||||||
04.02.25 18:12:59 D -> Message type: 5
|
|
||||||
04.02.25 18:12:59 I Log in to server
|
|
||||||
04.02.25 18:12:59 D -> Message type: 9
|
|
||||||
04.02.25 18:12:59 D -> Message type: 7
|
|
||||||
04.02.25 18:12:59 D -> Message type: 13
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 8
|
|
||||||
04.02.25 18:12:59 D -> Message type: 11
|
|
||||||
04.02.25 18:12:59 D -> Message type: 11
|
|
||||||
04.02.25 18:12:59 D -> Message type: 100
|
|
||||||
04.02.25 18:12:59 D -> Message type: 100
|
|
||||||
04.02.25 18:12:59 D -> Message type: 100
|
|
||||||
04.02.25 18:12:59 D -> Message type: 100
|
|
||||||
04.02.25 18:12:59 D -> Message type: 100
|
|
||||||
04.02.25 18:12:59 D -> Message type: 100
|
|
||||||
04.02.25 18:12:59 D -> Message type: 14
|
|
||||||
04.02.25 18:12:59 D -> Message type: 110
|
|
||||||
04.02.25 18:12:59 D -> Message type: 107
|
|
||||||
04.02.25 18:12:59 D -> Message type: 107
|
|
||||||
04.02.25 18:14:13 D -> Message type: 101
|
|
||||||
04.02.25 18:14:20 D -> Message type: 108
|
|
||||||
04.02.25 18:14:20 D -> Message type: 101
|
|
||||||
04.02.25 18:14:25 D -> Message type: 101
|
|
||||||
04.02.25 18:14:32 D -> Message type: 108
|
|
||||||
04.02.25 18:14:32 D -> Message type: 101
|
|
||||||
04.02.25 18:14:37 D -> Message type: 101
|
|
||||||
04.02.25 18:14:44 D -> Message type: 108
|
|
||||||
04.02.25 18:14:44 D -> Message type: 101
|
|
||||||
04.02.25 18:14:49 D -> Message type: 101
|
|
||||||
04.02.25 18:14:55 D -> Message type: 108
|
|
||||||
04.02.25 18:14:55 D -> Message type: 101
|
|
||||||
04.02.25 18:15:01 D -> Message type: 101
|
|
||||||
04.02.25 18:15:07 D -> Message type: 108
|
|
||||||
04.02.25 18:15:07 D -> Message type: 101
|
|
||||||
04.02.25 18:15:12 D -> Message type: 101
|
|
||||||
04.02.25 18:15:19 D -> Message type: 108
|
|
||||||
04.02.25 18:15:19 D -> Message type: 101
|
|
||||||
04.02.25 18:16:32 D -> Message type: 101
|
|
||||||
04.02.25 18:16:39 D -> Message type: 108
|
|
||||||
04.02.25 18:16:39 D -> Message type: 101
|
|
||||||
04.02.25 18:18:27 E Spojeni bylo ukonceno
|
|
||||||
04.02.25 18:18:32 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:18:32 D -> Message type: 1
|
|
||||||
04.02.25 18:18:32 D <- Message type: 1
|
|
||||||
04.02.25 18:18:32 D -> Message type: 3
|
|
||||||
04.02.25 18:18:32 D <- Message type: 4
|
|
||||||
04.02.25 18:18:32 D -> Message type: 5
|
|
||||||
04.02.25 18:18:32 I Log in to server
|
|
||||||
04.02.25 18:18:32 D -> Message type: 9
|
|
||||||
04.02.25 18:18:32 D -> Message type: 7
|
|
||||||
04.02.25 18:18:32 D -> Message type: 13
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 8
|
|
||||||
04.02.25 18:18:32 D -> Message type: 11
|
|
||||||
04.02.25 18:18:32 D -> Message type: 11
|
|
||||||
04.02.25 18:18:32 D -> Message type: 100
|
|
||||||
04.02.25 18:18:32 D -> Message type: 100
|
|
||||||
04.02.25 18:18:32 D -> Message type: 100
|
|
||||||
04.02.25 18:18:32 D -> Message type: 100
|
|
||||||
04.02.25 18:18:32 D -> Message type: 100
|
|
||||||
04.02.25 18:18:32 D -> Message type: 100
|
|
||||||
04.02.25 18:18:33 D -> Message type: 14
|
|
||||||
04.02.25 18:18:33 D -> Message type: 110
|
|
||||||
04.02.25 18:18:33 D -> Message type: 107
|
|
||||||
04.02.25 18:18:33 D -> Message type: 107
|
|
||||||
04.02.25 18:18:53 D -> Message type: 101
|
|
||||||
04.02.25 18:20:08 E Spojeni bylo ukonceno
|
|
||||||
04.02.25 18:20:13 E Zkousim se znovu pripojit...
|
|
||||||
04.02.25 18:20:13 D -> Message type: 1
|
|
||||||
04.02.25 18:20:13 D <- Message type: 1
|
|
||||||
04.02.25 18:20:13 D -> Message type: 3
|
|
||||||
04.02.25 18:20:13 D <- Message type: 4
|
|
||||||
04.02.25 18:20:13 D -> Message type: 5
|
|
||||||
04.02.25 18:20:13 I Log in to server
|
|
||||||
04.02.25 18:20:13 D -> Message type: 9
|
|
||||||
04.02.25 18:20:13 D -> Message type: 7
|
|
||||||
04.02.25 18:20:13 D -> Message type: 13
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 8
|
|
||||||
04.02.25 18:20:13 D -> Message type: 11
|
|
||||||
04.02.25 18:20:13 D -> Message type: 11
|
|
||||||
04.02.25 18:20:13 D -> Message type: 100
|
|
||||||
04.02.25 18:20:13 D -> Message type: 100
|
|
||||||
04.02.25 18:20:13 D -> Message type: 100
|
|
||||||
04.02.25 18:20:13 D -> Message type: 100
|
|
||||||
04.02.25 18:20:13 D -> Message type: 100
|
|
||||||
04.02.25 18:20:13 D -> Message type: 100
|
|
||||||
04.02.25 18:20:13 D -> Message type: 14
|
|
||||||
04.02.25 18:20:13 D -> Message type: 110
|
|
||||||
04.02.25 18:20:13 D -> Message type: 107
|
|
||||||
04.02.25 18:20:13 D -> Message type: 107
|
|
||||||
04.02.25 18:28:05 D -> Message type: 108
|
|
||||||
04.02.25 18:28:05 D -> Message type: 101
|
|
||||||
04.02.25 18:28:06 D -> Message type: 101
|
|
||||||
04.02.25 18:29:45 D -> Message type: 108
|
|
||||||
04.02.25 18:29:45 D -> Message type: 101
|
|
||||||
04.02.25 18:29:46 D -> Message type: 101
|
|
||||||
04.02.25 18:34:14 D -> Message type: 108
|
|
||||||
04.02.25 18:34:14 D -> Message type: 101
|
|
||||||
04.02.25 18:34:15 D -> Message type: 101
|
|
||||||
04.02.25 18:35:53 D -> Message type: 108
|
|
||||||
04.02.25 18:35:53 D -> Message type: 101
|
|
||||||
04.02.25 18:35:54 D -> Message type: 101
|
|
||||||
04.02.25 18:38:18 D -> Message type: 108
|
|
||||||
04.02.25 18:38:18 D -> Message type: 101
|
|
||||||
04.02.25 18:38:19 D -> Message type: 101
|
|
||||||
04.02.25 18:39:31 D -> Message type: 108
|
|
||||||
04.02.25 18:39:31 D -> Message type: 101
|
|
||||||
04.02.25 18:39:32 D -> Message type: 101
|
|
||||||
04.02.25 18:40:31 D -> Message type: 108
|
|
||||||
04.02.25 18:40:31 D -> Message type: 101
|
|
||||||
04.02.25 18:40:32 D -> Message type: 101
|
|
||||||
04.02.25 18:44:12 D -> Message type: 108
|
|
||||||
04.02.25 18:44:12 D -> Message type: 101
|
|
||||||
04.02.25 18:44:13 D -> Message type: 101
|
|
||||||
04.02.25 18:44:43 D -> Message type: 108
|
|
||||||
04.02.25 18:44:43 D -> Message type: 101
|
|
||||||
04.02.25 18:44:44 D -> Message type: 101
|
|
||||||
04.02.25 18:46:19 D -> Message type: 108
|
|
||||||
04.02.25 18:46:19 D -> Message type: 101
|
|
||||||
04.02.25 18:46:20 D -> Message type: 101
|
|
||||||
04.02.25 18:48:13 D -> Message type: 108
|
|
||||||
04.02.25 18:48:13 D -> Message type: 101
|
|
||||||
04.02.25 18:48:14 D -> Message type: 101
|
|
||||||
04.02.25 18:49:37 D -> Message type: 108
|
|
||||||
04.02.25 18:49:37 D -> Message type: 101
|
|
||||||
04.02.25 18:49:38 D -> Message type: 101
|
|
||||||
04.02.25 18:54:18 D -> Message type: 108
|
|
||||||
04.02.25 18:54:18 D -> Message type: 101
|
|
||||||
04.02.25 18:54:19 D -> Message type: 101
|
|
||||||
04.02.25 18:59:24 D -> Message type: 108
|
|
||||||
04.02.25 18:59:24 D -> Message type: 101
|
|
||||||
04.02.25 18:59:27 D -> Message type: 101
|
|
||||||
04.02.25 18:59:56 D -> Message type: 108
|
|
||||||
04.02.25 18:59:56 D -> Message type: 101
|
|
||||||
04.02.25 18:59:57 D -> Message type: 101
|
|
||||||
04.02.25 19:11:38 D -> Message type: 108
|
|
||||||
04.02.25 19:11:38 D -> Message type: 101
|
|
||||||
04.02.25 19:11:39 D -> Message type: 101
|
|
||||||
04.02.25 19:14:33 D -> Message type: 108
|
|
||||||
04.02.25 19:14:33 D -> Message type: 101
|
|
||||||
04.02.25 19:14:34 D -> Message type: 101
|
|
||||||
04.02.25 19:20:55 D -> Message type: 108
|
|
||||||
04.02.25 19:20:55 D -> Message type: 101
|
|
||||||
04.02.25 19:20:56 D -> Message type: 101
|
|
||||||
04.02.25 19:24:30 D -> Message type: 108
|
|
||||||
04.02.25 19:24:30 D -> Message type: 101
|
|
||||||
04.02.25 19:24:31 D -> Message type: 101
|
|
||||||
04.02.25 19:29:23 D -> Message type: 108
|
|
||||||
04.02.25 19:29:23 D -> Message type: 101
|
|
||||||
04.02.25 19:29:24 D -> Message type: 101
|
|
||||||
04.02.25 19:34:17 D -> Message type: 108
|
|
||||||
04.02.25 19:34:17 D -> Message type: 101
|
|
||||||
04.02.25 19:34:18 D -> Message type: 101
|
|
||||||
04.02.25 19:44:31 D -> Message type: 108
|
|
||||||
04.02.25 19:44:31 D -> Message type: 101
|
|
||||||
04.02.25 19:44:32 D -> Message type: 101
|
|
||||||
04.02.25 19:48:14 D -> Message type: 108
|
|
||||||
04.02.25 19:48:14 D -> Message type: 101
|
|
||||||
04.02.25 19:48:15 D -> Message type: 101
|
|
||||||
04.02.25 19:59:37 D -> Message type: 108
|
|
||||||
04.02.25 19:59:37 D -> Message type: 101
|
|
||||||
04.02.25 19:59:38 D -> Message type: 101
|
|
||||||
04.02.25 20:0:02 D -> Message type: 108
|
|
||||||
04.02.25 20:0:02 D -> Message type: 101
|
|
||||||
04.02.25 20:0:06 D -> Message type: 101
|
|
||||||
04.02.25 20:8:49 D -> Message type: 108
|
|
||||||
04.02.25 20:8:49 D -> Message type: 101
|
|
||||||
04.02.25 20:8:50 D -> Message type: 101
|
|
||||||
04.02.25 20:9:35 D -> Message type: 108
|
|
||||||
04.02.25 20:9:35 D -> Message type: 101
|
|
||||||
04.02.25 20:9:36 D -> Message type: 101
|
|
||||||
04.02.25 20:17:35 D -> Message type: 108
|
|
||||||
04.02.25 20:17:35 D -> Message type: 101
|
|
||||||
04.02.25 20:17:36 D -> Message type: 101
|
|
||||||
04.02.25 20:19:33 D -> Message type: 108
|
|
||||||
04.02.25 20:19:33 D -> Message type: 101
|
|
||||||
04.02.25 20:19:34 D -> Message type: 101
|
|
||||||
04.02.25 20:19:47 D -> Message type: 108
|
|
||||||
04.02.25 20:19:47 D -> Message type: 101
|
|
||||||
04.02.25 20:19:48 D -> Message type: 101
|
|
||||||
04.02.25 20:23:18 D -> Message type: 108
|
|
||||||
04.02.25 20:23:18 D -> Message type: 101
|
|
||||||
04.02.25 20:23:19 D -> Message type: 101
|
|
||||||
04.02.25 20:24:28 D -> Message type: 108
|
|
||||||
04.02.25 20:24:28 D -> Message type: 101
|
|
||||||
04.02.25 20:24:29 D -> Message type: 101
|
|
||||||
04.02.25 20:24:33 D -> Message type: 108
|
|
||||||
04.02.25 20:24:33 D -> Message type: 101
|
|
||||||
04.02.25 20:24:34 D -> Message type: 101
|
|
||||||
04.02.25 20:26:06 D -> Message type: 108
|
|
||||||
04.02.25 20:26:06 D -> Message type: 101
|
|
||||||
04.02.25 20:26:07 D -> Message type: 101
|
|
||||||
04.02.25 20:34:17 D -> Message type: 108
|
|
||||||
04.02.25 20:34:17 D -> Message type: 101
|
|
||||||
04.02.25 20:34:18 D -> Message type: 101
|
|
||||||
04.02.25 20:44:50 D -> Message type: 108
|
|
||||||
04.02.25 20:44:50 D -> Message type: 101
|
|
||||||
04.02.25 20:44:53 D -> Message type: 108
|
|
||||||
04.02.25 20:44:53 D -> Message type: 101
|
|
||||||
04.02.25 20:44:54 D -> Message type: 101
|
|
||||||
04.02.25 20:44:55 D -> Message type: 101
|
|
||||||
04.02.25 20:52:08 D -> Message type: 108
|
|
||||||
04.02.25 20:52:08 D -> Message type: 101
|
|
||||||
04.02.25 20:52:09 D -> Message type: 101
|
|
||||||
04.02.25 20:54:29 D -> Message type: 108
|
|
||||||
04.02.25 20:54:29 D -> Message type: 101
|
|
||||||
04.02.25 20:54:30 D -> Message type: 101
|
|
||||||
04.02.25 21:8:32 D -> Message type: 108
|
|
||||||
04.02.25 21:8:32 D -> Message type: 101
|
|
||||||
04.02.25 21:8:33 D -> Message type: 101
|
|
||||||
04.02.25 21:13:54 D -> Message type: 108
|
|
||||||
04.02.25 21:13:54 D -> Message type: 101
|
|
||||||
04.02.25 21:13:55 D -> Message type: 101
|
|
||||||
04.02.25 21:29:31 D -> Message type: 108
|
|
||||||
04.02.25 21:29:31 D -> Message type: 101
|
|
||||||
04.02.25 21:29:32 D -> Message type: 101
|
|
||||||
04.02.25 21:30:11 D -> Message type: 108
|
|
||||||
04.02.25 21:30:11 D -> Message type: 101
|
|
||||||
04.02.25 21:30:12 D -> Message type: 101
|
|
||||||
04.02.25 21:30:18 D -> Message type: 108
|
|
||||||
04.02.25 21:30:18 D -> Message type: 101
|
|
||||||
04.02.25 21:30:19 D -> Message type: 101
|
|
||||||
04.02.25 21:39:31 D -> Message type: 108
|
|
||||||
04.02.25 21:39:31 D -> Message type: 101
|
|
||||||
04.02.25 21:39:32 D -> Message type: 101
|
|
||||||
04.02.25 21:40:04 D -> Message type: 108
|
|
||||||
04.02.25 21:40:04 D -> Message type: 101
|
|
||||||
04.02.25 21:40:05 D -> Message type: 101
|
|
||||||
04.02.25 21:41:08 D -> Message type: 108
|
|
||||||
04.02.25 21:41:08 D -> Message type: 101
|
|
||||||
04.02.25 21:41:09 D -> Message type: 101
|
|
||||||
04.02.25 21:53:54 D -> Message type: 108
|
|
||||||
04.02.25 21:53:54 D -> Message type: 101
|
|
||||||
04.02.25 21:53:55 D -> Message type: 101
|
|
||||||
04.02.25 21:54:05 D -> Message type: 108
|
|
||||||
04.02.25 21:54:05 D -> Message type: 101
|
|
||||||
04.02.25 21:54:06 D -> Message type: 101
|
|
||||||
04.02.25 21:54:38 D -> Message type: 108
|
|
||||||
04.02.25 21:54:38 D -> Message type: 101
|
|
||||||
04.02.25 21:54:39 D -> Message type: 101
|
|
||||||
04.02.25 22:4:46 D -> Message type: 108
|
|
||||||
04.02.25 22:4:46 D -> Message type: 101
|
|
||||||
04.02.25 22:4:48 D -> Message type: 101
|
|
||||||
04.02.25 22:10:03 D -> Message type: 108
|
|
||||||
04.02.25 22:10:03 D -> Message type: 101
|
|
||||||
04.02.25 22:10:04 D -> Message type: 101
|
|
||||||
04.02.25 22:39:33 D -> Message type: 108
|
|
||||||
04.02.25 22:39:33 D -> Message type: 101
|
|
||||||
04.02.25 22:39:34 D -> Message type: 101
|
|
||||||
04.02.25 22:52:23 D -> Message type: 108
|
|
||||||
04.02.25 22:52:23 D -> Message type: 101
|
|
||||||
04.02.25 22:52:24 D -> Message type: 101
|
|
||||||
04.02.25 22:54:16 D -> Message type: 108
|
|
||||||
04.02.25 22:54:16 D -> Message type: 101
|
|
||||||
04.02.25 22:54:17 D -> Message type: 101
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
Manifest-Version: 1.0
|
|
||||||
X-COMMENT: Main-Class will be added automatically by build
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<actions>
|
||||||
|
<action>
|
||||||
|
<actionName>run</actionName>
|
||||||
|
<packagings>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
</packagings>
|
||||||
|
<goals>
|
||||||
|
<goal>process-classes</goal>
|
||||||
|
<goal>org.codehaus.mojo:exec-maven-plugin:3.5.1:exec</goal>
|
||||||
|
</goals>
|
||||||
|
<properties>
|
||||||
|
<exec.vmArgs>-Dio.netty.noUnsafe=true -Dio.netty.tryUnsafe=false</exec.vmArgs>
|
||||||
|
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
|
||||||
|
<exec.appArgs></exec.appArgs>
|
||||||
|
<exec.mainClass>${packageClassName}</exec.mainClass>
|
||||||
|
<exec.executable>java</exec.executable>
|
||||||
|
</properties>
|
||||||
|
</action>
|
||||||
|
<action>
|
||||||
|
<actionName>debug</actionName>
|
||||||
|
<packagings>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
</packagings>
|
||||||
|
<goals>
|
||||||
|
<goal>process-classes</goal>
|
||||||
|
<goal>org.codehaus.mojo:exec-maven-plugin:3.5.1:exec</goal>
|
||||||
|
</goals>
|
||||||
|
<properties>
|
||||||
|
<exec.vmArgs>-Dio.netty.noUnsafe=true -Dio.netty.tryUnsafe=false -agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</exec.vmArgs>
|
||||||
|
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
|
||||||
|
<exec.appArgs></exec.appArgs>
|
||||||
|
<exec.mainClass>${packageClassName}</exec.mainClass>
|
||||||
|
<exec.executable>java</exec.executable>
|
||||||
|
<jpda.listen>true</jpda.listen>
|
||||||
|
</properties>
|
||||||
|
</action>
|
||||||
|
<action>
|
||||||
|
<actionName>profile</actionName>
|
||||||
|
<packagings>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
</packagings>
|
||||||
|
<goals>
|
||||||
|
<goal>process-classes</goal>
|
||||||
|
<goal>org.codehaus.mojo:exec-maven-plugin:3.5.1:exec</goal>
|
||||||
|
</goals>
|
||||||
|
<properties>
|
||||||
|
<exec.vmArgs>-Dio.netty.noUnsafe=true -Dio.netty.tryUnsafe=false</exec.vmArgs>
|
||||||
|
<exec.args>${exec.vmArgs} -classpath %classpath ${exec.mainClass} ${exec.appArgs}</exec.args>
|
||||||
|
<exec.mainClass>${packageClassName}</exec.mainClass>
|
||||||
|
<exec.executable>java</exec.executable>
|
||||||
|
<exec.appArgs></exec.appArgs>
|
||||||
|
</properties>
|
||||||
|
</action>
|
||||||
|
</actions>
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,8 +0,0 @@
|
||||||
build.xml.data.CRC32=2260700f
|
|
||||||
build.xml.script.CRC32=a5a5f7c0
|
|
||||||
build.xml.stylesheet.CRC32=f85dc8f2@1.113.0.48
|
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
|
||||||
nbproject/build-impl.xml.data.CRC32=2260700f
|
|
||||||
nbproject/build-impl.xml.script.CRC32=379f78cb
|
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.113.0.48
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
||||||
annotation.processing.enabled=true
|
|
||||||
annotation.processing.enabled.in.editor=false
|
|
||||||
annotation.processing.processors.list=
|
|
||||||
annotation.processing.run.all.processors=true
|
|
||||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
|
||||||
application.title=jNetClient
|
|
||||||
application.vendor=cucky
|
|
||||||
build.classes.dir=${build.dir}/classes
|
|
||||||
build.classes.excludes=**/*.java,**/*.form
|
|
||||||
# This directory is removed when the project is cleaned:
|
|
||||||
build.dir=build
|
|
||||||
build.generated.dir=${build.dir}/generated
|
|
||||||
build.generated.sources.dir=${build.dir}/generated-sources
|
|
||||||
# Only compile against the classpath explicitly listed here:
|
|
||||||
build.sysclasspath=ignore
|
|
||||||
build.test.classes.dir=${build.dir}/test/classes
|
|
||||||
build.test.results.dir=${build.dir}/test/results
|
|
||||||
# Uncomment to specify the preferred debugger connection transport:
|
|
||||||
#debug.transport=dt_socket
|
|
||||||
debug.classpath=\
|
|
||||||
${run.classpath}
|
|
||||||
debug.modulepath=\
|
|
||||||
${run.modulepath}
|
|
||||||
debug.test.classpath=\
|
|
||||||
${run.test.classpath}
|
|
||||||
debug.test.modulepath=\
|
|
||||||
${run.test.modulepath}
|
|
||||||
# Files in build.classes.dir which should be excluded from distribution jar
|
|
||||||
dist.archive.excludes=
|
|
||||||
# This directory is removed when the project is cleaned:
|
|
||||||
dist.dir=dist
|
|
||||||
dist.jar=${dist.dir}/jNetClient.jar
|
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
|
||||||
dist.jlink.dir=${dist.dir}/jlink
|
|
||||||
dist.jlink.output=${dist.jlink.dir}/jNetClient
|
|
||||||
endorsed.classpath=
|
|
||||||
excludes=
|
|
||||||
file.reference.apache-commons-configuration2-2.9.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-configuration2-2.9.0.jar
|
|
||||||
file.reference.apache-commons-lang3-3.12.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-lang3-3.12.0.jar
|
|
||||||
file.reference.apache-commons-logging-1.2.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-logging-1.2.jar
|
|
||||||
file.reference.apache-commons-text-1.10.0.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\apache-commons-text-1.10.0.jar
|
|
||||||
file.reference.netty-all-4.1.68.Final.jar=C:\\Users\\cucky\\Documents\\NetBeansProjects\\jar_files\\netty-all-4.1.68.Final.jar
|
|
||||||
includes=**
|
|
||||||
jar.compress=false
|
|
||||||
javac.classpath=\
|
|
||||||
${reference.jNetLib.jar}:\
|
|
||||||
${file.reference.apache-commons-configuration2-2.9.0.jar}:\
|
|
||||||
${file.reference.netty-all-4.1.68.Final.jar}:\
|
|
||||||
${file.reference.apache-commons-logging-1.2.jar}:\
|
|
||||||
${file.reference.apache-commons-text-1.10.0.jar}:\
|
|
||||||
${file.reference.apache-commons-lang3-3.12.0.jar}
|
|
||||||
# Space-separated list of extra javac options
|
|
||||||
javac.compilerargs=
|
|
||||||
javac.deprecation=false
|
|
||||||
javac.external.vm=true
|
|
||||||
javac.modulepath=
|
|
||||||
javac.processormodulepath=
|
|
||||||
javac.processorpath=\
|
|
||||||
${javac.classpath}
|
|
||||||
javac.source=23
|
|
||||||
javac.target=23
|
|
||||||
javac.test.classpath=\
|
|
||||||
${javac.classpath}:\
|
|
||||||
${build.classes.dir}
|
|
||||||
javac.test.modulepath=\
|
|
||||||
${javac.modulepath}
|
|
||||||
javac.test.processorpath=\
|
|
||||||
${javac.test.classpath}
|
|
||||||
javadoc.additionalparam=
|
|
||||||
javadoc.author=false
|
|
||||||
javadoc.encoding=${source.encoding}
|
|
||||||
javadoc.html5=false
|
|
||||||
javadoc.noindex=false
|
|
||||||
javadoc.nonavbar=false
|
|
||||||
javadoc.notree=false
|
|
||||||
javadoc.private=false
|
|
||||||
javadoc.splitindex=true
|
|
||||||
javadoc.use=true
|
|
||||||
javadoc.version=false
|
|
||||||
javadoc.windowtitle=
|
|
||||||
# The jlink additional root modules to resolve
|
|
||||||
jlink.additionalmodules=
|
|
||||||
# The jlink additional command line parameters
|
|
||||||
jlink.additionalparam=
|
|
||||||
jlink.launcher=true
|
|
||||||
jlink.launcher.name=jNetClient
|
|
||||||
main.class=jnet.client.Client
|
|
||||||
manifest.file=manifest.mf
|
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
|
||||||
mkdist.disabled=false
|
|
||||||
platform.active=default_platform
|
|
||||||
project.jNetLib=../jNetLib
|
|
||||||
reference.jNetLib.jar=${project.jNetLib}/dist/jNetLib.jar
|
|
||||||
run.classpath=\
|
|
||||||
${javac.classpath}:\
|
|
||||||
${build.classes.dir}
|
|
||||||
# Space-separated list of JVM arguments used when running the project.
|
|
||||||
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
|
|
||||||
# To set system properties for unit tests define test-sys-prop.name=value:
|
|
||||||
run.jvmargs=
|
|
||||||
run.modulepath=\
|
|
||||||
${javac.modulepath}
|
|
||||||
run.test.classpath=\
|
|
||||||
${javac.test.classpath}:\
|
|
||||||
${build.test.classes.dir}
|
|
||||||
run.test.modulepath=\
|
|
||||||
${javac.test.modulepath}
|
|
||||||
source.encoding=UTF-8
|
|
||||||
src.dir=src
|
|
||||||
test.src.dir=test
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
|
||||||
<type>org.netbeans.modules.java.j2seproject</type>
|
|
||||||
<configuration>
|
|
||||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
|
||||||
<name>jNetClient</name>
|
|
||||||
<source-roots>
|
|
||||||
<root id="src.dir"/>
|
|
||||||
</source-roots>
|
|
||||||
<test-roots>
|
|
||||||
<root id="test.src.dir"/>
|
|
||||||
</test-roots>
|
|
||||||
</data>
|
|
||||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
|
||||||
<reference>
|
|
||||||
<foreign-project>jNetLib</foreign-project>
|
|
||||||
<artifact-type>jar</artifact-type>
|
|
||||||
<script>build.xml</script>
|
|
||||||
<target>jar</target>
|
|
||||||
<clean-target>clean</clean-target>
|
|
||||||
<id>jar</id>
|
|
||||||
</reference>
|
|
||||||
</references>
|
|
||||||
</configuration>
|
|
||||||
</project>
|
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>jnet</groupId>
|
||||||
|
<artifactId>jNetClient</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.release>26</maven.compiler.release>
|
||||||
|
<exec.mainClass>jnet.client.Client</exec.mainClass>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.netty</groupId>
|
||||||
|
<artifactId>netty-all</artifactId>
|
||||||
|
<version>4.1.118.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcprov-jdk18on</artifactId>
|
||||||
|
<version>1.78.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcpkix-jdk18on</artifactId>
|
||||||
|
<version>1.78.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>jNetLib</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- Nastavení názvu výsledného JAR -->
|
||||||
|
<finalName>jNetClient</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.3.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>copy-resources</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy-resources</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>${project.build.directory}</outputDirectory>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
Binary file not shown.
|
|
@ -1,14 +0,0 @@
|
||||||
autoconnect = true
|
|
||||||
debug = true
|
|
||||||
port = 1225
|
|
||||||
server = localhost
|
|
||||||
user = michal
|
|
||||||
volume = 75
|
|
||||||
start_minimalized = false
|
|
||||||
password = Michal2407
|
|
||||||
sound = true
|
|
||||||
debuger = true
|
|
||||||
sound_one_online=sound/schema1/one_online.wav
|
|
||||||
sound_next_offline=sound/schema1/next_offline.wav
|
|
||||||
sound_all_online = sound/schema1/all_online.wav
|
|
||||||
sound_first_offline=sound/schema1/first_offline.wav
|
|
||||||
|
|
@ -1,110 +0,0 @@
|
||||||
package jnet.client;
|
|
||||||
|
|
||||||
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;
|
|
||||||
import jnet.lib.object.Event;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
import jnet.lib.object.ObjectType;
|
|
||||||
import jnet.lib.object.OnlineClients;
|
|
||||||
import jnet.lib.object.ServerConfig;
|
|
||||||
import jnet.lib.object.SnmpProfile;
|
|
||||||
import jnet.lib.object.User;
|
|
||||||
|
|
||||||
|
|
||||||
public class Client {
|
|
||||||
|
|
||||||
// verze serveru
|
|
||||||
public static final int CLIENT_VERSION = 1;
|
|
||||||
// nazev aplikace
|
|
||||||
public static final String APP_NAME = "jNet";
|
|
||||||
|
|
||||||
public static List<Map> maps = new CopyOnWriteArrayList<>();
|
|
||||||
//public static List<MapObject> mapObject = new ArrayList<>();
|
|
||||||
public static List<OnlineClients> onlineClients = new ArrayList<>();
|
|
||||||
public static List<ObjectType> objectType = new ArrayList<>();
|
|
||||||
public static List<SnmpProfile> snmpProfile = new ArrayList<>();
|
|
||||||
public static List<User> users = new ArrayList<>();
|
|
||||||
public static List<Event> events = new ArrayList<>();
|
|
||||||
public static User user;
|
|
||||||
public static boolean connected = false;
|
|
||||||
public static Window okno = new Window();
|
|
||||||
public static Thread clientThread;
|
|
||||||
public static PropertiesManager config;
|
|
||||||
public static ServerConfig serverConfig;
|
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException {
|
|
||||||
|
|
||||||
|
|
||||||
LogFile.clear();
|
|
||||||
LogFile.printInfo("---------------------------------------------");
|
|
||||||
LogFile.printInfo(" jNet Client ");
|
|
||||||
LogFile.printInfo(" Version: " + CLIENT_VERSION + " (" + BuilddDate.get() + ")");
|
|
||||||
LogFile.printInfo("---------------------------------------------");
|
|
||||||
LogFile.printInfo("");
|
|
||||||
|
|
||||||
///
|
|
||||||
/// load config
|
|
||||||
///
|
|
||||||
LogFile.printInfo("Loading config ...");
|
|
||||||
try {
|
|
||||||
// Načtení existující konfigurace, pokud soubor existuje
|
|
||||||
config = new PropertiesManager("config.properties");
|
|
||||||
config.load();
|
|
||||||
LogFile.printInfo(" successfully");
|
|
||||||
} catch (PropertiesManager.FileException | PropertiesManager.ConfigException ex) {
|
|
||||||
LogFile.printErr(" fail. " + ex.getMessage());
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
/// debug rezim ?
|
|
||||||
///
|
|
||||||
if (config.getBoolean("debug")) {
|
|
||||||
LogFile.setDebug(true);
|
|
||||||
LogFile.printDebug("Debug mode on");
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
/// tray icon
|
|
||||||
///
|
|
||||||
new Tray().createAndShowTray();
|
|
||||||
|
|
||||||
///
|
|
||||||
/// spustit minimalozovane ?
|
|
||||||
///
|
|
||||||
if (config.getBoolean("start_minimalized")) {
|
|
||||||
okno.setVisible(false);
|
|
||||||
} else {
|
|
||||||
okno.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Spuštění klienta v novém vlákně
|
|
||||||
NettyClient client = new NettyClient(config.getString("server"), config.getInt("port"));
|
|
||||||
clientThread = new Thread(client);
|
|
||||||
clientThread.start();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//TODO TODO TODO TODO TODO TODO
|
|
||||||
static void setConnected() {
|
|
||||||
// nastavení serveru jako pripojeny
|
|
||||||
connected = true;
|
|
||||||
// smazání seznamu map
|
|
||||||
maps.clear();
|
|
||||||
// smazani object typu
|
|
||||||
objectType.clear();
|
|
||||||
// smazani uzivatelu
|
|
||||||
users.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,292 +0,0 @@
|
||||||
package jnet.client;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import jnet.client.gui.UIUpdater;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
import jnet.lib.object.Connection;
|
|
||||||
import jnet.lib.object.Event;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
import jnet.lib.object.ObjectType;
|
|
||||||
import jnet.lib.object.OnlineClients;
|
|
||||||
import jnet.lib.object.ServerConfig;
|
|
||||||
import jnet.lib.object.SnmpProfile;
|
|
||||||
import jnet.lib.object.User;
|
|
||||||
import jnet.lib.snmp.DeviceInfo;
|
|
||||||
import jnet.lib.snmp.Interface;
|
|
||||||
|
|
||||||
public class ClientMessageParser {
|
|
||||||
|
|
||||||
private static final java.util.Map<Integer, Consumer<Message>> handlers = new HashMap<>();
|
|
||||||
|
|
||||||
static {
|
|
||||||
handlers.put(Message.CLIENT_VERSION, ClientMessageParser::handleClientVersion);
|
|
||||||
handlers.put(Message.UPDATE, ClientMessageParser::handleUpdate);
|
|
||||||
handlers.put(Message.AUTH_REQUEST, ClientMessageParser::handleAuthRequest);
|
|
||||||
handlers.put(Message.AUTH_SUCEFULL, ClientMessageParser::handleAuthSuccessful);
|
|
||||||
handlers.put(Message.AUTH_FAIL, ClientMessageParser::handleAuthFail);
|
|
||||||
handlers.put(Message.ONLINE_CLIENTS, ClientMessageParser::handleOnlineClients);
|
|
||||||
handlers.put(Message.OBJECT_TYPE, ClientMessageParser::handleObjectType);
|
|
||||||
handlers.put(Message.USER, ClientMessageParser::handleUser);
|
|
||||||
handlers.put(Message.USER_INFO, ClientMessageParser::handleUserInfo);
|
|
||||||
handlers.put(Message.MAP, ClientMessageParser::handleMap);
|
|
||||||
handlers.put(Message.STATUS_UPDATE, ClientMessageParser::handleStatusUpdate);
|
|
||||||
handlers.put(Message.SET_MAP_LOCK, ClientMessageParser::handleSetMapLock);
|
|
||||||
handlers.put(Message.SNMP_PROFILE, ClientMessageParser::handleSnmpProfile);
|
|
||||||
handlers.put(Message.EVENT_LIST, ClientMessageParser::handleEventList);
|
|
||||||
handlers.put(Message.EVENT_NEW, ClientMessageParser::handleEventNew);
|
|
||||||
handlers.put(Message.EVENT_UPDATE, ClientMessageParser::handleEventUpdate);
|
|
||||||
handlers.put(Message.ADD_OBJECT, ClientMessageParser::handleAddObject);
|
|
||||||
handlers.put(Message.REMOVE_OBJECT, ClientMessageParser::handleRemoveObject);
|
|
||||||
handlers.put(Message.UPDATE_OBJECT, ClientMessageParser::handleUpdateObject);
|
|
||||||
handlers.put(Message.MAP_REMOVE, ClientMessageParser::handleMapRemove);
|
|
||||||
handlers.put(Message.USER_EDIT, ClientMessageParser::handleUserEdit);
|
|
||||||
handlers.put(Message.DELETE_LOG, ClientMessageParser::handleDeleteLog);
|
|
||||||
handlers.put(Message.SERVER_CONFIG, ClientMessageParser::handleServerConfig);
|
|
||||||
handlers.put(Message.SNMP_OBJECT_INFO, ClientMessageParser::handleSnmpObjectInfo);
|
|
||||||
handlers.put(Message.SNMP_OBJECT_INTERFACE, ClientMessageParser::handleSnmpObjectInterface);
|
|
||||||
handlers.put(Message.SNMP_TEST, ClientMessageParser::handleSnmpTest);
|
|
||||||
handlers.put(Message.SNMP_CONNECTION_INTERFACE, ClientMessageParser::handleSnmpConnectionInterface);
|
|
||||||
handlers.put(Message.CONNECTION_NEW, ClientMessageParser::handleConnectionNew);
|
|
||||||
handlers.put(Message.TRAFFIC, ClientMessageParser::handlerTraffic);
|
|
||||||
handlers.put(Message.CONNECTION_UPDATE, ClientMessageParser::handlerConnectionUpdate);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void parse(Message msg) {
|
|
||||||
LogFile.printDebug("-> Message type: " + msg.getType());
|
|
||||||
handlers.getOrDefault(msg.getType(), m -> LogFile.printErr("Neznámý typ zprávy")).accept(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleClientVersion(Message msg) {
|
|
||||||
NettyClient.send(Message.CLIENT_VERSION, Client.CLIENT_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleUpdate(Message msg) {
|
|
||||||
LogFile.printInfo("Received update request");
|
|
||||||
// TODO: Dialogové okno s informací o aktualizaci a odpočtem k jejímu provedení
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleAuthRequest(Message msg) {
|
|
||||||
String[] userPass = {Client.config.getString("user"), Client.config.getString("password"), String.valueOf(OnlineClients.PLATFORM_PC)};
|
|
||||||
NettyClient.send(Message.AUTH, userPass);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleAuthSuccessful(Message msg) {
|
|
||||||
LogFile.printInfo("Log in to server");
|
|
||||||
Client.setConnected();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleAuthFail(Message msg) {
|
|
||||||
LogFile.printInfo("Authorization failed on server");
|
|
||||||
JOptionPane.showMessageDialog(null, "Chybné přihlašovací údaje!", "Chyba", JOptionPane.ERROR_MESSAGE);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleOnlineClients(Message msg) {
|
|
||||||
Client.onlineClients = (ArrayList<OnlineClients>) msg.getMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleObjectType(Message msg) {
|
|
||||||
Client.objectType.add((ObjectType) msg.getMsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleUser(Message msg) {
|
|
||||||
Client.users.add((User) msg.getMsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleUserInfo(Message msg) {
|
|
||||||
Client.user = (User) msg.getMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleMap(Message msg) {
|
|
||||||
Map map = (Map) (Map) msg.getMsg();
|
|
||||||
Client.maps.add(map);
|
|
||||||
// aktualizace UI
|
|
||||||
UIUpdater.updateMapTree();
|
|
||||||
UIUpdater.updateTray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleStatusUpdate(Message msg) {
|
|
||||||
int[] o = (int[]) msg.getMsg();
|
|
||||||
int obj_id = o[0];
|
|
||||||
int status = o[1];
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (MapObject mapObject : map.getObjects()) {
|
|
||||||
if (mapObject.getId() == obj_id) {
|
|
||||||
mapObject.setStatus(status);
|
|
||||||
// aktualizace UI
|
|
||||||
UIUpdater.updateMapTree();
|
|
||||||
UIUpdater.updateTray();
|
|
||||||
UIUpdater.updateMapView();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SoundManager.changeStatus(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSetMapLock(Message msg) {
|
|
||||||
int[] data_lock = (int[]) msg.getMsg();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
if (map.getId() == data_lock[0]) {
|
|
||||||
map.setLock((data_lock[1] == 1));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSnmpProfile(Message msg) {
|
|
||||||
Client.snmpProfile.add((SnmpProfile) msg.getMsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleEventList(Message msg) {
|
|
||||||
Client.events = (ArrayList<Event>) msg.getMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleEventNew(Message msg) {
|
|
||||||
Client.events.add((Event) msg.getMsg());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleEventUpdate(Message msg) {
|
|
||||||
Event event_update = (Event) msg.getMsg();
|
|
||||||
for (int i = 0; i < Client.events.size(); i++) {
|
|
||||||
if (event_update.getId() == Client.events.get(i).getId()) {
|
|
||||||
Client.events.set(i, event_update);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleAddObject(Message msg) {
|
|
||||||
MapObject mo = (MapObject) msg.getMsg();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
if (map.getId() == mo.getMap()) {
|
|
||||||
map.getObjects().add(mo);
|
|
||||||
UIUpdater.updateMapView();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleRemoveObject(Message msg) {
|
|
||||||
int objId = (int) msg.getMsg();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (MapObject object : map.getObjects()) {
|
|
||||||
if (object.getId() == objId) {
|
|
||||||
map.getObjects().remove(object);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// aktualizace UI
|
|
||||||
UIUpdater.updateMapTree();
|
|
||||||
UIUpdater.updateTray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleUpdateObject(Message msg) {
|
|
||||||
MapObject mo = (MapObject) msg.getMsg();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleMapRemove(Message msg) {
|
|
||||||
int mapId = (int) msg.getMsg();
|
|
||||||
Client.maps.removeIf(map -> map.getId() == mapId);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleUserEdit(Message msg) {
|
|
||||||
User ue = (User) msg.getMsg();
|
|
||||||
Client.users.removeIf(user -> user.getId() == ue.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleDeleteLog(Message msg) {
|
|
||||||
int objId = (int) msg.getMsg();
|
|
||||||
Client.events.removeIf(event -> event.getObject() == objId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleServerConfig(Message msg) {
|
|
||||||
Client.serverConfig = (ServerConfig) msg.getMsg();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSnmpObjectInfo(Message msg) {
|
|
||||||
Object[] msg_obj = (Object[]) msg.getMsg();
|
|
||||||
String frame = (String) msg_obj[0];
|
|
||||||
DeviceInfo di = (DeviceInfo) msg_obj[1];
|
|
||||||
UIUpdater.updateObjectInfo(frame, di);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSnmpObjectInterface(Message msg) {
|
|
||||||
Object[] msg_obj = (Object[]) msg.getMsg();
|
|
||||||
String frame = (String) msg_obj[0];
|
|
||||||
List<Interface> iface = (List<Interface>) msg_obj[1];
|
|
||||||
UIUpdater.updateObjectInterface(frame, iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSnmpTest(Message msg) {
|
|
||||||
Object[] msg_obj = (Object[]) msg.getMsg();
|
|
||||||
String frame = (String) msg_obj[0];
|
|
||||||
boolean result = (boolean) msg_obj[1];
|
|
||||||
UIUpdater.showResultSnmpTest(frame, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleSnmpConnectionInterface(Message msg) {
|
|
||||||
Object[] msg_obj = (Object[]) msg.getMsg();
|
|
||||||
String frame = (String) msg_obj[0];
|
|
||||||
List<Interface> iface = (List<Interface>) msg_obj[1];
|
|
||||||
UIUpdater.updateConnectionInterface(frame, iface);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handleConnectionNew(Message msg) {
|
|
||||||
Connection c = (Connection) msg.getMsg();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
if (map.getId() == c.getMap()) {
|
|
||||||
map.getConnection().add(c);
|
|
||||||
System.out.println("jnet.client.ClientMessageParser.handleConnectionNew()");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UIUpdater.updateMapView();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handlerTraffic(Message msg) {
|
|
||||||
Object[] o = (Object[]) msg.getMsg();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (Connection connection : map.getConnection()) {
|
|
||||||
if (connection.getId() == (int) o[0]) {
|
|
||||||
connection.setRx((long) o[1]);
|
|
||||||
connection.setTx((long) o[2]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void handlerConnectionUpdate(Message msg) {
|
|
||||||
Connection c = (Connection) msg.getMsg();
|
|
||||||
// upravi v seznamu
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
List<Connection> connections = map.getConnection();
|
|
||||||
for (int i = 0; i < connections.size(); i++) {
|
|
||||||
if (connections.get(i).getId() == c.getId()) {
|
|
||||||
connections.set(i, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// update map view
|
|
||||||
UIUpdater.updateMapView();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
package jnet.client;
|
|
||||||
|
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
|
|
||||||
public class ExtAppManager {
|
|
||||||
|
|
||||||
private String PUTTY_PATH = "app/putty.exe";
|
|
||||||
private String WINBOX_PATH = "app/winbox.exe";
|
|
||||||
|
|
||||||
private static List<Process> processes;
|
|
||||||
|
|
||||||
public ExtAppManager() {
|
|
||||||
processes = new ArrayList<>();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void runApp(List<String> commands) {
|
|
||||||
try {
|
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder(commands);
|
|
||||||
Process process = processBuilder.start();
|
|
||||||
processes.add(process);
|
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
|
||||||
LogFile.printInfo("Terminating an external application...");
|
|
||||||
process.destroy();
|
|
||||||
}));
|
|
||||||
|
|
||||||
} catch (IOException ex) {
|
|
||||||
System.out.println(ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void closeApp() {
|
|
||||||
for (Process process : processes) {
|
|
||||||
if (process.isAlive()) {
|
|
||||||
process.destroy();
|
|
||||||
LogFile.printInfo("Terminating an external application ...");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runSshPutty(String address, String username, String password, int port) {
|
|
||||||
List<String> params = new ArrayList<>();
|
|
||||||
params.add(PUTTY_PATH);
|
|
||||||
params.add("-ssh");
|
|
||||||
params.add(username + "@" + address);
|
|
||||||
if (!password.equals("")) {
|
|
||||||
params.add("-pw");
|
|
||||||
params.add(password);
|
|
||||||
}
|
|
||||||
params.add(String.valueOf(port));
|
|
||||||
runApp(params);
|
|
||||||
LogFile.printInfo("Run Putty SSH (" + address + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runTelnetPutty(String address, String username, String password, int port) {
|
|
||||||
List<String> params = new ArrayList<>();
|
|
||||||
params.add(PUTTY_PATH);
|
|
||||||
params.add("-telnet ");
|
|
||||||
params.add(username + "@" + address);
|
|
||||||
if (!password.equals("")) {
|
|
||||||
params.add("-pw");
|
|
||||||
params.add(password);
|
|
||||||
}
|
|
||||||
params.add(String.valueOf(port));
|
|
||||||
runApp(params);
|
|
||||||
LogFile.printInfo("Run Putty Telnet (" + address + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runWinbox(String address, String username, String password, int port) {
|
|
||||||
List<String> params = new ArrayList<>();
|
|
||||||
params.add(WINBOX_PATH);
|
|
||||||
params.add(address + ":" + port);
|
|
||||||
params.add(username);
|
|
||||||
params.add(password);
|
|
||||||
runApp(params);
|
|
||||||
LogFile.printInfo("Run Winbox (" + address + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runWeb(int verze, String address, String port) {
|
|
||||||
try {
|
|
||||||
Desktop desktop = Desktop.getDesktop();
|
|
||||||
URI uri;
|
|
||||||
if (verze == 0) {
|
|
||||||
uri = new URI("http://" + address + ":" + port);
|
|
||||||
} else {
|
|
||||||
uri = new URI("https://" + address + ":" + port);
|
|
||||||
}
|
|
||||||
desktop.browse(uri);
|
|
||||||
} catch (URISyntaxException ex) {
|
|
||||||
Logger.getLogger(ExtAppManager.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(ExtAppManager.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
||||||
package jnet.client;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ListIterator;
|
|
||||||
import javax.sound.sampled.AudioInputStream;
|
|
||||||
import javax.sound.sampled.AudioSystem;
|
|
||||||
import javax.sound.sampled.Clip;
|
|
||||||
import javax.sound.sampled.FloatControl;
|
|
||||||
import javax.sound.sampled.LineUnavailableException;
|
|
||||||
import javax.sound.sampled.UnsupportedAudioFileException;
|
|
||||||
import jnet.lib.Status;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
|
|
||||||
public class SoundManager {
|
|
||||||
|
|
||||||
private static int count = 0;
|
|
||||||
|
|
||||||
|
|
||||||
public static void playOnline(){
|
|
||||||
int count = 0;
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (MapObject object : map.getObjects()) {
|
|
||||||
if (object.getStatus() == Status.OFFLINE && count != 0) {
|
|
||||||
playNextOffline();
|
|
||||||
break;
|
|
||||||
} else if (object.getStatus() == Status.OFFLINE) {
|
|
||||||
count++;
|
|
||||||
playFirstOffline();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void changeStatus(int state){
|
|
||||||
if (Client.config.getBoolean("sound")) {
|
|
||||||
if (count == 0 && state == Status.OFFLINE) {
|
|
||||||
count++;
|
|
||||||
playFirstOffline();
|
|
||||||
} else if (count > 0 && state == Status.OFFLINE) {
|
|
||||||
count++;
|
|
||||||
playNextOffline();
|
|
||||||
} else if (count != 1 && state == Status.OK) {
|
|
||||||
count--;
|
|
||||||
playOneOnline();
|
|
||||||
} else if (count == 1 && state == Status.OK) {
|
|
||||||
count--;
|
|
||||||
playAllOnline();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playOneOnline(){
|
|
||||||
playSound(Client.config.getString("sound_one_online"), Client.config.getInt("volume"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playAllOnline(){
|
|
||||||
playSound(Client.config.getString("sound_all_online"), Client.config.getInt("volume"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playFirstOffline(){
|
|
||||||
playSound(Client.config.getString("sound_first_offline"), Client.config.getInt("volume"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playNextOffline(){
|
|
||||||
playSound(Client.config.getString("sound_next_offline"), Client.config.getInt("volume"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void playSound(String filePath, int volume) {
|
|
||||||
try {
|
|
||||||
File zvukovySoubor = new File(filePath);
|
|
||||||
AudioInputStream audioStream = AudioSystem.getAudioInputStream(zvukovySoubor);
|
|
||||||
|
|
||||||
// Získání zvukového klipu
|
|
||||||
Clip clip = AudioSystem.getClip();
|
|
||||||
clip.open(audioStream);
|
|
||||||
|
|
||||||
// Nastavení hlasitosti
|
|
||||||
FloatControl ovladaniHlasitosti = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
|
||||||
|
|
||||||
setVolume(ovladaniHlasitosti, volume);
|
|
||||||
|
|
||||||
// Přehrání zvuku
|
|
||||||
clip.start();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Čekání na dokončení přehrávání
|
|
||||||
Thread.sleep(clip.getMicrosecondLength() / 1000);
|
|
||||||
|
|
||||||
} catch (UnsupportedAudioFileException e) {
|
|
||||||
System.out.println("Nepodporovaný formát souboru.");
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("Chyba při načítání souboru.");
|
|
||||||
}
|
|
||||||
catch (LineUnavailableException e) {
|
|
||||||
System.out.println("Zvukové zařízení není dostupné.");
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
System.out.println("Přehrávání bylo přerušeno.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Nastavení hlasitosti.
|
|
||||||
* @param volumeControl Objekt pro ovládání hlasitosti.
|
|
||||||
* @param percent Požadovaná hlasitost v procentech (0 - 100).
|
|
||||||
*/
|
|
||||||
private static void setVolume(FloatControl volumeControl, int percent) {
|
|
||||||
float min = volumeControl.getMinimum(); // Minimální hodnota v dB
|
|
||||||
float max = volumeControl.getMaximum(); // Maximální hodnota v dB
|
|
||||||
float range = max - min;
|
|
||||||
float value = min + (range * percent / 100); // Výpočet hodnoty v dB
|
|
||||||
volumeControl.setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,149 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.gui.dialog.AddMapDialog;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import javax.swing.JTree;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
|
||||||
import javax.swing.tree.TreeSelectionModel;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.MapComparator;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
|
|
||||||
public class MapTree extends JTree {
|
|
||||||
|
|
||||||
static DefaultTreeModel model;
|
|
||||||
static DefaultMutableTreeNode root = new DefaultMutableTreeNode("Mapy");
|
|
||||||
|
|
||||||
private static JTree tree;
|
|
||||||
|
|
||||||
public MapTree() {
|
|
||||||
|
|
||||||
tree = this;
|
|
||||||
|
|
||||||
// neni videt root element
|
|
||||||
this.setRootVisible(false);
|
|
||||||
// povoli pouze jeden vybrany radek
|
|
||||||
this.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
|
||||||
|
|
||||||
model = new DefaultTreeModel(root);
|
|
||||||
this.setModel(model);
|
|
||||||
|
|
||||||
this.setCellRenderer(new MapTreeCellRenderer());
|
|
||||||
|
|
||||||
//this.setComponentPopupMenu(getPopUpMenu());
|
|
||||||
MouseListener ml = new MouseAdapter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) getLastSelectedPathComponent();
|
|
||||||
if (SwingUtilities.isRightMouseButton(e)) {
|
|
||||||
// right click
|
|
||||||
if (node != null) {
|
|
||||||
Object obj = node.getUserObject();
|
|
||||||
|
|
||||||
getContextMenuMap(e, (Map) obj);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (SwingUtilities.isLeftMouseButton(e)) {
|
|
||||||
// left click
|
|
||||||
if (!node.isRoot()) {
|
|
||||||
if (e.getClickCount() == 1) { // jednoduchy klik
|
|
||||||
|
|
||||||
} else if (e.getClickCount() == 2) { // dvojklik
|
|
||||||
Object obj = node.getUserObject();
|
|
||||||
Window.setMapView((Map) obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
addMouseListener(ml);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getContextMenuMap(MouseEvent e, Map m) {
|
|
||||||
try {
|
|
||||||
JMenuItem mapAdd = new JMenuItem("Přidat mapu", new ImageIcon(ImageIO.read(MapTree.class.getResourceAsStream("/img/add.png"))));
|
|
||||||
mapAdd.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new AddMapDialog().setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JMenuItem mapDelete = new JMenuItem("Smazat mapu", new ImageIcon(ImageIO.read(MapTree.class.getResourceAsStream("/img/trash.png"))));
|
|
||||||
mapDelete.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
int option = JOptionPane.showConfirmDialog(
|
|
||||||
null,
|
|
||||||
"Smazat mapu " + m.getName() + " a všechny její objekty ?",
|
|
||||||
"Potvrzení akce",
|
|
||||||
JOptionPane.YES_NO_OPTION
|
|
||||||
);
|
|
||||||
|
|
||||||
if (option == JOptionPane.YES_OPTION) {
|
|
||||||
NettyClient.send(Message.MAP_REMOVE, m.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JPopupMenu menu = new JPopupMenu();
|
|
||||||
if (Client.user.isAddMap()) {
|
|
||||||
menu.add(mapAdd);
|
|
||||||
}
|
|
||||||
if (Client.user.isRemoveMap()) {
|
|
||||||
menu.add(mapDelete);
|
|
||||||
}
|
|
||||||
menu.show(e.getComponent(), e.getX(), e.getY());
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("MapTree error: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void expandAllNodes(JTree tree, int startingIndex, int rowCount) {
|
|
||||||
for (int i = startingIndex; i < rowCount; ++i) {
|
|
||||||
tree.expandRow(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tree.getRowCount() != rowCount) {
|
|
||||||
expandAllNodes(tree, rowCount, tree.getRowCount());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reload() {
|
|
||||||
try {
|
|
||||||
root.removeAllChildren();
|
|
||||||
Collections.sort(Client.maps, new MapComparator());
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode(map);
|
|
||||||
root.add(node);
|
|
||||||
}
|
|
||||||
model.reload();
|
|
||||||
expandAllNodes(tree, 0, tree.getRowCount());
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogFile.printErr("Map tree error: " + e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,63 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JTree;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
|
||||||
import javax.swing.tree.DefaultTreeCellRenderer;
|
|
||||||
import jnet.lib.Status;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
|
|
||||||
public class MapTreeCellRenderer extends DefaultTreeCellRenderer {
|
|
||||||
|
|
||||||
private JLabel label;
|
|
||||||
private BufferedImage image;
|
|
||||||
|
|
||||||
public MapTreeCellRenderer() {
|
|
||||||
label = new JLabel();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
|
|
||||||
label = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
|
|
||||||
Object o = ((DefaultMutableTreeNode) value).getUserObject();
|
|
||||||
if (o instanceof Map) {
|
|
||||||
try {
|
|
||||||
Map m = (Map) o;
|
|
||||||
String imagePath = "";
|
|
||||||
switch (m.getStatus()) {
|
|
||||||
case Status.OK: // online
|
|
||||||
imagePath = "/img/flag_green.png";
|
|
||||||
break;
|
|
||||||
case Status.WARNING: // warning
|
|
||||||
imagePath = "/img/flag_orange.png";
|
|
||||||
break;
|
|
||||||
case Status.OFFLINE: // offline
|
|
||||||
imagePath = "/img/flag_red.png";
|
|
||||||
break;
|
|
||||||
default: // other
|
|
||||||
imagePath = "/img/flag_gray.png";
|
|
||||||
}
|
|
||||||
image = ImageIO.read(getClass().getResourceAsStream(imagePath));
|
|
||||||
|
|
||||||
if (image != null) {
|
|
||||||
label.setIcon(new ImageIcon(image));
|
|
||||||
}
|
|
||||||
label.setText(m.getName());
|
|
||||||
} catch (Exception ex) {
|
|
||||||
System.err.println("Error tree icon: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// EmptyBorder(int top, int left, int bottom, int right)
|
|
||||||
EmptyBorder border = new EmptyBorder(7, 25, 3, 3);
|
|
||||||
label.setBorder(border);
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
|
||||||
import jnet.client.gui.dialog.LoginDialog;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.*;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
|
|
||||||
class MenuPanel extends JPanel {
|
|
||||||
|
|
||||||
public MenuPanel() {
|
|
||||||
|
|
||||||
setPreferredSize(new Dimension(50, 50));
|
|
||||||
setLayout(new FlowLayout(FlowLayout.LEFT));
|
|
||||||
|
|
||||||
// tlacitko pripojit / odpojit
|
|
||||||
try {
|
|
||||||
BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/connect.png"));
|
|
||||||
JButton bLogin = new JButton(new ImageIcon(buttonIcon));
|
|
||||||
bLogin.setFocusPainted(false);
|
|
||||||
bLogin.setContentAreaFilled(false);
|
|
||||||
bLogin.setToolTipText("Připojit / Odpojit");
|
|
||||||
bLogin.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (NettyClient.isConnected()) {
|
|
||||||
NettyClient.disconnect();
|
|
||||||
} else {
|
|
||||||
new LoginDialog().setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(bLogin);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("File not found: image connect.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
// tlacitko nastaveni
|
|
||||||
try {
|
|
||||||
BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/settings.png"));
|
|
||||||
JButton bSettings = new JButton(new ImageIcon(buttonIcon));
|
|
||||||
bSettings.setFocusPainted(false);
|
|
||||||
bSettings.setContentAreaFilled(false);
|
|
||||||
bSettings.setToolTipText("Nastavení programu");
|
|
||||||
bSettings.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Window.showSettings();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(bSettings);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("File not found: image settings.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
// tlacitko log
|
|
||||||
try {
|
|
||||||
BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/log.png"));
|
|
||||||
JButton bLog = new JButton(new ImageIcon(buttonIcon));
|
|
||||||
bLog.setFocusPainted(false);
|
|
||||||
bLog.setContentAreaFilled(false);
|
|
||||||
bLog.setToolTipText("Log událostí");
|
|
||||||
bLog.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Window.showEvents();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(bLog);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("File not found: image log.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
// tlacitko server settings
|
|
||||||
try {
|
|
||||||
BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/server_settings.png"));
|
|
||||||
JButton bServerSettings = new JButton(new ImageIcon(buttonIcon));
|
|
||||||
bServerSettings.setFocusPainted(false);
|
|
||||||
bServerSettings.setContentAreaFilled(false);
|
|
||||||
bServerSettings.setToolTipText("Nastavení serveru");
|
|
||||||
bServerSettings.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Window.showServerSettings(ServerSettingsPanel.TAB_DEFAULT);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(bServerSettings);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("File not found: image server_settings.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,252 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.File;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSlider;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
||||||
|
|
||||||
public class SettingsPanel extends JPanel {
|
|
||||||
|
|
||||||
|
|
||||||
public SettingsPanel() {
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void show() {
|
|
||||||
this.setLayout(null);
|
|
||||||
this.setPreferredSize(new Dimension(300, 800));
|
|
||||||
|
|
||||||
JLabel nadpisLabel = new JLabel("Obecné nastavení");
|
|
||||||
nadpisLabel.setBounds(20, 20, 400, 25);
|
|
||||||
nadpisLabel.setFont(nadpisLabel.getFont().deriveFont(20f));
|
|
||||||
this.add(nadpisLabel);
|
|
||||||
|
|
||||||
JCheckBox runMinimalized = new JCheckBox("Spouštět minimalizovaně");
|
|
||||||
runMinimalized.setBounds(30, getNextY(nadpisLabel) + 20, 400, 25);
|
|
||||||
runMinimalized.setSelected(Client.config.getBoolean("start_minimalized"));
|
|
||||||
this.add(runMinimalized);
|
|
||||||
|
|
||||||
JCheckBox enableDebug = new JCheckBox("Debug režim");
|
|
||||||
enableDebug.setBounds(30, getNextY(runMinimalized), 400, 25);
|
|
||||||
enableDebug.setSelected(Client.config.getBoolean("debug"));
|
|
||||||
this.add(enableDebug);
|
|
||||||
|
|
||||||
JLabel nadpisSoundLabel = new JLabel("Zvuky");
|
|
||||||
nadpisSoundLabel.setBounds(20, getNextY(enableDebug) + 20, 400, 25);
|
|
||||||
nadpisSoundLabel.setFont(nadpisLabel.getFont().deriveFont(20f));
|
|
||||||
this.add(nadpisSoundLabel);
|
|
||||||
|
|
||||||
JCheckBox enableSounds = new JCheckBox("Povolit zvuky");
|
|
||||||
enableSounds.setBounds(30, getNextY(nadpisSoundLabel), 400, 25);
|
|
||||||
enableSounds.setSelected(Client.config.getBoolean("sound"));
|
|
||||||
this.add(enableSounds);
|
|
||||||
|
|
||||||
// slider nastaveni hlasitosti
|
|
||||||
JLabel hlasLabel = new JLabel("Hlasitost");
|
|
||||||
hlasLabel.setBounds(30, getNextY(enableSounds), 80, 25);
|
|
||||||
this.add(hlasLabel);
|
|
||||||
|
|
||||||
JSlider volumeSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 50);
|
|
||||||
volumeSlider.setBounds(110, getNextY(enableSounds), 200, 50);
|
|
||||||
volumeSlider.setValue(Client.config.getInt("volume"));
|
|
||||||
volumeSlider.setPaintTrack(true);
|
|
||||||
volumeSlider.setPaintTicks(true);
|
|
||||||
volumeSlider.setPaintLabels(true);
|
|
||||||
volumeSlider.setMajorTickSpacing(50);
|
|
||||||
|
|
||||||
JLabel sliderValue = new JLabel(volumeSlider.getValue() + " %");
|
|
||||||
sliderValue.setBounds(350, getNextY(enableSounds), 50, 25);
|
|
||||||
this.add(sliderValue);
|
|
||||||
|
|
||||||
volumeSlider.addChangeListener(new ChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
sliderValue.setText(volumeSlider.getValue() + " %");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.add(volumeSlider);
|
|
||||||
|
|
||||||
// vyber souboru vse online
|
|
||||||
JLabel fileAllOkLabel = new JLabel("Zvuk vše online:");
|
|
||||||
fileAllOkLabel.setBounds(30, getNextY(volumeSlider), 150, 25);
|
|
||||||
this.add(fileAllOkLabel);
|
|
||||||
|
|
||||||
JTextField filePathFieldAllOk = new JTextField(25);
|
|
||||||
filePathFieldAllOk.setEditable(false);
|
|
||||||
filePathFieldAllOk.setBounds(200, getNextY(volumeSlider), 200, 25);
|
|
||||||
filePathFieldAllOk.setText(Client.config.getString("sound_all_online"));
|
|
||||||
this.add(filePathFieldAllOk);
|
|
||||||
|
|
||||||
JButton selectFileButtonAllOk = new JButton("Vyber soubor");
|
|
||||||
selectFileButtonAllOk.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// Vytvoření JFileChooser
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
|
|
||||||
// Nastavení filtru souborů (volitelné)
|
|
||||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Zvukove soubory WAV", "wav");
|
|
||||||
fileChooser.setFileFilter(filter);
|
|
||||||
|
|
||||||
// Zobrazení dialogu pro výběr souboru
|
|
||||||
int result = fileChooser.showOpenDialog(null);
|
|
||||||
|
|
||||||
// Zpracování výsledku
|
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File selectedFile = fileChooser.getSelectedFile();
|
|
||||||
filePathFieldAllOk.setText(selectedFile.getAbsolutePath());
|
|
||||||
} else {
|
|
||||||
filePathFieldAllOk.setText(Client.config.getString("sound_all_online"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selectFileButtonAllOk.setBounds(420, getNextY(volumeSlider), 80, 25);
|
|
||||||
this.add(selectFileButtonAllOk);
|
|
||||||
|
|
||||||
// vyber souboru jeden online
|
|
||||||
JLabel fileOneOkLabel = new JLabel("Zvuk jeden online:");
|
|
||||||
fileOneOkLabel.setBounds(30, getNextY(filePathFieldAllOk), 150, 25);
|
|
||||||
this.add(fileOneOkLabel);
|
|
||||||
|
|
||||||
JTextField filePathFieldOneOk = new JTextField(25);
|
|
||||||
filePathFieldOneOk.setEditable(false);
|
|
||||||
filePathFieldOneOk.setText(Client.config.getString("sound_one_online"));
|
|
||||||
filePathFieldOneOk.setBounds(200, getNextY(filePathFieldAllOk), 200, 25);
|
|
||||||
this.add(filePathFieldOneOk);
|
|
||||||
|
|
||||||
JButton selectFileButtonOneOk = new JButton("Vyber soubor");
|
|
||||||
selectFileButtonOneOk.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// Vytvoření JFileChooser
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
|
|
||||||
// Nastavení filtru souborů (volitelné)
|
|
||||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Zvukove soubory WAV", "wav");
|
|
||||||
fileChooser.setFileFilter(filter);
|
|
||||||
|
|
||||||
// Zobrazení dialogu pro výběr souboru
|
|
||||||
int result = fileChooser.showOpenDialog(null);
|
|
||||||
|
|
||||||
// Zpracování výsledku
|
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File selectedFile = fileChooser.getSelectedFile();
|
|
||||||
filePathFieldOneOk.setText(selectedFile.getAbsolutePath());
|
|
||||||
} else {
|
|
||||||
filePathFieldOneOk.setText(Client.config.getString("sound_one_online"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selectFileButtonOneOk.setBounds(420, getNextY(filePathFieldAllOk), 80, 25);
|
|
||||||
this.add(selectFileButtonOneOk);
|
|
||||||
|
|
||||||
// vyber souboru první offline
|
|
||||||
JLabel fileFirstKoLabel = new JLabel("Zvuk první offline:");
|
|
||||||
fileFirstKoLabel.setBounds(30, getNextY(filePathFieldOneOk), 150, 25);
|
|
||||||
this.add(fileFirstKoLabel);
|
|
||||||
|
|
||||||
JTextField filePathFieldFirstKo = new JTextField(25);
|
|
||||||
filePathFieldFirstKo.setEditable(false);
|
|
||||||
filePathFieldFirstKo.setText(Client.config.getString("sound_first_offline"));
|
|
||||||
filePathFieldFirstKo.setBounds(200, getNextY(filePathFieldOneOk), 200, 25);
|
|
||||||
this.add(filePathFieldFirstKo);
|
|
||||||
|
|
||||||
JButton selectFileButtonFirstKo = new JButton("Vyber soubor");
|
|
||||||
selectFileButtonFirstKo.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// Vytvoření JFileChooser
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
|
|
||||||
// Nastavení filtru souborů (volitelné)
|
|
||||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Zvukove soubory WAV", "wav");
|
|
||||||
fileChooser.setFileFilter(filter);
|
|
||||||
|
|
||||||
// Zobrazení dialogu pro výběr souboru
|
|
||||||
int result = fileChooser.showOpenDialog(null);
|
|
||||||
|
|
||||||
// Zpracování výsledku
|
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File selectedFile = fileChooser.getSelectedFile();
|
|
||||||
filePathFieldFirstKo.setText(selectedFile.getAbsolutePath());
|
|
||||||
} else {
|
|
||||||
filePathFieldFirstKo.setText(Client.config.getString("sound_first_offline"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selectFileButtonFirstKo.setBounds(420, getNextY(filePathFieldOneOk), 80, 25);
|
|
||||||
this.add(selectFileButtonFirstKo);
|
|
||||||
|
|
||||||
// vyber souboru dalsi offline
|
|
||||||
JLabel filefirstNextLabel = new JLabel("Zvuk další offline:");
|
|
||||||
filefirstNextLabel.setBounds(30, getNextY(filePathFieldFirstKo), 150, 25);
|
|
||||||
this.add(filefirstNextLabel);
|
|
||||||
|
|
||||||
JTextField filePathFieldNextKo = new JTextField(25);
|
|
||||||
filePathFieldNextKo.setEditable(false);
|
|
||||||
filePathFieldNextKo.setText(Client.config.getString("sound_next_offline"));
|
|
||||||
filePathFieldNextKo.setBounds(200, getNextY(filePathFieldFirstKo), 200, 25);
|
|
||||||
this.add(filePathFieldNextKo);
|
|
||||||
|
|
||||||
JButton selectFileButtonNextKo = new JButton("Vyber soubor");
|
|
||||||
selectFileButtonNextKo.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// Vytvoření JFileChooser
|
|
||||||
JFileChooser fileChooser = new JFileChooser();
|
|
||||||
|
|
||||||
// Nastavení filtru souborů (volitelné)
|
|
||||||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Zvukove soubory WAV", "wav");
|
|
||||||
fileChooser.setFileFilter(filter);
|
|
||||||
|
|
||||||
// Zobrazení dialogu pro výběr souboru
|
|
||||||
int result = fileChooser.showOpenDialog(null);
|
|
||||||
|
|
||||||
// Zpracování výsledku
|
|
||||||
if (result == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File selectedFile = fileChooser.getSelectedFile();
|
|
||||||
filePathFieldNextKo.setText(selectedFile.getAbsolutePath());
|
|
||||||
} else {
|
|
||||||
filePathFieldNextKo.setText(Client.config.getString("sound_next_offline"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
selectFileButtonNextKo.setBounds(420, getNextY(filePathFieldFirstKo), 80, 25);
|
|
||||||
this.add(selectFileButtonNextKo);
|
|
||||||
|
|
||||||
// tlacitko uložit
|
|
||||||
JButton b = new JButton("Uložit");
|
|
||||||
b.setBounds(20, getNextY(filePathFieldNextKo)+50, 100, 30);
|
|
||||||
b.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
|
|
||||||
Client.config.setBoolean("debuger", enableDebug.isSelected());
|
|
||||||
Client.config.setBoolean("start_minimalized", runMinimalized.isSelected());
|
|
||||||
Client.config.setBoolean("sound", enableSounds.isSelected());
|
|
||||||
Client.config.setInt("volume", volumeSlider.getValue());
|
|
||||||
Client.config.save();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.add(b);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getNextY(Component p) {
|
|
||||||
return p.getY() + p.getHeight() + 30;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,67 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import jnet.client.gui.dialog.OnlineClientsDialog;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
|
|
||||||
public class StatusBar extends JPanel {
|
|
||||||
|
|
||||||
private JLabel message;
|
|
||||||
private JLabel online;
|
|
||||||
private JButton btnOnline;
|
|
||||||
|
|
||||||
public StatusBar() {
|
|
||||||
super();
|
|
||||||
super.setPreferredSize(new Dimension(100, 35));
|
|
||||||
|
|
||||||
setLayout(null);
|
|
||||||
|
|
||||||
online = new JLabel("Odpojeno");
|
|
||||||
online.setBounds(10, 0, 100, 30);
|
|
||||||
add(online);
|
|
||||||
|
|
||||||
message = new JLabel("");
|
|
||||||
message.setBounds(250, 0, 100, 30);
|
|
||||||
add(message);
|
|
||||||
|
|
||||||
// tlacitko zobrazujici klienty
|
|
||||||
try {
|
|
||||||
BufferedImage buttonIcon = ImageIO.read(getClass().getResourceAsStream("/img/online_clients.png"));
|
|
||||||
btnOnline = new JButton(new ImageIcon(buttonIcon));
|
|
||||||
btnOnline.setFocusPainted(false);
|
|
||||||
btnOnline.setContentAreaFilled(false);
|
|
||||||
btnOnline.setBorderPainted(false);
|
|
||||||
btnOnline.setToolTipText("Online uživatelé");
|
|
||||||
btnOnline.addActionListener(new ActionListener(){
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
// TODO jeli offlice vypnout tlačítko
|
|
||||||
new OnlineClientsDialog();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
btnOnline.setBounds(200, 0, 32, 32);
|
|
||||||
add(btnOnline);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("File not found: image online_clinets.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String text) {
|
|
||||||
message.setText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setConectionStatus(String state){
|
|
||||||
online.setText(state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,83 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import jnet.client.gui.mapview.MapView;
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.Window;
|
|
||||||
import java.util.List;
|
|
||||||
import jnet.client.gui.dialog.ConnectionDialog;
|
|
||||||
import jnet.client.gui.dialog.object.ObjectDialog;
|
|
||||||
import jnet.lib.snmp.DeviceInfo;
|
|
||||||
import jnet.lib.snmp.Interface;
|
|
||||||
|
|
||||||
public class UIUpdater {
|
|
||||||
|
|
||||||
public static void updateMapUI() {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
MapTree.reload();
|
|
||||||
Tray.refresh();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateMapTree() {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
MapTree.reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateTray() {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
Tray.refresh();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateMapView() {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
MapView.updateMapView();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateObjectInfo(String frameName, DeviceInfo di) {
|
|
||||||
for (Window w : JFrame.getWindows()) {
|
|
||||||
if (w instanceof JFrame && frameName.equals(w.getName())) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
((ObjectDialog) w).setDeviceInfo(di);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateObjectInterface(String frameName, List<Interface> iface) {
|
|
||||||
for (Window w : JFrame.getWindows()) {
|
|
||||||
if (w instanceof JFrame && frameName.equals(w.getName())) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
((ObjectDialog) w).setDeviceInterface(iface);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showResultSnmpTest(String frameName, boolean result) {
|
|
||||||
for (Window w : JFrame.getWindows()) {
|
|
||||||
if (w instanceof JFrame && frameName.equals(w.getName())) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
((ObjectDialog) w).showResultSnmpTest(result);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateConnectionInterface(String frameName, List<Interface> iface) {
|
|
||||||
for (Window w : JFrame.getWindows()) {
|
|
||||||
if (w instanceof JFrame && frameName.equals(w.getName())) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
((ConnectionDialog) w).updateInterface(iface);
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
||||||
package jnet.client.gui;
|
|
||||||
|
|
||||||
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
|
||||||
import jnet.client.gui.mapview.MapView;
|
|
||||||
import jnet.client.Client;
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollBar;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JSplitPane;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
|
|
||||||
public class Window extends JFrame {
|
|
||||||
|
|
||||||
public static int currentMapIndex;
|
|
||||||
|
|
||||||
private static StatusBar statusBar;
|
|
||||||
private static JSplitPane jsp;
|
|
||||||
private static JTabbedPane serverSettings;
|
|
||||||
|
|
||||||
public Window() {
|
|
||||||
super(Client.APP_NAME); //titulek okna
|
|
||||||
|
|
||||||
//identifikator okna
|
|
||||||
this.setName("mainWindow");
|
|
||||||
|
|
||||||
Dimension d = new Dimension(1024, 800);
|
|
||||||
this.setPreferredSize(d);
|
|
||||||
this.setSize(d);
|
|
||||||
this.setLocationRelativeTo(null);
|
|
||||||
|
|
||||||
try {
|
|
||||||
this.setIconImage(ImageIO.read(getClass().getResourceAsStream("/img/app.png")));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("APP icon exception");
|
|
||||||
}
|
|
||||||
this.addWindowListener(new WindowAdapter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosing(WindowEvent windowEvent) {
|
|
||||||
// vola se pri zavreni okna krizkem
|
|
||||||
Object[] options = {
|
|
||||||
"Ukončit",
|
|
||||||
"Minimalizovat"
|
|
||||||
};
|
|
||||||
int n = JOptionPane.showOptionDialog(windowEvent.getWindow(),
|
|
||||||
"Ukončit nebo minimalozovat do lišty ?",
|
|
||||||
"Ukončit",
|
|
||||||
JOptionPane.YES_NO_OPTION,
|
|
||||||
JOptionPane.QUESTION_MESSAGE,
|
|
||||||
null, //do not use a custom Icon
|
|
||||||
options, //the titles of buttons
|
|
||||||
options[1]); //default button title
|
|
||||||
if (n == 0) {
|
|
||||||
LogFile.printInfo("Ukoncit");
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowDeiconified(WindowEvent e) {
|
|
||||||
// vola se pri obnoveni z listy
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowIconified(WindowEvent e) {
|
|
||||||
// pri minimalizaci
|
|
||||||
setVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
this.setLayout(new BorderLayout());
|
|
||||||
|
|
||||||
this.add(new MenuPanel(), BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// oddelovac leve a prave strany
|
|
||||||
jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
|
||||||
jsp.setDividerSize(5);
|
|
||||||
|
|
||||||
// levy panel
|
|
||||||
JPanel leftPanel = new JPanel();
|
|
||||||
leftPanel.setBackground(Color.WHITE);
|
|
||||||
leftPanel.setPreferredSize(new Dimension(200, 250));
|
|
||||||
leftPanel.setLayout(new BorderLayout());
|
|
||||||
leftPanel.add(new MapTree(), BorderLayout.PAGE_START);
|
|
||||||
//leftPanel.add(new MapList(), BorderLayout.PAGE_START);
|
|
||||||
jsp.add(leftPanel, JSplitPane.LEFT);
|
|
||||||
jsp.add(new JPanel(), JSplitPane.RIGHT);
|
|
||||||
|
|
||||||
this.add(jsp, BorderLayout.CENTER);
|
|
||||||
|
|
||||||
statusBar = new StatusBar();
|
|
||||||
this.add(statusBar, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
this.pack();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void blinkTaskBar() {
|
|
||||||
toFront();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setStatusBarMessage(String message) {
|
|
||||||
statusBar.setMessage(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setConectionStatus(String state) {
|
|
||||||
statusBar.setConectionStatus(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepnuti na stranku nastaveni
|
|
||||||
public static void showSettings() {
|
|
||||||
SettingsPanel set = new SettingsPanel();
|
|
||||||
JScrollPane scroll = new JScrollPane(set);
|
|
||||||
JScrollBar verticalBar = scroll.getVerticalScrollBar();
|
|
||||||
verticalBar.setUnitIncrement(20);
|
|
||||||
jsp.add(scroll, JSplitPane.RIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// prepnuti mapy
|
|
||||||
public static void setMapView(Map map) {
|
|
||||||
MapView mv = new MapView(map);
|
|
||||||
JScrollPane scroll = new JScrollPane(mv);
|
|
||||||
jsp.add(scroll, JSplitPane.RIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showServerSettings(int table) {
|
|
||||||
ServerSettingsPanel mv = new ServerSettingsPanel();
|
|
||||||
mv.setTable(table);
|
|
||||||
JScrollPane scroll = new JScrollPane(mv);
|
|
||||||
jsp.add(scroll, JSplitPane.RIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showEvents() {
|
|
||||||
EventsPanel ep = new EventsPanel();
|
|
||||||
jsp.add(ep, JSplitPane.RIGHT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// public static void showMessage(String text){
|
|
||||||
// // TODO co s tim ? nechat nebo vytvořit dialog ?
|
|
||||||
// //new ServerMessageDialog(text);
|
|
||||||
// JOptionPane.showMessageDialog(null, text);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
@ -1,144 +0,0 @@
|
||||||
package jnet.client.gui.dialog;
|
|
||||||
|
|
||||||
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
|
||||||
import jnet.client.gui.Window;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.util.Base64;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JFileChooser;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
import jnet.lib.object.ObjectType;
|
|
||||||
|
|
||||||
public class AddDeviceTypeDialog extends JDialog {
|
|
||||||
|
|
||||||
private JLabel info = new JLabel("PNG obrázek o šířce 32px");
|
|
||||||
private JTextField nazevText = new JTextField();
|
|
||||||
private String img_str = "";
|
|
||||||
|
|
||||||
public AddDeviceTypeDialog() {
|
|
||||||
|
|
||||||
setTitle("Přidat typ zařízení");
|
|
||||||
setSize(300, 180);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setAlwaysOnTop(false);
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
add(panel);
|
|
||||||
placeComponents(panel);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void placeComponents(JPanel panel) {
|
|
||||||
|
|
||||||
panel.setLayout(null);
|
|
||||||
|
|
||||||
JLabel serverLabel = new JLabel("Název:");
|
|
||||||
serverLabel.setBounds(20, 10, 80, 25);
|
|
||||||
panel.add(serverLabel);
|
|
||||||
|
|
||||||
nazevText.setBounds(110, 10, 160, 25);
|
|
||||||
panel.add(nazevText);
|
|
||||||
|
|
||||||
JLabel portLabel = new JLabel("Obrázek");
|
|
||||||
portLabel.setBounds(20, 40, 80, 25);
|
|
||||||
panel.add(portLabel);
|
|
||||||
|
|
||||||
JButton btnBrowse = new JButton("Browse");
|
|
||||||
btnBrowse.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
browseButtonActionPerformed(e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
btnBrowse.setBounds(110, 40, 160, 25);
|
|
||||||
panel.add(btnBrowse);
|
|
||||||
|
|
||||||
info.setBounds(20, 70, 200, 25);
|
|
||||||
panel.add(info);
|
|
||||||
|
|
||||||
JButton addButton = new JButton("Přidat");
|
|
||||||
addButton.setBounds(20, 100, 90, 25);
|
|
||||||
addButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (nazevText.getText().length() > 3) {
|
|
||||||
ObjectType ot = new ObjectType(nazevText.getText(), img_str);
|
|
||||||
NettyClient.send(Message.NEW_OBJECT_TYPE, ot);
|
|
||||||
// refresh tabulky
|
|
||||||
//TODO
|
|
||||||
Window.showServerSettings(ServerSettingsPanel.TAB_DEVICE_TYPE);
|
|
||||||
// zavreni dialogu
|
|
||||||
dispose();
|
|
||||||
} else {
|
|
||||||
info.setForeground(Color.RED);
|
|
||||||
info.setText("Název je moc krátký");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(addButton);
|
|
||||||
|
|
||||||
JButton closeButton = new JButton("Storno");
|
|
||||||
closeButton.setBounds(185, 100, 80, 25);
|
|
||||||
closeButton.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(closeButton);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void browseButtonActionPerformed(ActionEvent evt) {
|
|
||||||
JFileChooser fc = new JFileChooser(".");
|
|
||||||
fc.addChoosableFileFilter(new FileNameExtensionFilter("Image Files PNG", "png"));
|
|
||||||
|
|
||||||
int res = fc.showOpenDialog(null);
|
|
||||||
try {
|
|
||||||
if (res == JFileChooser.APPROVE_OPTION) {
|
|
||||||
File file = fc.getSelectedFile();
|
|
||||||
String ext = "png";
|
|
||||||
// TODO doresit overeni správného typu souboru
|
|
||||||
//String ext = FilenameUtils.getExtension("C:\\Users\\Michal\\Documents\\NetBeansProjects\\jGuardClient\\img\\app.png"); // returns "exe"
|
|
||||||
if (ext.equals("png")) {
|
|
||||||
Image image = ImageIO.read(file);
|
|
||||||
BufferedImage bimg = ImageIO.read(file);
|
|
||||||
if (bimg.getWidth() == 32) {
|
|
||||||
info.setText("");
|
|
||||||
img_str = encodeFileToBase64Binary(file);
|
|
||||||
} else {
|
|
||||||
info.setForeground(Color.RED);
|
|
||||||
info.setText("Chybný rozměr obrázku");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
info.setForeground(Color.RED);
|
|
||||||
info.setText("Chybný formát obrázku");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
LogFile.printErr("File choose exception: " + e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String encodeFileToBase64Binary(File file) throws Exception {
|
|
||||||
FileInputStream fileInputStreamReader = new FileInputStream(file);
|
|
||||||
byte[] bytes = new byte[(int) file.length()];
|
|
||||||
fileInputStreamReader.read(bytes);
|
|
||||||
return new String(Base64.getEncoder().encode(bytes), "UTF-8");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,73 +0,0 @@
|
||||||
package jnet.client.gui.dialog;
|
|
||||||
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
|
|
||||||
|
|
||||||
public class AddMapDialog extends JDialog {
|
|
||||||
|
|
||||||
public AddMapDialog() {
|
|
||||||
|
|
||||||
setTitle("Přidat mapu");
|
|
||||||
setSize(320,180);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setAlwaysOnTop(true);
|
|
||||||
setResizable(false);
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
add(panel);
|
|
||||||
placeComponents(panel);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setVisible(boolean b) {
|
|
||||||
super.setVisible(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel placeComponents(JPanel panel) {
|
|
||||||
|
|
||||||
panel.setLayout(null);
|
|
||||||
|
|
||||||
JLabel serverLabel = new JLabel("Název");
|
|
||||||
serverLabel.setBounds(20, 20, 80, 25);
|
|
||||||
panel.add(serverLabel);
|
|
||||||
|
|
||||||
JTextField nameText = new JTextField();
|
|
||||||
nameText.setBounds(110, 20, 160, 25);
|
|
||||||
panel.add(nameText);
|
|
||||||
|
|
||||||
JLabel error = new JLabel("");
|
|
||||||
error.setBounds(110, 45, 160, 25);
|
|
||||||
error.setForeground(Color.red);
|
|
||||||
panel.add(error);
|
|
||||||
|
|
||||||
JButton button = new JButton("Přidat");
|
|
||||||
button.setBounds(120, 80, 80, 25);
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (!nameText.getText().equals("")) {
|
|
||||||
NettyClient.send(Message.MAP_ADD, nameText.getText());
|
|
||||||
dispose();
|
|
||||||
} else {
|
|
||||||
error.setText("Název nesmí být prázdný");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(button);
|
|
||||||
|
|
||||||
return panel;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,128 +0,0 @@
|
||||||
package jnet.client.gui.dialog;
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTextArea;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
|
|
||||||
public class DialogLocalPing extends Thread {
|
|
||||||
|
|
||||||
public DialogLocalPing(String ip) {
|
|
||||||
|
|
||||||
// Spuštění vlákna pro ping
|
|
||||||
new Thread(() -> runPing(ip)).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void runPing(String host) {
|
|
||||||
int countOk = 0;
|
|
||||||
int countKo = 0;
|
|
||||||
ArrayList<Double> times = new ArrayList<>();
|
|
||||||
|
|
||||||
Border margin = BorderFactory.createEmptyBorder(20, 20, 20, 20); // 10px nahoře a dole, 20px vlevo a vpravo
|
|
||||||
|
|
||||||
JFrame frame = new JFrame("Ping " + host);
|
|
||||||
|
|
||||||
// Vytvoření hlavního okna
|
|
||||||
frame.setSize(450, 400);
|
|
||||||
frame.setResizable(false);
|
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
// Hlavní panel
|
|
||||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
|
||||||
|
|
||||||
// Textová oblast pro logy
|
|
||||||
JTextArea logTextArea = new JTextArea();
|
|
||||||
logTextArea.setEditable(false); // Zamezení úprav uživatelem
|
|
||||||
logTextArea.setFont(new Font("Monospaced", Font.PLAIN, 12)); // Monospace font pro logy
|
|
||||||
logTextArea.setBorder(margin);
|
|
||||||
// Posuvník pro textovou oblast
|
|
||||||
JScrollPane scrollPane = new JScrollPane(logTextArea);
|
|
||||||
//scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
|
||||||
|
|
||||||
// panel statistik
|
|
||||||
JLabel stat = new JLabel("test");
|
|
||||||
stat.setBorder(margin);
|
|
||||||
|
|
||||||
mainPanel.add(scrollPane, BorderLayout.CENTER); // TextArea uprostřed
|
|
||||||
mainPanel.add(stat, BorderLayout.SOUTH); // JLabel na spodek
|
|
||||||
|
|
||||||
// Přidání hlavního panelu do okna
|
|
||||||
frame.add(mainPanel);
|
|
||||||
|
|
||||||
// Zobrazení okna
|
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Použití správného příkazu pro OS
|
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
|
||||||
String command = os.contains("win") ? "ping -t " + host : "ping " + host;
|
|
||||||
|
|
||||||
Process process = Runtime.getRuntime().exec(command);
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
|
||||||
|
|
||||||
String firstLine = reader.readLine(); // Tento řádek bude přeskočen
|
|
||||||
String secondLine = reader.readLine(); // Tento řádek bude přeskočen
|
|
||||||
|
|
||||||
Pattern pattern1 = Pattern.compile("time=([0-9.]+)ms");
|
|
||||||
Pattern pattern2 = Pattern.compile("time[<]?([0-9.]+)ms");
|
|
||||||
|
|
||||||
String line;
|
|
||||||
while ((line = reader.readLine()) != null) {
|
|
||||||
|
|
||||||
Matcher matcher1 = pattern1.matcher(line);
|
|
||||||
Matcher matcher2 = pattern2.matcher(line);
|
|
||||||
if (matcher1.find()) {
|
|
||||||
// čas 1ms a vice
|
|
||||||
double time = Double.valueOf(matcher1.group(1));
|
|
||||||
countOk++;
|
|
||||||
times.add(time);
|
|
||||||
appendText(logTextArea, "Odpověď od " + host + " za " + time + " ms");
|
|
||||||
} else if (matcher2.find()) {
|
|
||||||
// cas mene nez 1 ms
|
|
||||||
double time = 0;
|
|
||||||
countOk++;
|
|
||||||
times.add(time);
|
|
||||||
appendText(logTextArea, "Odpověď od " + host + " za " + time + " ms");
|
|
||||||
} else {
|
|
||||||
countKo++;
|
|
||||||
appendText(logTextArea, line);
|
|
||||||
}
|
|
||||||
// aktualizace statistik
|
|
||||||
stat.setText("Odesláno: " + (countOk + countKo) + " "
|
|
||||||
+ "úspěšně: " + countOk + " "
|
|
||||||
+ "neuspěšně: " + countKo + " "
|
|
||||||
+ "průmerny čas: " + calculateAverage(times) + " ms");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
appendText(logTextArea, "Chyba při provádění pingu: " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void appendText(JTextArea logTextArea, String text) {
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
|
||||||
logTextArea.append(text + "\n");
|
|
||||||
logTextArea.setCaretPosition(logTextArea.getDocument().getLength()); // Auto-scroll dolů
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double calculateAverage(ArrayList<Double> list) {
|
|
||||||
double sum = 0;
|
|
||||||
// Sečítání všech hodnot v ArrayListu
|
|
||||||
for (double value : list) {
|
|
||||||
sum += value;
|
|
||||||
}
|
|
||||||
// Vypočítání průměru
|
|
||||||
return Math.round(sum / list.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
package jnet.client.gui.dialog;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JPasswordField;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
|
|
||||||
public class LoginDialog extends JDialog {
|
|
||||||
|
|
||||||
public LoginDialog() {
|
|
||||||
|
|
||||||
setTitle("Přihlásit");
|
|
||||||
setSize(300, 250);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setResizable(false);
|
|
||||||
setAlwaysOnTop(true);
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
add(panel);
|
|
||||||
placeComponents(panel);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setVisible(boolean b) {
|
|
||||||
super.setVisible(b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void placeComponents(JPanel panel) {
|
|
||||||
|
|
||||||
panel.setLayout(null);
|
|
||||||
|
|
||||||
JLabel serverLabel = new JLabel("Server");
|
|
||||||
serverLabel.setBounds(20, 10, 80, 25);
|
|
||||||
panel.add(serverLabel);
|
|
||||||
|
|
||||||
JTextField serverText = new JTextField(Client.config.getString("server"));
|
|
||||||
serverText.setBounds(110, 10, 160, 25);
|
|
||||||
panel.add(serverText);
|
|
||||||
|
|
||||||
JLabel portLabel = new JLabel("Port");
|
|
||||||
portLabel.setBounds(20, 40, 80, 25);
|
|
||||||
panel.add(portLabel);
|
|
||||||
|
|
||||||
JTextField portText = new JTextField(Client.config.getString("port"));
|
|
||||||
portText.setBounds(110, 40, 160, 25);
|
|
||||||
panel.add(portText);
|
|
||||||
|
|
||||||
JLabel userLabel = new JLabel("Uživatel");
|
|
||||||
userLabel.setBounds(20, 70, 80, 25);
|
|
||||||
panel.add(userLabel);
|
|
||||||
|
|
||||||
JTextField userText = new JTextField(Client.config.getString("user"));
|
|
||||||
userText.setBounds(110, 70, 160, 25);
|
|
||||||
panel.add(userText);
|
|
||||||
|
|
||||||
JLabel passwordLabel = new JLabel("Heslo");
|
|
||||||
passwordLabel.setBounds(20, 100, 80, 25);
|
|
||||||
panel.add(passwordLabel);
|
|
||||||
|
|
||||||
JPasswordField passwordText = new JPasswordField(Client.config.getString("password"));
|
|
||||||
passwordText.setBounds(110, 100, 160, 25);
|
|
||||||
panel.add(passwordText);
|
|
||||||
|
|
||||||
JButton loginButton = new JButton("Přihlásit");
|
|
||||||
loginButton.setBounds(20, 155, 90, 25);
|
|
||||||
loginButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
|
|
||||||
// ulozeni prihlasovacich udaju
|
|
||||||
Client.config.setString("server", serverText.getText());
|
|
||||||
Client.config.setString("port", new String(portText.getText()));
|
|
||||||
Client.config.setString("user", userText.getText());
|
|
||||||
Client.config.setString("password", new String(passwordText.getPassword()));
|
|
||||||
Client.config.save();
|
|
||||||
|
|
||||||
// pripojeni klienta
|
|
||||||
NettyClient client = new NettyClient(serverText.getText(), Integer.valueOf(portText.getText()));
|
|
||||||
Client.clientThread = new Thread(client);
|
|
||||||
Client.clientThread.start();
|
|
||||||
// zavreni dialogu
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(loginButton);
|
|
||||||
|
|
||||||
JButton closeButton = new JButton("Storno");
|
|
||||||
closeButton.setBounds(185, 155, 80, 25);
|
|
||||||
closeButton.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
dispose();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(closeButton);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,157 +0,0 @@
|
||||||
package jnet.client.gui.dialog;
|
|
||||||
|
|
||||||
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
|
||||||
import jnet.client.gui.Window;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.Random;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
import jnet.lib.object.User;
|
|
||||||
|
|
||||||
public class UserDialog extends JDialog {
|
|
||||||
|
|
||||||
JTextField userName = new JTextField();
|
|
||||||
JLabel userNameLabel = new JLabel("Uživatelské jméno");
|
|
||||||
JTextField password = new JTextField();
|
|
||||||
JLabel passwordLabel = new JLabel("Heslo");
|
|
||||||
JCheckBox setServer = new JCheckBox("Nastavit server");
|
|
||||||
JCheckBox addMap = new JCheckBox("Přidat mapu");
|
|
||||||
JCheckBox deleteMap = new JCheckBox("Odebrat mapu");
|
|
||||||
JCheckBox editMap = new JCheckBox("Upravit mapu");
|
|
||||||
JCheckBox addObjekt = new JCheckBox("Přidat objekt");
|
|
||||||
JCheckBox deleteObjekt = new JCheckBox("Odebrat objekt");
|
|
||||||
JCheckBox editObjekt = new JCheckBox("Upravit objekt");
|
|
||||||
|
|
||||||
User user;
|
|
||||||
|
|
||||||
public UserDialog(User user) {
|
|
||||||
|
|
||||||
this.user = user;
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
setTitle("Přidat uživatele");
|
|
||||||
} else {
|
|
||||||
setTitle("Upravit uživatele");
|
|
||||||
}
|
|
||||||
|
|
||||||
setSize(400, 600);
|
|
||||||
setLocationRelativeTo(null);
|
|
||||||
setAlwaysOnTop(false);
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
add(panel);
|
|
||||||
placeComponents(panel);
|
|
||||||
|
|
||||||
if (user != null) {
|
|
||||||
userName.setText(user.getUsername());
|
|
||||||
setServer.setSelected(user.isEditServer());
|
|
||||||
addMap.setSelected(user.isAddMap());
|
|
||||||
deleteMap.setSelected(user.isRemoveMap());
|
|
||||||
editMap.setSelected(user.isEditMap());
|
|
||||||
addObjekt.setSelected(user.isAddObject());
|
|
||||||
deleteObjekt.setSelected(user.isRemoveObject());
|
|
||||||
editObjekt.setSelected(user.isEditObject());
|
|
||||||
} else {
|
|
||||||
password.setText(generateRandomString(8));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void placeComponents(JPanel panel) {
|
|
||||||
panel.setLayout(null);
|
|
||||||
|
|
||||||
userName.setBounds(20, 10, 180, 25);
|
|
||||||
panel.add(userName);
|
|
||||||
|
|
||||||
userNameLabel.setBounds(210, 10, 160, 25);
|
|
||||||
panel.add(userNameLabel);
|
|
||||||
|
|
||||||
password.setBounds(20, 60, 180, 25);
|
|
||||||
panel.add(password);
|
|
||||||
|
|
||||||
passwordLabel.setBounds(210, 60, 160, 25);
|
|
||||||
panel.add(passwordLabel);
|
|
||||||
|
|
||||||
setServer.setBounds(20, 110, 300, 25);
|
|
||||||
panel.add(setServer);
|
|
||||||
|
|
||||||
addMap.setBounds(20, 160, 300, 25);
|
|
||||||
panel.add(addMap);
|
|
||||||
|
|
||||||
deleteMap.setBounds(20, 210, 300, 25);
|
|
||||||
panel.add(deleteMap);
|
|
||||||
|
|
||||||
editMap.setBounds(20, 260, 300, 25);
|
|
||||||
panel.add(editMap);
|
|
||||||
|
|
||||||
addObjekt.setBounds(20, 310, 300, 25);
|
|
||||||
panel.add(addObjekt);
|
|
||||||
|
|
||||||
deleteObjekt.setBounds(20, 360, 300, 25);
|
|
||||||
panel.add(deleteObjekt);
|
|
||||||
|
|
||||||
editObjekt.setBounds(20, 410, 300, 25);
|
|
||||||
panel.add(editObjekt);
|
|
||||||
|
|
||||||
JButton button = new JButton();
|
|
||||||
if (user == null) {
|
|
||||||
button.setText("Přidat");
|
|
||||||
} else {
|
|
||||||
button.setText("Upravit");
|
|
||||||
}
|
|
||||||
button.setBounds(20, 460, 90, 25);
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (userName.getText().length() > 3) {
|
|
||||||
User u = new User(
|
|
||||||
0,
|
|
||||||
userName.getText(),
|
|
||||||
password.getText(),
|
|
||||||
addMap.isSelected(),
|
|
||||||
deleteMap.isSelected(),
|
|
||||||
editMap.isSelected(),
|
|
||||||
addObjekt.isSelected(),
|
|
||||||
deleteObjekt.isSelected(),
|
|
||||||
editObjekt.isSelected(),
|
|
||||||
setServer.isSelected());
|
|
||||||
|
|
||||||
if (user == null) {
|
|
||||||
|
|
||||||
NettyClient.send(Message.USER, u);
|
|
||||||
} else {
|
|
||||||
u.setId(user.getId());
|
|
||||||
NettyClient.send(Message.USER_EDIT, u);
|
|
||||||
}
|
|
||||||
Window.showServerSettings(ServerSettingsPanel.TAB_USERS);
|
|
||||||
dispose();
|
|
||||||
} else {
|
|
||||||
JOptionPane.showMessageDialog(null, "Uživatelské jméno musí být delší než 3 znaky", "Chyba", JOptionPane.WARNING_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(button);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String generateRandomString(int length) {
|
|
||||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
Random random = new Random();
|
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
int index = random.nextInt(characters.length());
|
|
||||||
sb.append(characters.charAt(index));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
package jnet.client.gui.mapview;
|
|
||||||
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.geom.Line2D;
|
|
||||||
import jnet.client.gui.dialog.ConnectionDialog;
|
|
||||||
|
|
||||||
public class ConnectionListener implements MouseListener {
|
|
||||||
|
|
||||||
private final double TOLERANCE = 10;
|
|
||||||
|
|
||||||
private PaintConnection selectedConnection;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
if (e.getClickCount() == 2) {
|
|
||||||
// dvojité kliknutí
|
|
||||||
|
|
||||||
if (MapView.paintConnection == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedConnection = findObjectAt(e.getPoint());
|
|
||||||
|
|
||||||
if (selectedConnection != null) {
|
|
||||||
new ConnectionDialog(selectedConnection.getConnection());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPointNearLine(Point p, Line2D line, double tolerance) {
|
|
||||||
return line.ptSegDist(p) <= tolerance; // Zkontroluje vzdálenost bodu od čáry
|
|
||||||
}
|
|
||||||
|
|
||||||
private PaintConnection findObjectAt(Point p) {
|
|
||||||
for (PaintConnection node : MapView.paintConnection) {
|
|
||||||
Line2D.Double line = new Line2D.Double(node.getFrom().getX(), node.getFrom().getY(), node.getTo().getX(), node.getTo().getY());
|
|
||||||
//node.setSelected(false);
|
|
||||||
if (isPointNearLine(p, line, TOLERANCE)) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,136 +0,0 @@
|
||||||
package jnet.client.gui.mapview;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.Timer;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.object.Connection;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
|
|
||||||
public class MapView extends JPanel {
|
|
||||||
|
|
||||||
public static List<PaintObject> paintObjects = new ArrayList<>();
|
|
||||||
public static List<PaintConnection> paintConnection = new ArrayList<>();
|
|
||||||
|
|
||||||
private BufferedImage lockImage;
|
|
||||||
private BufferedImage unlockImage;
|
|
||||||
|
|
||||||
private static Map map;
|
|
||||||
|
|
||||||
public MapView(Map map) {
|
|
||||||
this.map = map;
|
|
||||||
|
|
||||||
LogFile.printDebug("View map: " + map.getName());
|
|
||||||
paintObjects.clear();
|
|
||||||
paintConnection.clear();
|
|
||||||
|
|
||||||
try {
|
|
||||||
lockImage = ImageIO.read(getClass().getResourceAsStream("/img/lock.png"));
|
|
||||||
unlockImage = ImageIO.read(getClass().getResourceAsStream("/img/unlock.png"));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("File not found: " + ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
loadConnection(map.getId());
|
|
||||||
loadObject(map.getId());
|
|
||||||
|
|
||||||
this.addMouseMotionListener(new MapViewAction(map));
|
|
||||||
this.addMouseListener(new MapViewAction(map));
|
|
||||||
this.addMouseListener(new ConnectionListener());
|
|
||||||
|
|
||||||
// periodicke prekreslovani
|
|
||||||
Timer timer = new Timer(100, (ActionEvent ae) -> {
|
|
||||||
if (NettyClient.isConnected()) {
|
|
||||||
this.setBackground(Color.white);
|
|
||||||
} else {
|
|
||||||
this.setBackground(Color.LIGHT_GRAY);
|
|
||||||
}
|
|
||||||
repaint();
|
|
||||||
});
|
|
||||||
timer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void paintComponent(Graphics g) {
|
|
||||||
super.paintComponent(g);
|
|
||||||
Graphics2D g2 = (Graphics2D) g.create();
|
|
||||||
|
|
||||||
// vykresleni lock/unlock mapy
|
|
||||||
g.drawImage(map.isLock() ? lockImage : unlockImage, 0, 0, this);
|
|
||||||
|
|
||||||
// vykresleni stavajicich propojeni
|
|
||||||
for (PaintConnection c : paintConnection) {
|
|
||||||
c.paint(g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Kreslení nového propojení
|
|
||||||
if (MapViewAction.createConnection && MapViewAction.startConMapObject != null && MapViewAction.endConnPoint != null) {
|
|
||||||
g.setColor(Color.RED); // Barva propojení
|
|
||||||
g.drawLine(
|
|
||||||
MapViewAction.startConMapObject.getPoint().x, MapViewAction.startConMapObject.getPoint().y,
|
|
||||||
MapViewAction.endConnPoint.x, MapViewAction.endConnPoint.y
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// vykresleni objektu
|
|
||||||
for (PaintObject paintObject : paintObjects) {
|
|
||||||
paintObject.paint(g2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateMapView(Map map) {
|
|
||||||
if (map.equals(MapView.map)) {
|
|
||||||
// obnoveni propojeni
|
|
||||||
paintConnection.clear();
|
|
||||||
loadConnection(map.getId());
|
|
||||||
// obnoveni objektu
|
|
||||||
paintObjects.clear();
|
|
||||||
loadObject(map.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void updateMapView() {
|
|
||||||
if (map.equals(MapView.map)) {
|
|
||||||
// obnoveni propojeni
|
|
||||||
paintConnection.clear();
|
|
||||||
loadConnection(map.getId());
|
|
||||||
// obnoveni objektu
|
|
||||||
paintObjects.clear();
|
|
||||||
// nahrat objekty
|
|
||||||
loadObject(map.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadObject(int mapId) {
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (MapObject obj : map.getObjects()) {
|
|
||||||
if (obj.getMap() == mapId) {
|
|
||||||
paintObjects.add(new PaintObject(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadConnection(int mapId) {
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (Connection con : map.getConnection()) {
|
|
||||||
if (con.getMap() == mapId) {
|
|
||||||
paintConnection.add(new PaintConnection(con));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,300 +0,0 @@
|
||||||
package jnet.client.gui.mapview;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.ExtAppManager;
|
|
||||||
import jnet.client.gui.dialog.DialogLocalPing;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
import java.awt.event.MouseMotionListener;
|
|
||||||
import java.io.IOException;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JMenuItem;
|
|
||||||
import javax.swing.JPopupMenu;
|
|
||||||
import jnet.client.gui.dialog.ConnectionDialog;
|
|
||||||
import jnet.client.gui.dialog.object.ObjectDialog;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
|
|
||||||
public class MapViewAction implements MouseMotionListener, MouseListener {
|
|
||||||
|
|
||||||
private Map map;
|
|
||||||
|
|
||||||
public MapViewAction(Map map) {
|
|
||||||
this.map = map;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static PaintObject selectedObject;
|
|
||||||
private static Point offset;
|
|
||||||
public static boolean createConnection = false;
|
|
||||||
public static PaintObject startConMapObject;
|
|
||||||
public static PaintObject endConMapObject;
|
|
||||||
public static Point endConnPoint;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
// vola se pri kliknuti v mape
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mousePressed(MouseEvent e) { // vola se pri stisknuti tlacitka
|
|
||||||
// vyhledani jestli se kliklo na nejaky objekt
|
|
||||||
if (MapView.paintObjects == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
selectedObject = findObjectAt(e.getPoint());
|
|
||||||
|
|
||||||
if (selectedObject != null) {
|
|
||||||
handleObjectSelection(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseReleased(MouseEvent e) { // vola se pri uvolneni tlacitka
|
|
||||||
if (selectedObject != null) {
|
|
||||||
handleObjectRelease(e);
|
|
||||||
} else if (e.getButton() == MouseEvent.BUTTON3) {
|
|
||||||
rigthClick(e);
|
|
||||||
}
|
|
||||||
selectedObject = null;
|
|
||||||
offset = null;
|
|
||||||
|
|
||||||
if (createConnection && startConMapObject != null) {
|
|
||||||
endConMapObject = findObjectAt(e.getPoint());
|
|
||||||
if (endConMapObject != null && endConMapObject != startConMapObject) {
|
|
||||||
// Uložení propojení mezi objekty
|
|
||||||
new ConnectionDialog(startConMapObject.getObject(), endConMapObject.getObject());
|
|
||||||
}
|
|
||||||
createConnection = false;
|
|
||||||
startConMapObject = null;
|
|
||||||
endConMapObject = null;
|
|
||||||
endConnPoint = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseEntered(MouseEvent e) {
|
|
||||||
// vola se pri vstupu kurzoru
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseExited(MouseEvent e) {
|
|
||||||
// vola se pri opusteni kurzoru
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseDragged(MouseEvent e) {
|
|
||||||
if (map.isLock() || !Client.user.isEditMap()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (createConnection) {
|
|
||||||
endConnPoint = findNearestObject(e.getPoint());
|
|
||||||
} else if (selectedObject != null && offset != null) {
|
|
||||||
moveObject(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void mouseMoved(MouseEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private PaintObject findObjectAt(Point p) {
|
|
||||||
for (PaintObject node : MapView.paintObjects) {
|
|
||||||
node.setSelected(false);
|
|
||||||
if (node.contains(p)) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Point findNearestObject(Point p) {
|
|
||||||
for (PaintObject node : MapView.paintObjects) {
|
|
||||||
if (node.contains(p)) {
|
|
||||||
return node.getPoint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleObjectSelection(MouseEvent e) {
|
|
||||||
selectedObject.setSelected(true);
|
|
||||||
|
|
||||||
if (createConnection) {
|
|
||||||
startConMapObject = selectedObject;
|
|
||||||
endConnPoint = e.getPoint();
|
|
||||||
} else {
|
|
||||||
offset = new Point(
|
|
||||||
selectedObject.getBoxX() - e.getX(),
|
|
||||||
selectedObject.getBoxY() - e.getY()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleObjectRelease(MouseEvent e) {
|
|
||||||
if (!map.isLock() && positionChanged()) {
|
|
||||||
NettyClient.send(Message.OBJECT_MOVE, new int[]{
|
|
||||||
selectedObject.getId(),
|
|
||||||
(int) selectedObject.getX(),
|
|
||||||
(int) selectedObject.getY()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (e.getClickCount() == 2) {
|
|
||||||
doubleClickOnObject(selectedObject);
|
|
||||||
}
|
|
||||||
if (e.getButton() == MouseEvent.BUTTON3) {
|
|
||||||
rightClickOnObject(e, selectedObject);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean positionChanged() {
|
|
||||||
return offset != null && (offset.x != 0 || offset.y != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void moveObject(MouseEvent e) {
|
|
||||||
Point to = new Point(e.getX() + offset.x, e.getY() + offset.y);
|
|
||||||
selectedObject.setPosition(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doubleClickOnObject(PaintObject selectedObject) {
|
|
||||||
int id = selectedObject.getId();
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
for (MapObject object : map.getObjects()) {
|
|
||||||
if (object.getId() == id) {
|
|
||||||
//new ObjectDialog(map.getId(), object, false);
|
|
||||||
new ObjectDialog(object);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rigthClick(MouseEvent me) {
|
|
||||||
JPopupMenu menu = new JPopupMenu();
|
|
||||||
// zamek mapy
|
|
||||||
JMenuItem itemLock;
|
|
||||||
if (map.isLock()) {
|
|
||||||
itemLock = new JMenuItem("Odemknout mapu", loadImageIcon("/img/unlock.png"));
|
|
||||||
} else {
|
|
||||||
itemLock = new JMenuItem("Zamknout mapu", loadImageIcon("/img/lock.png"));
|
|
||||||
}
|
|
||||||
itemLock.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
if (map.isLock()) {
|
|
||||||
int[] d = {map.getId(), 0};
|
|
||||||
NettyClient.send(Message.SET_MAP_LOCK, d);
|
|
||||||
} else {
|
|
||||||
int[] d = {map.getId(), 1};
|
|
||||||
NettyClient.send(Message.SET_MAP_LOCK, d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.add(itemLock);
|
|
||||||
|
|
||||||
// polozka pridat objekt
|
|
||||||
if (Client.user.isAddObject()) {
|
|
||||||
JMenuItem itemAdd = createMenuAction("Přidat objekt", "/img/add.png", new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MapObject mo = new MapObject();
|
|
||||||
mo.setX(me.getX());
|
|
||||||
mo.setY(me.getY());
|
|
||||||
mo.setMap(map.getId());
|
|
||||||
new ObjectDialog(mo, true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
itemAdd.setEnabled(!map.isLock());
|
|
||||||
menu.add(itemAdd);
|
|
||||||
}
|
|
||||||
// polozka pridani propojeni
|
|
||||||
JMenuItem itemPropoj = createMenuAction("Přidat propojení", "/img/arrow.png", new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
startConMapObject = null;
|
|
||||||
endConnPoint = null;
|
|
||||||
createConnection = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.add(itemPropoj);
|
|
||||||
|
|
||||||
menu.show(me.getComponent(), me.getX(), me.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void rightClickOnObject(MouseEvent e, PaintObject obj) {
|
|
||||||
JPopupMenu menu = new JPopupMenu();
|
|
||||||
if (obj.getObject().isWinbox()) {
|
|
||||||
JMenuItem itemWinbox = createMenuAction("Winbox", "/img/winbox.png", ()
|
|
||||||
-> new ExtAppManager().runWinbox(obj.getObject().getIp(), obj.getObject().getUser(), obj.getObject().getPassword(), Integer.valueOf(obj.getObject().getWinboxPort()))
|
|
||||||
);
|
|
||||||
menu.add(itemWinbox);
|
|
||||||
}
|
|
||||||
if (obj.getObject().isWeb()) {
|
|
||||||
JMenuItem itemWeb = createMenuAction("Otevřít v prohlížeči", "/img/browser.png", ()
|
|
||||||
-> new ExtAppManager().runWeb(obj.getObject().getWebVerze(), obj.getObject().getIp(), obj.getObject().getWebPort())
|
|
||||||
);
|
|
||||||
menu.add(itemWeb);
|
|
||||||
}
|
|
||||||
if (obj.getObject().isSsh()) {
|
|
||||||
JMenuItem itemSsh = createMenuAction("SSH", "/img/ssh.png", ()
|
|
||||||
-> new ExtAppManager().runSshPutty(obj.getObject().getIp(), obj.getObject().getUser(), obj.getObject().getPassword(), Integer.parseInt(obj.getObject().getSshPort()))
|
|
||||||
);
|
|
||||||
menu.add(itemSsh);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ping na objekt
|
|
||||||
JMenuItem itemPingRemote = new JMenuItem("Ping", loadImageIcon("/img/ping.png"));
|
|
||||||
itemPingRemote.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.add(itemPingRemote);
|
|
||||||
|
|
||||||
// ping na objekt
|
|
||||||
JMenuItem itemPingLocal = createMenuAction("Ping (lokální)", "/img/ping.png", new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
DialogLocalPing dp = new DialogLocalPing(obj.getObject().getIp());
|
|
||||||
Thread pingThread = new Thread(dp);
|
|
||||||
pingThread.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
menu.add(itemPingLocal);
|
|
||||||
|
|
||||||
// odebrani objektu
|
|
||||||
if (Client.user.isRemoveObject()) {
|
|
||||||
JMenuItem itemRemove = createMenuAction("Odebrat", "/img/trash.png", () -> NettyClient.send(Message.REMOVE_OBJECT, obj.getId()));
|
|
||||||
itemRemove.setEnabled(!map.isLock());
|
|
||||||
menu.add(itemRemove);
|
|
||||||
}
|
|
||||||
|
|
||||||
// zobrazeni menu
|
|
||||||
menu.show(e.getComponent(), e.getX(), e.getY());
|
|
||||||
}
|
|
||||||
|
|
||||||
private ImageIcon loadImageIcon(String path) {
|
|
||||||
try {
|
|
||||||
return new ImageIcon(ImageIO.read(MapViewAction.class.getResourceAsStream(path)));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("MapView error: " + ex.getMessage());
|
|
||||||
return null; // nebo nějaká výchozí ikona
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private JMenuItem createMenuAction(String label, String iconPath, Runnable action) {
|
|
||||||
JMenuItem menuItem = new JMenuItem(label, loadImageIcon(iconPath));
|
|
||||||
menuItem.addActionListener(e -> action.run());
|
|
||||||
return menuItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,195 +0,0 @@
|
||||||
package jnet.client.gui.mapview;
|
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
|
||||||
import java.awt.Canvas;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.geom.AffineTransform;
|
|
||||||
import java.awt.geom.Line2D;
|
|
||||||
import java.awt.geom.RoundRectangle2D;
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.lib.object.Connection;
|
|
||||||
import jnet.lib.object.Map;
|
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
|
|
||||||
public class PaintConnection extends Rectangle {
|
|
||||||
|
|
||||||
private Connection con;
|
|
||||||
private Graphics2D g2;
|
|
||||||
private Point from = null;
|
|
||||||
private Point to = null;
|
|
||||||
private String connection_text;
|
|
||||||
private Font font = new Font("Helvetica", Font.PLAIN, 10);
|
|
||||||
|
|
||||||
public PaintConnection(Connection con) {
|
|
||||||
this.con = con;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void paint(Graphics g) {
|
|
||||||
|
|
||||||
refreshData();
|
|
||||||
|
|
||||||
g2 = (Graphics2D) g.create();
|
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
|
|
||||||
switch (con.getType()) {
|
|
||||||
case Connection.TYPE_OTHER:
|
|
||||||
g2.setStroke(new BasicStroke(5));
|
|
||||||
connection_text = "";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_GE:
|
|
||||||
g2.setStroke(new BasicStroke(5));
|
|
||||||
connection_text = "GE";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_FE:
|
|
||||||
g2.setStroke(new BasicStroke(3));
|
|
||||||
connection_text = "FE";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_E:
|
|
||||||
g2.setStroke(new BasicStroke(1));
|
|
||||||
connection_text = "E";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_10GE:
|
|
||||||
g2.setStroke(new BasicStroke(5)); // TODO doresit tvar cary
|
|
||||||
connection_text = "10 GE";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_100M_FIBER:
|
|
||||||
g2.setStroke(new BasicStroke(5)); // TODO doresit tvar cary
|
|
||||||
connection_text = "100M Fiber";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_1G_FIBER:
|
|
||||||
g2.setStroke(new BasicStroke(5)); // TODO doresit tvar cary
|
|
||||||
connection_text = "1G Fiber";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_10G_FIBER:
|
|
||||||
g2.setStroke(new BasicStroke(5)); // TODO doresit tvar cary
|
|
||||||
connection_text = "10G Fiber";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_WIRELESS:
|
|
||||||
float[] dashingPattern = {2f, 2f};
|
|
||||||
g2.setStroke(new BasicStroke(2f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1.0f, dashingPattern, 2.0f));
|
|
||||||
connection_text = "Wireless";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_TUNEL:
|
|
||||||
g2.setStroke(new BasicStroke(5)); // TODO doresit tvar cary
|
|
||||||
connection_text = "Tunel";
|
|
||||||
break;
|
|
||||||
case Connection.TYPE_VLAN:
|
|
||||||
g2.setStroke(new BasicStroke(5)); // TODO doresit tvar cary
|
|
||||||
connection_text = "VLAN";
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
g2.draw(new Line2D.Double(this.from, this.to));
|
|
||||||
|
|
||||||
// stred cary
|
|
||||||
int stredX = (from.x + to.x) / 2; // Střed čáry (x)
|
|
||||||
int stredY = (from.y + to.y) / 2; // Střed čáry (y)
|
|
||||||
|
|
||||||
if (con.isReadTraffic()) {
|
|
||||||
// vyska, sirka
|
|
||||||
int sirka = 80;
|
|
||||||
int vyska = 42;
|
|
||||||
|
|
||||||
// vypocitani pocatecnich bodu
|
|
||||||
int x = stredX - sirka / 2;
|
|
||||||
int y = stredY - vyska / 2;
|
|
||||||
|
|
||||||
// TODO az bude vyresni detekce kliku na caru tak tyto promenen uplne zrusit
|
|
||||||
int xObdelnik, x2Obdelnik, yObdelnik, y2Obdelnik;
|
|
||||||
xObdelnik = x;
|
|
||||||
x2Obdelnik = x + sirka;
|
|
||||||
yObdelnik = y;
|
|
||||||
y2Obdelnik = y + vyska;
|
|
||||||
|
|
||||||
// zmeni barvu na cernou
|
|
||||||
g2.setPaint(new Color(220, 220, 220));
|
|
||||||
|
|
||||||
// vykresli oblast pro rx, tx
|
|
||||||
RoundRectangle2D.Double box = new RoundRectangle2D.Double(x, y, sirka, vyska, 10, 10);
|
|
||||||
g2.fill(box);
|
|
||||||
|
|
||||||
// zmeni barvu na cernou
|
|
||||||
g2.setPaint(new Color(0, 0, 0));
|
|
||||||
|
|
||||||
// nastavi font
|
|
||||||
g2.setFont(font);
|
|
||||||
|
|
||||||
// vypise typ
|
|
||||||
g2.drawString(connection_text, x + (int) (box.getWidth() / 2) - (getStringWidth(connection_text) / 2), y + 12);
|
|
||||||
|
|
||||||
// vypise TX
|
|
||||||
String tx = "Tx: " + con.getTx();
|
|
||||||
g2.drawString(tx, x + (int) (box.getWidth() / 2) - (getStringWidth(tx) / 2), y + 24);
|
|
||||||
|
|
||||||
// vypise RX
|
|
||||||
String rx = "Rx: " + con.getRx();
|
|
||||||
g2.drawString(rx, x + (int) (box.getWidth() / 2) - (getStringWidth(rx) / 2), y + 36);
|
|
||||||
} else {
|
|
||||||
// Výpočet úhlu otočení
|
|
||||||
double angle = Math.atan2(to.y - from.y, to.x - from.x);
|
|
||||||
|
|
||||||
// Uložení aktuálního transformu
|
|
||||||
AffineTransform oldTransform = g2.getTransform();
|
|
||||||
|
|
||||||
// Vytvoření nového transformu pro otočení textu
|
|
||||||
AffineTransform transform = new AffineTransform();
|
|
||||||
transform.translate(stredX, stredY); // Přesun do středu čáry
|
|
||||||
transform.rotate(angle); // Otočení podle úhlu čáry
|
|
||||||
|
|
||||||
g2.setTransform(transform);
|
|
||||||
g2.setColor(Color.RED);
|
|
||||||
|
|
||||||
// Posunutí textu, aby byl lépe vidět (mírně nad čárou)
|
|
||||||
g2.drawString(connection_text, -g2.getFontMetrics().stringWidth(connection_text) / 2, -5);
|
|
||||||
|
|
||||||
// Obnovení původního transformu
|
|
||||||
g2.setTransform(oldTransform);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void refreshData() {
|
|
||||||
// ziskani souradnic
|
|
||||||
for (Map map : Client.maps) {
|
|
||||||
if (con.getMap() == map.getId()) {
|
|
||||||
for (MapObject obj : map.getObjects()) {
|
|
||||||
if (obj.getId() == con.getSourceObj()) {
|
|
||||||
from = new Point(obj.getX(), obj.getY());
|
|
||||||
}
|
|
||||||
if (obj.getId() == con.getDestinationObj()) {
|
|
||||||
to = new Point(obj.getX(), obj.getY());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getStringWidth(String text) {
|
|
||||||
//return g.getFontMetrics().stringWidth(text);
|
|
||||||
Canvas c = new Canvas();
|
|
||||||
FontMetrics fm = c.getFontMetrics(font);
|
|
||||||
return fm.stringWidth(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point getFrom() {
|
|
||||||
return this.from;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point getTo() {
|
|
||||||
return this.to;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Connection getConnection() {
|
|
||||||
return this.con;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,253 +0,0 @@
|
||||||
package jnet.client.gui.mapview;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import java.awt.BasicStroke;
|
|
||||||
import java.awt.Canvas;
|
|
||||||
import java.awt.Color;
|
|
||||||
import java.awt.Font;
|
|
||||||
import java.awt.FontMetrics;
|
|
||||||
import java.awt.Graphics;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.Image;
|
|
||||||
import java.awt.Point;
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.awt.RenderingHints;
|
|
||||||
import java.awt.geom.RoundRectangle2D;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
import jnet.lib.object.ObjectType;
|
|
||||||
|
|
||||||
public class PaintObject extends Rectangle {
|
|
||||||
|
|
||||||
private MapObject obj;
|
|
||||||
|
|
||||||
private Image icon;
|
|
||||||
private int x;
|
|
||||||
private int y;
|
|
||||||
private int boxX = 0;
|
|
||||||
private int boxY;
|
|
||||||
|
|
||||||
private int paddingBoxu = 20;
|
|
||||||
|
|
||||||
private int sirka;
|
|
||||||
private int vyska;
|
|
||||||
private RoundRectangle2D box;
|
|
||||||
private Graphics2D g2;
|
|
||||||
private Boolean selected = false;
|
|
||||||
|
|
||||||
private Font fontNormal12 = new Font("Arial", Font.PLAIN, 12);
|
|
||||||
private Font fontBold12 = new Font("Arial", Font.BOLD, 12);
|
|
||||||
private Font fontNormalSmall = new Font("Arial", Font.PLAIN, 10);
|
|
||||||
|
|
||||||
public PaintObject(MapObject obj) {
|
|
||||||
this.obj = obj;
|
|
||||||
vypocitat_rozmery();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* vypocita vyšku boxu
|
|
||||||
*/
|
|
||||||
private void vypocitat_rozmery() {
|
|
||||||
// padding top
|
|
||||||
vyska = 5;
|
|
||||||
// vyska obrazku
|
|
||||||
if (this.icon != null) {
|
|
||||||
vyska += this.icon.getHeight(null);
|
|
||||||
}
|
|
||||||
// vyska prvniho radku s nazvem zarizeni
|
|
||||||
vyska += getStringHeight(fontBold12);
|
|
||||||
// vyska druheho radku s ip adresou (pokud je vyplnena)
|
|
||||||
if (!obj.getIp().equals("")) {
|
|
||||||
vyska += 5; // mezera mezi radky
|
|
||||||
vyska += getStringHeight(fontNormal12);
|
|
||||||
}
|
|
||||||
// padding bottom
|
|
||||||
vyska += 5;
|
|
||||||
|
|
||||||
//sirka boxu
|
|
||||||
List<Integer> sList = new ArrayList<Integer>();
|
|
||||||
sList.add(getStringWidth(obj.getName(), fontBold12) + paddingBoxu);
|
|
||||||
sList.add(getStringWidth(obj.getIp(), fontNormal12) + paddingBoxu);
|
|
||||||
sirka = Collections.max(sList);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void paint(Graphics g) {
|
|
||||||
|
|
||||||
g2 = (Graphics2D) g.create();
|
|
||||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
|
||||||
|
|
||||||
// nastaveni pozice x, y objektu
|
|
||||||
this.x = obj.getX();
|
|
||||||
this.y = obj.getY();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// nastaveni ikony objektu
|
|
||||||
try {
|
|
||||||
for (ObjectType ot : Client.objectType) {
|
|
||||||
if (ot.getId() == obj.getObjectType()) {
|
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(ot.getImgStr());
|
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(decodedBytes);
|
|
||||||
this.icon = ImageIO.read(bis);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (IOException ex) {
|
|
||||||
LogFile.printErr("Object icon exception: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
vypocitat_rozmery();
|
|
||||||
|
|
||||||
/* TODO box gradient
|
|
||||||
GradientPaint redtowhite = new GradientPaint(x, y, Color.red, 200, y,Color.blue);
|
|
||||||
g2.setPaint(redtowhite);
|
|
||||||
*/
|
|
||||||
|
|
||||||
// status objektu
|
|
||||||
switch (obj.getStatus()) {
|
|
||||||
case 1: // online
|
|
||||||
g2.setPaint(new Color(83, 241, 83));
|
|
||||||
break;
|
|
||||||
case 2: // warning
|
|
||||||
g2.setPaint(new Color(255, 131, 0));
|
|
||||||
break;
|
|
||||||
case 3: // offline
|
|
||||||
g2.setPaint(new Color(221, 63, 63));
|
|
||||||
break;
|
|
||||||
default: // other
|
|
||||||
g2.setPaint(new Color(172, 172, 172));
|
|
||||||
}
|
|
||||||
|
|
||||||
// vypocitani pocatecnich souradnic
|
|
||||||
boxX = x - (sirka / 2);
|
|
||||||
boxY = y - (vyska / 2);
|
|
||||||
|
|
||||||
// vykresleni boxu
|
|
||||||
box = new RoundRectangle2D.Double(boxX, boxY, sirka, vyska, 10, 10);
|
|
||||||
g2.fill(box);
|
|
||||||
|
|
||||||
if (selected) {
|
|
||||||
g2.setStroke(new BasicStroke(1.5f));
|
|
||||||
g2.setColor(Color.BLACK);
|
|
||||||
g2.draw(box);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
|
|
||||||
// nacteni ikonka zarizeni
|
|
||||||
if (icon != null) {
|
|
||||||
int imgX = boxX + sirka / 2 - (icon.getWidth(null) / 2);
|
|
||||||
int imgY = boxY + 5;
|
|
||||||
g.drawImage(icon, imgX, imgY, null);
|
|
||||||
boxY += icon.getHeight(null); // pricte vysku ikonky
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// vypsani nazvu prvku
|
|
||||||
g2.setPaint(Color.BLACK);
|
|
||||||
g2.setFont(fontBold12);
|
|
||||||
g2.drawString(obj.getName(), boxX + (int) (box.getWidth() / 2) - (getStringWidth(obj.getName(), g2.getFont()) / 2), boxY + getStringHeight(g2.getFont()));
|
|
||||||
|
|
||||||
// vypsani ip prvku
|
|
||||||
boxY += 20;
|
|
||||||
g2.setFont(fontNormal12);
|
|
||||||
g2.drawString(obj.getIp(), boxX + (int) (box.getWidth() / 2) - (getStringWidth(obj.getIp(), g2.getFont()) / 2), boxY + getStringHeight(g2.getFont()));
|
|
||||||
|
|
||||||
// vypsani snmp sond
|
|
||||||
g2.setFont(fontNormalSmall);
|
|
||||||
/*
|
|
||||||
for (SnmpProbe snmpProbe : obj.getSnmpProbe()) {
|
|
||||||
if (snmpProbe.isView()) {
|
|
||||||
boxY += 20;
|
|
||||||
String str = snmpProbe.getName() + ": " + snmpProbe.getValue();
|
|
||||||
g2.drawString(str, boxX + (int) (box.getWidth() / 2) - (getStringWidth(str, g2.getFont()) / 2), boxY + getStringHeight(g2.getFont()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
this.setBounds(boxX, boxY, sirka, vyska);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBoxX() {
|
|
||||||
return (int) box.getX();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBoxY() {
|
|
||||||
return (int) box.getY();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBoxWidth() {
|
|
||||||
return sirka;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getBoxHeight() {
|
|
||||||
return vyska;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelected(Boolean value) {
|
|
||||||
this.selected = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getStringWidth(String text, Font font) {
|
|
||||||
Canvas c = new Canvas();
|
|
||||||
FontMetrics fm = c.getFontMetrics(font);
|
|
||||||
return fm.stringWidth(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getStringHeight(Font font) {
|
|
||||||
Canvas c = new Canvas();
|
|
||||||
FontMetrics fm = c.getFontMetrics(font);
|
|
||||||
return fm.getHeight();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean contains(Point p) {
|
|
||||||
if ((box.getMinX() < p.getX() && p.getX() < box.getMaxX()) && (box.getMinY() < p.getY() && p.getY() < box.getMaxY())) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPosition(Point p) {
|
|
||||||
obj.setX(p.x + sirka / 2);
|
|
||||||
obj.setY(p.y + vyska / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return obj.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapObject getObject() {
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point getPoint() {
|
|
||||||
Point p = new Point();
|
|
||||||
p.x = this.x;
|
|
||||||
p.y = this.y;
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,242 +0,0 @@
|
||||||
package jnet.client.gui.serversettings;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.gui.dialog.AddDeviceTypeDialog;
|
|
||||||
import jnet.client.gui.dialog.UserDialog;
|
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import javax.swing.BoxLayout;
|
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JScrollPane;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.JTextField;
|
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ChangeListener;
|
|
||||||
import javax.swing.table.DefaultTableModel;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
import jnet.lib.object.SnmpProfile;
|
|
||||||
import jnet.lib.object.User;
|
|
||||||
|
|
||||||
public class ServerSettingsPanel extends JTabbedPane {
|
|
||||||
|
|
||||||
public static final int TAB_DEFAULT = 0;
|
|
||||||
public static final int TAB_DEVICE_TYPE = 1;
|
|
||||||
public static final int TAB_USERS = 2;
|
|
||||||
public static final int TAB_SNMP_PROFILE = 3;
|
|
||||||
|
|
||||||
public ServerSettingsPanel() {
|
|
||||||
|
|
||||||
this.addTab("Základní", tabZakladni());
|
|
||||||
this.addTab("Typy zařízení", tabZarizeni());
|
|
||||||
this.addTab("Uživatelé", tabUsers());
|
|
||||||
this.addTab("SNMP", tabSnmpProfile());
|
|
||||||
|
|
||||||
// vola se pri zmene zalozky
|
|
||||||
this.addChangeListener(new ChangeListener() {
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTable(int table) {
|
|
||||||
this.setSelectedIndex(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Component tabZakladni() {
|
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
|
|
||||||
panel.setLayout(null);
|
|
||||||
|
|
||||||
int x1 = 80;
|
|
||||||
int x2 = 150;
|
|
||||||
|
|
||||||
JLabel pingLabel = new JLabel("Ping");
|
|
||||||
pingLabel.setFont(pingLabel.getFont().deriveFont(20f));
|
|
||||||
pingLabel.setBounds(20, 20, 150, 25);
|
|
||||||
panel.add(pingLabel);
|
|
||||||
|
|
||||||
JTextField repeateField = new JTextField(String.valueOf(Client.serverConfig.getPingAttempt()));
|
|
||||||
repeateField.setBounds(x1, 60, 50, 25);
|
|
||||||
panel.add(repeateField);
|
|
||||||
|
|
||||||
JLabel repeateLabel = new JLabel("Opakovat ping každých ... sekund");
|
|
||||||
repeateLabel.setBounds(x2, 60, 300, 25);
|
|
||||||
panel.add(repeateLabel);
|
|
||||||
|
|
||||||
JTextField pokusuField = new JTextField(String.valueOf(Client.serverConfig.getPingAttempt()));
|
|
||||||
pokusuField.setBounds(x1, 100, 50, 25);
|
|
||||||
panel.add(pokusuField);
|
|
||||||
|
|
||||||
JLabel pokusuLabel = new JLabel("Počet pokusů před vyhodnocenim offline");
|
|
||||||
pokusuLabel.setBounds(x2, 100, 300, 25);
|
|
||||||
panel.add(pokusuLabel);
|
|
||||||
|
|
||||||
JTextField timeoutField = new JTextField(String.valueOf(Client.serverConfig.getPingTimeout()));
|
|
||||||
timeoutField.setBounds(x1, 140, 50, 25);
|
|
||||||
panel.add(timeoutField);
|
|
||||||
|
|
||||||
JLabel timeoutLabel = new JLabel("Úroveň timeout (s)");
|
|
||||||
timeoutLabel.setBounds(x2, 140, 300, 25);
|
|
||||||
panel.add(timeoutLabel);
|
|
||||||
|
|
||||||
JTextField pokusuNestField = new JTextField(String.valueOf(Client.serverConfig.getInstabilityAttempt()));
|
|
||||||
pokusuNestField.setBounds(x1, 180, 50, 25);
|
|
||||||
panel.add(pokusuNestField);
|
|
||||||
|
|
||||||
JLabel pokusuNestLabel = new JLabel("Počet pokusů před vyhodnocením nestability");
|
|
||||||
pokusuNestLabel.setBounds(x2, 180, 300, 25);
|
|
||||||
panel.add(pokusuNestLabel);
|
|
||||||
|
|
||||||
JTextField nestField = new JTextField(String.valueOf(Client.serverConfig.getInstabilityLimit()));
|
|
||||||
nestField.setBounds(x1, 220, 50, 25);
|
|
||||||
panel.add(nestField);
|
|
||||||
|
|
||||||
JLabel nestLabel = new JLabel("Úroveň nestability (s)");
|
|
||||||
nestLabel.setBounds(x2, 220, 300, 25);
|
|
||||||
panel.add(nestLabel);
|
|
||||||
|
|
||||||
JButton button = new JButton("Uložit");
|
|
||||||
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
Client.serverConfig.setPingRepeat(Integer.valueOf(repeateField.getText()));
|
|
||||||
Client.serverConfig.setPingAttempt(Integer.valueOf(pokusuField.getText()));
|
|
||||||
Client.serverConfig.setPingTimeout(Integer.valueOf(timeoutField.getText()));
|
|
||||||
Client.serverConfig.setInstabilityAttempt(Integer.valueOf(pokusuNestField.getText()));
|
|
||||||
Client.serverConfig.setInstabilityLimit(Integer.valueOf(nestField.getText()));
|
|
||||||
NettyClient.send(Message.SERVER_CONFIG, Client.serverConfig);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
button.setBounds(x1, 300, 100, 40);
|
|
||||||
panel.add(button);
|
|
||||||
|
|
||||||
JButton buttonRestart = new JButton("Restartovat server");
|
|
||||||
//buttonRestart.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
buttonRestart.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
int result = JOptionPane.showConfirmDialog(null,
|
|
||||||
"Opravdu chceš pokračovat?",
|
|
||||||
"Restart serveru",
|
|
||||||
JOptionPane.YES_NO_OPTION);
|
|
||||||
|
|
||||||
if (result == JOptionPane.YES_OPTION) {
|
|
||||||
LogFile.printInfo("Odeslan pozadavek na restart serveru");
|
|
||||||
NettyClient.send(Message.RESTART, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
buttonRestart.setBounds(x1+200, 300, 150, 40);
|
|
||||||
panel.add(buttonRestart);
|
|
||||||
|
|
||||||
return new JScrollPane(panel);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel tabZarizeni() {
|
|
||||||
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // Vertikální zarovnání
|
|
||||||
|
|
||||||
JTable table = new TableDeviceType();
|
|
||||||
JScrollPane scrollPane = new JScrollPane(table);
|
|
||||||
panel.add(new JScrollPane(scrollPane));
|
|
||||||
|
|
||||||
JButton button = new JButton("Přidat typ");
|
|
||||||
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new AddDeviceTypeDialog().setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(button);
|
|
||||||
|
|
||||||
return panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel tabUsers() {
|
|
||||||
JPanel panel = new JPanel();
|
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); // Vertikální zarovnání
|
|
||||||
|
|
||||||
JTable tableUsers = new TableUsers();
|
|
||||||
panel.add(new JScrollPane(tableUsers));
|
|
||||||
|
|
||||||
JButton button = new JButton("Přidat uživatele");
|
|
||||||
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
|
||||||
button.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
new UserDialog(null).setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
panel.add(button);
|
|
||||||
|
|
||||||
return panel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Component tabSnmpProfile() {
|
|
||||||
|
|
||||||
JTable table = new JTable(new TableModelSnmpProfile());
|
|
||||||
return new JScrollPane(table);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TableModelSnmpProfile extends DefaultTableModel {
|
|
||||||
|
|
||||||
public TableModelSnmpProfile() {
|
|
||||||
|
|
||||||
// sloupce
|
|
||||||
addColumn("Nazev");
|
|
||||||
addColumn("Verze");
|
|
||||||
addColumn("Community Read");
|
|
||||||
addColumn("Community Write");
|
|
||||||
addColumn("Port");
|
|
||||||
|
|
||||||
// radky
|
|
||||||
for (SnmpProfile sp : Client.snmpProfile) {
|
|
||||||
addRow(new Object[]{
|
|
||||||
sp.getName(),
|
|
||||||
sp.getVersion(),
|
|
||||||
sp.getCommunityRead(),
|
|
||||||
sp.getCommunityWrite(),
|
|
||||||
sp.getPort()});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TableModelUsers extends DefaultTableModel {
|
|
||||||
|
|
||||||
public TableModelUsers() {
|
|
||||||
|
|
||||||
// sloupce
|
|
||||||
addColumn("Jméno");
|
|
||||||
addColumn("Nastaveni serveru");
|
|
||||||
addColumn("Přidat mapu");
|
|
||||||
addColumn("Odebrat mapu");
|
|
||||||
// radky
|
|
||||||
for (User sp : Client.users) {
|
|
||||||
addRow(new Object[]{
|
|
||||||
sp.getUsername(),
|
|
||||||
"",
|
|
||||||
"",
|
|
||||||
sp.isAddMap(), //sp.isSetServer(),
|
|
||||||
//sp.isAddMap(),
|
|
||||||
//sp.isRemoveMap()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
package jnet.client.gui.serversettings;
|
|
||||||
|
|
||||||
import jnet.client.Client;
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
|
||||||
import javax.swing.table.DefaultTableModel;
|
|
||||||
import javax.swing.table.TableColumn;
|
|
||||||
import jnet.lib.object.ObjectType;
|
|
||||||
|
|
||||||
public class TableDeviceType extends JTable {
|
|
||||||
|
|
||||||
|
|
||||||
private static final String[] COLUMN_NAMES = {
|
|
||||||
"Ikona",
|
|
||||||
"Název zařízení"};
|
|
||||||
|
|
||||||
public TableDeviceType() {
|
|
||||||
|
|
||||||
tableSetup();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<?> getColumnClass(int column) {
|
|
||||||
if (column == 0) {
|
|
||||||
return ImageIcon.class;
|
|
||||||
} else {
|
|
||||||
return String.class;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tableSetup() {
|
|
||||||
DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, Client.objectType.size()) {
|
|
||||||
@Override
|
|
||||||
public boolean isCellEditable(int row, int column) {
|
|
||||||
//all cells false
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setModel(model);
|
|
||||||
|
|
||||||
DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
|
|
||||||
dtcr.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
|
|
||||||
this.setDefaultRenderer(String.class, dtcr);
|
|
||||||
|
|
||||||
int row = 0;
|
|
||||||
for (ObjectType obj : Client.objectType) {
|
|
||||||
try {
|
|
||||||
byte[] decodedBytes = Base64.getDecoder().decode(obj.getImgStr());
|
|
||||||
ByteArrayInputStream bis = new ByteArrayInputStream(decodedBytes);
|
|
||||||
ImageIcon icon = new ImageIcon(ImageIO.read(bis));
|
|
||||||
this.setValueAt(icon, row, 0);
|
|
||||||
this.setValueAt(obj.getName(), row, 1);
|
|
||||||
row++;
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(TableDeviceType.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// nastavení vysky radku
|
|
||||||
for (int i = 0; i < Client.objectType.size(); i++) {
|
|
||||||
this.setRowHeight(i, this.getRowHeight(i) + 40);
|
|
||||||
}
|
|
||||||
|
|
||||||
// nastavení sirky sloupce
|
|
||||||
for (int i = 0; i < COLUMN_NAMES.length; i++) {
|
|
||||||
TableColumn column = this.getColumnModel().getColumn(i);
|
|
||||||
column.setPreferredWidth(column.getPreferredWidth() + 80);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setVisible(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,134 +0,0 @@
|
||||||
package jnet.client.gui.serversettings;
|
|
||||||
|
|
||||||
import jnet.client.gui.serversettings.TableDeviceType;
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.gui.dialog.UserDialog;
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.awt.event.MouseAdapter;
|
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JTable;
|
|
||||||
import javax.swing.table.DefaultTableModel;
|
|
||||||
import javax.swing.table.TableCellRenderer;
|
|
||||||
import jnet.lib.object.User;
|
|
||||||
|
|
||||||
public class TableUsers extends JTable {
|
|
||||||
|
|
||||||
private static final String[] COLUMN_NAMES = {
|
|
||||||
"ID",
|
|
||||||
"Uživatel",
|
|
||||||
"Přidat mapu",
|
|
||||||
"Odebrat mapu",
|
|
||||||
"Upravit mapu",
|
|
||||||
"Přidat objekt",
|
|
||||||
"Odebrat objekt",
|
|
||||||
"Upravit objekt",
|
|
||||||
"Nastavit server"
|
|
||||||
};
|
|
||||||
|
|
||||||
public TableUsers() {
|
|
||||||
|
|
||||||
tableSetup();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void tableSetup() {
|
|
||||||
DefaultTableModel model = new DefaultTableModel(COLUMN_NAMES, Client.users.size()) {
|
|
||||||
@Override
|
|
||||||
public boolean isCellEditable(int row, int column) {
|
|
||||||
//all cells false
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<?> getColumnClass(int columnIndex) {
|
|
||||||
if (columnIndex > 1) {
|
|
||||||
return ImageIcon.class;
|
|
||||||
}
|
|
||||||
return super.getColumnClass(columnIndex);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.setModel(model);
|
|
||||||
|
|
||||||
this.setRowHeight(25);
|
|
||||||
|
|
||||||
this.getColumnModel().getColumn(1).setCellRenderer(new ImageRenderer());
|
|
||||||
|
|
||||||
this.addMouseListener(new MouseAdapter() {
|
|
||||||
@Override
|
|
||||||
public void mouseClicked(MouseEvent e) {
|
|
||||||
if (e.getClickCount() == 2) { // Kontrola dvojitého kliku
|
|
||||||
int row = getSelectedRow(); // Získání vybraného řádku
|
|
||||||
if (row != -1) {
|
|
||||||
Object id = getValueAt(row, 0);
|
|
||||||
for (User user : Client.users) {
|
|
||||||
if (user.getId() == (int) id) {
|
|
||||||
new UserDialog(user).setVisible(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
int row = 0;
|
|
||||||
for (User u : Client.users) {
|
|
||||||
try {
|
|
||||||
|
|
||||||
ImageIcon ii_yes = new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/img/yes.png")));
|
|
||||||
ImageIcon ii_no = new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/img/no.png")));
|
|
||||||
|
|
||||||
this.setValueAt(u.getId(), row, 0);
|
|
||||||
this.setValueAt(u.getUsername(), row, 1);
|
|
||||||
this.setValueAt((u.isAddMap() ? ii_yes : ii_no), row, 2);
|
|
||||||
this.setValueAt((u.isRemoveMap() ? ii_yes : ii_no), row, 3);
|
|
||||||
this.setValueAt((u.isEditMap() ? ii_yes : ii_no), row, 4);
|
|
||||||
this.setValueAt((u.isAddObject()? ii_yes : ii_no), row, 5);
|
|
||||||
this.setValueAt((u.isEditObject()? ii_yes : ii_no), row, 6);
|
|
||||||
this.setValueAt((u.isRemoveObject()? ii_yes : ii_no), row, 7);
|
|
||||||
this.setValueAt((u.isEditServer() ? ii_yes : ii_no), row, 8);
|
|
||||||
|
|
||||||
row++;
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(TableDeviceType.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ImageRenderer extends JLabel implements TableCellRenderer {
|
|
||||||
|
|
||||||
public ImageRenderer() {
|
|
||||||
setHorizontalAlignment(CENTER); // Obrázky budou centrované
|
|
||||||
setOpaque(true); // Zajištění vykreslení pozadí
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
|
||||||
if (isSelected) {
|
|
||||||
setBackground(table.getSelectionBackground());
|
|
||||||
} else {
|
|
||||||
setBackground(table.getBackground());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value instanceof ImageIcon) {
|
|
||||||
setIcon((ImageIcon) value);
|
|
||||||
setText(null); // Zamezení zobrazení textu
|
|
||||||
} else {
|
|
||||||
setIcon(null);
|
|
||||||
setText(value != null ? value.toString() : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,142 +0,0 @@
|
||||||
package jnet.client.network;
|
|
||||||
|
|
||||||
import io.netty.bootstrap.Bootstrap;
|
|
||||||
import jnet.client.Client;
|
|
||||||
import jnet.client.ClientMessageParser;
|
|
||||||
import jnet.client.gui.Tray;
|
|
||||||
import jnet.client.gui.Window;
|
|
||||||
import io.netty.channel.*;
|
|
||||||
import io.netty.channel.nio.NioEventLoopGroup;
|
|
||||||
import io.netty.channel.socket.nio.NioSocketChannel;
|
|
||||||
import io.netty.handler.codec.serialization.ClassResolvers;
|
|
||||||
import io.netty.handler.codec.serialization.ObjectDecoder;
|
|
||||||
import io.netty.handler.codec.serialization.ObjectEncoder;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import jnet.lib.LogFile;
|
|
||||||
import jnet.lib.Message;
|
|
||||||
|
|
||||||
public class NettyClient implements Runnable {
|
|
||||||
|
|
||||||
private final String host;
|
|
||||||
private final int port;
|
|
||||||
private final Bootstrap bootstrap;
|
|
||||||
private final EventLoopGroup group;
|
|
||||||
static private Channel channel;
|
|
||||||
|
|
||||||
private static boolean autoReconnectEnable;
|
|
||||||
|
|
||||||
public NettyClient(String host, int port) {
|
|
||||||
this.host = host;
|
|
||||||
this.port = port;
|
|
||||||
this.group = new NioEventLoopGroup();
|
|
||||||
this.bootstrap = new Bootstrap();
|
|
||||||
configureBootstrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void configureBootstrap() {
|
|
||||||
bootstrap.group(group)
|
|
||||||
.channel(NioSocketChannel.class)
|
|
||||||
.option(ChannelOption.SO_KEEPALIVE, true)
|
|
||||||
.handler(new ChannelInitializer<Channel>() {
|
|
||||||
@Override
|
|
||||||
protected void initChannel(Channel ch) throws Exception {
|
|
||||||
ch.pipeline().addLast("decoder", new ObjectDecoder(ClassResolvers.weakCachingConcurrentResolver(getClass().getClassLoader())));
|
|
||||||
ch.pipeline().addLast("encoder", new ObjectEncoder());
|
|
||||||
ch.pipeline().addLast("handler", new ClientHandler());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
connect();
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void connect() {
|
|
||||||
autoReconnectEnable = true;
|
|
||||||
bootstrap.connect(host, port).addListener((ChannelFutureListener) future -> {
|
|
||||||
if (future.isSuccess()) {
|
|
||||||
channel = future.channel();
|
|
||||||
System.out.println("Pripojeno k serveru " + host + ":" + port);
|
|
||||||
Window.setConectionStatus("Připojeno");
|
|
||||||
} else {
|
|
||||||
LogFile.printErr("Pripojeni selhalo: " + future.cause().getMessage());
|
|
||||||
reconnect();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reconnect() {
|
|
||||||
if (autoReconnectEnable) {
|
|
||||||
group.schedule(() -> {
|
|
||||||
LogFile.printErr("Zkousim se znovu pripojit...");
|
|
||||||
Window.setConectionStatus("Připojování ...");
|
|
||||||
connect();
|
|
||||||
}, 5, TimeUnit.SECONDS);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void send(int type, Object obj) {
|
|
||||||
channel.writeAndFlush(new Message(type, obj));
|
|
||||||
LogFile.printDebug("<- Message type: " + type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isConnected() {
|
|
||||||
if (channel != null && channel.isActive()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void disconnect() {
|
|
||||||
// vypne automaticke pripojeni
|
|
||||||
autoReconnectEnable = false;
|
|
||||||
// odpojí
|
|
||||||
channel.disconnect();
|
|
||||||
channel.close();
|
|
||||||
// vypise do okna informaci
|
|
||||||
Window.setConectionStatus("Odpojeno");
|
|
||||||
// zmeni tray icon
|
|
||||||
Tray.setStatusDisconnected();
|
|
||||||
// zapíše do logu
|
|
||||||
LogFile.printInfo("User disconnect");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void shutdown() {
|
|
||||||
group.shutdownGracefully();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ClientHandler extends ChannelInboundHandlerAdapter {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void channelRead(ChannelHandlerContext ctx, Object msg) {
|
|
||||||
if (msg instanceof Message) {
|
|
||||||
Message m = (Message) msg;
|
|
||||||
ClientMessageParser.parse((Message) msg);
|
|
||||||
}
|
|
||||||
if (msg instanceof String) {
|
|
||||||
System.out.println("Server message: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
|
||||||
LogFile.printErr("Spojeni bylo ukonceno");
|
|
||||||
reconnect();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
|
||||||
System.err.println("Client error: " + cause);
|
|
||||||
ctx.close();
|
|
||||||
Client.connected = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,137 @@
|
||||||
|
package jnet.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.client.gui.Tray;
|
||||||
|
import jnet.client.gui.Window;
|
||||||
|
import jnet.lib.ApacheConfig;
|
||||||
|
import jnet.lib.BuilddDate;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.DeviceType;
|
||||||
|
import jnet.lib.object.Event;
|
||||||
|
import jnet.lib.object.OnlineClients;
|
||||||
|
import jnet.lib.object.ServerConfig;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
import jnet.lib.object.SnmpProfile;
|
||||||
|
import jnet.lib.object.SnmpTemplate;
|
||||||
|
import jnet.lib.object.SnmpValueMap;
|
||||||
|
import jnet.lib.object.User;
|
||||||
|
import org.apache.commons.configuration2.Configuration;
|
||||||
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
|
|
||||||
|
public class Client {
|
||||||
|
|
||||||
|
// verze klienta
|
||||||
|
public static final int VERSION = 3;
|
||||||
|
// jméno aplikace
|
||||||
|
public static final String APP_NAME = "jNet client";
|
||||||
|
|
||||||
|
public static Configuration config;
|
||||||
|
|
||||||
|
public static ArrayList<OnlineClients> onlineClients = new ArrayList<>();
|
||||||
|
public static ArrayList<Site> site = new ArrayList<>();
|
||||||
|
public static ArrayList<DeviceType> deviceType = new ArrayList<>();
|
||||||
|
public static ArrayList<SnmpProfile> snmpProfile = new ArrayList<>();
|
||||||
|
public static ArrayList<User> users = new ArrayList<>();
|
||||||
|
public static ServerConfig serverConfig;
|
||||||
|
public static User user = new User();
|
||||||
|
public static List<Event> events = new ArrayList<>();
|
||||||
|
public static List<SnmpTemplate> snmpTemplate = new ArrayList<>();
|
||||||
|
public static List<SnmpValueMap> snmpValueMap = new ArrayList<>();
|
||||||
|
|
||||||
|
public static Window okno = Window.getInstance();
|
||||||
|
|
||||||
|
public static NettyClientManager nettyClient;
|
||||||
|
public static Tray trayIcon;
|
||||||
|
public static RemoteAdminTools remoteTools;
|
||||||
|
public static SoundManager soundManager;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
LogFile.clear();
|
||||||
|
LogFile.setDebug(false);
|
||||||
|
LogFile.printInfo("---------------------------------------------");
|
||||||
|
LogFile.printInfo(" jNet Client ");
|
||||||
|
LogFile.printInfo(" Version: " + VERSION + " (" + BuilddDate.get() + ")");
|
||||||
|
LogFile.printInfo("---------------------------------------------");
|
||||||
|
LogFile.printInfo("");
|
||||||
|
|
||||||
|
// Nahrani konfigurace
|
||||||
|
LogFile.printInfo("Loading config ...");
|
||||||
|
try {
|
||||||
|
config = ApacheConfig.loadProperties();
|
||||||
|
LogFile.printInfo(" successfully");
|
||||||
|
} catch (ConfigurationException ex) {
|
||||||
|
LogFile.printInfo(" fail: " + ex.getMessage());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("debug")) {
|
||||||
|
LogFile.setDebug(true);
|
||||||
|
LogFile.printInfo("Debug mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===== INICIALIZACE NÁSTROJŮ (VÝHRADNĚ ZE SLOŽKY app) =====
|
||||||
|
try {
|
||||||
|
remoteTools = new RemoteAdminTools();
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
LogFile.printErr("AdminTools selhal: " + e.getMessage());
|
||||||
|
// Můžeme pokračovat bez nástrojů (metody selžou)
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// sound manager
|
||||||
|
///
|
||||||
|
soundManager = new SoundManager();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tray icon
|
||||||
|
///
|
||||||
|
trayIcon = new Tray();
|
||||||
|
trayIcon.createAndShowTray();
|
||||||
|
|
||||||
|
|
||||||
|
///
|
||||||
|
/// okno
|
||||||
|
///
|
||||||
|
if (config.getBoolean("open_maximalized")) {
|
||||||
|
System.err.println("true");
|
||||||
|
okno.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||||
|
} else {
|
||||||
|
System.err.println("false");
|
||||||
|
okno.setSize(1024, 800);
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// spustit minimalozovane ?
|
||||||
|
///
|
||||||
|
if (config.getBoolean("start_minimalized")) {
|
||||||
|
okno.setVisible(false);
|
||||||
|
} else {
|
||||||
|
okno.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Netty client vlákna
|
||||||
|
nettyClient = new NettyClientManager(config.getString("server", "localhost"), config.getInt("port", 1225));
|
||||||
|
nettyClient.start();
|
||||||
|
|
||||||
|
// ===== SHUTDOWN HOOK =====
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
LogFile.printInfo("Shutdown signal received...");
|
||||||
|
nettyClient.stop();
|
||||||
|
if (remoteTools != null) {
|
||||||
|
remoteTools.closeAll(); // ZAVŘE VŠECHNY SPUŠTĚNÉ PROCESY
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sendMessage(Message msg) {
|
||||||
|
nettyClient.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,280 @@
|
||||||
|
package jnet.client;
|
||||||
|
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class RemoteAdminTools {
|
||||||
|
|
||||||
|
private final List<Process> runningProcesses = new ArrayList<>();
|
||||||
|
private final String puttyPath;
|
||||||
|
private final String winboxPath;
|
||||||
|
private final String browserPath;
|
||||||
|
private final String smsSdvPath;
|
||||||
|
private final String smsSdvIniPath;
|
||||||
|
private final String smsBthPath;
|
||||||
|
private final String smsBthIniPath;
|
||||||
|
private final String smsBtPath;
|
||||||
|
private final String smsBtIniPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Konstruktor – vždy hledá putty.exe a winbox.exe ve složce "app". Složka
|
||||||
|
* "app" se hledá: - vedle JAR souboru (pokud běžíme z JAR) - v aktuálním
|
||||||
|
* pracovním adresáři (pokud běžíme z IDE)
|
||||||
|
*/
|
||||||
|
public RemoteAdminTools() {
|
||||||
|
String appDir = findAppDirectory();
|
||||||
|
this.puttyPath = validateExecutable(appDir, "putty.exe");
|
||||||
|
this.winboxPath = validateExecutable(appDir, "winbox.exe");
|
||||||
|
this.browserPath = null; // prohlížeč necháme automaticky detekovat
|
||||||
|
this.smsSdvPath = validateExecutable(appDir, "smsc_sdv.exe");
|
||||||
|
this.smsSdvIniPath = appDir + File.separator + "smsc_sdv.INI";
|
||||||
|
this.smsBthPath = validateExecutable(appDir, "smsc_bth.exe");
|
||||||
|
this.smsBthIniPath = appDir + File.separator + "smsc_bth.INI";
|
||||||
|
this.smsBtPath = validateExecutable(appDir, "smsc_bt.exe");
|
||||||
|
this.smsBtIniPath = appDir + File.separator + "smsc_bt.INI";
|
||||||
|
LogFile.printInfo("RemoteAdminTools inicializovan, app dir: " + appDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Najde složku "app" – buď vedle JAR, nebo v aktuálním adresáři.
|
||||||
|
*/
|
||||||
|
private String findAppDirectory() {
|
||||||
|
// 1. Pokusíme se zjistit cestu k JAR
|
||||||
|
String jarDir = getJarDirectory();
|
||||||
|
if (jarDir != null) {
|
||||||
|
File appDir = new File(jarDir, "app");
|
||||||
|
if (appDir.exists() && appDir.isDirectory()) {
|
||||||
|
return appDir.getAbsolutePath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Fallback – aktuální pracovní adresář (funguje v NetBeans)
|
||||||
|
File appDir = new File(System.getProperty("user.dir"), "app");
|
||||||
|
if (appDir.exists() && appDir.isDirectory()) {
|
||||||
|
return appDir.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Ještě zkusíme src/main/resources/app (pro případ spuštění z IDE)
|
||||||
|
File srcAppDir = new File(System.getProperty("user.dir"), "src/main/resources/app");
|
||||||
|
if (srcAppDir.exists() && srcAppDir.isDirectory()) {
|
||||||
|
return srcAppDir.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
LogFile.printErr("Slozka 'app' nebyla nalezena!");
|
||||||
|
return System.getProperty("user.dir"); // vrátíme alespoň něco
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vrátí absolutní cestu ke složce, ve které se nachází spuštěný JAR. Pokud
|
||||||
|
* běžíme z IDE (classpath), vrátí null.
|
||||||
|
*/
|
||||||
|
private String getJarDirectory() {
|
||||||
|
try {
|
||||||
|
String path = RemoteAdminTools.class.getProtectionDomain()
|
||||||
|
.getCodeSource().getLocation().toURI().getPath();
|
||||||
|
File jarFile = new File(path);
|
||||||
|
if (jarFile.isFile()) {
|
||||||
|
return jarFile.getParent();
|
||||||
|
}
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
LogFile.printErr("Nepodarilo se zjistit cestu k JAR: " + e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ověří, že executable existuje ve složce app. Pokud ne, vyhodí chybu.
|
||||||
|
*/
|
||||||
|
private String validateExecutable(String appDir, String fileName) {
|
||||||
|
File exe = new File(appDir, fileName);
|
||||||
|
if (!exe.exists() || !exe.isFile()) {
|
||||||
|
LogFile.printErr("Soubor " + fileName + " nebyl nalezen v: " + exe.getAbsolutePath());
|
||||||
|
throw new RuntimeException("Chybi " + fileName + " ve slozce app!");
|
||||||
|
}
|
||||||
|
LogFile.printInfo("Nalezen " + fileName + " v: " + exe.getAbsolutePath());
|
||||||
|
return exe.getAbsolutePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Process startProcess(List<String> command) throws IOException {
|
||||||
|
ProcessBuilder pb = new ProcessBuilder(command);
|
||||||
|
Process p = pb.start();
|
||||||
|
runningProcesses.add(p);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otevře PuTTY v režimu SSH a automaticky se připojí.
|
||||||
|
*/
|
||||||
|
public void openPuttySSH(String host, String port, String username, String password) {
|
||||||
|
try {
|
||||||
|
List<String> cmd = new ArrayList<>();
|
||||||
|
cmd.add(puttyPath);
|
||||||
|
cmd.add("-ssh");
|
||||||
|
cmd.add("-P");
|
||||||
|
cmd.add(port);
|
||||||
|
if (username != null && !username.isEmpty()) {
|
||||||
|
cmd.add("-l");
|
||||||
|
cmd.add(username);
|
||||||
|
}
|
||||||
|
if (password != null && !password.isEmpty()) {
|
||||||
|
cmd.add("-pw");
|
||||||
|
cmd.add(password);
|
||||||
|
}
|
||||||
|
cmd.add(host);
|
||||||
|
startProcess(cmd);
|
||||||
|
LogFile.printInfo("PuTTY SSH spusten: " + host + ":" + port + " (uzivatel: " + username + ")");
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Nepodarilo se spustit PuTTY SSH: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otevře PuTTY v režimu SSH (bez hesla).
|
||||||
|
*/
|
||||||
|
public void openPuttySSH(String host, String port, String username) {
|
||||||
|
openPuttySSH(host, port, username, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otevře PuTTY v režimu Telnet.
|
||||||
|
*/
|
||||||
|
public void openPuttyTelnet(String host, String port) {
|
||||||
|
try {
|
||||||
|
List<String> cmd = new ArrayList<>();
|
||||||
|
cmd.add(puttyPath);
|
||||||
|
cmd.add("-telnet");
|
||||||
|
cmd.add("-P");
|
||||||
|
cmd.add(port);
|
||||||
|
cmd.add(host);
|
||||||
|
startProcess(cmd);
|
||||||
|
LogFile.printInfo("PuTTY Telnet spusten: " + host + ":" + port);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Nepodarilo se spustit PuTTY Telnet: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otevře Winbox a automaticky se připojí.
|
||||||
|
*/
|
||||||
|
public void openWinbox(String host, String username, String password) {
|
||||||
|
try {
|
||||||
|
List<String> cmd = new ArrayList<>();
|
||||||
|
cmd.add(winboxPath);
|
||||||
|
cmd.add(host);
|
||||||
|
if (username != null && !username.isEmpty()) {
|
||||||
|
//cmd.add("-u");
|
||||||
|
cmd.add(username);
|
||||||
|
}
|
||||||
|
if (password != null && !password.isEmpty()) {
|
||||||
|
//cmd.add("-p");
|
||||||
|
cmd.add(password);
|
||||||
|
}
|
||||||
|
System.err.println(cmd);
|
||||||
|
startProcess(cmd);
|
||||||
|
LogFile.printInfo("Winbox spusten pro: " + host + " (uzivatel: " + username + ")");
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Nepodarilo se spustit Winbox: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Otevře výchozí systémový prohlížeč s danou URL. POZOR: Tento proces nelze
|
||||||
|
* automaticky ukončit, protože Desktop.browse() nevrací objekt Process. Při
|
||||||
|
* ukončení hlavního programu se tedy prohlížeč nezavře – to je kompromis
|
||||||
|
* kvůli požadavku na "výchozí prohlížeč".
|
||||||
|
*/
|
||||||
|
public void openBrowser(String ip, String port, int version) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
switch (version) {
|
||||||
|
case 1: // HTTPS
|
||||||
|
sb.append("HTTPS://");
|
||||||
|
break;
|
||||||
|
default: // HTTP
|
||||||
|
sb.append("HTTP://");
|
||||||
|
}
|
||||||
|
sb.append(ip);
|
||||||
|
sb.append(":").append(port);
|
||||||
|
String url = sb.toString();
|
||||||
|
try {
|
||||||
|
URI uri = URI.create(url);
|
||||||
|
java.awt.Desktop.getDesktop().browse(uri);
|
||||||
|
LogFile.printInfo("Prohlizec otevren s URL: " + url);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogFile.printErr("Nepodarilo se otevrit prohlizec: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openSMS(String host, String port, String password, int version) {
|
||||||
|
String smsPath = null;
|
||||||
|
String iniPath = null;
|
||||||
|
switch (version) {
|
||||||
|
case 0: //SDV
|
||||||
|
smsPath = smsSdvPath;
|
||||||
|
iniPath = smsSdvIniPath;
|
||||||
|
break;
|
||||||
|
case 1: // BTH
|
||||||
|
smsPath = smsBthPath;
|
||||||
|
iniPath = smsBthIniPath;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
smsPath = smsBtPath;
|
||||||
|
iniPath = smsBtIniPath;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!createSmsIni(iniPath, host, port, password)) {
|
||||||
|
LogFile.printErr("Nepodarilo se vytvorit konfiguracni soubor pro SMS");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<String> cmd = new ArrayList<>();
|
||||||
|
cmd.add(smsPath);
|
||||||
|
startProcess(cmd);
|
||||||
|
LogFile.printInfo("SMS spustena pro " + host + ":" + port);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Nepodarilo se spustit SMS " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean createSmsIni(String iniPath, String host, String port, String password) {
|
||||||
|
try (PrintWriter writer = new PrintWriter(new FileWriter(iniPath))) {
|
||||||
|
writer.println("[Form]");
|
||||||
|
writer.println("IPaddr=" + host + ":" + port);
|
||||||
|
writer.println("IPpassw=" + password);
|
||||||
|
writer.flush();
|
||||||
|
LogFile.printInfo("INI soubor vytvoren " + iniPath);
|
||||||
|
return true;
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Chyba pri vytvoreni INI souboru " + e.getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ukončí všechny dosud spuštěné procesy.
|
||||||
|
*/
|
||||||
|
public void closeAll() {
|
||||||
|
for (Process p : runningProcesses) {
|
||||||
|
if (p != null && p.isAlive()) {
|
||||||
|
p.destroyForcibly();
|
||||||
|
try {
|
||||||
|
// Oprava: waitFor(long, TimeUnit) místo waitFor(long)
|
||||||
|
p.waitFor(1, TimeUnit.SECONDS);
|
||||||
|
} catch (InterruptedException ignored) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
LogFile.printInfo("Proces ukončen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
runningProcesses.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package jnet.client;
|
||||||
|
|
||||||
|
import jnet.lib.object.NodeProbe;
|
||||||
|
import org.snmp4j.smi.SMIConstants;
|
||||||
|
|
||||||
|
public class SnmpResponseParser {
|
||||||
|
|
||||||
|
public static String parse(NodeProbe probe) {
|
||||||
|
|
||||||
|
if (probe.getValue() == null) {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
if (probe.getValue().toString().equals("noSuchObject")) {
|
||||||
|
return "error";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
switch (probe.getDataType()) {
|
||||||
|
case SMIConstants.SYNTAX_INTEGER:
|
||||||
|
return parseInteger(probe).toString();
|
||||||
|
case SMIConstants.SYNTAX_OCTET_STRING:
|
||||||
|
return probe.getValue().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object parseInteger(NodeProbe probe) {
|
||||||
|
switch (probe.getConversionType()) {
|
||||||
|
case NodeProbe.CONVERSION_TYPE_DIVIDE:
|
||||||
|
double value = Integer.parseInt(probe.getValue().toString()) / probe.getConversionValue();
|
||||||
|
return value;
|
||||||
|
default:
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class parse {
|
||||||
|
|
||||||
|
public parse(NodeProbe probe) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
package jnet.client;
|
||||||
|
|
||||||
|
import javax.sound.sampled.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Status;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
public class SoundManager {
|
||||||
|
|
||||||
|
private static final String KEY_OFFLINE_FIRST = "sound.offline.first";
|
||||||
|
private static final String KEY_OFFLINE_OTHER = "sound.offline.other";
|
||||||
|
private static final String KEY_ONLINE_ONE = "sound.online.one";
|
||||||
|
private static final String KEY_ONLINE_ALL = "sound.online.all";
|
||||||
|
private static final String KEY_VOLUME = "sound.volume";
|
||||||
|
|
||||||
|
// ✅ SPRÁVNÉ názvy souborů podle vaší struktury (přímo v resources)
|
||||||
|
private static final String DEFAULT_OFFLINE_FIRST = "first_offline.wav";
|
||||||
|
private static final String DEFAULT_OFFLINE_OTHER = "next_offline.wav";
|
||||||
|
private static final String DEFAULT_ONLINE_ONE = "one_online.wav";
|
||||||
|
private static final String DEFAULT_ONLINE_ALL = "all_online.wav";
|
||||||
|
private static final float DEFAULT_VOLUME = 0.8f;
|
||||||
|
|
||||||
|
private final Map<String, Clip> soundCache = new HashMap<>();
|
||||||
|
private float volume = DEFAULT_VOLUME;
|
||||||
|
|
||||||
|
private static final String SOUND_OFFLINE_FIRST = "offlineFirst";
|
||||||
|
private static final String SOUND_OFFLINE_OTHER = "offlineOther";
|
||||||
|
private static final String SOUND_ONLINE_ONE = "onlineOne";
|
||||||
|
private static final String SOUND_ONLINE_ALL = "onlineAll";
|
||||||
|
|
||||||
|
public SoundManager() {
|
||||||
|
loadConfigAndSounds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigAndSounds() {
|
||||||
|
String pathOfflineFirst = Client.config.getString(KEY_OFFLINE_FIRST, DEFAULT_OFFLINE_FIRST);
|
||||||
|
String pathOfflineOther = Client.config.getString(KEY_OFFLINE_OTHER, DEFAULT_OFFLINE_OTHER);
|
||||||
|
String pathOnlineOne = Client.config.getString(KEY_ONLINE_ONE, DEFAULT_ONLINE_ONE);
|
||||||
|
String pathOnlineAll = Client.config.getString(KEY_ONLINE_ALL, DEFAULT_ONLINE_ALL);
|
||||||
|
float newVolume = Client.config.getFloat(KEY_VOLUME, DEFAULT_VOLUME);
|
||||||
|
setVolume(newVolume);
|
||||||
|
|
||||||
|
closeAll();
|
||||||
|
loadSound(SOUND_OFFLINE_FIRST, pathOfflineFirst);
|
||||||
|
loadSound(SOUND_OFFLINE_OTHER, pathOfflineOther);
|
||||||
|
loadSound(SOUND_ONLINE_ONE, pathOnlineOne);
|
||||||
|
loadSound(SOUND_ONLINE_ALL, pathOnlineAll);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadSound(String cacheKey, String filePath) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
URL url = null;
|
||||||
|
ClassLoader classLoader = getClass().getClassLoader();
|
||||||
|
|
||||||
|
// 1. ClassLoader.getResource() - hledá v classpath
|
||||||
|
url = classLoader.getResource(filePath);
|
||||||
|
|
||||||
|
// 2. getClass().getResource() s lomítkem
|
||||||
|
if (url == null) {
|
||||||
|
url = getClass().getResource("/" + filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. getClass().getResource() bez lomítka
|
||||||
|
if (url == null) {
|
||||||
|
url = getClass().getResource(filePath);
|
||||||
|
if (url != null) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 4. Jako soubor
|
||||||
|
if (url == null) {
|
||||||
|
File soundFile = new File(filePath);
|
||||||
|
if (soundFile.exists()) {
|
||||||
|
url = soundFile.toURI().toURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. src/main/resources/
|
||||||
|
if (url == null) {
|
||||||
|
File srcResource = new File("src/main/resources/" + filePath);
|
||||||
|
if (srcResource.exists()) {
|
||||||
|
url = srcResource.toURI().toURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. target/classes/
|
||||||
|
if (url == null) {
|
||||||
|
File targetResource = new File("target/classes/" + filePath);
|
||||||
|
if (targetResource.exists()) {
|
||||||
|
url = targetResource.toURI().toURL();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. Extrahovat název (pokud cesta obsahuje složky)
|
||||||
|
if (url == null && filePath.contains("/")) {
|
||||||
|
String fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
|
||||||
|
|
||||||
|
url = classLoader.getResource(fileName);
|
||||||
|
if (url == null) {
|
||||||
|
url = getClass().getResource("/" + fileName);
|
||||||
|
}
|
||||||
|
if (url == null) {
|
||||||
|
url = getClass().getResource(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url == null) {
|
||||||
|
System.err.println("❌ Zvukový soubor NENALEZEN: " + filePath);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
AudioInputStream audioIn = AudioSystem.getAudioInputStream(url);
|
||||||
|
Clip clip = AudioSystem.getClip();
|
||||||
|
clip.open(audioIn);
|
||||||
|
setClipVolume(clip, volume);
|
||||||
|
soundCache.put(cacheKey, clip);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
LogFile.printErr("❌ Chyba při načítání zvuku " + filePath + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void setVolume(float newVolume) {
|
||||||
|
this.volume = Math.max(0f, Math.min(1f, newVolume));
|
||||||
|
for (Clip clip : soundCache.values()) {
|
||||||
|
setClipVolume(clip, this.volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClipVolume(Clip clip, float volume) {
|
||||||
|
if (clip == null) return;
|
||||||
|
if (clip.isControlSupported(FloatControl.Type.MASTER_GAIN)) {
|
||||||
|
FloatControl gainControl = (FloatControl) clip.getControl(FloatControl.Type.MASTER_GAIN);
|
||||||
|
float min = gainControl.getMinimum();
|
||||||
|
float max = gainControl.getMaximum();
|
||||||
|
float range = max - min;
|
||||||
|
float gain = min + (range * volume);
|
||||||
|
gainControl.setValue(gain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void play(String cacheKey) {
|
||||||
|
Clip clip = soundCache.get(cacheKey);
|
||||||
|
if (clip != null) {
|
||||||
|
clip.setFramePosition(0);
|
||||||
|
clip.start();
|
||||||
|
System.out.println("🔊 Přehrávám zvuk: " + cacheKey);
|
||||||
|
} else {
|
||||||
|
System.err.println("❌ Zvuk '" + cacheKey + "' nebyl načten.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void evaluateAndPlay(List<Site> sites, boolean newOnline) {
|
||||||
|
int offlineCount = 0;
|
||||||
|
outer:
|
||||||
|
for (Site site : sites) {
|
||||||
|
for (Node node : site.getNode()) {
|
||||||
|
if (node.getStatus() == Status.OFFLINE) {
|
||||||
|
offlineCount++;
|
||||||
|
if (offlineCount > 1) {
|
||||||
|
break outer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// System.out.println("📊 Offline zařízení: " + offlineCount + ", nový stav: " + (newOnline ? "ONLINE" : "OFFLINE"));
|
||||||
|
|
||||||
|
if (!newOnline) {
|
||||||
|
if (offlineCount > 1) {
|
||||||
|
play(SOUND_OFFLINE_OTHER);
|
||||||
|
} else {
|
||||||
|
play(SOUND_OFFLINE_FIRST);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (offlineCount > 0) {
|
||||||
|
play(SOUND_ONLINE_ONE);
|
||||||
|
} else {
|
||||||
|
play(SOUND_ONLINE_ALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeAll() {
|
||||||
|
for (Clip clip : soundCache.values()) {
|
||||||
|
if (clip != null) {
|
||||||
|
clip.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
soundCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
loadConfigAndSounds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,66 @@
|
||||||
|
package jnet.client.client;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelHandler.Sharable;
|
||||||
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.gui.Window;
|
||||||
|
import jnet.client.message.MessageRegister;
|
||||||
|
import jnet.client.message.Register;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
@Sharable
|
||||||
|
public class ClientHandler extends SimpleChannelInboundHandler<Object> {
|
||||||
|
|
||||||
|
private NettyClientManager connectionThread;
|
||||||
|
private final MessageRegister messageRegistr = new MessageRegister();
|
||||||
|
|
||||||
|
|
||||||
|
public void setConnectionThread(NettyClientManager connectionThread) {
|
||||||
|
this.connectionThread = connectionThread;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelActive(ChannelHandlerContext ctx) {
|
||||||
|
LogFile.printInfo("Connected to server");
|
||||||
|
ctx.writeAndFlush(new Message(Message.CLIENT_TYPE, Client.VERSION));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
|
||||||
|
if (msg instanceof Message) {
|
||||||
|
Message message = (Message) msg;
|
||||||
|
LogFile.printDebug("Received message ID: "+ message.getType());
|
||||||
|
Register register = messageRegistr.getRegister(message.getType());
|
||||||
|
if (register != null) {
|
||||||
|
register.processing(ctx, message);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogFile.printDebug("Unknown message received");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void channelInactive(ChannelHandlerContext ctx) {
|
||||||
|
LogFile.printInfo("Connection inactive ..... reconnect initiated");
|
||||||
|
Window.setStatusBarMessage("Odpojeno");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
|
||||||
|
if (cause instanceof java.net.SocketException && cause.getMessage().contains("Connection reset")) {
|
||||||
|
LogFile.printInfo("Connection reset by server");
|
||||||
|
Window.setStatusBarMessage("Odpojeno");
|
||||||
|
} else {
|
||||||
|
cause.printStackTrace();
|
||||||
|
}
|
||||||
|
ctx.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(Message msg) {
|
||||||
|
if (connectionThread != null) {
|
||||||
|
connectionThread.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
package jnet.client.client;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelInitializer;
|
||||||
|
import io.netty.channel.socket.SocketChannel;
|
||||||
|
import io.netty.handler.codec.serialization.ClassResolvers;
|
||||||
|
import io.netty.handler.codec.serialization.ObjectDecoder;
|
||||||
|
import io.netty.handler.codec.serialization.ObjectEncoder;
|
||||||
|
import io.netty.handler.ssl.SslContext;
|
||||||
|
|
||||||
|
public class ClientInitializer extends ChannelInitializer<SocketChannel> {
|
||||||
|
|
||||||
|
private final SslContext sslCtx;
|
||||||
|
private final ClientHandler handler;
|
||||||
|
|
||||||
|
public ClientInitializer(SslContext sslCtx, ClientHandler handler) {
|
||||||
|
this.sslCtx = sslCtx;
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void initChannel(SocketChannel ch) {
|
||||||
|
ch.pipeline()
|
||||||
|
.addLast("ssl", sslCtx.newHandler(ch.alloc(), "localhost", 8443))
|
||||||
|
//.addLast("objectDecoder", new ObjectDecoder(ClassResolvers.cacheDisabled(null)))
|
||||||
|
//.addLast("objectEncoder", new ObjectEncoder())
|
||||||
|
.addLast(new ObjectDecoder(ClassResolvers.cacheDisabled(null)))
|
||||||
|
.addLast(new ObjectEncoder())
|
||||||
|
.addLast("handler", handler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,167 @@
|
||||||
|
package jnet.client.client;
|
||||||
|
|
||||||
|
import io.netty.bootstrap.Bootstrap;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelOption;
|
||||||
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
import io.netty.channel.nio.NioEventLoopGroup;
|
||||||
|
import io.netty.channel.socket.nio.NioSocketChannel;
|
||||||
|
import io.netty.handler.ssl.SslContext;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
public class NettyClientManager extends Thread {
|
||||||
|
|
||||||
|
private final String host;
|
||||||
|
private final int port;
|
||||||
|
|
||||||
|
private SslContext sslCtx = null;
|
||||||
|
private final ClientHandler handler;
|
||||||
|
private final EventLoopGroup group;
|
||||||
|
|
||||||
|
private static Channel channel;
|
||||||
|
|
||||||
|
private volatile boolean manualDisconnect = false;
|
||||||
|
private volatile boolean running = true;
|
||||||
|
private int reconnectAttempt = 0;
|
||||||
|
private static final int MAX_RECONNECT_DELAY = 15; // max doma za kterou se pokusí klient znovu připojit
|
||||||
|
|
||||||
|
public NettyClientManager(String host, int port) {
|
||||||
|
super("NettyClientManager"); // pojmenujeme vlákno
|
||||||
|
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
|
||||||
|
this.handler = new ClientHandler();
|
||||||
|
this.group = new NioEventLoopGroup();
|
||||||
|
// Propojíme handler s tímto vláknem (aby mohl posílat zprávy)
|
||||||
|
handler.setConnectionThread(this);
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.sslCtx = SslUtil.createClientSslContext();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
System.getLogger("Client SSL exception: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
|
Bootstrap bootstrap = new Bootstrap();
|
||||||
|
bootstrap.group(group)
|
||||||
|
.channel(NioSocketChannel.class)
|
||||||
|
.option(ChannelOption.SO_KEEPALIVE, true)
|
||||||
|
.handler(new ClientInitializer(sslCtx, handler));
|
||||||
|
|
||||||
|
while (running) {
|
||||||
|
try {
|
||||||
|
System.out.println("Connecting to " + host + ":" + port + " (attempt " + (reconnectAttempt + 1) + ")");
|
||||||
|
ChannelFuture future = bootstrap.connect(host, port).sync();
|
||||||
|
channel = future.channel();
|
||||||
|
System.out.println("Connected successfully");
|
||||||
|
reconnectAttempt = 0;
|
||||||
|
|
||||||
|
channel.closeFuture().sync();
|
||||||
|
System.out.println("Connection lost");
|
||||||
|
|
||||||
|
// Pokud bylo provedeno manuální odpojení, přerušíme smyčku
|
||||||
|
if (manualDisconnect) {
|
||||||
|
System.out.println("Manual disconnect – stopping reconnect loop");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!running) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int delay = Math.min(1 << reconnectAttempt, MAX_RECONNECT_DELAY);
|
||||||
|
reconnectAttempt++;
|
||||||
|
System.out.println("Reconnecting in " + delay + "s...");
|
||||||
|
Thread.sleep(delay * 1000L);
|
||||||
|
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
System.out.println("Connection thread interrupted");
|
||||||
|
// Pokud je to manuální odpojení, ukončíme smyčku
|
||||||
|
if (manualDisconnect) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
break;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Connection error: " + e.getMessage());
|
||||||
|
if (running && !manualDisconnect) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(3000);
|
||||||
|
} catch (InterruptedException ie) {
|
||||||
|
if (manualDisconnect) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Úklid po ukončení smyčky
|
||||||
|
shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Zastaví vlákno a uvolní zdroje
|
||||||
|
*/
|
||||||
|
public void stop() {
|
||||||
|
running = false;
|
||||||
|
if (channel != null) {
|
||||||
|
channel.close();
|
||||||
|
}
|
||||||
|
group.shutdownGracefully();
|
||||||
|
// Přerušíme vlákno, pokud čeká v sleep
|
||||||
|
this.interrupt();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shutdown() {
|
||||||
|
if (channel != null && channel.isActive()) {
|
||||||
|
channel.close();
|
||||||
|
}
|
||||||
|
group.shutdownGracefully();
|
||||||
|
System.out.println("Connection thread shut down");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConnected() {
|
||||||
|
return channel != null && channel.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Odešle zprávu serveru (pokud je spojení aktivní)
|
||||||
|
*/
|
||||||
|
public static void sendMessage(Message msg) {
|
||||||
|
if (channel != null && channel.isActive()) {
|
||||||
|
channel.writeAndFlush(msg);
|
||||||
|
} else {
|
||||||
|
System.out.println("Cannot send message – not connected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendMessage(int type, Object msg) {
|
||||||
|
if (channel != null && channel.isActive()) {
|
||||||
|
channel.writeAndFlush(new Message(type, msg));
|
||||||
|
} else {
|
||||||
|
System.out.println("Cannot send message – not connected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disconnect() {
|
||||||
|
manualDisconnect = true;
|
||||||
|
if (channel != null) {
|
||||||
|
channel.close(); // zavře spojení – spustí channel.closeFuture().sync() v run()
|
||||||
|
}
|
||||||
|
this.interrupt(); // přeruší případné čekání
|
||||||
|
System.out.println("Manual disconnect initiated");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package jnet.client.client;
|
||||||
|
|
||||||
|
import io.netty.bootstrap.Bootstrap;
|
||||||
|
import io.netty.channel.ChannelFuture;
|
||||||
|
import io.netty.channel.ChannelFutureListener;
|
||||||
|
import io.netty.channel.EventLoopGroup;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class ReconnectManager {
|
||||||
|
|
||||||
|
private final Bootstrap bootstrap;
|
||||||
|
private final EventLoopGroup group;
|
||||||
|
private final String host;
|
||||||
|
private final int port;
|
||||||
|
private final ClientHandler handler;
|
||||||
|
|
||||||
|
private int attempt = 0;
|
||||||
|
private static final int MAX_ATTEMPTS = Integer.MAX_VALUE;
|
||||||
|
private static final int BASE_DELAY_SECONDS = 1;
|
||||||
|
private static final int MAX_DELAY_SECONDS = 30;
|
||||||
|
|
||||||
|
public ReconnectManager(Bootstrap bootstrap, EventLoopGroup group,
|
||||||
|
String host, int port, ClientHandler handler) {
|
||||||
|
this.bootstrap = bootstrap;
|
||||||
|
this.group = group;
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void scheduleReconnect() {
|
||||||
|
if (attempt >= MAX_ATTEMPTS) {
|
||||||
|
System.out.println("Max reconnect attempts reached, giving up.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int delay = Math.min(BASE_DELAY_SECONDS * (int) Math.pow(2, attempt), MAX_DELAY_SECONDS);
|
||||||
|
attempt++;
|
||||||
|
|
||||||
|
System.out.println("Reconnect attempt " + attempt + " in " + delay + "s");
|
||||||
|
|
||||||
|
group.schedule(() -> {
|
||||||
|
if (!Thread.currentThread().isInterrupted()) {
|
||||||
|
tryReconnect();
|
||||||
|
}
|
||||||
|
}, delay, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryReconnect() {
|
||||||
|
bootstrap.connect(host, port).addListener(new ChannelFutureListener() {
|
||||||
|
@Override
|
||||||
|
public void operationComplete(ChannelFuture future) {
|
||||||
|
if (future.isSuccess()) {
|
||||||
|
System.out.println("Reconnect successful!");
|
||||||
|
attempt = 0;
|
||||||
|
} else {
|
||||||
|
System.out.println("Reconnect failed – will retry");
|
||||||
|
scheduleReconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetAttempts() {
|
||||||
|
attempt = 0;
|
||||||
|
System.out.println("Reconnect attempts reset");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package jnet.client.client;
|
||||||
|
|
||||||
|
import io.netty.handler.ssl.SslContext;
|
||||||
|
import io.netty.handler.ssl.SslContextBuilder;
|
||||||
|
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
|
||||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import java.security.Security;
|
||||||
|
|
||||||
|
public class SslUtil {
|
||||||
|
static {
|
||||||
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SslContext createClientSslContext() throws Exception {
|
||||||
|
return SslContextBuilder.forClient()
|
||||||
|
.trustManager(InsecureTrustManagerFactory.INSTANCE) // DŮLEŽITÉ!
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -5,31 +5,47 @@ import java.awt.BorderLayout;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.ListIterator;
|
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import jnet.lib.EventComparator;
|
import jnet.lib.EventComparator;
|
||||||
import jnet.lib.object.Map;
|
import jnet.lib.Status;
|
||||||
import jnet.lib.object.MapObject;
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
public class EventsPanel extends JPanel {
|
public class EventsPanel extends JPanel {
|
||||||
|
|
||||||
|
private static final int DEFAULT_LIMIT = 50;
|
||||||
|
|
||||||
|
private DefaultTableModel tableModel;
|
||||||
|
private JTable table;
|
||||||
|
|
||||||
public EventsPanel() {
|
public EventsPanel() {
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
int limit = 50;
|
String[] column = {"Začátek", "Konec", "Délka", "Stav", "Mapa", "Zařízení"};
|
||||||
|
tableModel = new DefaultTableModel(column, 0) {
|
||||||
String column[] = {"Začátek", "Konec", "Délka", "Stav", "Mapa", "Zařízení"};
|
|
||||||
DefaultTableModel tableModel = new DefaultTableModel(column, 0) {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int column) {
|
public boolean isCellEditable(int row, int column) {
|
||||||
//all cells false
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
table = new JTable(tableModel);
|
||||||
|
table.setRowHeight(30);
|
||||||
|
add(new JScrollPane(table), BorderLayout.CENTER);
|
||||||
|
|
||||||
|
refresh(); // naplní tabulku
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obnoví obsah tabulky podle aktuálních dat v Client.events.
|
||||||
|
*/
|
||||||
|
public void refresh() {
|
||||||
|
tableModel.setRowCount(0); // smaže všechny řádky
|
||||||
|
|
||||||
|
int limit = DEFAULT_LIMIT;
|
||||||
Collections.sort(Client.events, new EventComparator());
|
Collections.sort(Client.events, new EventComparator());
|
||||||
Collections.reverse(Client.events);
|
Collections.reverse(Client.events);
|
||||||
|
|
||||||
|
|
@ -38,25 +54,25 @@ public class EventsPanel extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < limit; i++) {
|
for (int i = 0; i < limit; i++) {
|
||||||
String[] info = getObjetInfo(Client.events.get(i).getObject());
|
String[] info = getObjetInfo(Client.events.get(i).getNode());
|
||||||
Object[] d = {
|
// pokud se objekt nenajde, info bude null – ošetříme
|
||||||
|
if (info == null) {
|
||||||
|
info = new String[]{"Neznámá", "Neznámé"};
|
||||||
|
}
|
||||||
|
Object[] row = {
|
||||||
getDate(Client.events.get(i).getStart()),
|
getDate(Client.events.get(i).getStart()),
|
||||||
getDate(Client.events.get(i).getEnd()),
|
getDate(Client.events.get(i).getEnd()),
|
||||||
getDuration(Client.events.get(i).getStart(), Client.events.get(i).getEnd()),
|
getDuration(Client.events.get(i).getStart(), Client.events.get(i).getEnd()),
|
||||||
Client.events.get(i).getDescription(),
|
Status.getStatusName(Client.events.get(i).getStatus()),
|
||||||
info[0],
|
info[0],
|
||||||
info[1]};
|
info[1]
|
||||||
tableModel.addRow(d);
|
};
|
||||||
|
tableModel.addRow(row);
|
||||||
}
|
}
|
||||||
|
tableModel.fireTableDataChanged();
|
||||||
JTable table = new JTable(tableModel);
|
|
||||||
table.setRowHeight(30);
|
|
||||||
|
|
||||||
this.setLayout(new BorderLayout()); // Ujistěte se, že používáte vhodný layout
|
|
||||||
this.add(new JScrollPane(table), BorderLayout.CENTER); // Ujistěte se, že je tabulka ve JScrollPane
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- stávající pomocné metody (getDate, getDuration, getObjetInfo) zůstávají beze změny --
|
||||||
private String getDate(long date) {
|
private String getDate(long date) {
|
||||||
if (date != 0) {
|
if (date != 0) {
|
||||||
SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
SimpleDateFormat ft = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
|
||||||
|
|
@ -68,31 +84,22 @@ public class EventsPanel extends JPanel {
|
||||||
private String getDuration(long startTime, long endTime) {
|
private String getDuration(long startTime, long endTime) {
|
||||||
if (endTime != 0) {
|
if (endTime != 0) {
|
||||||
long difference = endTime - startTime;
|
long difference = endTime - startTime;
|
||||||
|
|
||||||
// převod na sekundy, minuty, hodiny
|
|
||||||
long seconds = difference / 1000;
|
long seconds = difference / 1000;
|
||||||
long minutes = difference / (1000 * 60);
|
long minutes = difference / (1000 * 60);
|
||||||
long hours = difference / (1000 * 60 * 60);
|
long hours = difference / (1000 * 60 * 60);
|
||||||
|
|
||||||
SimpleDateFormat ft = new SimpleDateFormat("HH:mm:ss");
|
|
||||||
return hours + "h " + minutes + "m " + seconds + "s";
|
return hours + "h " + minutes + "m " + seconds + "s";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] getObjetInfo(int id) {
|
private String[] getObjetInfo(int id) {
|
||||||
for (Map map : Client.maps) {
|
for (Site map : Client.site) {
|
||||||
for (MapObject mapObject : map.getObjects()) {
|
for (Node mapObject : map.getNode()) {
|
||||||
if (mapObject.getId() == id) {
|
if (mapObject.getId() == id) {
|
||||||
if (map.getId() == mapObject.getMap()) {
|
return new String[]{map.getName(), mapObject.getName()};
|
||||||
String[] data = {map.getName(), mapObject.getName()};
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package jnet.client.gui;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.gui.dialog.DialogLogin;
|
||||||
|
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Horní lišta s ovládacími tlačítky.
|
||||||
|
*/
|
||||||
|
public class MenuPanel extends JPanel {
|
||||||
|
|
||||||
|
public MenuPanel() {
|
||||||
|
setPreferredSize(new Dimension(50, 50));
|
||||||
|
setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||||
|
|
||||||
|
// Tlačítko Připojit / Odpojit
|
||||||
|
add(createIconButton("img/connect.png", "Připojit", e -> {
|
||||||
|
if (Client.nettyClient != null && Client.nettyClient.isConnected()) {
|
||||||
|
Client.nettyClient.disconnect();
|
||||||
|
}
|
||||||
|
// Otevře přihlašovací dialog
|
||||||
|
SwingUtilities.invokeLater(() -> new DialogLogin().setVisible(true));
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Tlačítko Nastavení (klienta)
|
||||||
|
add(createIconButton("img/settings.png", "Nastavení", e
|
||||||
|
-> SwingUtilities.invokeLater(Window::showSettings)));
|
||||||
|
|
||||||
|
// Tlačítko Log (zatím prázdné)
|
||||||
|
add(createIconButton("img/log.png", "Log", e
|
||||||
|
-> SwingUtilities.invokeLater(Window::showLog)));
|
||||||
|
|
||||||
|
// Tlačítko Nastavení serveru
|
||||||
|
if (Client.user.isEditServer()) {
|
||||||
|
add(createIconButton("img/server_settings.png", "Nastavení serveru", e
|
||||||
|
-> SwingUtilities.invokeLater(() -> Window.showServerSettings(ServerSettingsPanel.TAB_DEFAULT))));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rebuild() {
|
||||||
|
removeAll();
|
||||||
|
// znovu přidáme tlačítka podle Client.user
|
||||||
|
// ...
|
||||||
|
revalidate();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pomocná metoda pro vytvoření tlačítka s ikonou.
|
||||||
|
*/
|
||||||
|
private JButton createIconButton(String resourcePath, String tooltip, ActionListener action) {
|
||||||
|
try {
|
||||||
|
var image = ImageIO.read(ResourceLoader.getFile(resourcePath));
|
||||||
|
JButton button = new JButton(new ImageIcon(image));
|
||||||
|
button.setFocusPainted(false);
|
||||||
|
button.setContentAreaFilled(false);
|
||||||
|
button.setToolTipText(tooltip);
|
||||||
|
button.addActionListener(action);
|
||||||
|
return button;
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("Nepodařilo se načíst obrázek: " + resourcePath);
|
||||||
|
// Fallback – tlačítko s textem
|
||||||
|
JButton fallback = new JButton(tooltip);
|
||||||
|
fallback.addActionListener(action);
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,213 @@
|
||||||
|
package jnet.client.gui;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JFileChooser;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JSlider;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
|
import jnet.lib.ApacheConfig;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
|
|
||||||
|
public class SettingsPanel extends JPanel {
|
||||||
|
|
||||||
|
public SettingsPanel() {
|
||||||
|
show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void show() {
|
||||||
|
this.setLayout(null);
|
||||||
|
this.setPreferredSize(new Dimension(300, 800));
|
||||||
|
|
||||||
|
// ===== NADPIS =====
|
||||||
|
JLabel nadpisLabel = new JLabel("Obecné nastavení");
|
||||||
|
nadpisLabel.setBounds(20, 20, 400, 25);
|
||||||
|
nadpisLabel.setFont(nadpisLabel.getFont().deriveFont(20f));
|
||||||
|
this.add(nadpisLabel);
|
||||||
|
|
||||||
|
// ===== CHECKBOX =====
|
||||||
|
JCheckBox runMinimalized = new JCheckBox("Spouštět minimalizovaně");
|
||||||
|
runMinimalized.setBounds(30, getNextY(nadpisLabel) + 20, 400, 25);
|
||||||
|
runMinimalized.setSelected(Client.config.getBoolean("start_minimalized"));
|
||||||
|
this.add(runMinimalized);
|
||||||
|
|
||||||
|
JCheckBox openMaxWindow = new JCheckBox("Otevírat maximalizované okno");
|
||||||
|
openMaxWindow.setBounds(30, getNextY(runMinimalized), 400, 25);
|
||||||
|
openMaxWindow.setSelected(Client.config.getBoolean("open_maximalized"));
|
||||||
|
this.add(openMaxWindow);
|
||||||
|
|
||||||
|
JCheckBox enableDebug = new JCheckBox("Debug režim");
|
||||||
|
enableDebug.setBounds(30, getNextY(openMaxWindow), 400, 25);
|
||||||
|
enableDebug.setSelected(Client.config.getBoolean("debug"));
|
||||||
|
this.add(enableDebug);
|
||||||
|
|
||||||
|
// ===== ZVUKY =====
|
||||||
|
JLabel nadpisSoundLabel = new JLabel("Zvuky");
|
||||||
|
nadpisSoundLabel.setBounds(20, getNextY(enableDebug) + 20, 400, 25);
|
||||||
|
nadpisSoundLabel.setFont(nadpisLabel.getFont().deriveFont(20f));
|
||||||
|
this.add(nadpisSoundLabel);
|
||||||
|
|
||||||
|
JCheckBox enableSounds = new JCheckBox("Povolit zvuky");
|
||||||
|
enableSounds.setBounds(30, getNextY(nadpisSoundLabel), 400, 25);
|
||||||
|
enableSounds.setSelected(Client.config.getBoolean("sound"));
|
||||||
|
this.add(enableSounds);
|
||||||
|
|
||||||
|
// ===== HLASITOST =====
|
||||||
|
JLabel hlasLabel = new JLabel("Hlasitost");
|
||||||
|
hlasLabel.setBounds(30, getNextY(enableSounds), 80, 25);
|
||||||
|
this.add(hlasLabel);
|
||||||
|
|
||||||
|
double volume = Client.config.getDouble("sound.volume", 0.75);
|
||||||
|
int volumePercent = (int) (volume * 100);
|
||||||
|
|
||||||
|
JSlider volumeSlider = new JSlider(JSlider.HORIZONTAL, 0, 100, 50);
|
||||||
|
volumeSlider.setBounds(110, getNextY(enableSounds), 200, 50);
|
||||||
|
volumeSlider.setValue(volumePercent);
|
||||||
|
volumeSlider.setPaintTrack(true);
|
||||||
|
volumeSlider.setPaintTicks(true);
|
||||||
|
volumeSlider.setPaintLabels(true);
|
||||||
|
volumeSlider.setMajorTickSpacing(50);
|
||||||
|
|
||||||
|
JLabel sliderValue = new JLabel(volumeSlider.getValue() + " %");
|
||||||
|
sliderValue.setBounds(350, getNextY(enableSounds), 50, 25);
|
||||||
|
this.add(sliderValue);
|
||||||
|
|
||||||
|
volumeSlider.addChangeListener(e -> sliderValue.setText(volumeSlider.getValue() + " %"));
|
||||||
|
this.add(volumeSlider);
|
||||||
|
|
||||||
|
// ===== VÝBĚR SOUBORŮ (POUŽÍVÁME SPRÁVNÉ KLÍČE) =====
|
||||||
|
|
||||||
|
// --- 1. Vše online ---
|
||||||
|
JLabel fileAllOkLabel = new JLabel("Zvuk vše online:");
|
||||||
|
fileAllOkLabel.setBounds(30, getNextY(volumeSlider), 150, 25);
|
||||||
|
this.add(fileAllOkLabel);
|
||||||
|
|
||||||
|
JTextField filePathFieldAllOk = new JTextField(25);
|
||||||
|
filePathFieldAllOk.setEditable(false);
|
||||||
|
filePathFieldAllOk.setBounds(200, getNextY(volumeSlider), 200, 25);
|
||||||
|
filePathFieldAllOk.setText(Client.config.getString("sound.online.all", ""));
|
||||||
|
this.add(filePathFieldAllOk);
|
||||||
|
|
||||||
|
JButton selectFileButtonAllOk = new JButton("Vyber soubor");
|
||||||
|
selectFileButtonAllOk.setBounds(420, getNextY(volumeSlider), 80, 25);
|
||||||
|
selectFileButtonAllOk.addActionListener(e -> {
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setFileFilter(new FileNameExtensionFilter("Zvukové soubory WAV", "wav"));
|
||||||
|
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
filePathFieldAllOk.setText(fc.getSelectedFile().getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
// při zrušení vrátíme původní hodnotu z konfigurace
|
||||||
|
filePathFieldAllOk.setText(Client.config.getString("sound.online.all", ""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(selectFileButtonAllOk);
|
||||||
|
|
||||||
|
// --- 2. Jeden online ---
|
||||||
|
JLabel fileOneOkLabel = new JLabel("Zvuk jeden online:");
|
||||||
|
fileOneOkLabel.setBounds(30, getNextY(filePathFieldAllOk), 150, 25);
|
||||||
|
this.add(fileOneOkLabel);
|
||||||
|
|
||||||
|
JTextField filePathFieldOneOk = new JTextField(25);
|
||||||
|
filePathFieldOneOk.setEditable(false);
|
||||||
|
filePathFieldOneOk.setBounds(200, getNextY(filePathFieldAllOk), 200, 25);
|
||||||
|
filePathFieldOneOk.setText(Client.config.getString("sound.online.one", ""));
|
||||||
|
this.add(filePathFieldOneOk);
|
||||||
|
|
||||||
|
JButton selectFileButtonOneOk = new JButton("Vyber soubor");
|
||||||
|
selectFileButtonOneOk.setBounds(420, getNextY(filePathFieldAllOk), 80, 25);
|
||||||
|
selectFileButtonOneOk.addActionListener(e -> {
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setFileFilter(new FileNameExtensionFilter("Zvukové soubory WAV", "wav"));
|
||||||
|
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
filePathFieldOneOk.setText(fc.getSelectedFile().getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
filePathFieldOneOk.setText(Client.config.getString("sound.online.one", ""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(selectFileButtonOneOk);
|
||||||
|
|
||||||
|
// --- 3. První offline ---
|
||||||
|
JLabel fileFirstKoLabel = new JLabel("Zvuk první offline:");
|
||||||
|
fileFirstKoLabel.setBounds(30, getNextY(filePathFieldOneOk), 150, 25);
|
||||||
|
this.add(fileFirstKoLabel);
|
||||||
|
|
||||||
|
JTextField filePathFieldFirstKo = new JTextField(25);
|
||||||
|
filePathFieldFirstKo.setEditable(false);
|
||||||
|
filePathFieldFirstKo.setBounds(200, getNextY(filePathFieldOneOk), 200, 25);
|
||||||
|
filePathFieldFirstKo.setText(Client.config.getString("sound.offline.first", ""));
|
||||||
|
this.add(filePathFieldFirstKo);
|
||||||
|
|
||||||
|
JButton selectFileButtonFirstKo = new JButton("Vyber soubor");
|
||||||
|
selectFileButtonFirstKo.setBounds(420, getNextY(filePathFieldOneOk), 80, 25);
|
||||||
|
selectFileButtonFirstKo.addActionListener(e -> {
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setFileFilter(new FileNameExtensionFilter("Zvukové soubory WAV", "wav"));
|
||||||
|
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
filePathFieldFirstKo.setText(fc.getSelectedFile().getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
filePathFieldFirstKo.setText(Client.config.getString("sound.offline.first", ""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(selectFileButtonFirstKo);
|
||||||
|
|
||||||
|
// --- 4. Další offline ---
|
||||||
|
JLabel fileNextKoLabel = new JLabel("Zvuk další offline:");
|
||||||
|
fileNextKoLabel.setBounds(30, getNextY(filePathFieldFirstKo), 150, 25);
|
||||||
|
this.add(fileNextKoLabel);
|
||||||
|
|
||||||
|
JTextField filePathFieldNextKo = new JTextField(25);
|
||||||
|
filePathFieldNextKo.setEditable(false);
|
||||||
|
filePathFieldNextKo.setBounds(200, getNextY(filePathFieldFirstKo), 200, 25);
|
||||||
|
filePathFieldNextKo.setText(Client.config.getString("sound.offline.other", ""));
|
||||||
|
this.add(filePathFieldNextKo);
|
||||||
|
|
||||||
|
JButton selectFileButtonNextKo = new JButton("Vyber soubor");
|
||||||
|
selectFileButtonNextKo.setBounds(420, getNextY(filePathFieldFirstKo), 80, 25);
|
||||||
|
selectFileButtonNextKo.addActionListener(e -> {
|
||||||
|
JFileChooser fc = new JFileChooser();
|
||||||
|
fc.setFileFilter(new FileNameExtensionFilter("Zvukové soubory WAV", "wav"));
|
||||||
|
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
filePathFieldNextKo.setText(fc.getSelectedFile().getAbsolutePath());
|
||||||
|
} else {
|
||||||
|
filePathFieldNextKo.setText(Client.config.getString("sound.offline.other", ""));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(selectFileButtonNextKo);
|
||||||
|
|
||||||
|
// ===== TLAČÍTKO ULOŽIT =====
|
||||||
|
JButton saveButton = new JButton("Uložit");
|
||||||
|
saveButton.setBounds(20, getNextY(filePathFieldNextKo) + 50, 100, 30);
|
||||||
|
saveButton.addActionListener(e -> {
|
||||||
|
// Uložíme všechny hodnoty z komponent do konfigurace
|
||||||
|
Client.config.setProperty("debug", enableDebug.isSelected());
|
||||||
|
Client.config.setProperty("start_minimalized", runMinimalized.isSelected());
|
||||||
|
Client.config.setProperty("open_maximalized", openMaxWindow.isSelected());
|
||||||
|
Client.config.setProperty("sound", enableSounds.isSelected());
|
||||||
|
Client.config.setProperty("sound.volume", volumeSlider.getValue() / 100.0);
|
||||||
|
|
||||||
|
// ===== ukládání cest =====
|
||||||
|
Client.config.setProperty("sound.online.all", filePathFieldAllOk.getText());
|
||||||
|
Client.config.setProperty("sound.online.one", filePathFieldOneOk.getText());
|
||||||
|
Client.config.setProperty("sound.offline.first", filePathFieldFirstKo.getText());
|
||||||
|
Client.config.setProperty("sound.offline.other", filePathFieldNextKo.getText());
|
||||||
|
|
||||||
|
try {
|
||||||
|
ApacheConfig.saveProperties(Client.config);
|
||||||
|
LogFile.printInfo("Nastavení uloženo.");
|
||||||
|
} catch (ConfigurationException ex) {
|
||||||
|
LogFile.printErr("Nastavení nebylo uloženo. " + ex.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(saveButton);
|
||||||
|
}
|
||||||
|
private int getNextY(Component p) {
|
||||||
|
return p.getY() + p.getHeight() + 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package jnet.client.gui;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import jnet.client.gui.dialog.DialogOnlineClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spodní stavová lišta – zprávy a počet online klientů.
|
||||||
|
*/
|
||||||
|
public class StatusBar extends JPanel {
|
||||||
|
|
||||||
|
private final JLabel messageLabel = new JLabel();
|
||||||
|
private final JLabel onlineLabel = new JLabel();
|
||||||
|
|
||||||
|
public StatusBar() {
|
||||||
|
setPreferredSize(new Dimension(100, 35));
|
||||||
|
setBorder(BorderFactory.createEtchedBorder());
|
||||||
|
setLayout(new FlowLayout(FlowLayout.LEFT, 10, 5));
|
||||||
|
|
||||||
|
messageLabel.setPreferredSize(new Dimension(200, 25));
|
||||||
|
add(messageLabel);
|
||||||
|
|
||||||
|
add(Box.createHorizontalGlue());
|
||||||
|
|
||||||
|
// tlacitko zobrazujici klienty
|
||||||
|
try {
|
||||||
|
var img = ImageIO.read(ResourceLoader.getFile("img/online_clients.png"));
|
||||||
|
JButton btnOnline = new JButton(new ImageIcon(img));
|
||||||
|
btnOnline.setFocusPainted(false);
|
||||||
|
btnOnline.setContentAreaFilled(false);
|
||||||
|
btnOnline.setBorderPainted(false);
|
||||||
|
btnOnline.setToolTipText("Online uživatelé");
|
||||||
|
btnOnline.addActionListener(e
|
||||||
|
-> new DialogOnlineClients());
|
||||||
|
add(btnOnline);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("Nepodařilo se načíst ikonu online_clients.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
onlineLabel.setPreferredSize(new Dimension(150, 25));
|
||||||
|
add(onlineLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String text) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
messageLabel.setText(text);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnlineCount() {
|
||||||
|
SwingUtilities.invokeLater(()
|
||||||
|
-> onlineLabel.setText("Klientů online: " + Client.onlineClients.size())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,12 +2,15 @@ package jnet.client.gui;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import jnet.client.Client;
|
import jnet.client.Client;
|
||||||
import jnet.lib.LogFile;
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
import jnet.lib.Status;
|
import jnet.lib.Status;
|
||||||
import jnet.lib.object.Map;
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
public class Tray {
|
public class Tray {
|
||||||
|
|
||||||
|
|
@ -35,12 +38,18 @@ public class Tray {
|
||||||
trayIcon = new TrayIcon(loadImage("/img/flag_gray.png"), Client.APP_NAME, menu);
|
trayIcon = new TrayIcon(loadImage("/img/flag_gray.png"), Client.APP_NAME, menu);
|
||||||
trayIcon.setImageAutoSize(true);
|
trayIcon.setImageAutoSize(true);
|
||||||
trayIcon.addActionListener(e -> {
|
trayIcon.addActionListener(e -> {
|
||||||
// Dvojklik - obnovit/minimalizovat okno
|
boolean visible = Client.okno.isVisible();
|
||||||
Client.okno.setVisible(!Client.okno.isVisible());
|
Client.okno.setVisible(!visible);
|
||||||
|
if (!visible) {
|
||||||
|
// Okno bylo skryté – po zobrazení ho uvedeme do normálního režimu
|
||||||
|
Client.okno.setExtendedState(JFrame.NORMAL);
|
||||||
|
Client.okno.toFront();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tray = SystemTray.getSystemTray();
|
tray = SystemTray.getSystemTray();
|
||||||
tray.add(trayIcon);
|
tray.add(trayIcon);
|
||||||
|
refresh();
|
||||||
|
|
||||||
} catch (IOException | AWTException ex) {
|
} catch (IOException | AWTException ex) {
|
||||||
LogFile.printErr("TrayIcon error: " + ex.getMessage());
|
LogFile.printErr("TrayIcon error: " + ex.getMessage());
|
||||||
|
|
@ -48,13 +57,20 @@ public class Tray {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static BufferedImage loadImage(String path) throws IOException {
|
private static BufferedImage loadImage(String path) throws IOException {
|
||||||
try (var input = Tray.class.getResourceAsStream(path)) {
|
|
||||||
if (input == null) {
|
File input = ResourceLoader.getFile(path);
|
||||||
throw new IOException("Soubor nenalezen: " + path);
|
if (input == null) {
|
||||||
}
|
throw new IOException("Soubor nenalezen: " + path);
|
||||||
return ImageIO.read(input);
|
|
||||||
}
|
}
|
||||||
|
return ImageIO.read(input);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void showMessage(String title, String message) {
|
||||||
|
if (trayIcon != null) {
|
||||||
|
trayIcon.displayMessage(title, message, TrayIcon.MessageType.INFO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setIcon(String icon) {
|
public static void setIcon(String icon) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -81,17 +97,17 @@ public class Tray {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void refresh() {
|
public static void refresh() {
|
||||||
setStatusOnline(); // Výchozí stav
|
for (Site map : Client.site) {
|
||||||
|
int status = map.getSiteState();
|
||||||
for (Map map : Client.maps) {
|
|
||||||
int status = map.getStatus();
|
|
||||||
if (status == Status.OFFLINE) {
|
if (status == Status.OFFLINE) {
|
||||||
setStatusOffline();
|
setStatusOffline();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (status == Status.WARNING) {
|
if (status == Status.WARNING) {
|
||||||
setStatusWarning();
|
setStatusWarning();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
setStatusOnline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,392 @@
|
||||||
|
package jnet.client.gui;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.gui.dialog.DialogSite;
|
||||||
|
import jnet.client.gui.maptree.MapTree;
|
||||||
|
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import java.io.IOException;
|
||||||
|
import jnet.client.gui.mapview.MapView;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hlavní okno aplikace – implementováno jako singleton.
|
||||||
|
*/
|
||||||
|
public class Window extends JFrame {
|
||||||
|
|
||||||
|
private static Window instance;
|
||||||
|
|
||||||
|
private JSplitPane splitPane;
|
||||||
|
private StatusBar statusBar;
|
||||||
|
private MapTree mapTree;
|
||||||
|
private MenuPanel menuPanel;
|
||||||
|
private static ServerSettingsPanel currentServerSettingsPanel;
|
||||||
|
private static EventsPanel currentEventsPanel;
|
||||||
|
|
||||||
|
// Nové: reference na aktuální MapView a jeho scroll panel
|
||||||
|
private static MapView currentMapView;
|
||||||
|
private static JScrollPane currentMapViewScrollPane;
|
||||||
|
|
||||||
|
private Window() {
|
||||||
|
super(Client.APP_NAME);
|
||||||
|
setIcon();
|
||||||
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
|
addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
handleClosing();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
initComponents();
|
||||||
|
|
||||||
|
// pack();
|
||||||
|
// setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
menuPanel = new MenuPanel();
|
||||||
|
add(menuPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
|
||||||
|
splitPane.setDividerSize(5);
|
||||||
|
|
||||||
|
JPanel leftPanel = new JPanel(new BorderLayout());
|
||||||
|
leftPanel.setBackground(Color.WHITE);
|
||||||
|
leftPanel.setPreferredSize(new Dimension(200, 250));
|
||||||
|
|
||||||
|
mapTree = new MapTree();
|
||||||
|
leftPanel.add(mapTree, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
if (Client.user != null && Client.user.isAddMap()) {
|
||||||
|
JButton addSiteButton = new JButton("Přidat mapu");
|
||||||
|
addSiteButton.addActionListener(e -> new DialogSite().setVisible(true));
|
||||||
|
leftPanel.add(addSiteButton, BorderLayout.SOUTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
splitPane.add(leftPanel, JSplitPane.LEFT);
|
||||||
|
|
||||||
|
// Pravý panel – prázdný
|
||||||
|
splitPane.add(new JPanel(), JSplitPane.RIGHT);
|
||||||
|
|
||||||
|
add(splitPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
if (statusBar == null) {
|
||||||
|
statusBar = new StatusBar();
|
||||||
|
}
|
||||||
|
add(statusBar, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
currentServerSettingsPanel = null;
|
||||||
|
currentEventsPanel = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Window getInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
instance = new Window();
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadWindow() {
|
||||||
|
getContentPane().removeAll();
|
||||||
|
initComponents();
|
||||||
|
revalidate();
|
||||||
|
repaint();
|
||||||
|
currentEventsPanel = null;
|
||||||
|
// Po znovunačtení okna zrušíme referenci na MapView, protože byl zničen
|
||||||
|
currentMapView = null;
|
||||||
|
currentMapViewScrollPane = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Soukromé pomocné metody
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private void setIcon() {
|
||||||
|
try {
|
||||||
|
var icon = ImageIO.read(ResourceLoader.getFile("img/app.png"));
|
||||||
|
setIconImage(icon);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("APP icon exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleClosing() {
|
||||||
|
int n = JOptionPane.showOptionDialog(this,
|
||||||
|
"Ukončit nebo minimalizovat do lišty?",
|
||||||
|
"Ukončit",
|
||||||
|
JOptionPane.YES_NO_OPTION,
|
||||||
|
JOptionPane.QUESTION_MESSAGE,
|
||||||
|
null,
|
||||||
|
new Object[]{"Ukončit", "Minimalizovat"},
|
||||||
|
"Minimalizovat");
|
||||||
|
if (n == 0) {
|
||||||
|
LogFile.printInfo("Ukončit");
|
||||||
|
System.exit(0);
|
||||||
|
} else if (n == 1) {
|
||||||
|
// Skryjeme okno – zůstane pouze tray ikona
|
||||||
|
setVisible(false);
|
||||||
|
// Volitelně můžeme zobrazit bublinu s informací
|
||||||
|
Tray.showMessage("jNet client", "Aplikace byla minimalizována do lišty.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setVisible(boolean b) {
|
||||||
|
super.setVisible(b);
|
||||||
|
if (b) {
|
||||||
|
// Pro jistotu zpozdíme maximalizaci, aby se provedla až po dokončení layoutu
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||||
|
toFront();
|
||||||
|
requestFocus();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Statické přístupové metody pro ostatní komponenty
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
public static void setStatusBarMessage(String message) {
|
||||||
|
if (instance != null && instance.statusBar != null) {
|
||||||
|
instance.statusBar.setMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void reloadOnlineClients() {
|
||||||
|
if (instance != null && instance.statusBar != null) {
|
||||||
|
instance.statusBar.setOnlineCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Nastaví nebo aktualizuje MapView pro daný Site. Odstraní starý pravý
|
||||||
|
* panel a vloží nový MapView.
|
||||||
|
*/
|
||||||
|
public static void setMapView(Site site) {
|
||||||
|
if (instance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
// Odstraníme starý pravý panel (pokud existuje)
|
||||||
|
Component right = instance.splitPane.getRightComponent();
|
||||||
|
if (right != null) {
|
||||||
|
instance.splitPane.remove(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Vytvoříme nový MapView
|
||||||
|
currentMapView = new MapView(site);
|
||||||
|
currentMapViewScrollPane = new JScrollPane(currentMapView);
|
||||||
|
instance.splitPane.add(currentMapViewScrollPane, JSplitPane.RIGHT);
|
||||||
|
|
||||||
|
instance.splitPane.revalidate();
|
||||||
|
instance.splitPane.repaint();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualizuje stav uzlu v aktuálním MapView. Volá se z handleru po příchodu
|
||||||
|
* zprávy o změně stavu.
|
||||||
|
*/
|
||||||
|
public static void updateNodeStatusInMapView(int nodeId, int newStatus) {
|
||||||
|
if (currentMapView != null) {
|
||||||
|
currentMapView.updateNodeStatus(nodeId, newStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualizuje pozici uzlu v aktuálním MapView. Volá se z handleru po
|
||||||
|
* příchodu zprávy o změně stavu.
|
||||||
|
*/
|
||||||
|
public static void updateNodePositionInMapView(int nodeId, int x, int y) {
|
||||||
|
if (currentMapView != null) {
|
||||||
|
currentMapView.updateNodePosition(nodeId, x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualizuje pozici uzlu v aktuálním MapView. Volá se z handleru po
|
||||||
|
* příchodu zprávy o změně stavu.
|
||||||
|
*/
|
||||||
|
public static void addNodeInMapView(Node node) {
|
||||||
|
if (currentMapView != null) {
|
||||||
|
currentMapView.addNodeFromServer(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kompletně obnoví MapView z nového Site objektu (např. po hromadné změně).
|
||||||
|
*/
|
||||||
|
public static void refreshMapView(Site site) {
|
||||||
|
if (currentMapView != null) {
|
||||||
|
currentMapView.refreshFromServer(site);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obnoví aktuální zobrazení mapy podle dat ze serveru. Pokud není žádná
|
||||||
|
* mapa otevřena, nic neprovede.
|
||||||
|
*/
|
||||||
|
public static void refreshCurrentMapView() {
|
||||||
|
if (currentMapView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
Site currentSite = currentMapView.getModel().getSite();
|
||||||
|
if (currentSite == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Najdeme aktuální verzi site v Client.site
|
||||||
|
for (Site s : Client.site) {
|
||||||
|
if (s.getId() == currentSite.getId()) {
|
||||||
|
currentMapView.refreshFromServer(s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* odebere node z mapview
|
||||||
|
*/
|
||||||
|
public static void removeNodeFromMapView(int nodeId) {
|
||||||
|
if (currentMapView != null) {
|
||||||
|
currentMapView.removeNodeFromServer(nodeId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showSettings() {
|
||||||
|
if (instance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
JScrollPane panel = new JScrollPane(new SettingsPanel());
|
||||||
|
// Rychlejší posouvání šipkami a kolečkem
|
||||||
|
panel.getVerticalScrollBar().setUnitIncrement(20);
|
||||||
|
// Rychlejší posouvání Page Up / Page Down
|
||||||
|
panel.getVerticalScrollBar().setBlockIncrement(100);
|
||||||
|
// Povolení rychlejšího kolečka (volitelné)
|
||||||
|
panel.putClientProperty("JScrollBar.fastWheelScrolling", Boolean.TRUE);
|
||||||
|
instance.splitPane.add(panel, JSplitPane.RIGHT);
|
||||||
|
instance.splitPane.revalidate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showLog() {
|
||||||
|
if (instance == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
Component right = instance.splitPane.getRightComponent();
|
||||||
|
if (right != null) {
|
||||||
|
instance.splitPane.remove(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentEventsPanel == null) {
|
||||||
|
currentEventsPanel = new EventsPanel();
|
||||||
|
} else {
|
||||||
|
currentEventsPanel.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
instance.splitPane.add(currentEventsPanel, JSplitPane.RIGHT);
|
||||||
|
instance.splitPane.revalidate();
|
||||||
|
instance.splitPane.repaint();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showServerSettings(int tab) {
|
||||||
|
if (instance == null) {
|
||||||
|
System.err.println("instance is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
// if (currentServerSettingsPanel == null) {
|
||||||
|
currentServerSettingsPanel = new ServerSettingsPanel();
|
||||||
|
//JScrollPane scroll = new JScrollPane(currentServerSettingsPanel);
|
||||||
|
instance.splitPane.add(currentServerSettingsPanel, JSplitPane.RIGHT);
|
||||||
|
instance.splitPane.revalidate();
|
||||||
|
// }
|
||||||
|
currentServerSettingsPanel.setTable(tab);
|
||||||
|
switch (tab) {
|
||||||
|
case ServerSettingsPanel.TAB_DEVICE_TYPE:
|
||||||
|
currentServerSettingsPanel.refreshDeviceTypes();
|
||||||
|
break;
|
||||||
|
case ServerSettingsPanel.TAB_USERS:
|
||||||
|
currentServerSettingsPanel.refreshUsers();
|
||||||
|
break;
|
||||||
|
case ServerSettingsPanel.TAB_SNMP_PROFILE:
|
||||||
|
currentServerSettingsPanel.refreshSnmpProfiles();
|
||||||
|
break;
|
||||||
|
case ServerSettingsPanel.TAB_SNMP_TEMPLATE:
|
||||||
|
currentServerSettingsPanel.refreshSnmpTemplates();
|
||||||
|
break;
|
||||||
|
case ServerSettingsPanel.TAB_LOG:
|
||||||
|
//currentServerSettingsPanel.refreshL();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void putServerLog(String[] log) {
|
||||||
|
if (currentServerSettingsPanel != null) {
|
||||||
|
currentServerSettingsPanel.putLog(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshDeviceTypes() {
|
||||||
|
if (currentServerSettingsPanel != null) {
|
||||||
|
currentServerSettingsPanel.refreshDeviceTypes();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshUsers() {
|
||||||
|
if (currentServerSettingsPanel != null) {
|
||||||
|
currentServerSettingsPanel.refreshUsers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshSnmpProfiles() {
|
||||||
|
if (currentServerSettingsPanel != null) {
|
||||||
|
currentServerSettingsPanel.refreshSnmpProfiles();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshSnmpTemplates() {
|
||||||
|
if (currentServerSettingsPanel != null) {
|
||||||
|
currentServerSettingsPanel.refreshSnmpTemplates();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshValueMap() {
|
||||||
|
if (currentServerSettingsPanel != null) {
|
||||||
|
currentServerSettingsPanel.refreshValueMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshMapTree() {
|
||||||
|
if (instance != null) {
|
||||||
|
instance.mapTree.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MapTree getMapTree() {
|
||||||
|
return instance != null ? instance.mapTree : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void refreshEventsIfVisible() {
|
||||||
|
if (currentEventsPanel != null && currentEventsPanel.isShowing()) {
|
||||||
|
currentEventsPanel.refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,33 +1,41 @@
|
||||||
package jnet.client.gui.dialog;
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
import java.awt.HeadlessException;
|
import java.awt.HeadlessException;
|
||||||
|
import java.awt.Image;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemEvent;
|
||||||
import java.awt.event.ItemListener;
|
import java.awt.event.ItemListener;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import jnet.client.Client;
|
import jnet.client.Client;
|
||||||
import jnet.client.network.NettyClient;
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
import jnet.lib.Message;
|
import jnet.lib.Message;
|
||||||
import jnet.lib.object.Connection;
|
import jnet.lib.ResourceLoader;
|
||||||
import jnet.lib.object.Map;
|
import jnet.lib.object.Interface;
|
||||||
import jnet.lib.object.MapObject;
|
import jnet.lib.object.Node;
|
||||||
import jnet.lib.snmp.Interface;
|
import jnet.lib.object.NodeConnection;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
public class ConnectionDialog extends JFrame {
|
public class DialogConnection extends JFrame {
|
||||||
|
|
||||||
private MapObject startObj;
|
private Node startObj;
|
||||||
private MapObject endObj;
|
private Node endObj;
|
||||||
private Boolean newObject;
|
private Boolean newObject;
|
||||||
private List<Interface> iface = new ArrayList<>();
|
private List<Interface> iface = new ArrayList<>();
|
||||||
private Connection connection = new Connection();
|
private NodeConnection connection = new NodeConnection();
|
||||||
|
private JLabel loadingLabel;
|
||||||
|
|
||||||
private JComboBox<String> typComboBox = new JComboBox<String>(new DefaultComboBoxModel(new String[]{
|
private JComboBox<String> typComboBox = new JComboBox<String>(new DefaultComboBoxModel(new String[]{
|
||||||
"Neznámé",
|
"Neznámé",
|
||||||
|
|
@ -47,30 +55,42 @@ public class ConnectionDialog extends JFrame {
|
||||||
private JComboBox<String> sourceDeviceComboBox = new JComboBox<>();
|
private JComboBox<String> sourceDeviceComboBox = new JComboBox<>();
|
||||||
private JComboBox<Item> sourceInterfaceComboBox = new JComboBox<>();
|
private JComboBox<Item> sourceInterfaceComboBox = new JComboBox<>();
|
||||||
|
|
||||||
public ConnectionDialog(MapObject startObj, MapObject endObj) throws HeadlessException {
|
// public DialogConnection(Node startObj, Node endObj, boolean newObject) throws HeadlessException {
|
||||||
this.startObj = startObj;
|
// this.startObj = startObj;
|
||||||
this.endObj = endObj;
|
// this.endObj = endObj;
|
||||||
this.newObject = true;
|
// this.newObject = newObject;
|
||||||
|
//
|
||||||
init();
|
// init();
|
||||||
}
|
// }
|
||||||
|
public DialogConnection(NodeConnection connection, boolean newObject) throws HeadlessException {
|
||||||
public ConnectionDialog(Connection connection) throws HeadlessException {
|
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.newObject = false;
|
this.newObject = newObject;
|
||||||
|
|
||||||
// nastaveni pocatecniho a koncoveho objektu podle id
|
// nastaveni pocatecniho a koncoveho objektu podle id
|
||||||
for (Map map : Client.maps) {
|
for (Site map : Client.site) {
|
||||||
for (MapObject object : map.getObjects()) {
|
for (Node object : map.getNode()) {
|
||||||
if (object.getId() == connection.getSourceObj()) {
|
if (object.getId() == connection.getNodeFrom()) {
|
||||||
this.startObj = object;
|
this.startObj = object;
|
||||||
}
|
}
|
||||||
if (object.getId() == connection.getDestinationObj()) {
|
if (object.getId() == connection.getNodeTo()) {
|
||||||
this.endObj = object;
|
this.endObj = object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sourceDeviceComboBox.setEnabled(false);
|
||||||
|
sourceInterfaceComboBox.setEnabled(false);
|
||||||
|
|
||||||
|
if (!newObject) {
|
||||||
|
if (connection.isReadTraffic()) {
|
||||||
|
readTraffic.setSelected(true);
|
||||||
|
sourceDeviceComboBox.setEnabled(true);
|
||||||
|
sourceDeviceComboBox.setSelectedItem(startObj.getName());
|
||||||
|
sourceInterfaceComboBox.setEnabled(true);
|
||||||
|
sourceInterfaceComboBox.setSelectedItem(connection.getTrafficIface());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -107,6 +127,17 @@ public class ConnectionDialog extends JFrame {
|
||||||
typLabel.setBounds(x, 100, 140, 25);
|
typLabel.setBounds(x, 100, 140, 25);
|
||||||
add(typLabel);
|
add(typLabel);
|
||||||
|
|
||||||
|
try {
|
||||||
|
loadingLabel = new JLabel();
|
||||||
|
loadingLabel.setBounds(410, 300, 35, 35);
|
||||||
|
Image image = ImageIO.read(ResourceLoader.getFile("/img/wait.png"));
|
||||||
|
loadingLabel.setIcon(new ImageIcon(image));
|
||||||
|
loadingLabel.setVisible(false);
|
||||||
|
add(loadingLabel);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr(ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
typComboBox.setBounds(200, 100, 200, 25);
|
typComboBox.setBounds(200, 100, 200, 25);
|
||||||
add(typComboBox);
|
add(typComboBox);
|
||||||
|
|
||||||
|
|
@ -132,7 +163,6 @@ public class ConnectionDialog extends JFrame {
|
||||||
|
|
||||||
sourceDeviceComboBox.addItem(startObj.getName());
|
sourceDeviceComboBox.addItem(startObj.getName());
|
||||||
sourceDeviceComboBox.addItem(endObj.getName());
|
sourceDeviceComboBox.addItem(endObj.getName());
|
||||||
sourceDeviceComboBox.setEnabled(false);
|
|
||||||
sourceDeviceComboBox.setBounds(200, 250, 200, 25);
|
sourceDeviceComboBox.setBounds(200, 250, 200, 25);
|
||||||
sourceDeviceComboBox.addActionListener(new ActionListener() {
|
sourceDeviceComboBox.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -146,7 +176,6 @@ public class ConnectionDialog extends JFrame {
|
||||||
sourceInterfaceLabel.setBounds(x, 300, 140, 25);
|
sourceInterfaceLabel.setBounds(x, 300, 140, 25);
|
||||||
add(sourceInterfaceLabel);
|
add(sourceInterfaceLabel);
|
||||||
|
|
||||||
sourceInterfaceComboBox.setEnabled(false);
|
|
||||||
sourceInterfaceComboBox.setBounds(200, 300, 200, 25);
|
sourceInterfaceComboBox.setBounds(200, 300, 200, 25);
|
||||||
add(sourceInterfaceComboBox);
|
add(sourceInterfaceComboBox);
|
||||||
|
|
||||||
|
|
@ -175,29 +204,31 @@ public class ConnectionDialog extends JFrame {
|
||||||
// nastaveni hodnot upravovaného spojení
|
// nastaveni hodnot upravovaného spojení
|
||||||
typComboBox.setSelectedIndex(connection.getType());
|
typComboBox.setSelectedIndex(connection.getType());
|
||||||
readTraffic.setSelected(connection.isReadTraffic());
|
readTraffic.setSelected(connection.isReadTraffic());
|
||||||
sourceDeviceComboBox.setSelectedIndex((connection.getTrafficObject() == startObj.getId() ? 0 : 1));
|
sourceDeviceComboBox.setSelectedIndex((connection.getTrafficNode() == startObj.getId() ? 0 : 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadIface() {
|
private void loadIface() {
|
||||||
MapObject obj;
|
loadingLabel.setVisible(true);
|
||||||
|
Node obj;
|
||||||
if (sourceDeviceComboBox.getSelectedIndex() == 0) {
|
if (sourceDeviceComboBox.getSelectedIndex() == 0) {
|
||||||
obj = startObj;
|
obj = startObj;
|
||||||
} else {
|
} else {
|
||||||
obj = endObj;
|
obj = endObj;
|
||||||
}
|
}
|
||||||
Object[] o = {this.getName(), obj};
|
Object[] o = {this.getName(), obj};
|
||||||
NettyClient.send(Message.SNMP_CONNECTION_INTERFACE, o);
|
NettyClientManager.sendMessage(Message.NODE_CONNECTION_SNMP_INTERFACE, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateInterface(List<Interface> iface) {
|
public void updateInterface(List<Interface> iface) {
|
||||||
|
loadingLabel.setVisible(false);
|
||||||
this.iface = iface;
|
this.iface = iface;
|
||||||
|
|
||||||
sourceInterfaceComboBox.removeAllItems();
|
sourceInterfaceComboBox.removeAllItems();
|
||||||
|
|
||||||
for (Interface ifs : iface) {
|
for (Interface ifs : iface) {
|
||||||
Item item = new Item(ifs.getId(), ifs.getDescription());
|
Item item = new Item(ifs.getId(), ifs.getShortDescription() + " (" + ifs.getAlias() + ")");
|
||||||
sourceInterfaceComboBox.addItem(item);
|
sourceInterfaceComboBox.addItem(item);
|
||||||
// pokud se nejedna o nový objekt a souhlasi index rozhrani nastavit polozku v seznamu
|
// pokud se nejedna o nový objekt a souhlasi index rozhrani nastavit polozku v seznamu
|
||||||
if (!newObject && ifs.getId() == connection.getTrafficIface()) {
|
if (!newObject && ifs.getId() == connection.getTrafficIface()) {
|
||||||
|
|
@ -214,17 +245,17 @@ public class ConnectionDialog extends JFrame {
|
||||||
connection.setReadTraffic(readTraffic.isSelected());
|
connection.setReadTraffic(readTraffic.isSelected());
|
||||||
if (readTraffic.isSelected()) {
|
if (readTraffic.isSelected()) {
|
||||||
// pokud je zapnute cteni nastavi zdrojovy objekt a interface
|
// pokud je zapnute cteni nastavi zdrojovy objekt a interface
|
||||||
connection.setTrafficObject(sourceDeviceComboBox.getSelectedIndex() == 0 ? startObj.getId() : endObj.getId());
|
connection.setTrafficNode(sourceDeviceComboBox.getSelectedIndex() == 0 ? startObj.getId() : endObj.getId());
|
||||||
connection.setTrafficIface(sellectedIface.getId());
|
connection.setTrafficIface(sellectedIface.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newObject) {
|
if (newObject) {
|
||||||
connection.setSourceObj(startObj.getId());
|
connection.setNodeFrom(startObj.getId());
|
||||||
connection.setDestinationObj(endObj.getId());
|
connection.setNodeTo(endObj.getId());
|
||||||
connection.setMap(startObj.getMap());
|
connection.setSite(startObj.getSiteId());
|
||||||
NettyClient.send(Message.CONNECTION_NEW, connection);
|
NettyClientManager.sendMessage(Message.NODE_CONNECTION_NEW, connection);
|
||||||
} else {
|
} else {
|
||||||
NettyClient.send(Message.CONNECTION_UPDATE, connection);
|
NettyClientManager.sendMessage(Message.NODE_CONNECTION_EDIT, connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,144 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import jnet.client.gui.Window;
|
||||||
|
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.DeviceType;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.util.Base64;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
|
||||||
|
public class DialogDeviceType extends JDialog {
|
||||||
|
|
||||||
|
|
||||||
|
private JLabel info = new JLabel("PNG obrázek o šířce 32px");
|
||||||
|
private JTextField nazevText = new JTextField(15);
|
||||||
|
private String imgStr = "";
|
||||||
|
|
||||||
|
public DialogDeviceType() {
|
||||||
|
setTitle("Přidat typ zařízení");
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
initComponents();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
// Název
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(new JLabel("Název:"), gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(nazevText, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
// Obrázek
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(new JLabel("Obrázek"), gbc);
|
||||||
|
|
||||||
|
JButton browseButton = new JButton("Browse");
|
||||||
|
browseButton.addActionListener(e -> browseImage());
|
||||||
|
gbc.gridx = 1;
|
||||||
|
panel.add(browseButton, gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(info, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
// Tlačítka
|
||||||
|
JButton addButton = new JButton("Přidat");
|
||||||
|
addButton.addActionListener(e -> addDeviceType());
|
||||||
|
JButton cancelButton = new JButton("Storno");
|
||||||
|
cancelButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(addButton, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelButton, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browseImage() {
|
||||||
|
JFileChooser fc = new JFileChooser(".");
|
||||||
|
fc.setFileFilter(new FileNameExtensionFilter("PNG obrázky", "png"));
|
||||||
|
if (fc.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
||||||
|
File file = fc.getSelectedFile();
|
||||||
|
try {
|
||||||
|
String mimeType = Files.probeContentType(file.toPath());
|
||||||
|
if (!"image/png".equals(mimeType)) {
|
||||||
|
info.setForeground(Color.RED);
|
||||||
|
info.setText("Chybný formát – vyberte PNG.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BufferedImage bimg = ImageIO.read(file);
|
||||||
|
if (bimg == null || bimg.getWidth() != 32) {
|
||||||
|
info.setForeground(Color.RED);
|
||||||
|
info.setText("Obrázek musí mít šířku 32px.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
imgStr = encodeFileToBase64(file);
|
||||||
|
info.setForeground(Color.BLACK);
|
||||||
|
info.setText("Obrázek nahrán (" + file.getName() + ")");
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("Chyba při načítání obrázku" + ex.getMessage());
|
||||||
|
info.setForeground(Color.RED);
|
||||||
|
info.setText("Chyba čtení souboru.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addDeviceType() {
|
||||||
|
String name = nazevText.getText().trim();
|
||||||
|
if (name.length() < 3) {
|
||||||
|
info.setForeground(Color.RED);
|
||||||
|
info.setText("Název musí mít alespoň 3 znaky.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (imgStr.isEmpty()) {
|
||||||
|
info.setForeground(Color.RED);
|
||||||
|
info.setText("Musíte vybrat obrázek.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_ICON_NEW, new DeviceType(name, imgStr)));
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
Window.showServerSettings(ServerSettingsPanel.TAB_DEVICE_TYPE);
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String encodeFileToBase64(File file) throws IOException {
|
||||||
|
try (FileInputStream fis = new FileInputStream(file)) {
|
||||||
|
byte[] bytes = new byte[(int) file.length()];
|
||||||
|
int read = fis.read(bytes);
|
||||||
|
if (read != bytes.length) {
|
||||||
|
throw new IOException("Přečteno méně bajtů než očekáváno.");
|
||||||
|
}
|
||||||
|
return Base64.getEncoder().encodeToString(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,162 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.ApacheConfig;
|
||||||
|
import org.apache.commons.configuration2.PropertiesConfiguration;
|
||||||
|
import org.apache.commons.configuration2.ex.ConfigurationException;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import static jnet.client.Client.nettyClient;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
|
||||||
|
public class DialogLogin extends JDialog {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(DialogLogin.class.getName());
|
||||||
|
|
||||||
|
private JTextField serverText;
|
||||||
|
private JTextField portText;
|
||||||
|
private JTextField userText;
|
||||||
|
private JPasswordField passwordText;
|
||||||
|
|
||||||
|
public DialogLogin() {
|
||||||
|
setTitle("Přihlásit");
|
||||||
|
setSize(350, 250);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setResizable(false);
|
||||||
|
setModal(true);
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 5, 5, 5);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
|
||||||
|
// Načtení uložených hodnot (plain text)
|
||||||
|
String savedServer = Client.config.getString("server", "");
|
||||||
|
String savedPort = Client.config.getString("port", "");
|
||||||
|
String savedUser = Client.config.getString("user", "");
|
||||||
|
String savedPassword = Client.config.getString("password", "");
|
||||||
|
|
||||||
|
// Server
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 0;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(new JLabel("Server:"), gbc);
|
||||||
|
|
||||||
|
serverText = new JTextField(savedServer, 15);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(serverText, gbc);
|
||||||
|
|
||||||
|
// Port
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 1;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(new JLabel("Port:"), gbc);
|
||||||
|
|
||||||
|
portText = new JTextField(savedPort, 5);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(portText, gbc);
|
||||||
|
|
||||||
|
// Uživatel
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 2;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(new JLabel("Uživatel:"), gbc);
|
||||||
|
|
||||||
|
userText = new JTextField(savedUser, 15);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(userText, gbc);
|
||||||
|
|
||||||
|
// Heslo
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 3;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(new JLabel("Heslo:"), gbc);
|
||||||
|
|
||||||
|
passwordText = new JPasswordField(savedPassword, 15);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(passwordText, gbc);
|
||||||
|
|
||||||
|
// Tlačítka
|
||||||
|
JButton loginButton = new JButton("Přihlásit");
|
||||||
|
loginButton.addActionListener(e -> performLogin());
|
||||||
|
|
||||||
|
JButton closeButton = new JButton("Storno");
|
||||||
|
closeButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = 4;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.anchor = GridBagConstraints.CENTER;
|
||||||
|
panel.add(loginButton, gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(closeButton, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
pack();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performLogin() {
|
||||||
|
String server = serverText.getText().trim();
|
||||||
|
String portStr = portText.getText().trim();
|
||||||
|
String user = userText.getText().trim();
|
||||||
|
String password = new String(passwordText.getPassword());
|
||||||
|
|
||||||
|
// Validace
|
||||||
|
if (server.isEmpty() || portStr.isEmpty() || user.isEmpty() || password.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this,
|
||||||
|
"Všechna pole musí být vyplněna.",
|
||||||
|
"Chyba",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int port;
|
||||||
|
try {
|
||||||
|
port = Integer.parseInt(portStr);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
JOptionPane.showMessageDialog(this,
|
||||||
|
"Port musí být číslo.",
|
||||||
|
"Chyba",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Uložení do konfigurace (bez hashování – zatím plain text)
|
||||||
|
try {
|
||||||
|
Client.config.setProperty("server", server);
|
||||||
|
Client.config.setProperty("port", portStr);
|
||||||
|
Client.config.setProperty("user", user);
|
||||||
|
Client.config.setProperty("password", password); // plain text
|
||||||
|
ApacheConfig.saveProperties( Client.config);
|
||||||
|
|
||||||
|
// Připojení klienta (mimo EDT – Netty)
|
||||||
|
Client.nettyClient = new NettyClientManager(server, port);
|
||||||
|
nettyClient.start();
|
||||||
|
|
||||||
|
// Zavření dialogu
|
||||||
|
dispose();
|
||||||
|
|
||||||
|
} catch (ConfigurationException ex) {
|
||||||
|
LogFile.printErr("Chyba při ukládání konfigurace");
|
||||||
|
JOptionPane.showMessageDialog(this,
|
||||||
|
"Chyba při ukládání nastavení: " + ex.getMessage(),
|
||||||
|
"Chyba",
|
||||||
|
JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.DefaultListCellRenderer;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.gui.mapview.MapView;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
public class DialogNodeChangeSite extends JDialog {
|
||||||
|
|
||||||
|
private final Node node;
|
||||||
|
private final MapView mapView; // může být null
|
||||||
|
|
||||||
|
// Původní konstruktor pro zachování kompatibility
|
||||||
|
public DialogNodeChangeSite(Node node) {
|
||||||
|
this(node, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nový konstruktor s MapView
|
||||||
|
public DialogNodeChangeSite(Node node, MapView mapView) {
|
||||||
|
this.node = node;
|
||||||
|
this.mapView = mapView;
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
init();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setTitle("Přesun na jinou mapu");
|
||||||
|
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
JLabel labelMap = new JLabel("Nová mapa");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(labelMap, gbc);
|
||||||
|
|
||||||
|
JComboBox<Site> comboBoxMap = new JComboBox<>();
|
||||||
|
DefaultComboBoxModel<Site> model = new DefaultComboBoxModel<>();
|
||||||
|
for (Site site : Client.site) {
|
||||||
|
model.addElement(site);
|
||||||
|
}
|
||||||
|
comboBoxMap.setModel(model);
|
||||||
|
comboBoxMap.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value,
|
||||||
|
int index, boolean isSelected,
|
||||||
|
boolean cellHasFocus) {
|
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
if (value instanceof Site) {
|
||||||
|
setText(((Site) value).getName());
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Pouze informativní výpis – neměníme node!
|
||||||
|
comboBoxMap.addActionListener(e -> {
|
||||||
|
Site selected = (Site) comboBoxMap.getSelectedItem();
|
||||||
|
if (selected != null) {
|
||||||
|
System.out.println("Vybráno: " + selected.getName() + " (ID: " + selected.getId() + ")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(comboBoxMap, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JButton addButton = new JButton("Uložit");
|
||||||
|
JButton cancelButton = new JButton("Storno");
|
||||||
|
|
||||||
|
addButton.addActionListener(e -> {
|
||||||
|
Site selected = (Site) comboBoxMap.getSelectedItem();
|
||||||
|
if (selected != null && mapView != null) {
|
||||||
|
// Spustíme režim umístění na cílové mapě
|
||||||
|
mapView.startNodePlacement(node, selected.getId());
|
||||||
|
// Přepneme na cílovou mapu
|
||||||
|
mapView.switchToSite(selected.getId());
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(this, "Nebyla vybrána cílová mapa nebo chybí MapView.");
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(addButton, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelButton, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
import javax.swing.DefaultListCellRenderer;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JList;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
|
||||||
|
public class DialogNodeMapLink extends JDialog {
|
||||||
|
|
||||||
|
private Boolean newObject;
|
||||||
|
private Node node;
|
||||||
|
|
||||||
|
public DialogNodeMapLink(Node node, Boolean newObject) {
|
||||||
|
this.newObject = newObject;
|
||||||
|
this.node = node;
|
||||||
|
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
init();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
|
||||||
|
if (newObject) {
|
||||||
|
setTitle("Nový statický object");
|
||||||
|
} else {
|
||||||
|
setTitle(node.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
JLabel labelMap = new JLabel("Mapa");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(labelMap, gbc);
|
||||||
|
|
||||||
|
JComboBox<Site> comboBoxMap = new JComboBox<>();
|
||||||
|
// Naplníme model
|
||||||
|
DefaultComboBoxModel<Site> model = new DefaultComboBoxModel<>();
|
||||||
|
for (Site site : Client.site) {
|
||||||
|
model.addElement(site);
|
||||||
|
}
|
||||||
|
comboBoxMap.setModel(model);
|
||||||
|
comboBoxMap.setRenderer(new DefaultListCellRenderer() {
|
||||||
|
@Override
|
||||||
|
public Component getListCellRendererComponent(JList<?> list, Object value,
|
||||||
|
int index, boolean isSelected,
|
||||||
|
boolean cellHasFocus) {
|
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
if (value instanceof Site) {
|
||||||
|
Site s = (Site) value;
|
||||||
|
setText(s.getName()); // zobrazí jméno
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
comboBoxMap.addActionListener(e -> {
|
||||||
|
Site selected = (Site) comboBoxMap.getSelectedItem();
|
||||||
|
if (selected != null) {
|
||||||
|
int id = selected.getId();
|
||||||
|
String name = selected.getName();
|
||||||
|
node.setName(selected.getName());
|
||||||
|
node.setSiteLink(selected.getId());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(comboBoxMap, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JButton addButton = new JButton("Uložit");
|
||||||
|
JButton cancelButton = new JButton("Storno");
|
||||||
|
|
||||||
|
addButton.addActionListener(e -> {
|
||||||
|
|
||||||
|
node.setPing(false);
|
||||||
|
node.setType(Node.NODE_MAP);
|
||||||
|
node.setIcon(1);
|
||||||
|
|
||||||
|
if (newObject) {
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_ADD, node));
|
||||||
|
dispose();
|
||||||
|
} else {
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_CHANGE, node));
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(addButton, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelButton, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||||
|
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
public class DialogNodeStatic extends JDialog {
|
||||||
|
|
||||||
|
private Boolean newObject;
|
||||||
|
private Node node;
|
||||||
|
|
||||||
|
public DialogNodeStatic(Node node, Boolean newObject) {
|
||||||
|
this.newObject = newObject;
|
||||||
|
this.node = node;
|
||||||
|
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
init();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
|
||||||
|
if (newObject) {
|
||||||
|
setTitle("Nový statický object");
|
||||||
|
} else {
|
||||||
|
setTitle(node.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
JLabel label = new JLabel("Název");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(label, gbc);
|
||||||
|
|
||||||
|
JTextField nameField = new JTextField(15);
|
||||||
|
nameField.setText(node.getName());
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(nameField, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JButton addButton = new JButton("Uložit");
|
||||||
|
JButton cancelButton = new JButton("Storno");
|
||||||
|
|
||||||
|
addButton.addActionListener(e -> {
|
||||||
|
String name = nameField.getText().trim();
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Název nesmí být prázdný.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (name.length() < 3) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Název musí mít alespoň 3 znaky.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
node.setPing(false);
|
||||||
|
node.setName(name);
|
||||||
|
node.setType(Node.NODE_STATIC);
|
||||||
|
node.setIcon(1);
|
||||||
|
node.setSnmpProfile(1);
|
||||||
|
|
||||||
|
if (newObject) {
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_ADD, node));
|
||||||
|
dispose();
|
||||||
|
} else {
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_CHANGE, node));
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(addButton, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelButton, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,6 @@ package jnet.client.gui.dialog;
|
||||||
import jnet.client.Client;
|
import jnet.client.Client;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import javax.swing.Box;
|
import javax.swing.Box;
|
||||||
|
|
@ -14,11 +13,12 @@ import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
import jnet.lib.LogFile;
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
import jnet.lib.object.OnlineClients;
|
import jnet.lib.object.OnlineClients;
|
||||||
|
|
||||||
public class OnlineClientsDialog extends JDialog {
|
public class DialogOnlineClients extends JDialog {
|
||||||
|
|
||||||
public OnlineClientsDialog() {
|
public DialogOnlineClients() {
|
||||||
setTitle("Online klienti");
|
setTitle("Online klienti");
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
setAlwaysOnTop(true);
|
setAlwaysOnTop(true);
|
||||||
|
|
@ -35,10 +35,10 @@ public class OnlineClientsDialog extends JDialog {
|
||||||
JLabel line = new JLabel(" " + oc.getUsername() + " (" + oc.getIp() + ")");
|
JLabel line = new JLabel(" " + oc.getUsername() + " (" + oc.getIp() + ")");
|
||||||
switch (oc.getPlatform()) {
|
switch (oc.getPlatform()) {
|
||||||
case OnlineClients.PLATFORM_MOBILE:
|
case OnlineClients.PLATFORM_MOBILE:
|
||||||
line.setIcon(new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/img/platform_android.png"))));
|
line.setIcon(new ImageIcon(ImageIO.read(ResourceLoader.getFile("/img/platform_android.png"))));
|
||||||
break;
|
break;
|
||||||
case OnlineClients.PLATFORM_PC:
|
case OnlineClients.PLATFORM_PC:
|
||||||
line.setIcon(new ImageIcon(ImageIO.read(getClass().getResourceAsStream("/img/platform_pc.png"))));
|
line.setIcon(new ImageIcon(ImageIO.read(ResourceLoader.getFile("/img/platform_pc.png"))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
panel.add(line);
|
panel.add(line);
|
||||||
|
|
@ -0,0 +1,496 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.client.gui.dialog.node.DialogNodeDevice;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeProbe;
|
||||||
|
import jnet.lib.object.SnmpTemplate;
|
||||||
|
import jnet.lib.object.SnmpValueMap;
|
||||||
|
import org.snmp4j.smi.SMIConstants;
|
||||||
|
|
||||||
|
public class DialogProbe extends JFrame {
|
||||||
|
|
||||||
|
private DialogNodeDevice parentDialog;
|
||||||
|
private Node node;
|
||||||
|
private NodeProbe probe;
|
||||||
|
private boolean newProbe;
|
||||||
|
private JComboBox<TemplateItem> templateComboBox;
|
||||||
|
private JComboBox<DataTypeItem> dataTypeComBox = new JComboBox<>();
|
||||||
|
private JComboBox<TypeItem> conversionTypeComBox = new JComboBox<>();
|
||||||
|
private JComboBox<ValueMapItem> mapValueComBox = new JComboBox<>();
|
||||||
|
private JTextField oidField = new JTextField();
|
||||||
|
private JTextField conversionValueField = new JTextField();
|
||||||
|
private JTextField conversionExpressionField = new JTextField();
|
||||||
|
private JTextField intervalField = new JTextField();
|
||||||
|
private JTextField unitField = new JTextField();
|
||||||
|
private JTextField nameField = new JTextField();
|
||||||
|
private JCheckBox viewInMapCheckBox = new JCheckBox("Zobrazit v mapě");
|
||||||
|
|
||||||
|
public DialogProbe(NodeProbe probe, Node node, boolean newProbe, DialogNodeDevice parentDialog) {
|
||||||
|
this.parentDialog = parentDialog;
|
||||||
|
this.node = node;
|
||||||
|
this.probe = probe;
|
||||||
|
this.newProbe = newProbe;
|
||||||
|
|
||||||
|
// identifikator okna
|
||||||
|
this.setName("probe_detail_" + node.getId());
|
||||||
|
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(-1, ""));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_INTEGER, "Integer32"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_OCTET_STRING, "OctetString"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_NULL, "Null"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_OBJECT_IDENTIFIER, "OID"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_IPADDRESS, "IP address"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_COUNTER32, "Counter32"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_GAUGE32, "Gauge32"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_TIMETICKS, "TimeTicks"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_OPAQUE, "Opaque"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_COUNTER64, "Counter64"));
|
||||||
|
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_DIVIDE, "Dělení"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_EXPRESSION, "Výraz"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_MULTIPLY, "Násobení"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_NONE, "Žádný"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_OFFSET, "Offset"));
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
|
||||||
|
if (newProbe) {
|
||||||
|
setTitle("Nová sonda");
|
||||||
|
} else {
|
||||||
|
setTitle(probe.getName());
|
||||||
|
nameField.setText(probe.getName());
|
||||||
|
oidField.setText(probe.getOid());
|
||||||
|
conversionValueField.setText(String.valueOf(probe.getConversionValue()));
|
||||||
|
conversionExpressionField.setText(probe.getConversionExpression());
|
||||||
|
intervalField.setText(String.valueOf(probe.getInterval()));
|
||||||
|
unitField.setText(probe.getUnit());
|
||||||
|
dataTypeComBox.setSelectedIndex(getDataTypeItemIndex(probe.getDataType()));
|
||||||
|
conversionTypeComBox.setSelectedIndex(getConverssionTypeItemIndex(probe.getConversionType()));
|
||||||
|
viewInMapCheckBox.setSelected(probe.isViewOnMap());
|
||||||
|
}
|
||||||
|
|
||||||
|
setSize(400, 700);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setAlwaysOnTop(false);
|
||||||
|
setResizable(false);
|
||||||
|
|
||||||
|
setLayout(null);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole nazev
|
||||||
|
///
|
||||||
|
JLabel nameLabel = new JLabel("Název");
|
||||||
|
nameLabel.setBounds(20, 20, 120, 25);
|
||||||
|
this.add(nameLabel);
|
||||||
|
|
||||||
|
nameField.setBounds(150, 20, 200, 25);
|
||||||
|
this.add(nameField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// zobrazit v mape
|
||||||
|
///
|
||||||
|
viewInMapCheckBox.setBounds(20, getNextY(nameLabel), 120, 25);
|
||||||
|
this.add(viewInMapCheckBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole ze sablony
|
||||||
|
///
|
||||||
|
JCheckBox checkBoxTemplate = new JCheckBox("Ze šablony");
|
||||||
|
checkBoxTemplate.setBounds(20, getNextY(viewInMapCheckBox), 200, 25);
|
||||||
|
checkBoxTemplate.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (checkBoxTemplate.isSelected()) {
|
||||||
|
templateComboBox.setEnabled(true);
|
||||||
|
} else {
|
||||||
|
templateComboBox.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.add(checkBoxTemplate);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole vyberu sablony
|
||||||
|
///
|
||||||
|
JLabel templateLabel = new JLabel("Šablona");
|
||||||
|
templateLabel.setBounds(20, getNextY(checkBoxTemplate), 120, 25);
|
||||||
|
this.add(templateLabel);
|
||||||
|
|
||||||
|
templateComboBox = new JComboBox<>();
|
||||||
|
templateComboBox.setEnabled(false);
|
||||||
|
templateComboBox.setBounds(150, getNextY(checkBoxTemplate), 200, 25);
|
||||||
|
for (SnmpTemplate template : Client.snmpTemplate) {
|
||||||
|
if (node.getDeviceType() == template.getDeviceType()) {
|
||||||
|
TemplateItem item = new TemplateItem(template.getId(), template.getName(), template);
|
||||||
|
templateComboBox.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
templateComboBox.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
TemplateItem selectedItem = (TemplateItem) templateComboBox.getSelectedItem();
|
||||||
|
SnmpTemplate template = selectedItem.getTemplate();
|
||||||
|
// nastaveni polí podle vybrané šablony
|
||||||
|
oidField.setText(template.getOid());
|
||||||
|
unitField.setText(template.getUnit());
|
||||||
|
dataTypeComBox.setSelectedIndex(getDataTypeItemIndex(template.getDataType()));
|
||||||
|
conversionTypeComBox.setSelectedIndex(getConverssionTypeItemIndex(template.getConversionType()));
|
||||||
|
conversionValueField.setText(String.valueOf(template.getConversionValue()));
|
||||||
|
conversionExpressionField.setText(template.getConversionExpression());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(templateComboBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole oid
|
||||||
|
///
|
||||||
|
JLabel oidLabel = new JLabel("OID");
|
||||||
|
oidLabel.setBounds(20, getNextY(templateComboBox), 120, 25);
|
||||||
|
this.add(oidLabel);
|
||||||
|
|
||||||
|
oidField.setBounds(150, getNextY(templateComboBox), 200, 25);
|
||||||
|
this.add(oidField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole vyberu data type
|
||||||
|
///
|
||||||
|
JLabel dataTypeLabel = new JLabel("Typ dat");
|
||||||
|
dataTypeLabel.setBounds(20, getNextY(oidLabel), 120, 25);
|
||||||
|
this.add(dataTypeLabel);
|
||||||
|
|
||||||
|
dataTypeComBox.setBounds(150, getNextY(oidLabel), 200, 25);
|
||||||
|
dataTypeComBox.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
DialogSnmpTemplate.DataTypeItem item = (DialogSnmpTemplate.DataTypeItem) dataTypeComBox.getSelectedItem();
|
||||||
|
switch (item.getId()) {
|
||||||
|
case SMIConstants.SYNTAX_INTEGER:
|
||||||
|
conversionTypeComBox.setEnabled(true);
|
||||||
|
conversionValueField.setEnabled(true);
|
||||||
|
conversionExpressionField.setEnabled(false);
|
||||||
|
mapValueComBox.setEnabled(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
conversionTypeComBox.setEnabled(false);
|
||||||
|
conversionExpressionField.setEnabled(false);
|
||||||
|
conversionValueField.setEnabled(false);
|
||||||
|
mapValueComBox.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(dataTypeComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole vyberu conversion type
|
||||||
|
///
|
||||||
|
JLabel conversionTypeLabel = new JLabel("Konverzní typ");
|
||||||
|
conversionTypeLabel.setBounds(20, getNextY(dataTypeLabel), 120, 25);
|
||||||
|
this.add(conversionTypeLabel);
|
||||||
|
|
||||||
|
conversionTypeComBox.setEnabled(false);
|
||||||
|
conversionTypeComBox.setBounds(150, getNextY(dataTypeLabel), 200, 25);
|
||||||
|
add(conversionTypeComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole conversion value
|
||||||
|
///
|
||||||
|
JLabel conversionValueLabel = new JLabel("Konverzní hodnota");
|
||||||
|
conversionValueLabel.setBounds(20, getNextY(conversionTypeLabel), 120, 25);
|
||||||
|
this.add(conversionValueLabel);
|
||||||
|
|
||||||
|
conversionValueField.setEnabled(false);
|
||||||
|
conversionValueField.setBounds(150, getNextY(conversionTypeLabel), 200, 25);
|
||||||
|
this.add(conversionValueField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole conversion value
|
||||||
|
///
|
||||||
|
JLabel conversionExpressionLabel = new JLabel("Konverzní výraz");
|
||||||
|
conversionExpressionLabel.setBounds(20, getNextY(conversionValueLabel), 120, 25);
|
||||||
|
this.add(conversionExpressionLabel);
|
||||||
|
|
||||||
|
conversionExpressionField.setEnabled(false);
|
||||||
|
conversionExpressionField = new JTextField();
|
||||||
|
conversionExpressionField.setBounds(150, getNextY(conversionValueLabel), 200, 75);
|
||||||
|
this.add(conversionExpressionField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole mapovani hodnot
|
||||||
|
///
|
||||||
|
JLabel mapValueLabel = new JLabel("Mapování hodnot");
|
||||||
|
mapValueLabel.setBounds(20, getNextY(conversionExpressionField), 120, 25);
|
||||||
|
this.add(mapValueLabel);
|
||||||
|
|
||||||
|
mapValueComBox.setEnabled(false);
|
||||||
|
mapValueComBox.setBounds(150, getNextY(conversionExpressionField), 200, 25);
|
||||||
|
for (SnmpValueMap snmpValueMap : Client.snmpValueMap) {
|
||||||
|
ValueMapItem valueMapItem = new ValueMapItem(snmpValueMap.getId(), snmpValueMap.getName());
|
||||||
|
mapValueComBox.addItem(valueMapItem);
|
||||||
|
}
|
||||||
|
add(mapValueComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole unit
|
||||||
|
///
|
||||||
|
JLabel unitLabel = new JLabel("Jednotka (V, °C, ...)");
|
||||||
|
unitLabel.setBounds(20, getNextY(mapValueLabel), 120, 25);
|
||||||
|
this.add(unitLabel);
|
||||||
|
|
||||||
|
unitField.setBounds(150, getNextY(mapValueLabel), 200, 25);
|
||||||
|
this.add(unitField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole interval
|
||||||
|
///
|
||||||
|
JLabel intervalLabel = new JLabel("Interval (sekund)");
|
||||||
|
intervalLabel.setBounds(20, getNextY(unitLabel), 120, 25);
|
||||||
|
this.add(intervalLabel);
|
||||||
|
|
||||||
|
intervalField = new JTextField();
|
||||||
|
intervalField.setBounds(150, getNextY(unitLabel), 200, 25);
|
||||||
|
intervalField.setText("30");
|
||||||
|
this.add(intervalField);
|
||||||
|
|
||||||
|
// spodni tlacitka
|
||||||
|
JPanel pane = new JPanel();
|
||||||
|
pane.setBounds(0, getNextY(intervalLabel), this.getWidth(), this.getHeight());
|
||||||
|
JButton save = new JButton("Ulozit");
|
||||||
|
save.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
// kontrola chyb
|
||||||
|
DataTypeItem dataType = (DataTypeItem) dataTypeComBox.getSelectedItem();
|
||||||
|
TypeItem conversionType = (TypeItem) conversionTypeComBox.getSelectedItem();
|
||||||
|
ValueMapItem valueMap = (ValueMapItem) mapValueComBox.getSelectedItem();
|
||||||
|
// kontrola chyb
|
||||||
|
if (nameField.getText().trim().isEmpty()) {
|
||||||
|
// Chyba - pole je prázdné
|
||||||
|
JOptionPane.showMessageDialog(null, "Prosím, vyplňte textové pole.");
|
||||||
|
nameField.requestFocus(); // vrátí kurzor zpět do pole
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (oidField.getText().trim().isEmpty()) {
|
||||||
|
// Chyba - pole je prázdné
|
||||||
|
JOptionPane.showMessageDialog(null, "Prosím, vyplňte textové pole.");
|
||||||
|
oidField.requestFocus(); // vrátí kurzor zpět do pole
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dataType.getId() == -1) {
|
||||||
|
// Chyba - pole je prázdné
|
||||||
|
JOptionPane.showMessageDialog(null, "Prosím, vyberte datový typ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// sestaveni probe
|
||||||
|
probe.setNodeId(node.getId());
|
||||||
|
probe.setName(nameField.getText());
|
||||||
|
probe.setOid(oidField.getText());
|
||||||
|
probe.setUnit(unitField.getText());
|
||||||
|
probe.setDataType(dataType.id);
|
||||||
|
probe.setConversionType(conversionType.id);
|
||||||
|
probe.setConversionValue(Double.parseDouble(conversionValueField.getText()));
|
||||||
|
probe.setValueMap(valueMap.id);
|
||||||
|
probe.setInterval(Integer.parseInt(intervalField.getText()));
|
||||||
|
probe.setViewOnMap(viewInMapCheckBox.isSelected());
|
||||||
|
// odeslani
|
||||||
|
Object[] obj = {probe, parentDialog.getName()};
|
||||||
|
if (newProbe) {
|
||||||
|
NettyClientManager.sendMessage(Message.NODE_PROBE_NEW, obj);
|
||||||
|
} else {
|
||||||
|
NettyClientManager.sendMessage(Message.NODE_PROBE_EDIT, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// zavreni dialogu
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pane.add(save);
|
||||||
|
|
||||||
|
JButton cancel = new JButton("Zavřít");
|
||||||
|
cancel.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pane.add(cancel);
|
||||||
|
|
||||||
|
add(pane, BorderLayout.PAGE_END);
|
||||||
|
|
||||||
|
setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getNextY(Component p) {
|
||||||
|
return p.getY() + p.getHeight() + 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getDataTypeItemIndex(int value) {
|
||||||
|
switch (value) {
|
||||||
|
case SMIConstants.SYNTAX_INTEGER -> {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_OCTET_STRING -> {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_NULL -> {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_OBJECT_IDENTIFIER -> {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_IPADDRESS -> {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_COUNTER32 -> {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_GAUGE32 -> {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_TIMETICKS -> {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_OPAQUE -> {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_COUNTER64 -> {
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getConverssionTypeItemIndex(String value) {
|
||||||
|
switch (value) {
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_DIVIDE -> {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_EXPRESSION -> {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_MULTIPLY -> {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_NONE -> {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_OFFSET -> {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DataTypeItem {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public DataTypeItem(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TemplateItem {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private SnmpTemplate template;
|
||||||
|
|
||||||
|
public TemplateItem(int id, String name, SnmpTemplate template) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.template = template;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnmpTemplate getTemplate() {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TypeItem {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public TypeItem(String id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeItem(String name) {
|
||||||
|
this.id = name;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ValueMapItem {
|
||||||
|
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
public ValueMapItem(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,68 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DialogSite extends JDialog {
|
||||||
|
|
||||||
|
public DialogSite() {
|
||||||
|
setTitle("Přidat mapu");
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
initComponents();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
JLabel label = new JLabel("Název");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(label, gbc);
|
||||||
|
|
||||||
|
JTextField nameField = new JTextField(15);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(nameField, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JButton addButton = new JButton("Přidat");
|
||||||
|
JButton cancelButton = new JButton("Storno");
|
||||||
|
|
||||||
|
addButton.addActionListener(e -> {
|
||||||
|
String name = nameField.getText().trim();
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Název nesmí být prázdný.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (name.length() < 3) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Název musí mít alespoň 3 znaky.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.SITE_ADD, name));
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
cancelButton.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(addButton, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelButton, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.GridBagConstraints;
|
||||||
|
import java.awt.GridBagLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.BorderFactory;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.SnmpProfile;
|
||||||
|
|
||||||
|
public class DialogSnmpProfile extends JDialog {
|
||||||
|
|
||||||
|
private SnmpProfile profile;
|
||||||
|
private boolean newProfile;
|
||||||
|
|
||||||
|
private JTextField nameField = new JTextField(15);
|
||||||
|
private JTextField readField = new JTextField(15);
|
||||||
|
private JTextField portField = new JTextField(15);
|
||||||
|
private JComboBox<Item> vesrionComboBox = new JComboBox<>();
|
||||||
|
|
||||||
|
public DialogSnmpProfile(SnmpProfile profile, boolean newProfile) {
|
||||||
|
this.profile = profile;
|
||||||
|
this.newProfile = newProfile;
|
||||||
|
|
||||||
|
prepare();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DialogSnmpProfile(SnmpProfile profile) {
|
||||||
|
this.profile = profile;
|
||||||
|
this.newProfile = false;
|
||||||
|
|
||||||
|
prepare();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepare() {
|
||||||
|
if (!newProfile) {
|
||||||
|
nameField.setText(profile.getName());
|
||||||
|
readField.setText(profile.getCommunityRead());
|
||||||
|
portField.setText(profile.getPort());
|
||||||
|
} else {
|
||||||
|
profile = new SnmpProfile();
|
||||||
|
portField.setText("161");
|
||||||
|
}
|
||||||
|
|
||||||
|
// nastaveni okna
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
init();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setSize(400, getHeight()); // zachová výšku z pack(), ale šířku nastaví pevně
|
||||||
|
setResizable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
if (newProfile) {
|
||||||
|
setTitle("Přidat SNMP profil");
|
||||||
|
} else {
|
||||||
|
setTitle(profile.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
// Přidá vnitřní okraj 10 pixelů od všech okrajů dialogu
|
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
|
||||||
|
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
JLabel nameLabel = new JLabel("Název");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.weightx = 1.0;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(nameLabel, gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
gbc.weightx = 0.0;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(nameField, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JLabel readLabel = new JLabel("Community read");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.weightx = 1.0;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(readLabel, gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
gbc.weightx = 0.0;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(readField, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JLabel portLabel = new JLabel("Port");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.weightx = 1.0;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(portLabel, gbc);
|
||||||
|
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
gbc.weightx = 0.0;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(portField, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JLabel verzeLabel = new JLabel("Port");
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.weightx = 1.0;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(verzeLabel, gbc);
|
||||||
|
|
||||||
|
vesrionComboBox.addItem(new Item(SnmpProfile.version1, "Verze 1"));
|
||||||
|
vesrionComboBox.addItem(new Item(SnmpProfile.version2c, "Verze 2c"));
|
||||||
|
vesrionComboBox.addItem(new Item(SnmpProfile.version3, "Verze 3"));
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
gbc.weightx = 0.0;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(vesrionComboBox, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JButton actionBtn = new JButton(newProfile ? "Přidat" : "Upravit");
|
||||||
|
JButton cancelBtn = new JButton("Storno");
|
||||||
|
|
||||||
|
actionBtn.addActionListener(e -> performAction());
|
||||||
|
cancelBtn.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(actionBtn, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelBtn, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performAction() {
|
||||||
|
String name = nameField.getText().trim();
|
||||||
|
if (name.length() < 3) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Název musí mít alespoň 3 znaky.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String read = readField.getText().trim();
|
||||||
|
if (read.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Community read nesmí být prázdné.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String port = portField.getText().trim();
|
||||||
|
if (read.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Port nesmí být prázdné.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
profile.setName(name);
|
||||||
|
profile.setCommunityRead(read);
|
||||||
|
profile.setPort(port);
|
||||||
|
Item version = (Item) vesrionComboBox.getSelectedItem();
|
||||||
|
profile.setVersion(version.getId());
|
||||||
|
|
||||||
|
if (newProfile) {
|
||||||
|
NettyClientManager.sendMessage(Message.SNMP_PROFILE_NEW, profile);
|
||||||
|
} else{
|
||||||
|
NettyClientManager.sendMessage(Message.SNMP_PROFILE_EDIT, profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Item {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public Item(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,439 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.DeviceType;
|
||||||
|
import jnet.lib.object.SnmpTemplate;
|
||||||
|
import jnet.lib.object.SnmpValueMap;
|
||||||
|
import org.snmp4j.smi.SMIConstants;
|
||||||
|
|
||||||
|
public class DialogSnmpTemplate extends JFrame {
|
||||||
|
|
||||||
|
private SnmpTemplate template;
|
||||||
|
private boolean newTemplate;
|
||||||
|
private JComboBox<DataTypeItem> dataTypeComBox = new JComboBox<>();
|
||||||
|
private JComboBox<TypeItem> conversionTypeComBox = new JComboBox<>();
|
||||||
|
private JComboBox<ValueMapItem> mapValueComBox = new JComboBox<>();
|
||||||
|
private JComboBox<DeviceTypeItem> deviceTypeComBox = new JComboBox<>();
|
||||||
|
private JTextField oidField = new JTextField();
|
||||||
|
private JTextField conversionValueField = new JTextField();
|
||||||
|
private JTextField conversionExpressionField = new JTextField();
|
||||||
|
private JTextField unitField = new JTextField();
|
||||||
|
private JTextField nameField = new JTextField();
|
||||||
|
|
||||||
|
public DialogSnmpTemplate(SnmpTemplate template, boolean newTemplate) {
|
||||||
|
this.template = template;
|
||||||
|
this.newTemplate = newTemplate;
|
||||||
|
|
||||||
|
// identifikator okna
|
||||||
|
this.setName("template_detail_" + template.getId());
|
||||||
|
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(-1, ""));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_INTEGER, "Integer32"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_OCTET_STRING, "OctetString"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_NULL, "Null"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_OBJECT_IDENTIFIER, "OID"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_IPADDRESS, "IP address"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_COUNTER32, "Counter32"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_GAUGE32, "Gauge32"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_TIMETICKS, "TimeTicks"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_OPAQUE, "Opaque"));
|
||||||
|
dataTypeComBox.addItem(new DataTypeItem(SMIConstants.SYNTAX_COUNTER64, "Counter64"));
|
||||||
|
|
||||||
|
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_DIVIDE, "Dělení"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_EXPRESSION, "Výraz"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_MULTIPLY, "Násobení"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_NONE, "Žádný"));
|
||||||
|
conversionTypeComBox.addItem(new TypeItem(SnmpTemplate.CONVERSION_TYPE_OFFSET, "Offset"));
|
||||||
|
|
||||||
|
for (DeviceType devicType : Client.deviceType) {
|
||||||
|
DeviceTypeItem item = new DeviceTypeItem(devicType.getId(), devicType.getName());
|
||||||
|
deviceTypeComBox.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
oidField.setText(template.getOid());
|
||||||
|
dataTypeComBox.setSelectedIndex(getDataTypeItemIndex(template.getDataType()));
|
||||||
|
if (newTemplate) {
|
||||||
|
setTitle("Nová šablona");
|
||||||
|
} else {
|
||||||
|
setTitle(template.getName());
|
||||||
|
nameField.setText(template.getName());
|
||||||
|
oidField.setText(template.getOid());
|
||||||
|
conversionValueField.setText(String.valueOf(template.getConversionValue()));
|
||||||
|
conversionExpressionField.setText(template.getConversionExpression());
|
||||||
|
unitField.setText(template.getUnit());
|
||||||
|
for (int i = 0; i < Client.deviceType.size(); i++) {
|
||||||
|
if (Client.deviceType.get(i).getId() == template.getDeviceType()) {
|
||||||
|
deviceTypeComBox.setSelectedIndex(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setSize(400, 700);
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setAlwaysOnTop(false);
|
||||||
|
setResizable(false);
|
||||||
|
|
||||||
|
setLayout(null);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole nazev
|
||||||
|
///
|
||||||
|
JLabel nameLabel = new JLabel("Název");
|
||||||
|
nameLabel.setBounds(20, 20, 120, 25);
|
||||||
|
this.add(nameLabel);
|
||||||
|
|
||||||
|
nameField.setBounds(150, 20, 200, 25);
|
||||||
|
this.add(nameField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole vyber zařízení
|
||||||
|
///
|
||||||
|
JLabel templateLabel = new JLabel("Typ zařízení");
|
||||||
|
templateLabel.setBounds(20, getNextY(nameField), 120, 25);
|
||||||
|
this.add(templateLabel);
|
||||||
|
|
||||||
|
deviceTypeComBox.setBounds(150, getNextY(nameField), 200, 25);
|
||||||
|
add(deviceTypeComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole oid
|
||||||
|
///
|
||||||
|
JLabel oidLabel = new JLabel("OID");
|
||||||
|
oidLabel.setBounds(20, getNextY(deviceTypeComBox), 120, 25);
|
||||||
|
this.add(oidLabel);
|
||||||
|
|
||||||
|
oidField.setBounds(150, getNextY(deviceTypeComBox), 200, 25);
|
||||||
|
this.add(oidField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole vyberu data type
|
||||||
|
///
|
||||||
|
JLabel dataTypeLabel = new JLabel("Typ dat");
|
||||||
|
dataTypeLabel.setBounds(20, getNextY(oidLabel), 120, 25);
|
||||||
|
|
||||||
|
this.add(dataTypeLabel);
|
||||||
|
|
||||||
|
dataTypeComBox.setBounds(150, getNextY(oidLabel), 200, 25);
|
||||||
|
dataTypeComBox.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
DataTypeItem item = (DataTypeItem) dataTypeComBox.getSelectedItem();
|
||||||
|
switch (item.getId()) {
|
||||||
|
case SMIConstants.SYNTAX_INTEGER:
|
||||||
|
conversionTypeComBox.setEnabled(true);
|
||||||
|
conversionValueField.setEnabled(true);
|
||||||
|
conversionExpressionField.setEnabled(false);
|
||||||
|
mapValueComBox.setEnabled(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
conversionTypeComBox.setEnabled(false);
|
||||||
|
conversionExpressionField.setEnabled(false);
|
||||||
|
conversionValueField.setEnabled(false);
|
||||||
|
mapValueComBox.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(dataTypeComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole vyberu conversion type
|
||||||
|
///
|
||||||
|
JLabel conversionTypeLabel = new JLabel("Konverzní typ");
|
||||||
|
conversionTypeLabel.setBounds(20, getNextY(dataTypeLabel), 120, 25);
|
||||||
|
this.add(conversionTypeLabel);
|
||||||
|
|
||||||
|
conversionTypeComBox.setBounds(150, getNextY(dataTypeLabel), 200, 25);
|
||||||
|
conversionTypeComBox.setEnabled(false);
|
||||||
|
add(conversionTypeComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole conversion value
|
||||||
|
///
|
||||||
|
JLabel conversionValueLabel = new JLabel("Konverzní hodnota");
|
||||||
|
conversionValueLabel.setBounds(20, getNextY(conversionTypeLabel), 120, 25);
|
||||||
|
this.add(conversionValueLabel);
|
||||||
|
|
||||||
|
conversionValueField.setBounds(150, getNextY(conversionTypeLabel), 200, 25);
|
||||||
|
conversionValueField.setEnabled(false);
|
||||||
|
this.add(conversionValueField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole conversion extension
|
||||||
|
///
|
||||||
|
JLabel conversionExpressionLabel = new JLabel("Konverzní výraz");
|
||||||
|
conversionExpressionLabel.setBounds(20, getNextY(conversionValueLabel), 120, 25);
|
||||||
|
this.add(conversionExpressionLabel);
|
||||||
|
|
||||||
|
conversionExpressionField.setBounds(150, getNextY(conversionValueLabel), 200, 75);
|
||||||
|
conversionExpressionField.setEnabled(false);
|
||||||
|
this.add(conversionExpressionField);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// rozeviraci pole mapovani hodnot
|
||||||
|
///
|
||||||
|
JLabel mapValueLabel = new JLabel("Mapování hodnot");
|
||||||
|
mapValueLabel.setBounds(20, getNextY(conversionExpressionField), 120, 25);
|
||||||
|
this.add(mapValueLabel);
|
||||||
|
|
||||||
|
mapValueComBox.setBounds(150, getNextY(conversionExpressionField), 200, 25);
|
||||||
|
mapValueComBox.setEnabled(false);
|
||||||
|
for (SnmpValueMap snmpValueMap : Client.snmpValueMap) {
|
||||||
|
ValueMapItem valueMapItem = new ValueMapItem(snmpValueMap.getId(), snmpValueMap.getName());
|
||||||
|
mapValueComBox.addItem(valueMapItem);
|
||||||
|
}
|
||||||
|
add(mapValueComBox);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// pole unit
|
||||||
|
///
|
||||||
|
JLabel unitLabel = new JLabel("Jednotka (V, °C, ...)");
|
||||||
|
unitLabel.setBounds(20, getNextY(mapValueLabel), 120, 25);
|
||||||
|
this.add(unitLabel);
|
||||||
|
|
||||||
|
unitField.setBounds(150, getNextY(mapValueLabel), 200, 25);
|
||||||
|
this.add(unitField);
|
||||||
|
|
||||||
|
// spodni tlacitka
|
||||||
|
JPanel pane = new JPanel();
|
||||||
|
pane.setBounds(0, getNextY(unitLabel) + 30, this.getWidth(), this.getHeight());
|
||||||
|
JButton save = new JButton("Ulozit");
|
||||||
|
save.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
DeviceTypeItem deviceType = (DeviceTypeItem) deviceTypeComBox.getSelectedItem();
|
||||||
|
DataTypeItem dataType = (DataTypeItem) dataTypeComBox.getSelectedItem();
|
||||||
|
TypeItem conversionType = (TypeItem) conversionTypeComBox.getSelectedItem();
|
||||||
|
|
||||||
|
// kontrola chyb
|
||||||
|
if (nameField.getText().trim().isEmpty()) {
|
||||||
|
// Chyba - pole je prázdné
|
||||||
|
JOptionPane.showMessageDialog(null, "Prosím, vyplňte textové pole.");
|
||||||
|
nameField.requestFocus(); // vrátí kurzor zpět do pole
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (oidField.getText().trim().isEmpty()) {
|
||||||
|
// Chyba - pole je prázdné
|
||||||
|
JOptionPane.showMessageDialog(null, "Prosím, vyplňte textové pole.");
|
||||||
|
oidField.requestFocus(); // vrátí kurzor zpět do pole
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dataType.getId() == -1) {
|
||||||
|
// Chyba - pole je prázdné
|
||||||
|
JOptionPane.showMessageDialog(null, "Prosím, vyberte datový typ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// sestaveni template
|
||||||
|
template.setName(nameField.getText());
|
||||||
|
template.setOid(oidField.getText());
|
||||||
|
template.setUnit(unitField.getText());
|
||||||
|
template.setDeviceType(deviceType.getId());
|
||||||
|
template.setDataType(dataType.id);
|
||||||
|
template.setConversionType(conversionType.id);
|
||||||
|
if (oidField.getText().trim().isEmpty()) {
|
||||||
|
template.setConversionValue(0.0);
|
||||||
|
} else {
|
||||||
|
template.setConversionValue(Double.parseDouble(conversionValueField.getText()));
|
||||||
|
}
|
||||||
|
|
||||||
|
ValueMapItem valueMap = (ValueMapItem) mapValueComBox.getSelectedItem();
|
||||||
|
template.setValueMap(valueMap.id);
|
||||||
|
// odeslani
|
||||||
|
if (newTemplate) {
|
||||||
|
NettyClientManager.sendMessage(Message.SNMP_TEMPLATE_NEW, template);
|
||||||
|
} else {
|
||||||
|
NettyClientManager.sendMessage(Message.SNMP_TEMPLATE_EDIT, template);
|
||||||
|
}
|
||||||
|
|
||||||
|
// zavreni dialogu
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pane.add(save);
|
||||||
|
|
||||||
|
JButton cancel = new JButton("Zavřít");
|
||||||
|
cancel.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pane.add(cancel);
|
||||||
|
|
||||||
|
add(pane, BorderLayout.PAGE_END);
|
||||||
|
|
||||||
|
setVisible(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getNextY(Component p) {
|
||||||
|
return p.getY() + p.getHeight() + 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isTextFieldEmpty(JTextField field) {
|
||||||
|
return field.getText().trim().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getDataTypeItemIndex(int value) {
|
||||||
|
switch (value) {
|
||||||
|
case SMIConstants.SYNTAX_INTEGER -> {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_OCTET_STRING -> {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_NULL -> {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_OBJECT_IDENTIFIER -> {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_IPADDRESS -> {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_COUNTER32 -> {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_GAUGE32 -> {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_TIMETICKS -> {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_OPAQUE -> {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
case SMIConstants.SYNTAX_COUNTER64 -> {
|
||||||
|
return 9;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getConverssionTypeItemIndex(String value) {
|
||||||
|
switch (value) {
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_DIVIDE -> {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_EXPRESSION -> {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_MULTIPLY -> {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_NONE -> {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
case SnmpTemplate.CONVERSION_TYPE_OFFSET -> {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
class TypeItem {
|
||||||
|
|
||||||
|
private String id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public TypeItem(String id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TypeItem(String name) {
|
||||||
|
this.id = name;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DataTypeItem {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public DataTypeItem(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeviceTypeItem {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public DeviceTypeItem(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ValueMapItem {
|
||||||
|
|
||||||
|
int id;
|
||||||
|
String name;
|
||||||
|
|
||||||
|
public ValueMapItem(int id, String name) {
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name; // Zobrazí se pouze název
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,173 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.object.SnmpValueMap;
|
||||||
|
import jnet.lib.object.SnmpValueMapItem;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
public class DialogSnmpValueMap extends JDialog {
|
||||||
|
|
||||||
|
private JTextField nameField = new JTextField(20);
|
||||||
|
private JTable table;
|
||||||
|
private DefaultTableModel tableModel;
|
||||||
|
private int fixedWidth;
|
||||||
|
private boolean newMaping = false;
|
||||||
|
private SnmpValueMap valueMap;
|
||||||
|
|
||||||
|
public DialogSnmpValueMap(SnmpValueMap valueMap) {
|
||||||
|
|
||||||
|
this.valueMap = valueMap;
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
if (valueMap == null) {
|
||||||
|
newMaping = true;
|
||||||
|
setTitle("Nové SNMP mapování hodnot");
|
||||||
|
this.valueMap = new SnmpValueMap();
|
||||||
|
} else {
|
||||||
|
setTitle(valueMap.getName());
|
||||||
|
loadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
// Hlavní panel s vnitřním marginem (padding)
|
||||||
|
JPanel mainPanel = new JPanel(new BorderLayout(10, 10));
|
||||||
|
mainPanel.setBorder(new EmptyBorder(15, 15, 15, 15)); // horní, levý, dolní, pravý
|
||||||
|
|
||||||
|
// ---- Horní panel: název na střed ----
|
||||||
|
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
|
topPanel.add(new JLabel("Název:"));
|
||||||
|
topPanel.add(nameField);
|
||||||
|
mainPanel.add(topPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
// ---- Tabulka se dvěma sloupci: rawValue a mappedValue ----
|
||||||
|
String[] columns = {"RAW data", "Mapovana hodnota"};
|
||||||
|
tableModel = new DefaultTableModel(columns, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
table = new JTable(tableModel);
|
||||||
|
JScrollPane scrollPane = new JScrollPane(table);
|
||||||
|
scrollPane.setPreferredSize(new Dimension(400, 150));
|
||||||
|
|
||||||
|
// ---- Tlačítka Přidat / Odebrat řádek ----
|
||||||
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
|
JButton addButton = new JButton("Přidat řádek");
|
||||||
|
JButton removeButton = new JButton("Odebrat řádek");
|
||||||
|
buttonPanel.add(addButton);
|
||||||
|
buttonPanel.add(removeButton);
|
||||||
|
|
||||||
|
JPanel centerPanel = new JPanel(new BorderLayout(5, 5));
|
||||||
|
centerPanel.add(scrollPane, BorderLayout.CENTER);
|
||||||
|
centerPanel.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
mainPanel.add(centerPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// ---- Spodní panel: tlačítka Uložit / Zrušit na střed ----
|
||||||
|
JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
|
||||||
|
JButton saveButton = new JButton("Uložit");
|
||||||
|
JButton cancelButton = new JButton("Zrušit");
|
||||||
|
bottomPanel.add(saveButton);
|
||||||
|
bottomPanel.add(cancelButton);
|
||||||
|
mainPanel.add(bottomPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
// Přidáme mainPanel do dialogu
|
||||||
|
add(mainPanel);
|
||||||
|
|
||||||
|
// ---- Akce tlačítek ----
|
||||||
|
addButton.addActionListener(e -> tableModel.addRow(new Object[]{"", ""}));
|
||||||
|
|
||||||
|
removeButton.addActionListener(e -> {
|
||||||
|
int selectedRow = table.getSelectedRow();
|
||||||
|
if (selectedRow != -1) {
|
||||||
|
tableModel.removeRow(selectedRow);
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(this, "Vyberte řádek k odebrání.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// UPRAVA: Před uložením ukončíme editaci tabulky
|
||||||
|
saveButton.addActionListener(e -> {
|
||||||
|
// Ukončíme právě probíhající editaci buňky (pokud nějaká je)
|
||||||
|
if (table.isEditing()) {
|
||||||
|
table.getCellEditor().stopCellEditing();
|
||||||
|
}
|
||||||
|
saveData();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Pro jistotu i při zrušení ukončíme editaci (ale není nutné)
|
||||||
|
cancelButton.addActionListener(e -> {
|
||||||
|
if (table.isEditing()) {
|
||||||
|
table.getCellEditor().cancelCellEditing();
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
|
||||||
|
// ---- Nastavení okna ----
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
fixedWidth = getWidth();
|
||||||
|
setResizable(true);
|
||||||
|
addComponentListener(new ComponentAdapter() {
|
||||||
|
@Override
|
||||||
|
public void componentResized(ComponentEvent e) {
|
||||||
|
if (getWidth() != fixedWidth) {
|
||||||
|
setSize(fixedWidth, getHeight());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData() {
|
||||||
|
nameField.setText(valueMap.getName());
|
||||||
|
for (SnmpValueMapItem vmi : valueMap.getItem()) {
|
||||||
|
tableModel.addRow(new Object[]{vmi.getRawValue(), vmi.getMappedValue()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void saveData() {
|
||||||
|
String name = nameField.getText().trim();
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Vyplňte prosím název.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SnmpValueMapItem> items = new ArrayList<>();
|
||||||
|
for (int i = 0; i < tableModel.getRowCount(); i++) {
|
||||||
|
String raw = tableModel.getValueAt(i, 0) != null ? tableModel.getValueAt(i, 0).toString().trim() : "";
|
||||||
|
String mapped = tableModel.getValueAt(i, 1) != null ? tableModel.getValueAt(i, 1).toString().trim() : "";
|
||||||
|
items.add(new SnmpValueMapItem(raw, mapped));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (items.size() == 0) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Vyplňte mapování");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
valueMap.setName(name);
|
||||||
|
valueMap.setItem(items);
|
||||||
|
|
||||||
|
if (newMaping) {
|
||||||
|
NettyClientManager.sendMessage(Message.VALUE_MAP_NEW, valueMap);
|
||||||
|
} else {
|
||||||
|
NettyClientManager.sendMessage(Message.VALUE_MAP_EDIT, valueMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,304 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.Toolkit;
|
||||||
|
import java.awt.datatransfer.Clipboard;
|
||||||
|
import java.awt.datatransfer.StringSelection;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JComboBox;
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import javax.swing.SwingWorker;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.lib.SnmpWalk;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.SnmpProfile;
|
||||||
|
import jnet.lib.object.SnmpTemplate;
|
||||||
|
import jnet.lib.object.SnmpWalkItem;
|
||||||
|
import org.snmp4j.CommunityTarget;
|
||||||
|
import org.snmp4j.mp.SnmpConstants;
|
||||||
|
import org.snmp4j.smi.GenericAddress;
|
||||||
|
import org.snmp4j.smi.OctetString;
|
||||||
|
|
||||||
|
public class DialogSnmpWalk extends JDialog {
|
||||||
|
|
||||||
|
private JTextField ipField = new JTextField("192.168.1.1", 15);
|
||||||
|
private JTextField portField = new JTextField("161", 5);
|
||||||
|
private JTextField communityField = new JTextField("public", 15);
|
||||||
|
private JTextField rootOidField = new JTextField(".1.3.6.1.2.1", 30);
|
||||||
|
private JComboBox<String> versionCombo = new JComboBox<>(new String[]{"v1", "v2c"});
|
||||||
|
private JButton walkButton;
|
||||||
|
private JButton stopButton;
|
||||||
|
private JTable resultTable;
|
||||||
|
private DefaultTableModel tableModel;
|
||||||
|
private JLabel statusLabel;
|
||||||
|
private AtomicBoolean cancelFlag = new AtomicBoolean(false);
|
||||||
|
private SwingWorker<List<SnmpWalkItem>, Void> currentWorker;
|
||||||
|
|
||||||
|
public DialogSnmpWalk() {
|
||||||
|
prepare();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DialogSnmpWalk(Node node) {
|
||||||
|
prepare();
|
||||||
|
|
||||||
|
SnmpProfile profile = Client.snmpProfile.stream()
|
||||||
|
.filter(p -> p.getId() == node.getSnmpProfile())
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
ipField.setText(node.getIp());
|
||||||
|
communityField.setText(profile.getCommunityRead());
|
||||||
|
portField.setText(profile.getPort());
|
||||||
|
versionCombo.setSelectedIndex(profile.getVersion());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepare() {
|
||||||
|
setModal(false);
|
||||||
|
setTitle("SNMP Walk");
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
init();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setMinimumSize(new Dimension(1000, getHeight()));
|
||||||
|
setResizable(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
|
||||||
|
// === Horní panel s nastavením ===
|
||||||
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
|
JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
|
||||||
|
|
||||||
|
// ip
|
||||||
|
topPanel.add(new JLabel("IP:"));
|
||||||
|
topPanel.add(ipField);
|
||||||
|
|
||||||
|
// Port
|
||||||
|
topPanel.add(new JLabel("Port:"));
|
||||||
|
topPanel.add(portField);
|
||||||
|
|
||||||
|
// Community
|
||||||
|
topPanel.add(new JLabel("Community:"));
|
||||||
|
topPanel.add(communityField);
|
||||||
|
|
||||||
|
// Verze
|
||||||
|
topPanel.add(new JLabel("Verze:"));
|
||||||
|
topPanel.add(versionCombo);
|
||||||
|
|
||||||
|
// oid
|
||||||
|
topPanel.add(new JLabel("Kořenový OID:"));
|
||||||
|
topPanel.add(rootOidField);
|
||||||
|
|
||||||
|
// Tlačítko Walk
|
||||||
|
walkButton = new JButton("Walk");
|
||||||
|
walkButton.addActionListener(e -> doWalk());
|
||||||
|
topPanel.add(walkButton);
|
||||||
|
|
||||||
|
// Tlačítko stop
|
||||||
|
stopButton = new JButton("Stop");
|
||||||
|
stopButton.addActionListener(e -> doStop());
|
||||||
|
topPanel.add(stopButton);
|
||||||
|
|
||||||
|
panel.add(topPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
|
||||||
|
// === Tabulka výsledků ===
|
||||||
|
String[] COLUMN_NAMES = {"Type zařízeni", "Název", "Poznámka"};
|
||||||
|
tableModel = new DefaultTableModel(COLUMN_NAMES, 0);
|
||||||
|
tableModel = new DefaultTableModel(COLUMN_NAMES, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
resultTable = new JTable(tableModel);
|
||||||
|
resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
|
||||||
|
JScrollPane scrollPane = new JScrollPane(resultTable);
|
||||||
|
panel.add(scrollPane, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// === Spodní stavový řádek ===
|
||||||
|
statusLabel = new JLabel("Připraven");
|
||||||
|
panel.add(statusLabel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
// === Kontextové menu pro tabulku ===
|
||||||
|
resultTable.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger()) {
|
||||||
|
showPopup(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger()) {
|
||||||
|
showPopup(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPopup(MouseEvent e) {
|
||||||
|
int row = resultTable.rowAtPoint(e.getPoint());
|
||||||
|
if (row >= 0) {
|
||||||
|
// Vybereme řádek pod kurzorem
|
||||||
|
resultTable.setRowSelectionInterval(row, row);
|
||||||
|
Object oid = tableModel.getValueAt(row, 0);
|
||||||
|
Object type = tableModel.getValueAt(row, 1);
|
||||||
|
Object value = tableModel.getValueAt(row, 2);
|
||||||
|
|
||||||
|
JPopupMenu popup = new JPopupMenu();
|
||||||
|
|
||||||
|
JMenuItem createTemplate = new JMenuItem("Vytvořit šablonu sondy");
|
||||||
|
createTemplate.addActionListener(ev -> {
|
||||||
|
createTemplate(oid.toString(), SnmpWalk.getTypeId(type.toString()));
|
||||||
|
});
|
||||||
|
popup.add(createTemplate);
|
||||||
|
|
||||||
|
JMenuItem copyOid = new JMenuItem("Kopírovat OID");
|
||||||
|
copyOid.addActionListener(ev -> {
|
||||||
|
if (oid != null) {
|
||||||
|
copyToClipboard(oid.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.add(copyOid);
|
||||||
|
|
||||||
|
JMenuItem copyValue = new JMenuItem("Kopírovat hodnotu");
|
||||||
|
copyValue.addActionListener(ev -> {
|
||||||
|
if (value != null) {
|
||||||
|
copyToClipboard(value.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popup.add(copyValue);
|
||||||
|
|
||||||
|
JMenuItem copyRow = new JMenuItem("Kopírovat celý řádek");
|
||||||
|
copyRow.addActionListener(ev -> {
|
||||||
|
String rowStr = (oid != null ? oid : "") + "\t"
|
||||||
|
+ (type != null ? type : "") + "\t"
|
||||||
|
+ (value != null ? value : "");
|
||||||
|
copyToClipboard(rowStr);
|
||||||
|
});
|
||||||
|
popup.add(copyRow);
|
||||||
|
|
||||||
|
popup.show(resultTable, e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doWalk() {
|
||||||
|
// Validace vstupů
|
||||||
|
String ip = ipField.getText().trim();
|
||||||
|
if (ip.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Zadejte IP adresu.", "Chyba", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int port;
|
||||||
|
try {
|
||||||
|
port = Integer.parseInt(portField.getText().trim());
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Neplatný port.", "Chyba", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String community = communityField.getText().trim();
|
||||||
|
if (community.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Zadejte community.", "Chyba", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int version = versionCombo.getSelectedIndex() == 0 ? SnmpConstants.version1 : SnmpConstants.version2c;
|
||||||
|
String rootOid = rootOidField.getText().trim();
|
||||||
|
if (rootOid.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Zadejte kořenový OID.", "Chyba", JOptionPane.ERROR_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Příprava
|
||||||
|
tableModel.setRowCount(0);
|
||||||
|
statusLabel.setText("Probíhá walk...");
|
||||||
|
walkButton.setEnabled(false);
|
||||||
|
stopButton.setEnabled(true);
|
||||||
|
cancelFlag.set(false);
|
||||||
|
|
||||||
|
// Spuštění walku v pozadí
|
||||||
|
currentWorker = new SwingWorker<List<SnmpWalkItem>, Void>() {
|
||||||
|
@Override
|
||||||
|
protected List<SnmpWalkItem> doInBackground() throws Exception {
|
||||||
|
CommunityTarget target = new CommunityTarget();
|
||||||
|
target.setCommunity(new OctetString(community));
|
||||||
|
target.setAddress(GenericAddress.parse("udp:" + ip + "/" + port));
|
||||||
|
target.setRetries(2);
|
||||||
|
target.setTimeout(1500);
|
||||||
|
target.setVersion(version);
|
||||||
|
return SnmpWalk.walk(rootOid, target, cancelFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void done() {
|
||||||
|
walkButton.setEnabled(true);
|
||||||
|
stopButton.setEnabled(false);
|
||||||
|
try {
|
||||||
|
List<SnmpWalkItem> items = get();
|
||||||
|
if (items == null) {
|
||||||
|
statusLabel.setText("Walk přerušen.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
statusLabel.setText("Hotovo, nalezeno " + items.size() + " položek.");
|
||||||
|
for (SnmpWalkItem item : items) {
|
||||||
|
tableModel.addRow(new Object[]{item.getOid(), item.getType(), item.getValue()});
|
||||||
|
}
|
||||||
|
if (items.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(DialogSnmpWalk.this,
|
||||||
|
"Walk nevrátil žádná data.\nZkontrolujte IP, community a verzi.",
|
||||||
|
"Informace", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
statusLabel.setText("Chyba: " + ex.getMessage());
|
||||||
|
JOptionPane.showMessageDialog(DialogSnmpWalk.this,
|
||||||
|
"Chyba při walku:\n" + ex.getMessage(),
|
||||||
|
"Chyba", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
currentWorker = null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
currentWorker.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void doStop() {
|
||||||
|
// Zatím prázdná – možno později implementovat přerušení
|
||||||
|
}
|
||||||
|
|
||||||
|
// === Pomocná metoda pro kopírování do schránky ===
|
||||||
|
private void copyToClipboard(String text) {
|
||||||
|
if (text == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||||
|
StringSelection selection = new StringSelection(text);
|
||||||
|
clipboard.setContents(selection, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createTemplate(String oid, int type) {
|
||||||
|
SnmpTemplate template = new SnmpTemplate();
|
||||||
|
template.setOid(oid);
|
||||||
|
template.setDataType(type);
|
||||||
|
new DialogSnmpTemplate(template, true).show();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,175 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import jnet.client.gui.Window;
|
||||||
|
import jnet.client.gui.serversettings.ServerSettingsPanel;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.User;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
public class DialogUser extends JDialog {
|
||||||
|
|
||||||
|
private boolean newUser;
|
||||||
|
private final User user;
|
||||||
|
private JTextField userNameField;
|
||||||
|
private JTextField passwordField;
|
||||||
|
private JCheckBox setServer;
|
||||||
|
private JCheckBox addMap;
|
||||||
|
private JCheckBox deleteMap;
|
||||||
|
private JCheckBox editMap;
|
||||||
|
private JCheckBox addObject;
|
||||||
|
private JCheckBox deleteObject;
|
||||||
|
private JCheckBox editObject;
|
||||||
|
|
||||||
|
public DialogUser(User user, boolean newUser) {
|
||||||
|
this.user = user;
|
||||||
|
this.newUser = newUser;
|
||||||
|
|
||||||
|
setTitle(user == null ? "Přidat uživatele" : "Upravit uživatele");
|
||||||
|
setModal(true);
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
initComponents();
|
||||||
|
if (!newUser) {
|
||||||
|
loadUserData();
|
||||||
|
} else {
|
||||||
|
passwordField.setText(generateRandomPassword(8));
|
||||||
|
}
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initComponents() {
|
||||||
|
JPanel panel = new JPanel(new GridBagLayout());
|
||||||
|
GridBagConstraints gbc = new GridBagConstraints();
|
||||||
|
gbc.insets = new Insets(5, 10, 5, 10);
|
||||||
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
||||||
|
gbc.anchor = GridBagConstraints.WEST;
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
userNameField = new JTextField(15);
|
||||||
|
addRow(panel, gbc, row++, "Uživatelské jméno", userNameField);
|
||||||
|
|
||||||
|
passwordField = new JTextField(15);
|
||||||
|
addRow(panel, gbc, row++, "Heslo", passwordField);
|
||||||
|
|
||||||
|
setServer = new JCheckBox("Nastavit server");
|
||||||
|
addMap = new JCheckBox("Přidat mapu");
|
||||||
|
deleteMap = new JCheckBox("Odebrat mapu");
|
||||||
|
editMap = new JCheckBox("Upravit mapu");
|
||||||
|
addObject = new JCheckBox("Přidat objekt");
|
||||||
|
deleteObject = new JCheckBox("Odebrat objekt");
|
||||||
|
editObject = new JCheckBox("Upravit objekt");
|
||||||
|
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(setServer, gbc);
|
||||||
|
row++;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(addMap, gbc);
|
||||||
|
row++;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(deleteMap, gbc);
|
||||||
|
row++;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(editMap, gbc);
|
||||||
|
row++;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(addObject, gbc);
|
||||||
|
row++;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(deleteObject, gbc);
|
||||||
|
row++;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(editObject, gbc);
|
||||||
|
row++;
|
||||||
|
|
||||||
|
JButton actionBtn = new JButton(user == null ? "Přidat" : "Upravit");
|
||||||
|
JButton cancelBtn = new JButton("Storno");
|
||||||
|
|
||||||
|
actionBtn.addActionListener(e -> performAction());
|
||||||
|
cancelBtn.addActionListener(e -> dispose());
|
||||||
|
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
panel.add(actionBtn, gbc);
|
||||||
|
gbc.gridx = 2;
|
||||||
|
panel.add(cancelBtn, gbc);
|
||||||
|
|
||||||
|
add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addRow(JPanel panel, GridBagConstraints gbc, int row, String label, JComponent comp) {
|
||||||
|
gbc.gridx = 0;
|
||||||
|
gbc.gridy = row;
|
||||||
|
gbc.gridwidth = 1;
|
||||||
|
panel.add(new JLabel(label), gbc);
|
||||||
|
gbc.gridx = 1;
|
||||||
|
gbc.gridwidth = 2;
|
||||||
|
panel.add(comp, gbc);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadUserData() {
|
||||||
|
userNameField.setText(user.getUsername());
|
||||||
|
setServer.setSelected(user.isEditServer());
|
||||||
|
addMap.setSelected(user.isAddMap());
|
||||||
|
deleteMap.setSelected(user.isRemoveMap());
|
||||||
|
editMap.setSelected(user.isEditMap());
|
||||||
|
addObject.setSelected(user.isAddObject());
|
||||||
|
deleteObject.setSelected(user.isRemoveObject());
|
||||||
|
editObject.setSelected(user.isEditObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performAction() {
|
||||||
|
String name = userNameField.getText().trim();
|
||||||
|
if (name.length() < 3) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Uživatelské jméno musí mít alespoň 3 znaky.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String pwd = passwordField.getText().trim();
|
||||||
|
if (pwd.isEmpty() && newUser) {
|
||||||
|
JOptionPane.showMessageDialog(this, "Heslo nesmí být prázdné.", "Chyba", JOptionPane.WARNING_MESSAGE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
User u = new User(
|
||||||
|
0,
|
||||||
|
name,
|
||||||
|
pwd,
|
||||||
|
addMap.isSelected(),
|
||||||
|
deleteMap.isSelected(),
|
||||||
|
editMap.isSelected(),
|
||||||
|
addObject.isSelected(),
|
||||||
|
deleteObject.isSelected(),
|
||||||
|
editObject.isSelected(),
|
||||||
|
setServer.isSelected()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (newUser) {
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.USER_ADD, u));
|
||||||
|
} else {
|
||||||
|
u.setId(user.getId());
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.USER_EDIT, u));
|
||||||
|
}
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
Window.showServerSettings(ServerSettingsPanel.TAB_USERS);
|
||||||
|
dispose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String generateRandomPassword(int length) {
|
||||||
|
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
|
SecureRandom random = new SecureRandom();
|
||||||
|
StringBuilder sb = new StringBuilder(length);
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
sb.append(chars.charAt(random.nextInt(chars.length())));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
package jnet.client.gui.dialog;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.WindowAdapter;
|
||||||
|
import java.awt.event.WindowEvent;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.PingResponseParser;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.PingResult;
|
||||||
|
|
||||||
|
public class DialogUserPing extends JFrame {
|
||||||
|
|
||||||
|
private Node node;
|
||||||
|
private JTextArea resultArea = new JTextArea();
|
||||||
|
private JLabel statLabel = new JLabel("Statistika: Čekám na odpovědi...");
|
||||||
|
private JButton startButton = new JButton("Start");
|
||||||
|
private JButton stopButton = new JButton("Stop");
|
||||||
|
|
||||||
|
// Statistiky
|
||||||
|
private int totalSent = 0;
|
||||||
|
private int successful = 0;
|
||||||
|
private int failed = 0;
|
||||||
|
private long totalTimeMs = 0;
|
||||||
|
|
||||||
|
public DialogUserPing(Node node) {
|
||||||
|
this.node = node;
|
||||||
|
|
||||||
|
prepare();
|
||||||
|
|
||||||
|
// Automaticky spustíme ping po otevření dialogu
|
||||||
|
startPing();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepare() {
|
||||||
|
setTitle("Ping: " + node.getName());
|
||||||
|
setName("pingNode_" + node.getId());
|
||||||
|
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||||
|
|
||||||
|
// Přidáme listener pro zavření okna
|
||||||
|
addWindowListener(new WindowAdapter() {
|
||||||
|
@Override
|
||||||
|
public void windowClosing(WindowEvent e) {
|
||||||
|
stopPing();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
init();
|
||||||
|
pack();
|
||||||
|
setLocationRelativeTo(null);
|
||||||
|
setSize(new Dimension(400, 450));
|
||||||
|
setResizable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
|
// === Statistiky ===
|
||||||
|
statLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||||
|
statLabel.setHorizontalAlignment(JLabel.CENTER);
|
||||||
|
panel.add(statLabel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
// === Textová oblast pro odpovědi ===
|
||||||
|
resultArea.setEditable(false);
|
||||||
|
resultArea.setRows(10);
|
||||||
|
resultArea.setLineWrap(true);
|
||||||
|
resultArea.setWrapStyleWord(true);
|
||||||
|
resultArea.setMargin(new Insets(10, 15, 10, 15));
|
||||||
|
|
||||||
|
panel.add(new JScrollPane(resultArea), BorderLayout.CENTER);
|
||||||
|
|
||||||
|
// === Tlačítka ===
|
||||||
|
JPanel buttonPanel = new JPanel();
|
||||||
|
startButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
startPing();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonPanel.add(startButton);
|
||||||
|
|
||||||
|
stopButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
stopPing();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonPanel.add(stopButton);
|
||||||
|
|
||||||
|
panel.add(buttonPanel, BorderLayout.SOUTH);
|
||||||
|
add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startPing() {
|
||||||
|
startButton.setEnabled(false);
|
||||||
|
stopButton.setEnabled(true);
|
||||||
|
|
||||||
|
// Reset statistik
|
||||||
|
totalSent = 0;
|
||||||
|
successful = 0;
|
||||||
|
failed = 0;
|
||||||
|
totalTimeMs = 0;
|
||||||
|
updateStats();
|
||||||
|
|
||||||
|
// Vyčistíme textovou oblast
|
||||||
|
resultArea.setText("");
|
||||||
|
|
||||||
|
Object[] obj = {node.getIp(), getName()};
|
||||||
|
NettyClientManager.sendMessage(Message.USER_PING_START, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopPing() {
|
||||||
|
startButton.setEnabled(true);
|
||||||
|
stopButton.setEnabled(false);
|
||||||
|
Object[] obj = {node.getIp(), getName()};
|
||||||
|
NettyClientManager.sendMessage(Message.USER_PING_STOP, obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendLine(String text) {
|
||||||
|
resultArea.append(text + "\n\n");
|
||||||
|
resultArea.setCaretPosition(resultArea.getDocument().getLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualizuje zobrazení statistiky.
|
||||||
|
*/
|
||||||
|
private void updateStats() {
|
||||||
|
String avgText = "";
|
||||||
|
if (successful > 0) {
|
||||||
|
double avg = (double) totalTimeMs / successful;
|
||||||
|
avgText = String.format(", průměr: %.1f ms", avg);
|
||||||
|
}
|
||||||
|
|
||||||
|
String stats = String.format("Odesláno: %d | Úspěšných: %d | Chybných: %d%s",
|
||||||
|
totalSent, successful, failed, avgText);
|
||||||
|
statLabel.setText(stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void response(String response) {
|
||||||
|
PingResult result = PingResponseParser.parse(response);
|
||||||
|
|
||||||
|
// Zvýšíme počet odeslaných
|
||||||
|
totalSent++;
|
||||||
|
|
||||||
|
if (result != null && result.isSuccess()) {
|
||||||
|
// Úspěšný ping
|
||||||
|
successful++;
|
||||||
|
totalTimeMs += result.getTimeMs();
|
||||||
|
|
||||||
|
String formatted = String.format("✓ Odpověď od %s za %d ms (TTL=%d, bytes=%d)",
|
||||||
|
result.getIp(), result.getTimeMs(), result.getTtl(), result.getBytes());
|
||||||
|
appendLine(formatted);
|
||||||
|
|
||||||
|
} else if (result != null && !result.isSuccess()) {
|
||||||
|
// Neúspěšný ping (timeout apod.)
|
||||||
|
failed++;
|
||||||
|
appendLine("✗ " + response);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Neznámý řádek (např. statistika na konci)
|
||||||
|
appendLine(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Aktualizujeme statistiku na hlavním vlákně Swing
|
||||||
|
javax.swing.SwingUtilities.invokeLater(() -> updateStats());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
package jnet.client.gui.dialog.object;
|
package jnet.client.gui.dialog.node;
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JDialog;
|
import javax.swing.JDialog;
|
||||||
|
|
@ -18,16 +19,17 @@ import javax.swing.SwingUtilities;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
import jnet.client.Client;
|
import jnet.client.Client;
|
||||||
import jnet.client.network.NettyClient;
|
import jnet.client.client.NettyClientManager;
|
||||||
import jnet.lib.Message;
|
import jnet.lib.Message;
|
||||||
import jnet.lib.Status;
|
import jnet.lib.Status;
|
||||||
import jnet.lib.object.MapObject;
|
import jnet.lib.object.DeviceInfo;
|
||||||
import jnet.lib.snmp.DeviceInfo;
|
import jnet.lib.object.Interface;
|
||||||
import jnet.lib.snmp.Interface;
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.SnmpProfile;
|
||||||
|
|
||||||
public class ObjectDialog extends JFrame {
|
public class DialogNodeDevice extends JFrame {
|
||||||
|
|
||||||
private MapObject obj;
|
private Node obj;
|
||||||
private int mapId;
|
private int mapId;
|
||||||
private Boolean newObject;
|
private Boolean newObject;
|
||||||
|
|
||||||
|
|
@ -35,14 +37,14 @@ public class ObjectDialog extends JFrame {
|
||||||
private TabSettings tabSettings;
|
private TabSettings tabSettings;
|
||||||
private TabServices tabServices;
|
private TabServices tabServices;
|
||||||
private TabEvents tabEvents;
|
private TabEvents tabEvents;
|
||||||
|
private TabProbes tabProbes;
|
||||||
|
|
||||||
private JButton snmpTest = new JButton("Test SNMP");
|
private JButton snmpTest = new JButton("Test SNMP");
|
||||||
private JButton btnRefresh = new JButton("Obnovit");
|
private JButton btnRefresh = new JButton("Obnovit");
|
||||||
private JDialog progress;
|
private JDialog progress;
|
||||||
|
|
||||||
public ObjectDialog(MapObject obj) {
|
public DialogNodeDevice(Node obj) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.mapId = obj.getMap();
|
|
||||||
this.newObject = false;
|
this.newObject = false;
|
||||||
|
|
||||||
// identifikator okna
|
// identifikator okna
|
||||||
|
|
@ -50,17 +52,19 @@ public class ObjectDialog extends JFrame {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectDialog(MapObject obj, boolean newObject) {
|
public DialogNodeDevice(Node obj, boolean newObject) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.mapId = obj.getMap();
|
|
||||||
this.newObject = newObject;
|
this.newObject = newObject;
|
||||||
|
if (newObject) {
|
||||||
|
obj.setProbe(new ArrayList<>());
|
||||||
|
}
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init() {
|
private void init() {
|
||||||
|
|
||||||
if (newObject) {
|
if (newObject) {
|
||||||
setTitle("Nový objekt");
|
setTitle("Nové zařízení");
|
||||||
} else {
|
} else {
|
||||||
setTitle(obj.getName());
|
setTitle(obj.getName());
|
||||||
}
|
}
|
||||||
|
|
@ -81,19 +85,20 @@ public class ObjectDialog extends JFrame {
|
||||||
tabSettings = new TabSettings(obj, newObject);
|
tabSettings = new TabSettings(obj, newObject);
|
||||||
tabServices = new TabServices(obj, newObject);
|
tabServices = new TabServices(obj, newObject);
|
||||||
tabEvents = new TabEvents(obj);
|
tabEvents = new TabEvents(obj);
|
||||||
|
tabProbes = new TabProbes(obj, this);
|
||||||
|
|
||||||
tabbedPane.addTab("Informace", tabInfo);
|
tabbedPane.addTab("Informace", tabInfo);
|
||||||
|
tabbedPane.addTab("Události", tabEvents);
|
||||||
tabbedPane.addTab("Nastaveni", tabSettings);
|
tabbedPane.addTab("Nastaveni", tabSettings);
|
||||||
tabbedPane.addTab("Služby", tabServices);
|
tabbedPane.addTab("Služby", tabServices);
|
||||||
tabbedPane.addTab("Události", tabEvents);
|
tabbedPane.addTab("Sondy", tabProbes);
|
||||||
//tabbedPane.addTab("Sondy", tabSondy());
|
|
||||||
|
|
||||||
// Přidání listeneru na změnu tabu
|
// Přidání listeneru na změnu tabu
|
||||||
tabbedPane.addChangeListener(new ChangeListener() {
|
tabbedPane.addChangeListener(new ChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void stateChanged(ChangeEvent e) {
|
public void stateChanged(ChangeEvent e) {
|
||||||
int selectedIndex = tabbedPane.getSelectedIndex();
|
int selectedIndex = tabbedPane.getSelectedIndex();
|
||||||
if (selectedIndex == 1) { // pokud je zobrazena zalozka nastaveni zobrazit tlačítko test snmp
|
if (selectedIndex == 2) { // pokud je zobrazena zalozka nastaveni zobrazit tlačítko test snmp
|
||||||
snmpTest.setVisible(true);
|
snmpTest.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
snmpTest.setVisible(false);
|
snmpTest.setVisible(false);
|
||||||
|
|
@ -108,9 +113,10 @@ public class ObjectDialog extends JFrame {
|
||||||
|
|
||||||
// pokud se jedna o novy objekt
|
// pokud se jedna o novy objekt
|
||||||
if (newObject) {
|
if (newObject) {
|
||||||
tabbedPane.setSelectedIndex(1); // prepne na kartu nastaveni
|
tabbedPane.setSelectedIndex(2); // prepne na kartu nastaveni
|
||||||
tabbedPane.setEnabledAt(0, false); // vypne kartu informace
|
tabbedPane.setEnabledAt(0, false); // vypne kartu informace
|
||||||
tabbedPane.setEnabledAt(3, false); // vypne kartu udalosti
|
tabbedPane.setEnabledAt(1, false); // vypne kartu udalosti
|
||||||
|
tabbedPane.setEnabledAt(4, false); // vypne kartu udalosti
|
||||||
} else {
|
} else {
|
||||||
// pokud se nejsedna o novy objekt odeslat snmp pozadavek na ziskani informaci o zarizeni
|
// pokud se nejsedna o novy objekt odeslat snmp pozadavek na ziskani informaci o zarizeni
|
||||||
snmpRequest();
|
snmpRequest();
|
||||||
|
|
@ -133,14 +139,14 @@ public class ObjectDialog extends JFrame {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ulozeni do objektu
|
// ulozeni do objektu
|
||||||
obj.setMap(mapId);
|
obj.setType(Node.NODE_DEVICE);
|
||||||
obj.setName(nazev);
|
obj.setName(nazev);
|
||||||
obj.setIp(ip);
|
obj.setIp(ip);
|
||||||
obj.setUser(tabSettings.getUser());
|
obj.setUser(tabSettings.getUser());
|
||||||
obj.setPassword(new String(tabSettings.getPassword()));
|
obj.setPassword(new String(tabSettings.getPassword()));
|
||||||
obj.setObjectType(Client.objectType.get(tabSettings.getObjType()).getId());
|
obj.setIcon(Client.deviceType.get(tabSettings.getObjType()).getId());
|
||||||
obj.setSnmpProfile(Client.snmpProfile.get(tabSettings.getSnmpProfile()).getId());
|
obj.setSnmpProfile(Client.snmpProfile.get(tabSettings.getSnmpProfile()).getId());
|
||||||
obj.setActive(tabSettings.isActive());
|
obj.setPing(tabSettings.isActive());
|
||||||
obj.setDescription(tabSettings.getDesc());
|
obj.setDescription(tabSettings.getDesc());
|
||||||
obj.setLocation(tabSettings.getLoc());
|
obj.setLocation(tabSettings.getLoc());
|
||||||
|
|
||||||
|
|
@ -177,7 +183,7 @@ public class ObjectDialog extends JFrame {
|
||||||
obj.setSmsPort(smsPort);
|
obj.setSmsPort(smsPort);
|
||||||
obj.setSmsVerze(tabServices.getSmsVersion());
|
obj.setSmsVerze(tabServices.getSmsVersion());
|
||||||
|
|
||||||
if (!obj.isActive() || newObject) {
|
if (!obj.isPing() || newObject) {
|
||||||
obj.setStatus(Status.NA);
|
obj.setStatus(Status.NA);
|
||||||
}
|
}
|
||||||
// ArrayList<SnmpProbe> probe = new ArrayList<>();
|
// ArrayList<SnmpProbe> probe = new ArrayList<>();
|
||||||
|
|
@ -185,11 +191,12 @@ public class ObjectDialog extends JFrame {
|
||||||
// probe.addAll(obj.getSnmpProbe());
|
// probe.addAll(obj.getSnmpProbe());
|
||||||
// }
|
// }
|
||||||
// obj.setSnmpProbe(probe);
|
// obj.setSnmpProbe(probe);
|
||||||
|
|
||||||
if (newObject) {
|
if (newObject) {
|
||||||
NettyClient.send(Message.ADD_OBJECT, obj);
|
NettyClientManager.sendMessage(new Message(Message.NODE_ADD, obj));
|
||||||
|
dispose();
|
||||||
} else {
|
} else {
|
||||||
NettyClient.send(Message.UPDATE_OBJECT, obj);
|
NettyClientManager.sendMessage(new Message(Message.NODE_CHANGE, obj));
|
||||||
|
dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -208,8 +215,9 @@ public class ObjectDialog extends JFrame {
|
||||||
snmpTest.addActionListener(new ActionListener() {
|
snmpTest.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Object[] o = {getName(), obj};
|
SnmpProfile profile = Client.snmpProfile.get(tabSettings.getSnmpProfile());
|
||||||
NettyClient.send(Message.SNMP_TEST, o);
|
Object[] o = {tabSettings.getIp(), profile.getPort(), profile.getVersion(), profile.getCommunityRead(), getName()};
|
||||||
|
NettyClientManager.sendMessage(Message.SNMP_TEST, o);
|
||||||
progress = showProgress();
|
progress = showProgress();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -240,6 +248,7 @@ public class ObjectDialog extends JFrame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setDeviceInfo(DeviceInfo di) {
|
public void setDeviceInfo(DeviceInfo di) {
|
||||||
this.tabInfo.setName(di.getSysName());
|
this.tabInfo.setName(di.getSysName());
|
||||||
this.tabInfo.setDesc(di.getSysDescr());
|
this.tabInfo.setDesc(di.getSysDescr());
|
||||||
|
|
@ -284,8 +293,11 @@ public class ObjectDialog extends JFrame {
|
||||||
|
|
||||||
private void snmpRequest() {
|
private void snmpRequest() {
|
||||||
Object[] data = {getName(), this.obj};
|
Object[] data = {getName(), this.obj};
|
||||||
NettyClient.send(Message.SNMP_OBJECT_INFO, data);
|
NettyClientManager.sendMessage(Message.NODE_SNMP_INFO, data);
|
||||||
NettyClient.send(Message.SNMP_OBJECT_INTERFACE, data);
|
NettyClientManager.sendMessage(Message.NODE_SNMP_INTERFACE, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshProbeTab() {
|
||||||
|
tabProbes.loadData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jnet.client.gui.dialog.object;
|
package jnet.client.gui.dialog.node;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
|
@ -12,21 +12,20 @@ import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import jnet.client.Client;
|
import jnet.client.Client;
|
||||||
import jnet.client.network.NettyClient;
|
|
||||||
import jnet.lib.EventComparator;
|
import jnet.lib.EventComparator;
|
||||||
import jnet.lib.LogFile;
|
import jnet.lib.LogFile;
|
||||||
import jnet.lib.Message;
|
import jnet.lib.Status;
|
||||||
import jnet.lib.object.Event;
|
import jnet.lib.object.Event;
|
||||||
import jnet.lib.object.MapObject;
|
import jnet.lib.object.Node;
|
||||||
|
|
||||||
public class TabEvents extends JPanel {
|
public class TabEvents extends JPanel {
|
||||||
|
|
||||||
private MapObject obj;
|
private Node obj;
|
||||||
|
|
||||||
public TabEvents(MapObject obj) {
|
public TabEvents(Node obj) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
|
|
||||||
String column[] = {"Začátek", "Konec", "Stav"};
|
String column[] = {"Začátek", "Konec", "Délka", "Stav"};
|
||||||
DefaultTableModel tableModel = new DefaultTableModel(column, 0) {
|
DefaultTableModel tableModel = new DefaultTableModel(column, 0) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -37,15 +36,15 @@ public class TabEvents extends JPanel {
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO pri vytvareni noveho objektu to vyhodi chybu
|
|
||||||
Collections.sort(Client.events, new EventComparator());
|
Collections.sort(Client.events, new EventComparator());
|
||||||
Collections.reverse(Client.events);
|
Collections.reverse(Client.events);
|
||||||
for (Event e : Client.events) {
|
for (Event e : Client.events) {
|
||||||
if (e.getObject() == obj.getId()) {
|
if (e.getNode()== obj.getId()) {
|
||||||
Object[] d = {
|
Object[] d = {
|
||||||
getDate(e.getStart()),
|
getDate(e.getStart()),
|
||||||
getDate(e.getEnd()),
|
getDate(e.getEnd()),
|
||||||
e.getDescription()};
|
getDuration(e.getStart(), e.getEnd()),
|
||||||
|
Status.getStatusName(e.getStatus())};
|
||||||
tableModel.addRow(d);
|
tableModel.addRow(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +62,7 @@ public class TabEvents extends JPanel {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
tableModel.setRowCount(0);
|
tableModel.setRowCount(0);
|
||||||
NettyClient.send(Message.DELETE_LOG, obj.getId());
|
//NettyClient.send(Message.DELETE_LOG, obj.getId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -78,5 +77,16 @@ public class TabEvents extends JPanel {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDuration(long startTime, long endTime) {
|
||||||
|
if (endTime != 0) {
|
||||||
|
long difference = endTime - startTime;
|
||||||
|
long seconds = difference / 1000;
|
||||||
|
long minutes = difference / (1000 * 60);
|
||||||
|
long hours = difference / (1000 * 60 * 60);
|
||||||
|
return hours + "h " + minutes + "m " + seconds + "s";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jnet.client.gui.dialog.object;
|
package jnet.client.gui.dialog.node;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
@ -6,15 +6,13 @@ import javax.swing.JPanel;
|
||||||
import javax.swing.JScrollPane;
|
import javax.swing.JScrollPane;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.DefaultTableModel;
|
import javax.swing.table.DefaultTableModel;
|
||||||
import jnet.client.network.NettyClient;
|
import jnet.lib.object.Interface;
|
||||||
import jnet.lib.Message;
|
import jnet.lib.object.Node;
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
import jnet.lib.snmp.Interface;
|
|
||||||
|
|
||||||
public class TabInfo extends JPanel {
|
public class TabInfo extends JPanel {
|
||||||
|
|
||||||
private String frameName;
|
private String frameName;
|
||||||
private MapObject obj;
|
private Node obj;
|
||||||
private JLabel uptime = new JLabel();
|
private JLabel uptime = new JLabel();
|
||||||
private JLabel name = new JLabel();
|
private JLabel name = new JLabel();
|
||||||
private JLabel description = new JLabel();
|
private JLabel description = new JLabel();
|
||||||
|
|
@ -22,7 +20,7 @@ public class TabInfo extends JPanel {
|
||||||
private DefaultTableModel tableModel;
|
private DefaultTableModel tableModel;
|
||||||
private JTable ifaceTable;
|
private JTable ifaceTable;
|
||||||
|
|
||||||
public TabInfo(String frameName, MapObject obj) {
|
public TabInfo(String frameName, Node obj) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.frameName = frameName;
|
this.frameName = frameName;
|
||||||
init();
|
init();
|
||||||
|
|
@ -67,7 +65,7 @@ public class TabInfo extends JPanel {
|
||||||
this.add(uptime);
|
this.add(uptime);
|
||||||
y = y + 30;
|
y = y + 30;
|
||||||
|
|
||||||
String column[] = {"Název", "Stav", "Admin", "Rychlost", "Typ", "Poslední změna"};
|
String column[] = {"Název", "Popis portu", "Stav", "Admin", "Rychlost", "Typ"};
|
||||||
tableModel = new DefaultTableModel(column, 0) {
|
tableModel = new DefaultTableModel(column, 0) {
|
||||||
@Override
|
@Override
|
||||||
public boolean isCellEditable(int row, int column) {
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
|
@ -78,11 +76,11 @@ public class TabInfo extends JPanel {
|
||||||
ifaceTable = new JTable(tableModel);
|
ifaceTable = new JTable(tableModel);
|
||||||
ifaceTable.getTableHeader().setReorderingAllowed(false); // Zakáže přeskupování sloupců
|
ifaceTable.getTableHeader().setReorderingAllowed(false); // Zakáže přeskupování sloupců
|
||||||
ifaceTable.getTableHeader().setResizingAllowed(false); // Zakáže změnu velikosti sloupců
|
ifaceTable.getTableHeader().setResizingAllowed(false); // Zakáže změnu velikosti sloupců
|
||||||
ifaceTable.getColumnModel().getColumn(0).setPreferredWidth(150); // Sloupec 0 bude mít šířku 100 px
|
ifaceTable.getColumnModel().getColumn(0).setPreferredWidth(80); // Sloupec 0 bude mít šířku 100 px
|
||||||
ifaceTable.getColumnModel().getColumn(1).setPreferredWidth(40); // Sloupec 1 bude mít šířku 100 px
|
ifaceTable.getColumnModel().getColumn(1).setPreferredWidth(120); // Sloupec 1 bude mít šířku 100 px
|
||||||
ifaceTable.getColumnModel().getColumn(2).setPreferredWidth(40); // Sloupec 2 bude mít šířku 100 px
|
ifaceTable.getColumnModel().getColumn(2).setPreferredWidth(40); // Sloupec 2 bude mít šířku 100 px
|
||||||
ifaceTable.getColumnModel().getColumn(3).setPreferredWidth(50); // Sloupec 3 bude mít šířku 100 px
|
ifaceTable.getColumnModel().getColumn(3).setPreferredWidth(40); // Sloupec 3 bude mít šířku 100 px
|
||||||
ifaceTable.getColumnModel().getColumn(4).setPreferredWidth(60); // Sloupec 4 bude mít šířku 100 px
|
ifaceTable.getColumnModel().getColumn(4).setPreferredWidth(40); // Sloupec 4 bude mít šířku 100 px
|
||||||
//ifaceTable.getColumnModel().getColumn(5).setPreferredWidth(100); // Sloupec 5 bude mít šířku 100 px
|
//ifaceTable.getColumnModel().getColumn(5).setPreferredWidth(100); // Sloupec 5 bude mít šířku 100 px
|
||||||
|
|
||||||
JScrollPane tableScroll = new JScrollPane(ifaceTable);
|
JScrollPane tableScroll = new JScrollPane(ifaceTable);
|
||||||
|
|
@ -111,12 +109,13 @@ public class TabInfo extends JPanel {
|
||||||
tableModel.setRowCount(0);
|
tableModel.setRowCount(0);
|
||||||
for (Interface i : iface) {
|
for (Interface i : iface) {
|
||||||
Object[] d = {
|
Object[] d = {
|
||||||
i.getDescription(),
|
i.getShortDescription(),
|
||||||
|
i.getAlias(),
|
||||||
i.getOperStatus(),
|
i.getOperStatus(),
|
||||||
i.getAdminStatus(),
|
i.getAdminStatus(),
|
||||||
i.getSpeed(),
|
i.getSpeed(),
|
||||||
i.getType(),
|
i.getType()
|
||||||
i.getLastChangeTime()};
|
};
|
||||||
tableModel.addRow(d);
|
tableModel.addRow(d);
|
||||||
}
|
}
|
||||||
ifaceTable.revalidate();
|
ifaceTable.revalidate();
|
||||||
|
|
@ -0,0 +1,150 @@
|
||||||
|
package jnet.client.gui.dialog.node;
|
||||||
|
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.SnmpResponseParser;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeProbe;
|
||||||
|
import jnet.client.gui.dialog.DialogProbe;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
public class TabProbes extends JPanel {
|
||||||
|
|
||||||
|
String COLUMN_NAMES[] = {"#", "Nazev", "Hodota", "Zobrazit v mapě"};
|
||||||
|
DefaultTableModel model;
|
||||||
|
Node obj;
|
||||||
|
private DialogNodeDevice parentDialog;
|
||||||
|
|
||||||
|
TabProbes(Node obj, DialogNodeDevice parentDialog) {
|
||||||
|
this.parentDialog = parentDialog;
|
||||||
|
this.obj = obj;
|
||||||
|
initTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTable() {
|
||||||
|
model = new DefaultTableModel(COLUMN_NAMES, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
JTable table = new JTable(model);
|
||||||
|
|
||||||
|
table.setPreferredScrollableViewportSize(
|
||||||
|
new Dimension(500, 350)); // Šířka 500, výška 300
|
||||||
|
|
||||||
|
table.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
int row = table.getSelectedRow();
|
||||||
|
int id = (int) table.getValueAt(row, 0);
|
||||||
|
|
||||||
|
// zjistime objekt
|
||||||
|
for (Site site : Client.site) {
|
||||||
|
for (Node node : site.getNode()) {
|
||||||
|
node.getProbe().stream()
|
||||||
|
.filter(probe -> probe.getId() == id)
|
||||||
|
.findFirst()
|
||||||
|
.ifPresent(probe -> {
|
||||||
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
||||||
|
// Ověříme, zda bylo kliknuto pravým tlačítkem (BUTTON3)
|
||||||
|
zobrazMenu(e, id);
|
||||||
|
} else if (e.getClickCount() == 2) {
|
||||||
|
//dvojklik
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
new DialogProbe(probe, node, false, parentDialog).show();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void zobrazMenu(MouseEvent e, int id) {
|
||||||
|
try {
|
||||||
|
JPopupMenu menu = new JPopupMenu();
|
||||||
|
JMenuItem delete = new JMenuItem("Smazat", new ImageIcon(ImageIO.read(ResourceLoader.getFile("/img/trash.png"))));
|
||||||
|
delete.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
int option = JOptionPane.showConfirmDialog(
|
||||||
|
null,
|
||||||
|
"Smazat sondu ID " + id + " ?",
|
||||||
|
"Potvrzení akce",
|
||||||
|
JOptionPane.YES_NO_OPTION
|
||||||
|
);
|
||||||
|
|
||||||
|
if (option == JOptionPane.YES_OPTION) {
|
||||||
|
Object[] obj = {id, parentDialog.getName()};
|
||||||
|
Client.sendMessage(new Message(Message.NODE_PROBE_DELETE, obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.add(delete);
|
||||||
|
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("Load icon error: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
add(new JScrollPane(table));
|
||||||
|
|
||||||
|
// tlačítko
|
||||||
|
JButton btn = new JButton("Přidat sondu");
|
||||||
|
|
||||||
|
btn.addActionListener(
|
||||||
|
new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e
|
||||||
|
) {
|
||||||
|
new DialogProbe(new NodeProbe(), obj, true, parentDialog).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
this.add(btn);
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadData() {
|
||||||
|
model.setRowCount(0);
|
||||||
|
|
||||||
|
if (obj.getProbe() != null) {
|
||||||
|
for (NodeProbe probe : obj.getProbe()) {
|
||||||
|
model.addRow(new Object[]{
|
||||||
|
probe.getId(),
|
||||||
|
probe.getName(),
|
||||||
|
SnmpResponseParser.parse(probe) + " " + probe.getUnit(),
|
||||||
|
(probe.isViewOnMap() ? "ano" : "ne")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package jnet.client.gui.dialog.object;
|
package jnet.client.gui.dialog.node;
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
|
|
@ -6,11 +6,11 @@ import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import jnet.lib.object.MapObject;
|
import jnet.lib.object.Node;
|
||||||
|
|
||||||
class TabServices extends JPanel {
|
class TabServices extends JPanel {
|
||||||
|
|
||||||
private MapObject obj;
|
private Node obj;
|
||||||
private boolean newObject;
|
private boolean newObject;
|
||||||
|
|
||||||
private JCheckBox winboxBox = new JCheckBox("Winbox");
|
private JCheckBox winboxBox = new JCheckBox("Winbox");
|
||||||
|
|
@ -26,7 +26,7 @@ class TabServices extends JPanel {
|
||||||
private JTextField portSms = new JTextField("5020");
|
private JTextField portSms = new JTextField("5020");
|
||||||
private JComboBox<String> smsVerzeComboBox = new JComboBox<String>();
|
private JComboBox<String> smsVerzeComboBox = new JComboBox<String>();
|
||||||
|
|
||||||
public TabServices(MapObject obj, boolean newObject) {
|
public TabServices(Node obj, boolean newObject) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.newObject = newObject;
|
this.newObject = newObject;
|
||||||
|
|
||||||
|
|
@ -94,7 +94,7 @@ class TabServices extends JPanel {
|
||||||
sms_verze.setBounds(260, 150, 60, 25);
|
sms_verze.setBounds(260, 150, 60, 25);
|
||||||
this.add(sms_verze);
|
this.add(sms_verze);
|
||||||
|
|
||||||
smsVerzeComboBox.setModel(new DefaultComboBoxModel(new String[]{"SDV", "BT"}));
|
smsVerzeComboBox.setModel(new DefaultComboBoxModel(new String[]{"SDV", "BTH", "BT"}));
|
||||||
smsVerzeComboBox.setBounds(320, 150, 80, 25);
|
smsVerzeComboBox.setBounds(320, 150, 80, 25);
|
||||||
this.add(smsVerzeComboBox);
|
this.add(smsVerzeComboBox);
|
||||||
|
|
||||||
|
|
@ -1,13 +1,10 @@
|
||||||
package jnet.client.gui.dialog.object;
|
package jnet.client.gui.dialog.node;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
import javax.swing.JButton;
|
|
||||||
import javax.swing.JCheckBox;
|
import javax.swing.JCheckBox;
|
||||||
import javax.swing.JComboBox;
|
import javax.swing.JComboBox;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
@ -16,15 +13,13 @@ import javax.swing.JPasswordField;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.JTextField;
|
import javax.swing.JTextField;
|
||||||
import jnet.client.Client;
|
import jnet.client.Client;
|
||||||
import jnet.client.network.NettyClient;
|
import jnet.lib.object.Node;
|
||||||
import jnet.lib.Message;
|
import jnet.lib.object.DeviceType;
|
||||||
import jnet.lib.object.MapObject;
|
|
||||||
import jnet.lib.object.ObjectType;
|
|
||||||
import jnet.lib.object.SnmpProfile;
|
import jnet.lib.object.SnmpProfile;
|
||||||
|
|
||||||
public class TabSettings extends JPanel {
|
public class TabSettings extends JPanel {
|
||||||
|
|
||||||
private MapObject obj;
|
private Node obj;
|
||||||
private boolean newObject;
|
private boolean newObject;
|
||||||
|
|
||||||
private JTextField nazevText = new JTextField();
|
private JTextField nazevText = new JTextField();
|
||||||
|
|
@ -40,7 +35,7 @@ public class TabSettings extends JPanel {
|
||||||
private JTextArea descriptionText = new JTextArea();
|
private JTextArea descriptionText = new JTextArea();
|
||||||
private JComboBox<String> snmpProfileComboBox = new JComboBox<String>();
|
private JComboBox<String> snmpProfileComboBox = new JComboBox<String>();
|
||||||
|
|
||||||
public TabSettings(MapObject obj, boolean newObject) {
|
public TabSettings(Node obj, boolean newObject) {
|
||||||
this.obj = obj;
|
this.obj = obj;
|
||||||
this.newObject = newObject;
|
this.newObject = newObject;
|
||||||
|
|
||||||
|
|
@ -69,12 +64,12 @@ public class TabSettings extends JPanel {
|
||||||
ipWarning.setVisible(false);
|
ipWarning.setVisible(false);
|
||||||
this.add(ipWarning);
|
this.add(ipWarning);
|
||||||
|
|
||||||
JLabel typLabel = new JLabel("Typ");
|
JLabel typLabel = new JLabel("Ikona");
|
||||||
typLabel.setBounds(20, 130, 80, 25);
|
typLabel.setBounds(20, 130, 80, 25);
|
||||||
this.add(typLabel);
|
this.add(typLabel);
|
||||||
|
|
||||||
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
|
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
|
||||||
for (ObjectType ot : Client.objectType) {
|
for (DeviceType ot : Client.deviceType) {
|
||||||
model.addElement(ot.getName());
|
model.addElement(ot.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +103,7 @@ public class TabSettings extends JPanel {
|
||||||
snmpProfileComboBox.setBounds(390, 130, 160, 25);
|
snmpProfileComboBox.setBounds(390, 130, 160, 25);
|
||||||
this.add(snmpProfileComboBox);
|
this.add(snmpProfileComboBox);
|
||||||
|
|
||||||
JLabel disableLabel = new JLabel("Aktivní");
|
JLabel disableLabel = new JLabel("Ping");
|
||||||
disableLabel.setBounds(20, 180, 80, 25);
|
disableLabel.setBounds(20, 180, 80, 25);
|
||||||
this.add(disableLabel);
|
this.add(disableLabel);
|
||||||
|
|
||||||
|
|
@ -138,8 +133,8 @@ public class TabSettings extends JPanel {
|
||||||
ipText.setText(obj.getIp());
|
ipText.setText(obj.getIp());
|
||||||
userText.setText(obj.getUser());
|
userText.setText(obj.getUser());
|
||||||
hesloText.setText(obj.getPassword());
|
hesloText.setText(obj.getPassword());
|
||||||
for (int i = 0; i < Client.objectType.size() - 1; i++) {
|
for (int i = 0; i < Client.deviceType.size() - 1; i++) {
|
||||||
if (obj.getObjectType() == Client.objectType.get(i).getId()) {
|
if (obj.getIcon()== Client.deviceType.get(i).getId()) {
|
||||||
typeComboBox.setSelectedIndex(i);
|
typeComboBox.setSelectedIndex(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -149,7 +144,7 @@ public class TabSettings extends JPanel {
|
||||||
snmpProfileComboBox.setSelectedIndex(i);
|
snmpProfileComboBox.setSelectedIndex(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
disableCheBox.setSelected(obj.isActive());
|
disableCheBox.setSelected(obj.isPing());
|
||||||
descriptionText.setText(obj.getDescription());
|
descriptionText.setText(obj.getDescription());
|
||||||
locationText.setText(obj.getLocation());
|
locationText.setText(obj.getLocation());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -0,0 +1,141 @@
|
||||||
|
package jnet.client.gui.maptree;
|
||||||
|
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.gui.Window;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
|
import javax.swing.tree.TreeSelectionModel;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.MapComparator;
|
||||||
|
|
||||||
|
public class MapTree extends JTree {
|
||||||
|
|
||||||
|
private final DefaultTreeModel model;
|
||||||
|
private final DefaultMutableTreeNode root = new DefaultMutableTreeNode("Mapy");
|
||||||
|
|
||||||
|
public MapTree() {
|
||||||
|
setRootVisible(false);
|
||||||
|
getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
||||||
|
model = new DefaultTreeModel(root);
|
||||||
|
setModel(model);
|
||||||
|
setCellRenderer(new MapTreeCellRenderer());
|
||||||
|
|
||||||
|
addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
handleMouseEvent(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleMouseEvent(MouseEvent e) {
|
||||||
|
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) getLastSelectedPathComponent();
|
||||||
|
if (treeNode == null) return;
|
||||||
|
|
||||||
|
if (SwingUtilities.isRightMouseButton(e)) {
|
||||||
|
Object obj = treeNode.getUserObject();
|
||||||
|
getContextMenuMap(e, (Site) obj);
|
||||||
|
} else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 2) {
|
||||||
|
Object obj = treeNode.getUserObject();
|
||||||
|
if (obj instanceof Site) {
|
||||||
|
SwingUtilities.invokeLater(() -> Window.setMapView((Site) obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obnoví strom – načte aktuální seznam site z Client.site.
|
||||||
|
* Ošetřeno pro případ, že Client.site je null.
|
||||||
|
*/
|
||||||
|
public void refresh() {
|
||||||
|
root.removeAllChildren();
|
||||||
|
|
||||||
|
Collections.sort(Client.site, new MapComparator());
|
||||||
|
|
||||||
|
// OŠETŘENÍ: Client.site může být null při prvním spuštění
|
||||||
|
if (Client.site != null) {
|
||||||
|
for (Site site : Client.site) {
|
||||||
|
root.add(new DefaultMutableTreeNode(site));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LogFile.printInfo("MapTree: Client.site je null, strom zůstává prázdný.");
|
||||||
|
}
|
||||||
|
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
model.reload();
|
||||||
|
expandAll();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Statická metoda pro obnovení stromu z jiných tříd.
|
||||||
|
*/
|
||||||
|
public static void refreshTree() {
|
||||||
|
Window.getInstance().refreshMapTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void expandAll() {
|
||||||
|
for (int i = 0; i < getRowCount(); i++) {
|
||||||
|
expandRow(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void getContextMenuMap(MouseEvent e, Site m) {
|
||||||
|
try {
|
||||||
|
|
||||||
|
JPopupMenu menu = new JPopupMenu();
|
||||||
|
|
||||||
|
//// smazat
|
||||||
|
JMenuItem mapDelete = new JMenuItem("Smazat mapu", new ImageIcon(ImageIO.read(ResourceLoader.getFile("/img/trash.png"))));
|
||||||
|
mapDelete.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
int option = JOptionPane.showConfirmDialog(
|
||||||
|
null,
|
||||||
|
"Smazat mapu " + m.getName() + " a všechny její objekty ?",
|
||||||
|
"Potvrzení akce",
|
||||||
|
JOptionPane.YES_NO_OPTION
|
||||||
|
);
|
||||||
|
|
||||||
|
if (option == JOptionPane.YES_OPTION) {
|
||||||
|
Client.sendMessage(new Message(Message.SITE_DELETE, m.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (Client.user.isRemoveMap()) {
|
||||||
|
menu.add(mapDelete);
|
||||||
|
}
|
||||||
|
|
||||||
|
//// prejmenovat
|
||||||
|
JMenuItem mapRename = new JMenuItem("Přejmenovat mapu", new ImageIcon(ImageIO.read(ResourceLoader.getFile("/img/trash.png"))));
|
||||||
|
mapRename.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (Client.user.isEditMap()) {
|
||||||
|
menu.add(mapRename);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu.show(e.getComponent(), e.getX(), e.getY());
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("MapTree error: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,75 @@
|
||||||
|
package jnet.client.gui.maptree;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTree;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
|
import javax.swing.tree.DefaultTreeCellRenderer;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.Status;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
public class MapTreeCellRenderer extends DefaultTreeCellRenderer {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(MapTreeCellRenderer.class.getName());
|
||||||
|
private static final Map<Integer, ImageIcon> iconCache = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
||||||
|
boolean selected, boolean expanded,
|
||||||
|
boolean leaf, int row, boolean hasFocus) {
|
||||||
|
JLabel label = (JLabel) super.getTreeCellRendererComponent(
|
||||||
|
tree, value, selected, expanded, leaf, row, hasFocus);
|
||||||
|
|
||||||
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
|
||||||
|
Object o = node.getUserObject();
|
||||||
|
|
||||||
|
if (o instanceof Site) {
|
||||||
|
Site site = (Site) o;
|
||||||
|
ImageIcon icon = loadIconForState(site.getSiteState());
|
||||||
|
label.setIcon(icon);
|
||||||
|
label.setText(site.getName());
|
||||||
|
} else {
|
||||||
|
label.setText(o != null ? o.toString() : "");
|
||||||
|
label.setIcon(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
label.setBorder(new EmptyBorder(7, 25, 3, 3));
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ImageIcon loadIconForState(int state) {
|
||||||
|
return iconCache.computeIfAbsent(state, key -> {
|
||||||
|
String filename;
|
||||||
|
switch (key) {
|
||||||
|
case Status.OK:
|
||||||
|
filename = "img/flag_green.png";
|
||||||
|
break;
|
||||||
|
case Status.WARNING:
|
||||||
|
filename = "img/flag_orange.png";
|
||||||
|
break;
|
||||||
|
case Status.OFFLINE:
|
||||||
|
filename = "img/flag_red.png";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
filename = "img/flag_gray.png";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
BufferedImage img = ImageIO.read(ResourceLoader.getFile(filename));
|
||||||
|
return img != null ? new ImageIcon(img) : null;
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.log(Level.SEVERE, "Failed to load icon: " + filename, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.Line2D;
|
||||||
|
|
||||||
|
public class Connection {
|
||||||
|
private PaintSiteObject source;
|
||||||
|
private PaintSiteObject target;
|
||||||
|
private Color color = Color.BLACK;
|
||||||
|
|
||||||
|
public Connection(PaintSiteObject source, PaintSiteObject target) {
|
||||||
|
this.source = source;
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Graphics2D g2) {
|
||||||
|
if (source == null || target == null) return;
|
||||||
|
Point p1 = source.getCenter();
|
||||||
|
Point p2 = target.getCenter();
|
||||||
|
g2.setColor(color);
|
||||||
|
g2.setStroke(new BasicStroke(2));
|
||||||
|
g2.draw(new Line2D.Double(p1, p2));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gettery a settery
|
||||||
|
public PaintSiteObject getSource() { return source; }
|
||||||
|
public PaintSiteObject getTarget() { return target; }
|
||||||
|
public void setColor(Color color) { this.color = color; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.Stroke;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
|
||||||
|
public class DeviceNodeRenderer implements NodeRenderer {
|
||||||
|
|
||||||
|
private static final int ARC = 10;
|
||||||
|
private static final Stroke THIN_STROKE = new BasicStroke(1.0f);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics2D g2, NodeView nodeView) {
|
||||||
|
Node node = nodeView.getNode();
|
||||||
|
int cx = nodeView.getCenterX();
|
||||||
|
int cy = nodeView.getCenterY();
|
||||||
|
int w = nodeView.getWidth();
|
||||||
|
int h = nodeView.getHeight();
|
||||||
|
|
||||||
|
RoundRectangle2D shape = new RoundRectangle2D.Double(cx - w/2, cy - h/2, w, h, ARC, ARC);
|
||||||
|
|
||||||
|
// Pozadí
|
||||||
|
g2.setColor(getStatusColor(node.getStatus()));
|
||||||
|
g2.fill(shape);
|
||||||
|
|
||||||
|
// Tenké ohraničení
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.setStroke(THIN_STROKE);
|
||||||
|
g2.draw(shape);
|
||||||
|
|
||||||
|
// Ikona
|
||||||
|
Image icon = nodeView.getIcon();
|
||||||
|
int imgY = (int) shape.getY() + 8; // větší horní odstup
|
||||||
|
int iconHeight = 0;
|
||||||
|
if (icon != null) {
|
||||||
|
int imgX = (int) (shape.getX() + (w - icon.getWidth(null)) / 2);
|
||||||
|
g2.drawImage(icon, imgX, imgY, null);
|
||||||
|
iconHeight = icon.getHeight(null);
|
||||||
|
imgY += iconHeight + 8; // větší mezera mezi ikonou a textem
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZMĚNA: text + sondy pomocí nové metody
|
||||||
|
int textStartY = imgY + 2;
|
||||||
|
TextUtils.drawNodeInfo(g2, node, cx, textStartY,
|
||||||
|
nodeView.getFontMetricsBold(),
|
||||||
|
nodeView.getFontMetricsNormal());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color getStatusColor(int status) {
|
||||||
|
switch (status) {
|
||||||
|
case 1: return new Color(83, 241, 83);
|
||||||
|
case 2: return new Color(255, 131, 0);
|
||||||
|
case 3: return new Color(221, 63, 63);
|
||||||
|
default: return new Color(172, 172, 172);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,179 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Point;
|
||||||
|
import java.awt.RenderingHints;
|
||||||
|
import jnet.lib.object.NodeConnection;
|
||||||
|
|
||||||
|
public class EdgeView {
|
||||||
|
|
||||||
|
private final NodeView source;
|
||||||
|
private final NodeView target;
|
||||||
|
private final NodeConnection connection;
|
||||||
|
private boolean selected = false;
|
||||||
|
|
||||||
|
private static final Font TRAFFIC_FONT = new Font("Arial", Font.PLAIN, 10);
|
||||||
|
|
||||||
|
public EdgeView(NodeView source, NodeView target) {
|
||||||
|
this(source, target, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public EdgeView(NodeView source, NodeView target, NodeConnection connection) {
|
||||||
|
this.source = source;
|
||||||
|
this.target = target;
|
||||||
|
this.connection = connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics2D g2) {
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
g2.setColor(selected ? Color.BLUE : Color.DARK_GRAY);
|
||||||
|
g2.setStroke(new BasicStroke(2.0f));
|
||||||
|
|
||||||
|
int x1 = source.getCenterX();
|
||||||
|
int y1 = source.getCenterY();
|
||||||
|
int x2 = target.getCenterX();
|
||||||
|
int y2 = target.getCenterY();
|
||||||
|
|
||||||
|
g2.drawLine(x1, y1, x2, y2);
|
||||||
|
|
||||||
|
// Zobrazení traffic informací, pokud je spojení označeno pro čtení
|
||||||
|
if (connection != null && connection.isReadTraffic()) {
|
||||||
|
int mx = (x1 + x2) / 2;
|
||||||
|
int my = (y1 + y2) / 2;
|
||||||
|
|
||||||
|
String rxText = "RX: " + formatTrafficBytesToBits(connection.getRx());
|
||||||
|
String txText = "TX: " + formatTrafficBytesToBits(connection.getTx());
|
||||||
|
|
||||||
|
g2.setFont(TRAFFIC_FONT);
|
||||||
|
FontMetrics fm = g2.getFontMetrics();
|
||||||
|
int rxWidth = fm.stringWidth(rxText);
|
||||||
|
int txWidth = fm.stringWidth(txText);
|
||||||
|
int textWidth = Math.max(rxWidth, txWidth);
|
||||||
|
int textHeight = fm.getHeight();
|
||||||
|
int padding = 4;
|
||||||
|
|
||||||
|
int rectWidth = textWidth + 2 * padding;
|
||||||
|
int rectHeight = 2 * textHeight + padding + 4;
|
||||||
|
int rectX = mx - rectWidth / 2;
|
||||||
|
int rectY = my - rectHeight / 2;
|
||||||
|
|
||||||
|
// Plně bílé pozadí bez ohraničení
|
||||||
|
g2.setColor(Color.WHITE);
|
||||||
|
g2.fillRoundRect(rectX, rectY, rectWidth, rectHeight, 6, 6);
|
||||||
|
|
||||||
|
// Text – oba řádky horizontálně vycentrované
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
int yOffset = rectY + fm.getAscent() + padding;
|
||||||
|
g2.drawString(rxText, rectX + (rectWidth - rxWidth) / 2, yOffset);
|
||||||
|
g2.drawString(txText, rectX + (rectWidth - txWidth) / 2, yOffset + textHeight + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formátuje přenosovou rychlost v bytech za sekundu (B/s) do formátu jako
|
||||||
|
* The Dude (bps s dekadickými jednotkami).
|
||||||
|
*/
|
||||||
|
private String formatTrafficBytesToBits(long bytesPerSecond) {
|
||||||
|
long bps = bytesPerSecond * 8; // převod B/s → bps
|
||||||
|
return formatTrafficBits(bps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formátuje přenosovou rychlost v bitech za sekundu (bps) do čitelného
|
||||||
|
* formátu s dekadickými jednotkami (1000) jako The Dude.
|
||||||
|
*
|
||||||
|
* @param bps Rychlost v bitech za sekundu (bits per second)
|
||||||
|
* @return Formátovaný řetězec např. "436 Mbps", "28.8 Mbps", "4.2 Gbps"
|
||||||
|
*/
|
||||||
|
private String formatTrafficBits(long bps) {
|
||||||
|
if (bps < 0) {
|
||||||
|
return "0 bps";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bps < 1_000) {
|
||||||
|
return bps + " bps";
|
||||||
|
}
|
||||||
|
|
||||||
|
double kbps = bps / 1_000.0;
|
||||||
|
if (kbps < 1_000) {
|
||||||
|
return formatDecimal(kbps) + " Kbps";
|
||||||
|
}
|
||||||
|
|
||||||
|
double mbps = kbps / 1_000.0;
|
||||||
|
if (mbps < 1_000) {
|
||||||
|
return formatDecimal(mbps) + " Mbps";
|
||||||
|
}
|
||||||
|
|
||||||
|
double gbps = mbps / 1_000.0;
|
||||||
|
if (gbps < 1_000) {
|
||||||
|
return formatDecimal(gbps) + " Gbps";
|
||||||
|
}
|
||||||
|
|
||||||
|
double tbps = gbps / 1_000.0;
|
||||||
|
return formatDecimal(tbps) + " Tbps";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Formátuje desetinné číslo s rozumným počtem desetinných míst. Pro The
|
||||||
|
* Dude styl: 1 desetinné místo pro Mbps, celé pro Kbps.
|
||||||
|
*/
|
||||||
|
private String formatDecimal(double value) {
|
||||||
|
if (value >= 100) {
|
||||||
|
return String.format("%.0f", value);
|
||||||
|
} else if (value >= 10) {
|
||||||
|
return String.format("%.1f", value);
|
||||||
|
} else {
|
||||||
|
return String.format("%.1f", value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSelected() {
|
||||||
|
return selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelected(boolean selected) {
|
||||||
|
this.selected = selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeView getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeView getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeConnection getConnection() {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Point p, int threshold) {
|
||||||
|
int x1 = source.getCenterX();
|
||||||
|
int y1 = source.getCenterY();
|
||||||
|
int x2 = target.getCenterX();
|
||||||
|
int y2 = target.getCenterY();
|
||||||
|
double dist = distanceToSegment(p.x, p.y, x1, y1, x2, y2);
|
||||||
|
return dist <= threshold;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double distanceToSegment(int px, int py, int x1, int y1, int x2, int y2) {
|
||||||
|
double vx = x2 - x1;
|
||||||
|
double vy = y2 - y1;
|
||||||
|
double dx = px - x1;
|
||||||
|
double dy = py - y1;
|
||||||
|
double t = (dx * vx + dy * vy) / (vx * vx + vy * vy);
|
||||||
|
if (t < 0) {
|
||||||
|
t = 0;
|
||||||
|
}
|
||||||
|
if (t > 1) {
|
||||||
|
t = 1;
|
||||||
|
}
|
||||||
|
double projX = x1 + t * vx;
|
||||||
|
double projY = y1 + t * vy;
|
||||||
|
return Math.hypot(px - projX, py - projY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,207 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeConnection;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Datový model mapy – spravuje seznamy uzlů, hran a výběr.
|
||||||
|
*/
|
||||||
|
public class MapModel {
|
||||||
|
|
||||||
|
private final List<NodeView> nodeViews = new ArrayList<>();
|
||||||
|
private final List<EdgeView> edgeViews = new ArrayList<>();
|
||||||
|
private final Set<NodeView> selectedNodes = new HashSet<>();
|
||||||
|
private final Set<EdgeView> selectedEdges = new HashSet<>();
|
||||||
|
|
||||||
|
private Site site;
|
||||||
|
private MapView mapView; // ← reference pro konstruktor NodeView
|
||||||
|
private Runnable onChange;
|
||||||
|
|
||||||
|
public MapModel(Site site, MapView mapView) {
|
||||||
|
this.site = site;
|
||||||
|
this.mapView = mapView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnChange(Runnable onChange) {
|
||||||
|
this.onChange = onChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireChange() {
|
||||||
|
if (onChange != null) onChange.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Inicializace ----------
|
||||||
|
public void initFromSite() {
|
||||||
|
nodeViews.clear();
|
||||||
|
edgeViews.clear();
|
||||||
|
selectedNodes.clear();
|
||||||
|
selectedEdges.clear();
|
||||||
|
|
||||||
|
for (Node node : site.getNode()) {
|
||||||
|
nodeViews.add(new NodeView(node, mapView));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NodeConnection nc : site.getNodeConnection()) {
|
||||||
|
NodeView source = findNodeViewById(nc.getNodeFrom());
|
||||||
|
NodeView target = findNodeViewById(nc.getNodeTo());
|
||||||
|
if (source != null && target != null) {
|
||||||
|
boolean exists = edgeViews.stream().anyMatch(e ->
|
||||||
|
(e.getSource() == source && e.getTarget() == target) ||
|
||||||
|
(e.getSource() == target && e.getTarget() == source)
|
||||||
|
);
|
||||||
|
if (!exists) {
|
||||||
|
// NOVÉ – předáváme i NodeConnection
|
||||||
|
edgeViews.add(new EdgeView(source, target, nc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Vyhledávání ----------
|
||||||
|
public NodeView findNodeViewById(int nodeId) {
|
||||||
|
return nodeViews.stream()
|
||||||
|
.filter(nv -> nv.getNode().getId() == nodeId)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NodeView findNodeAt(Point p) {
|
||||||
|
for (int i = nodeViews.size() - 1; i >= 0; i--) {
|
||||||
|
NodeView nv = nodeViews.get(i);
|
||||||
|
if (nv.contains(p)) return nv;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EdgeView findEdgeAt(Point p, int threshold) {
|
||||||
|
return edgeViews.stream()
|
||||||
|
.filter(e -> e.contains(p, threshold))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Správa uzlů a hran ----------
|
||||||
|
public void addNode(NodeView nodeView) {
|
||||||
|
nodeViews.add(nodeView);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addEdge(EdgeView edgeView) {
|
||||||
|
edgeViews.add(edgeView);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeNode(NodeView nodeView) {
|
||||||
|
edgeViews.removeIf(e -> e.getSource() == nodeView || e.getTarget() == nodeView);
|
||||||
|
nodeViews.remove(nodeView);
|
||||||
|
selectedNodes.remove(nodeView);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeEdge(EdgeView edgeView) {
|
||||||
|
edgeViews.remove(edgeView);
|
||||||
|
selectedEdges.remove(edgeView);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteSelected() {
|
||||||
|
for (NodeView n : new ArrayList<>(selectedNodes)) {
|
||||||
|
removeNode(n);
|
||||||
|
}
|
||||||
|
for (EdgeView e : new ArrayList<>(selectedEdges)) {
|
||||||
|
removeEdge(e);
|
||||||
|
}
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Správa výběru ----------
|
||||||
|
public void selectNode(NodeView nv) {
|
||||||
|
if (nv != null && !selectedNodes.contains(nv)) {
|
||||||
|
selectedNodes.add(nv);
|
||||||
|
nv.setSelected(true);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deselectNode(NodeView nv) {
|
||||||
|
if (nv != null && selectedNodes.contains(nv)) {
|
||||||
|
selectedNodes.remove(nv);
|
||||||
|
nv.setSelected(false);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleNode(NodeView nv) {
|
||||||
|
if (selectedNodes.contains(nv)) deselectNode(nv);
|
||||||
|
else selectNode(nv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectEdge(EdgeView ev) {
|
||||||
|
if (ev != null && !selectedEdges.contains(ev)) {
|
||||||
|
selectedEdges.add(ev);
|
||||||
|
ev.setSelected(true);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deselectEdge(EdgeView ev) {
|
||||||
|
if (ev != null && selectedEdges.contains(ev)) {
|
||||||
|
selectedEdges.remove(ev);
|
||||||
|
ev.setSelected(false);
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void toggleEdge(EdgeView ev) {
|
||||||
|
if (selectedEdges.contains(ev)) deselectEdge(ev);
|
||||||
|
else selectEdge(ev);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearSelection() {
|
||||||
|
for (NodeView nv : new ArrayList<>(selectedNodes)) {
|
||||||
|
nv.setSelected(false);
|
||||||
|
}
|
||||||
|
for (EdgeView ev : new ArrayList<>(selectedEdges)) {
|
||||||
|
ev.setSelected(false);
|
||||||
|
}
|
||||||
|
selectedNodes.clear();
|
||||||
|
selectedEdges.clear();
|
||||||
|
fireChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Gettery ----------
|
||||||
|
public List<NodeView> getNodeViews() {
|
||||||
|
return Collections.unmodifiableList(nodeViews);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<EdgeView> getEdgeViews() {
|
||||||
|
return Collections.unmodifiableList(edgeViews);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<NodeView> getSelectedNodes() {
|
||||||
|
return Collections.unmodifiableSet(selectedNodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<EdgeView> getSelectedEdges() {
|
||||||
|
return Collections.unmodifiableSet(selectedEdges);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Site getSite() {
|
||||||
|
return site;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSite(Site site) {
|
||||||
|
this.site = site;
|
||||||
|
initFromSite();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapView getMapView() {
|
||||||
|
return mapView;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,283 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.client.gui.dialog.DialogConnection;
|
||||||
|
import jnet.client.gui.dialog.node.DialogNodeDevice;
|
||||||
|
import jnet.client.gui.dialog.DialogNodeStatic;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeConnection;
|
||||||
|
|
||||||
|
public class MapMouseHandler implements MouseListener, MouseMotionListener, MouseWheelListener {
|
||||||
|
|
||||||
|
private static final int EDGE_THRESHOLD = 8;
|
||||||
|
|
||||||
|
private final MapModel model;
|
||||||
|
private final Runnable repainter;
|
||||||
|
private final MapView mapView;
|
||||||
|
|
||||||
|
private Point dragStart = null;
|
||||||
|
private Point lastMousePos = null;
|
||||||
|
private Rectangle selectionRect = null;
|
||||||
|
private boolean isDragging = false;
|
||||||
|
private boolean isSelecting = false;
|
||||||
|
|
||||||
|
private Set<Integer> draggedNodeIds = new HashSet<>();
|
||||||
|
private Map<Integer, Point> startPositions = new HashMap<>();
|
||||||
|
|
||||||
|
public MapMouseHandler(MapModel model, Runnable repainter, MapView mapView) {
|
||||||
|
this.model = model;
|
||||||
|
this.repainter = repainter;
|
||||||
|
this.mapView = mapView;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
dragStart = e.getPoint();
|
||||||
|
lastMousePos = e.getPoint();
|
||||||
|
|
||||||
|
draggedNodeIds.clear();
|
||||||
|
startPositions.clear();
|
||||||
|
|
||||||
|
NodeView clickedNode = model.findNodeAt(dragStart);
|
||||||
|
EdgeView clickedEdge = (clickedNode == null) ? model.findEdgeAt(dragStart, EDGE_THRESHOLD) : null;
|
||||||
|
|
||||||
|
boolean isLocked = model.getSite().isLock();
|
||||||
|
|
||||||
|
if (clickedNode != null) {
|
||||||
|
if (e.isControlDown() || e.isShiftDown()) {
|
||||||
|
model.toggleNode(clickedNode);
|
||||||
|
} else {
|
||||||
|
if (!model.getSelectedNodes().contains(clickedNode)) {
|
||||||
|
model.clearSelection();
|
||||||
|
model.selectNode(clickedNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isLocked) {
|
||||||
|
for (NodeView nv : model.getSelectedNodes()) {
|
||||||
|
int nodeId = nv.getNode().getId();
|
||||||
|
draggedNodeIds.add(nodeId);
|
||||||
|
startPositions.put(nodeId, new Point(nv.getCenterX(), nv.getCenterY()));
|
||||||
|
}
|
||||||
|
isDragging = true;
|
||||||
|
} else {
|
||||||
|
isDragging = false;
|
||||||
|
LogFile.printDebug("MapMouseHandler: Site je zamcena, pretahovani zakazano");
|
||||||
|
}
|
||||||
|
isSelecting = false;
|
||||||
|
|
||||||
|
} else if (clickedEdge != null) {
|
||||||
|
if (e.isControlDown() || e.isShiftDown()) {
|
||||||
|
model.toggleEdge(clickedEdge);
|
||||||
|
} else {
|
||||||
|
model.clearSelection();
|
||||||
|
model.selectEdge(clickedEdge);
|
||||||
|
}
|
||||||
|
isDragging = false;
|
||||||
|
isSelecting = false;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (!e.isControlDown() && !e.isShiftDown()) {
|
||||||
|
model.clearSelection();
|
||||||
|
draggedNodeIds.clear();
|
||||||
|
startPositions.clear();
|
||||||
|
}
|
||||||
|
selectionRect = new Rectangle(dragStart);
|
||||||
|
isSelecting = true;
|
||||||
|
isDragging = false;
|
||||||
|
}
|
||||||
|
repainter.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
boolean isLocked = model.getSite().isLock();
|
||||||
|
|
||||||
|
if (isDragging && !isLocked) {
|
||||||
|
Set<NodeView> currentSelection = model.getSelectedNodes();
|
||||||
|
|
||||||
|
for (NodeView nv : currentSelection) {
|
||||||
|
int nodeId = nv.getNode().getId();
|
||||||
|
if (draggedNodeIds.contains(nodeId)) {
|
||||||
|
Node node = nv.getNode();
|
||||||
|
Point startPos = startPositions.get(nodeId);
|
||||||
|
if (startPos != null && (startPos.x != node.getX() || startPos.y != node.getY())) {
|
||||||
|
LogFile.printDebug("Posun uzlu " + node.getName() + " (ID=" + nodeId
|
||||||
|
+ ") na [" + node.getX() + ", " + node.getY() + "]");
|
||||||
|
int[] data = {node.getId(), node.getX(), node.getY()};
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_POSITION_CHANGE, data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
isDragging = false;
|
||||||
|
draggedNodeIds.clear();
|
||||||
|
startPositions.clear();
|
||||||
|
repainter.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSelecting && selectionRect != null) {
|
||||||
|
Rectangle rect = selectionRect;
|
||||||
|
for (NodeView nv : model.getNodeViews()) {
|
||||||
|
if (rect.intersects(nv.getBounds())) {
|
||||||
|
model.selectNode(nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectionRect = null;
|
||||||
|
isSelecting = false;
|
||||||
|
repainter.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseDragged(MouseEvent e) {
|
||||||
|
if (model.getSite().isLock()) {
|
||||||
|
if (isSelecting && selectionRect != null) {
|
||||||
|
Point current = e.getPoint();
|
||||||
|
selectionRect = new Rectangle(
|
||||||
|
Math.min(dragStart.x, current.x),
|
||||||
|
Math.min(dragStart.y, current.y),
|
||||||
|
Math.abs(current.x - dragStart.x),
|
||||||
|
Math.abs(current.y - dragStart.y)
|
||||||
|
);
|
||||||
|
repainter.run();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Point current = e.getPoint();
|
||||||
|
|
||||||
|
if (isDragging && !draggedNodeIds.isEmpty()) {
|
||||||
|
Set<NodeView> currentSelection = model.getSelectedNodes();
|
||||||
|
|
||||||
|
List<NodeView> nodesToDrag = new ArrayList<>();
|
||||||
|
for (NodeView nv : currentSelection) {
|
||||||
|
if (draggedNodeIds.contains(nv.getNode().getId())) {
|
||||||
|
nodesToDrag.add(nv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nodesToDrag.isEmpty()) {
|
||||||
|
LogFile.printDebug("MapMouseHandler: Zbyly 0 uzlu k pretazeni, ukoncuji drag");
|
||||||
|
isDragging = false;
|
||||||
|
draggedNodeIds.clear();
|
||||||
|
startPositions.clear();
|
||||||
|
repainter.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dx = current.x - lastMousePos.x;
|
||||||
|
int dy = current.y - lastMousePos.y;
|
||||||
|
for (NodeView nv : nodesToDrag) {
|
||||||
|
nv.translate(dx, dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
lastMousePos = current;
|
||||||
|
repainter.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSelecting && selectionRect != null) {
|
||||||
|
selectionRect = new Rectangle(
|
||||||
|
Math.min(dragStart.x, current.x),
|
||||||
|
Math.min(dragStart.y, current.y),
|
||||||
|
Math.abs(current.x - dragStart.x),
|
||||||
|
Math.abs(current.y - dragStart.y)
|
||||||
|
);
|
||||||
|
repainter.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(MouseEvent e) {
|
||||||
|
lastMousePos = e.getPoint();
|
||||||
|
|
||||||
|
if (model.getSite().isLock()) {
|
||||||
|
NodeView nv = model.findNodeAt(e.getPoint());
|
||||||
|
if (nv != null) {
|
||||||
|
e.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||||
|
} else {
|
||||||
|
e.getComponent().setCursor(Cursor.getDefaultCursor());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
// Režim umístění uzlu
|
||||||
|
if (mapView.isWaitingForPlacement()) {
|
||||||
|
if (e.getButton() == MouseEvent.BUTTON1) {
|
||||||
|
mapView.placeNodeAt(e.getPoint());
|
||||||
|
} else if (e.getButton() == MouseEvent.BUTTON3) {
|
||||||
|
mapView.cancelNodePlacement();
|
||||||
|
JOptionPane.showMessageDialog(mapView, "Přesun zrušen.");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.getClickCount() == 2) {
|
||||||
|
NodeView nv = model.findNodeAt(e.getPoint());
|
||||||
|
if (nv != null) {
|
||||||
|
Node node = nv.getNode();
|
||||||
|
switch (node.getType()) {
|
||||||
|
case Node.NODE_DEVICE -> {
|
||||||
|
LogFile.printDebug("MapMouseHandler: Dvojklik na uzel " + node.getName());
|
||||||
|
DialogNodeDevice dialog = new DialogNodeDevice(nv.getNode(), false);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
case Node.NODE_MAP -> {
|
||||||
|
int targetSiteId = node.getSiteLink();
|
||||||
|
if (targetSiteId > 0 && mapView != null) {
|
||||||
|
mapView.switchToSite(targetSiteId);
|
||||||
|
} else {
|
||||||
|
LogFile.printDebug("MapMouseHandler: Node typu mapa nemá nastaveno ID cílové site.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case Node.NODE_STATIC -> {
|
||||||
|
DialogNodeStatic snd = new DialogNodeStatic(nv.getNode(), false);
|
||||||
|
snd.show();
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Dvojklik na spojení (hranu)
|
||||||
|
EdgeView ev = model.findEdgeAt(e.getPoint(), EDGE_THRESHOLD);
|
||||||
|
if (ev != null) {
|
||||||
|
// NOVÉ – získáme celý NodeConnection
|
||||||
|
NodeConnection conn = ev.getConnection();
|
||||||
|
if (conn != null) {
|
||||||
|
|
||||||
|
// Můžete zde také otevřít dialog pro úpravu spojení, např.:
|
||||||
|
new DialogConnection(conn, false).show();
|
||||||
|
} else {
|
||||||
|
LogFile.printDebug("MapMouseHandler: EdgeView nemá přiřazený NodeConnection");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseEntered(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseExited(MouseEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rectangle getSelectionRect() {
|
||||||
|
return selectionRect;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Stroke;
|
||||||
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
|
public class MapNodeRenderer implements NodeRenderer {
|
||||||
|
|
||||||
|
private static final Stroke THIN_STROKE = new BasicStroke(1.0f);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics2D g2, NodeView nodeView) {
|
||||||
|
int cx = nodeView.getCenterX();
|
||||||
|
int cy = nodeView.getCenterY();
|
||||||
|
int w = nodeView.getWidth();
|
||||||
|
int h = nodeView.getHeight();
|
||||||
|
|
||||||
|
Ellipse2D oval = new Ellipse2D.Double(cx - w/2, cy - h/2, w, h);
|
||||||
|
g2.setColor(new Color(173, 216, 230));
|
||||||
|
g2.fill(oval);
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.setStroke(THIN_STROKE);
|
||||||
|
g2.draw(oval);
|
||||||
|
|
||||||
|
TextUtils.drawCenteredText(g2,
|
||||||
|
nodeView.getNode().getName(),
|
||||||
|
nodeView.getNode().getIp(),
|
||||||
|
cx, cy,
|
||||||
|
nodeView.getFontMetricsBold(),
|
||||||
|
nodeView.getFontMetricsNormal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,275 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.client.gui.dialog.DialogConnection;
|
||||||
|
import jnet.client.gui.dialog.DialogSnmpWalk;
|
||||||
|
import jnet.client.gui.dialog.DialogNodeChangeSite;
|
||||||
|
import jnet.client.gui.dialog.node.DialogNodeDevice;
|
||||||
|
import jnet.client.gui.dialog.DialogNodeStatic;
|
||||||
|
import jnet.client.gui.dialog.DialogNodeMapLink;
|
||||||
|
import jnet.client.gui.dialog.DialogUserPing;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeConnection;
|
||||||
|
|
||||||
|
public class MapPopupMenu {
|
||||||
|
|
||||||
|
private final MapModel model;
|
||||||
|
private final Component parent;
|
||||||
|
private final Runnable refresher;
|
||||||
|
|
||||||
|
private JPopupMenu popupMenu;
|
||||||
|
private Point lastMousePos = new Point(0, 0);
|
||||||
|
private NodeView clickedNode = null;
|
||||||
|
private EdgeView clickedEdge = null; // NOVÉ
|
||||||
|
|
||||||
|
public MapPopupMenu(MapModel model, Component parent, Runnable refresher) {
|
||||||
|
this.model = model;
|
||||||
|
this.parent = parent;
|
||||||
|
this.refresher = refresher;
|
||||||
|
this.popupMenu = new JPopupMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
// UPRAVENO – přidán parametr EdgeView
|
||||||
|
public void show(Component invoker, int x, int y, NodeView node, EdgeView edge) {
|
||||||
|
this.lastMousePos = new Point(x, y);
|
||||||
|
this.clickedNode = node;
|
||||||
|
this.clickedEdge = edge;
|
||||||
|
buildMenu(node != null, edge != null);
|
||||||
|
popupMenu.show(invoker, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ImageIcon loadImageIcon(String path) {
|
||||||
|
try {
|
||||||
|
BufferedImage img = ImageIO.read(ResourceLoader.getFile(path));
|
||||||
|
return new ImageIcon(img);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("MapView error: " + ex.getMessage());
|
||||||
|
return null; // nebo nějaká výchozí ikona
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// UPRAVENO – rozlišuje hasNode a hasEdge
|
||||||
|
private void buildMenu(boolean hasNode, boolean hasEdge) {
|
||||||
|
popupMenu.removeAll();
|
||||||
|
|
||||||
|
// 1) Kliknutí na SPOJENÍ
|
||||||
|
if (hasEdge) {
|
||||||
|
if (Client.user.isRemoveObject()) {
|
||||||
|
addItem("Smazat spojení",
|
||||||
|
loadImageIcon("img/trash.png"),
|
||||||
|
e -> deleteEdge(clickedEdge));
|
||||||
|
}
|
||||||
|
if (Client.user.isEditObject()) {
|
||||||
|
addItem("Upravit spojení",
|
||||||
|
loadImageIcon("img/edit.png"),
|
||||||
|
e -> editEdge(clickedEdge));
|
||||||
|
}
|
||||||
|
return; // menu pro spojení je samostatné
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2) Kliknutí na UZEL
|
||||||
|
if (hasNode) {
|
||||||
|
Node node = clickedNode.getNode();
|
||||||
|
if (node.isWinbox()) {
|
||||||
|
addItem("Winbox",
|
||||||
|
loadImageIcon("img/winbox.png"),
|
||||||
|
e -> Client.remoteTools.openWinbox(node.getIp() + ":" + node.getWinboxPort(), node.getUser(), node.getPassword()));
|
||||||
|
}
|
||||||
|
if (node.isWeb()) {
|
||||||
|
addItem("Prohlížeč",
|
||||||
|
loadImageIcon("img/browser.png"),
|
||||||
|
e -> Client.remoteTools.openBrowser(node.getIp(), node.getWebPort(), node.getWebVerze()));
|
||||||
|
}
|
||||||
|
if (node.isSsh()) {
|
||||||
|
addItem("SSH",
|
||||||
|
loadImageIcon("img/ssh.png"),
|
||||||
|
e -> Client.remoteTools.openPuttySSH(node.getIp(), node.getSshPort(), node.getUser(), node.getPassword()));
|
||||||
|
}
|
||||||
|
if (node.isTelnet()) {
|
||||||
|
addItem("Telnet",
|
||||||
|
loadImageIcon("img/ssh.png"),
|
||||||
|
e -> Client.remoteTools.openPuttyTelnet(node.getIp(), node.getTelnetPort()));
|
||||||
|
}
|
||||||
|
if (node.isSms()) {
|
||||||
|
addItem("SMS (Summit)",
|
||||||
|
e -> Client.remoteTools.openSMS(node.getIp(), node.getSmsPort(), node.getPassword(), node.getSmsVerze()));
|
||||||
|
}
|
||||||
|
if (node.getType() == Node.NODE_DEVICE) {
|
||||||
|
addItem("Ping",
|
||||||
|
loadImageIcon("img/ping.png"),
|
||||||
|
e -> new DialogUserPing(node).show());
|
||||||
|
addItem("SNMP walk",
|
||||||
|
e -> new DialogSnmpWalk(node).show());
|
||||||
|
}
|
||||||
|
if (!model.getSite().isLock()) {
|
||||||
|
if (node.isWinbox() || node.isWeb() || node.isSsh() || node.isTelnet() || node.isSms()) {
|
||||||
|
popupMenu.addSeparator();
|
||||||
|
}
|
||||||
|
|
||||||
|
addItem("Přesunout na jinou mapu", e -> {
|
||||||
|
if (parent instanceof MapView) {
|
||||||
|
new DialogNodeChangeSite(node, (MapView) parent).show();
|
||||||
|
} else {
|
||||||
|
new DialogNodeChangeSite(node).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (Client.user.isRemoveObject()) {
|
||||||
|
addItem("Smazat", e -> deleteNode(clickedNode));
|
||||||
|
}
|
||||||
|
//addItem("Zrušit výběr", e -> model.clearSelection());
|
||||||
|
if (Client.user.isAddObject()) {
|
||||||
|
addItem("Přidat spojení",
|
||||||
|
loadImageIcon("img/trash.png"),
|
||||||
|
e -> startEdgeCreation());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3) Kliknutí na PRÁZDNOU PLOCHU
|
||||||
|
if (model.getSite().isLock()) {
|
||||||
|
addItem("Odemknout mapu",
|
||||||
|
loadImageIcon("img/unlock.png"),
|
||||||
|
e -> mapLock(model.getSite()));
|
||||||
|
} else {
|
||||||
|
addItem("Zamknout mapu",
|
||||||
|
loadImageIcon("img/lock.png"),
|
||||||
|
e -> mapLock(model.getSite()));
|
||||||
|
if (Client.user.isAddObject()) {
|
||||||
|
addItem("Přidat zařízení",
|
||||||
|
loadImageIcon("img/add.png"),
|
||||||
|
e -> showDeviceDialog(lastMousePos));
|
||||||
|
addItem("Přidat statický object",
|
||||||
|
loadImageIcon("img/add.png"),
|
||||||
|
e -> showStaticDialog(lastMousePos));
|
||||||
|
addItem("Přidat odkaz na mapu",
|
||||||
|
loadImageIcon("img/add.png"),
|
||||||
|
e -> showMapLinkDialog(lastMousePos));
|
||||||
|
}
|
||||||
|
|
||||||
|
popupMenu.addSeparator();
|
||||||
|
if (Client.user.isRemoveObject()) {
|
||||||
|
addItem("Smazat vybrané",
|
||||||
|
loadImageIcon("img/trash.png"),
|
||||||
|
e -> model.deleteSelected());
|
||||||
|
}
|
||||||
|
addItem("Zrušit výběr", e -> model.clearSelection());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addItem(String text, Icon icon, ActionListener listener) {
|
||||||
|
JMenuItem item = new JMenuItem(text, icon);
|
||||||
|
item.addActionListener(listener);
|
||||||
|
popupMenu.add(item);
|
||||||
|
}
|
||||||
|
private void addItem(String text, ActionListener listener) {
|
||||||
|
JMenuItem item = new JMenuItem(text);
|
||||||
|
item.addActionListener(listener);
|
||||||
|
popupMenu.add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Akce pro prázdnou plochu ----------
|
||||||
|
private void showDeviceDialog(Point location) {
|
||||||
|
int siteId = model.getSite().getId();
|
||||||
|
Node obj = new Node();
|
||||||
|
obj.setX(location.x);
|
||||||
|
obj.setY(location.y);
|
||||||
|
obj.setSiteId(siteId);
|
||||||
|
DialogNodeDevice dialog = new DialogNodeDevice(obj, true);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showStaticDialog(Point location) {
|
||||||
|
int siteId = model.getSite().getId();
|
||||||
|
Node obj = new Node();
|
||||||
|
obj.setX(location.x);
|
||||||
|
obj.setY(location.y);
|
||||||
|
obj.setSiteId(siteId);
|
||||||
|
DialogNodeStatic dialog = new DialogNodeStatic(obj, true);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showMapLinkDialog(Point location) {
|
||||||
|
int siteId = model.getSite().getId();
|
||||||
|
Node obj = new Node();
|
||||||
|
obj.setX(location.x);
|
||||||
|
obj.setY(location.y);
|
||||||
|
obj.setSiteId(siteId);
|
||||||
|
DialogNodeMapLink dialog = new DialogNodeMapLink(obj, true);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startEdgeCreation() {
|
||||||
|
if (model.getSelectedNodes().size() >= 2) {
|
||||||
|
var it = model.getSelectedNodes().iterator();
|
||||||
|
NodeView src = it.next();
|
||||||
|
NodeView tgt = it.next();
|
||||||
|
EdgeView ev = new EdgeView(src, tgt);
|
||||||
|
model.addEdge(ev);
|
||||||
|
NodeConnection nc = new NodeConnection();
|
||||||
|
nc.setNodeFrom(src.getNode().getId());
|
||||||
|
nc.setNodeTo(tgt.getNode().getId());
|
||||||
|
new DialogConnection(nc, true).show();
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(parent, "Vyberte alespoň dva uzly pro vytvoření spojení.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deleteNode(NodeView nodeView) {
|
||||||
|
int confirm = JOptionPane.showConfirmDialog(parent,
|
||||||
|
"Opravdu chcete smazat " + nodeView.getNode().getName() + "?",
|
||||||
|
"Smazání",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
if (confirm == JOptionPane.YES_OPTION) {
|
||||||
|
NettyClientManager.sendMessage(Message.NODE_DELETE, nodeView.getNode().getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- NOVÉ AKCE PRO SPOJENÍ ----------
|
||||||
|
private void deleteEdge(EdgeView edgeView) {
|
||||||
|
int confirm = JOptionPane.showConfirmDialog(parent,
|
||||||
|
"Opravdu chcete smazat spojení?",
|
||||||
|
"Smazání spojení",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
if (confirm == JOptionPane.YES_OPTION) {
|
||||||
|
NodeConnection conn = edgeView.getConnection();
|
||||||
|
if (conn != null && conn.getId() > 0) {
|
||||||
|
NettyClientManager.sendMessage(Message.NODE_CONNECTION_DELETE, conn.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void editEdge(EdgeView edgeView) {
|
||||||
|
NodeConnection conn = edgeView.getConnection();
|
||||||
|
// if (conn == null) {
|
||||||
|
// // Vytvoříme nové spojení mezi stejnými uzly
|
||||||
|
// NodeView src = edgeView.getSource();
|
||||||
|
// NodeView tgt = edgeView.getTarget();
|
||||||
|
// conn = new NodeConnection();
|
||||||
|
// conn.setNodeFrom(src.getNode().getId());
|
||||||
|
// conn.setNodeTo(tgt.getNode().getId());
|
||||||
|
// }
|
||||||
|
new DialogConnection(conn, false).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------- Ostatní ----------
|
||||||
|
public JPopupMenu getPopupMenu() {
|
||||||
|
return popupMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void mapLock(Site site) {
|
||||||
|
Object[] data = {site.getId(), !site.isLock()};
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.SITE_SET_LOCK, data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,272 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.Site;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyAdapter;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
public class MapView extends JPanel {
|
||||||
|
|
||||||
|
private static final Color SELECTION_FILL = new Color(0, 0, 255, 50);
|
||||||
|
private static final Color SELECTION_BORDER = Color.BLUE;
|
||||||
|
private static final int EDGE_THRESHOLD = 8; // NOVÉ
|
||||||
|
|
||||||
|
private static BufferedImage lockImage;
|
||||||
|
private static BufferedImage unlockImage;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
lockImage = ImageIO.read(ResourceLoader.getFile("img/lock.png"));
|
||||||
|
unlockImage = ImageIO.read(ResourceLoader.getFile("img/unlock.png"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("MapView: Failed to load lock/unlock images: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final MapModel model;
|
||||||
|
private final MapMouseHandler mouseHandler;
|
||||||
|
private final MapPopupMenu popupMenu;
|
||||||
|
|
||||||
|
private Node pendingNode;
|
||||||
|
private int pendingTargetSiteId;
|
||||||
|
private boolean isWaitingForPlacement = false;
|
||||||
|
private final List<Node> pendingNodesToAdd = new ArrayList<>();
|
||||||
|
|
||||||
|
public MapView(Site site) {
|
||||||
|
this.model = new MapModel(site, this);
|
||||||
|
this.model.setOnChange(this::repaint);
|
||||||
|
|
||||||
|
this.mouseHandler = new MapMouseHandler(model, this::repaint, this);
|
||||||
|
this.popupMenu = new MapPopupMenu(model, this, this::requestRefreshFromServer);
|
||||||
|
|
||||||
|
setBackground(Color.WHITE);
|
||||||
|
setLayout(null);
|
||||||
|
setFocusable(true);
|
||||||
|
|
||||||
|
addMouseListener(mouseHandler);
|
||||||
|
addMouseMotionListener(mouseHandler);
|
||||||
|
addMouseWheelListener(mouseHandler);
|
||||||
|
|
||||||
|
// UPRAVENÝ MouseAdapter pro pravý klik – zjišťuje i hranu
|
||||||
|
addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (e.getButton() == MouseEvent.BUTTON3) {
|
||||||
|
NodeView clickedNode = model.findNodeAt(e.getPoint());
|
||||||
|
EdgeView clickedEdge = null;
|
||||||
|
if (clickedNode == null) {
|
||||||
|
clickedEdge = model.findEdgeAt(e.getPoint(), EDGE_THRESHOLD);
|
||||||
|
}
|
||||||
|
popupMenu.show(MapView.this, e.getX(), e.getY(), clickedNode, clickedEdge);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setupKeyListener();
|
||||||
|
model.initFromSite();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ...... zbytek třídy zůstává beze změny ......
|
||||||
|
// (všechny ostatní metody: startNodePlacement, cancelNodePlacement,
|
||||||
|
// placeNodeAt, switchToSite, paintComponent, refreshFromServer atd.)
|
||||||
|
|
||||||
|
// Pro úplnost uvádím i zbylé metody, ale jejich kód je totožný s původním
|
||||||
|
|
||||||
|
public void startNodePlacement(Node node, int targetSiteId) {
|
||||||
|
this.pendingNode = node;
|
||||||
|
this.pendingTargetSiteId = targetSiteId;
|
||||||
|
this.isWaitingForPlacement = true;
|
||||||
|
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
|
||||||
|
setToolTipText("Klikněte levým tlačítkem pro umístění uzlu, pravým tlačítkem / ESC zruší.");
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelNodePlacement() {
|
||||||
|
this.isWaitingForPlacement = false;
|
||||||
|
this.pendingNode = null;
|
||||||
|
setCursor(Cursor.getDefaultCursor());
|
||||||
|
setToolTipText(null);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void placeNodeAt(Point location) {
|
||||||
|
if (!isWaitingForPlacement || pendingNode == null) return;
|
||||||
|
pendingNode.setX(location.x);
|
||||||
|
pendingNode.setY(location.y);
|
||||||
|
pendingNodesToAdd.add(pendingNode);
|
||||||
|
int[] data = {pendingNode.getId(), pendingTargetSiteId, location.x, location.y};
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.NODE_MOVE_TO_SITE, data));
|
||||||
|
NodeView nv = model.findNodeViewById(pendingNode.getId());
|
||||||
|
if (nv != null) {
|
||||||
|
model.removeNode(nv);
|
||||||
|
}
|
||||||
|
cancelNodePlacement();
|
||||||
|
JOptionPane.showMessageDialog(this, "Uzel byl odeslán k přesunu na cílovou mapu.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWaitingForPlacement() {
|
||||||
|
return isWaitingForPlacement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void switchToSite(int siteId) {
|
||||||
|
LogFile.printDebug("MapView: Switching to site ID " + siteId);
|
||||||
|
if (isWaitingForPlacement && siteId != pendingTargetSiteId) {
|
||||||
|
cancelNodePlacement();
|
||||||
|
JOptionPane.showMessageDialog(this, "Režim umístění byl zrušen přepnutím mapy.");
|
||||||
|
}
|
||||||
|
for (Site site : Client.site) {
|
||||||
|
if (site.getId() == siteId) {
|
||||||
|
model.setSite(site);
|
||||||
|
Iterator<Node> it = pendingNodesToAdd.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
Node node = it.next();
|
||||||
|
if (node.getSiteId() == siteId) {
|
||||||
|
model.addNode(new NodeView(node, this));
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isWaitingForPlacement) {
|
||||||
|
setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
|
||||||
|
} else {
|
||||||
|
setCursor(Cursor.getDefaultCursor());
|
||||||
|
}
|
||||||
|
repaint();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupKeyListener() {
|
||||||
|
addKeyListener(new KeyAdapter() {
|
||||||
|
@Override
|
||||||
|
public void keyPressed(KeyEvent e) {
|
||||||
|
if (e.getKeyCode() == KeyEvent.VK_ESCAPE && isWaitingForPlacement) {
|
||||||
|
cancelNodePlacement();
|
||||||
|
JOptionPane.showMessageDialog(MapView.this, "Přesun zrušen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void paintComponent(Graphics g) {
|
||||||
|
super.paintComponent(g);
|
||||||
|
Graphics2D g2 = (Graphics2D) g.create();
|
||||||
|
|
||||||
|
if (lockImage != null && unlockImage != null) {
|
||||||
|
Image img = model.getSite().isLock() ? lockImage : unlockImage;
|
||||||
|
g2.drawImage(img, 0, 0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (EdgeView edge : model.getEdgeViews()) {
|
||||||
|
edge.paint(g2);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (NodeView node : model.getNodeViews()) {
|
||||||
|
node.paint(g2);
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle rect = mouseHandler.getSelectionRect();
|
||||||
|
if (rect != null) {
|
||||||
|
g2.setColor(SELECTION_FILL);
|
||||||
|
g2.fill(rect);
|
||||||
|
g2.setColor(SELECTION_BORDER);
|
||||||
|
g2.draw(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isWaitingForPlacement) {
|
||||||
|
g2.setColor(Color.RED);
|
||||||
|
g2.setFont(new Font("Arial", Font.BOLD, 16));
|
||||||
|
String msg = "Klikněte levým tlačítkem pro umístění uzlu (pravé tlačítko / ESC pro zrušení)";
|
||||||
|
FontMetrics fm = g2.getFontMetrics();
|
||||||
|
int x = (getWidth() - fm.stringWidth(msg)) / 2;
|
||||||
|
int y = getHeight() - 30;
|
||||||
|
g2.drawString(msg, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
g2.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshFromServer(Site site) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
if (model.getSite().getId() == site.getId()) {
|
||||||
|
model.setSite(site);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addNodeFromServer(Node newNode) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
if (model.getSite().getId() == newNode.getSiteId()) {
|
||||||
|
model.addNode(new NodeView(newNode, this));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeNodeFromServer(int nodeId) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
NodeView nv = model.findNodeViewById(nodeId);
|
||||||
|
if (nv != null) {
|
||||||
|
model.removeNode(nv);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateNodeStatus(int nodeId, int newStatus) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
NodeView nv = model.findNodeViewById(nodeId);
|
||||||
|
if (nv != null) {
|
||||||
|
nv.getNode().setStatus(newStatus);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateNodePosition(int nodeId, int x, int y) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
NodeView nv = model.findNodeViewById(nodeId);
|
||||||
|
if (nv != null) {
|
||||||
|
nv.setLocation(x, y);
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateNodeData(int nodeId, String name, String ip) {
|
||||||
|
SwingUtilities.invokeLater(() -> {
|
||||||
|
NodeView nv = model.findNodeViewById(nodeId);
|
||||||
|
if (nv != null) {
|
||||||
|
nv.getNode().setName(name);
|
||||||
|
nv.getNode().setIp(ip);
|
||||||
|
nv.recalculateDimensions();
|
||||||
|
repaint();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void requestRefreshFromServer() {
|
||||||
|
LogFile.printDebug("MapView: Requesting refresh from server");
|
||||||
|
JOptionPane.showMessageDialog(this, "Obnovení ze serveru - implementujte volání");
|
||||||
|
}
|
||||||
|
|
||||||
|
public MapModel getModel() {
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
|
||||||
|
public interface NodeRenderer {
|
||||||
|
void paint(Graphics2D g2, NodeView nodeView);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,224 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.SnmpResponseParser;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeProbe;
|
||||||
|
import jnet.lib.object.DeviceType;
|
||||||
|
|
||||||
|
public class NodeView {
|
||||||
|
|
||||||
|
public static final Font FONT_BOLD_12 = new Font("Arial", Font.BOLD, 12);
|
||||||
|
public static final Font FONT_NORMAL_12 = new Font("Arial", Font.PLAIN, 12);
|
||||||
|
|
||||||
|
// Zvětšený padding pro zařízení
|
||||||
|
private static final int PADDING_DEVICE = 30;
|
||||||
|
private static final int PADDING_OVAL = 30;
|
||||||
|
private static final int PADDING_CIRCLE = 25;
|
||||||
|
|
||||||
|
private static final Map<Integer, Image> iconCache = new HashMap<>();
|
||||||
|
|
||||||
|
private final Node node;
|
||||||
|
private Image icon;
|
||||||
|
private int centerX, centerY;
|
||||||
|
private int width, height;
|
||||||
|
private boolean selected = false;
|
||||||
|
private final MapView parent;
|
||||||
|
|
||||||
|
private final NodeRenderer renderer;
|
||||||
|
|
||||||
|
private FontMetrics fmBold;
|
||||||
|
private FontMetrics fmNormal;
|
||||||
|
|
||||||
|
public NodeView(Node node, MapView parent) {
|
||||||
|
this.node = node;
|
||||||
|
this.parent = parent;
|
||||||
|
this.centerX = node.getX();
|
||||||
|
this.centerY = node.getY();
|
||||||
|
this.icon = loadIcon(node.getIcon());
|
||||||
|
|
||||||
|
int type = node.getType();
|
||||||
|
if (type == 2) {
|
||||||
|
renderer = new MapNodeRenderer();
|
||||||
|
} else if (type == 3) {
|
||||||
|
renderer = new StaticNodeRenderer();
|
||||||
|
} else {
|
||||||
|
renderer = new DeviceNodeRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
|
recalculateDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Image loadIcon(int typeId) {
|
||||||
|
return iconCache.computeIfAbsent(typeId, id -> {
|
||||||
|
for (DeviceType devicType : Client.deviceType) {
|
||||||
|
if (devicType.getId() == id) {
|
||||||
|
try {
|
||||||
|
byte[] decoded = Base64.getDecoder().decode(devicType.getImgStr());
|
||||||
|
try (ByteArrayInputStream bis = new ByteArrayInputStream(decoded)) {
|
||||||
|
return ImageIO.read(bis);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("NodeView: Icon load error for type " + id + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void recalculateDimensions() {
|
||||||
|
fmBold = parent.getFontMetrics(FONT_BOLD_12);
|
||||||
|
fmNormal = parent.getFontMetrics(FONT_NORMAL_12);
|
||||||
|
|
||||||
|
String name = node.getName() != null ? node.getName() : "";
|
||||||
|
String ip = node.getIp() != null ? node.getIp() : "";
|
||||||
|
|
||||||
|
int nameWidth = fmBold.stringWidth(name);
|
||||||
|
int ipWidth = fmNormal.stringWidth(ip);
|
||||||
|
int iconWidth = (icon != null) ? icon.getWidth(null) : 0;
|
||||||
|
int iconHeight = (icon != null) ? icon.getHeight(null) : 0;
|
||||||
|
|
||||||
|
// ZMĚNA: získáme viditelné sondy
|
||||||
|
List<NodeProbe> visibleProbes = node.getProbe() != null
|
||||||
|
? node.getProbe().stream().filter(NodeProbe::isViewOnMap).collect(Collectors.toList())
|
||||||
|
: java.util.Collections.emptyList();
|
||||||
|
|
||||||
|
int probeCount = visibleProbes.size();
|
||||||
|
|
||||||
|
// ZMĚNA: spočítáme maximální šířku pro text sond (název + hodnota)
|
||||||
|
int maxProbeWidth = 0;
|
||||||
|
for (NodeProbe probe : visibleProbes) {
|
||||||
|
String value = probe.getValue() != null ? SnmpResponseParser.parse(probe) : "?";
|
||||||
|
int w = fmNormal.stringWidth(value);
|
||||||
|
if (w > maxProbeWidth) maxProbeWidth = w;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxTextWidth = Math.max(nameWidth, ipWidth);
|
||||||
|
maxTextWidth = Math.max(maxTextWidth, maxProbeWidth);
|
||||||
|
|
||||||
|
int type = node.getType();
|
||||||
|
|
||||||
|
// ZMĚNA: výška pro každou sondu (řádek)
|
||||||
|
int probeHeight = probeCount * (fmNormal.getHeight() + 2);
|
||||||
|
|
||||||
|
if (type == 1) {
|
||||||
|
// Větší vnitřní prostor
|
||||||
|
width = Math.max(maxTextWidth, iconWidth) + PADDING_DEVICE;
|
||||||
|
height = 8 + iconHeight + 8 + fmBold.getHeight() + 8 + fmNormal.getHeight() + 8 + probeHeight + 8;
|
||||||
|
if (icon == null) {
|
||||||
|
height -= iconHeight + 8;
|
||||||
|
height += 8; // kompenzace
|
||||||
|
}
|
||||||
|
} else if (type == 2) {
|
||||||
|
int textHeight = fmBold.getHeight() + 5 + fmNormal.getHeight() + probeHeight;
|
||||||
|
width = Math.max(maxTextWidth + PADDING_OVAL, 100);
|
||||||
|
height = Math.max(textHeight + PADDING_OVAL, 50);
|
||||||
|
if (width < height * 1.6) {
|
||||||
|
width = (int) (height * 1.8);
|
||||||
|
}
|
||||||
|
} else if (type == 3) {
|
||||||
|
int textHeight = fmBold.getHeight() + 5 + fmNormal.getHeight() + probeHeight;
|
||||||
|
int needed = Math.max(maxTextWidth + PADDING_CIRCLE, textHeight + PADDING_CIRCLE);
|
||||||
|
width = Math.max(needed, 70);
|
||||||
|
height = width;
|
||||||
|
} else {
|
||||||
|
width = Math.max(maxTextWidth, iconWidth) + PADDING_DEVICE;
|
||||||
|
height = 8 + iconHeight + 8 + fmBold.getHeight() + 8 + fmNormal.getHeight() + 8 + probeHeight + 8;
|
||||||
|
if (icon == null) {
|
||||||
|
height -= iconHeight + 8;
|
||||||
|
height += 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics2D g2) {
|
||||||
|
fmBold = g2.getFontMetrics(FONT_BOLD_12);
|
||||||
|
fmNormal = g2.getFontMetrics(FONT_NORMAL_12);
|
||||||
|
|
||||||
|
recalculateDimensions();
|
||||||
|
|
||||||
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
|
renderer.paint(g2, this);
|
||||||
|
|
||||||
|
// Výběr - silnější oranžové ohraničení (zůstává)
|
||||||
|
if (selected) {
|
||||||
|
Shape selShape = getShape();
|
||||||
|
if (selShape != null) {
|
||||||
|
g2.setColor(new Color(255, 255, 0, 60));
|
||||||
|
g2.fill(selShape);
|
||||||
|
g2.setStroke(new BasicStroke(3.0f));
|
||||||
|
g2.setColor(new Color(255, 165, 0));
|
||||||
|
g2.draw(selShape);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Shape getShape() {
|
||||||
|
int cx = centerX;
|
||||||
|
int cy = centerY;
|
||||||
|
int w = width;
|
||||||
|
int h = height;
|
||||||
|
int type = node.getType();
|
||||||
|
if (type == 1) {
|
||||||
|
return new java.awt.geom.RoundRectangle2D.Double(cx - w/2, cy - h/2, w, h, 10, 10);
|
||||||
|
} else if (type == 2) {
|
||||||
|
return new java.awt.geom.Ellipse2D.Double(cx - w/2, cy - h/2, w, h);
|
||||||
|
} else if (type == 3) {
|
||||||
|
int size = Math.min(w, h);
|
||||||
|
return new java.awt.geom.Ellipse2D.Double(cx - size/2, cy - size/2, size, size);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean contains(Point p) {
|
||||||
|
Shape s = getShape();
|
||||||
|
return s != null && s.contains(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void translate(int dx, int dy) {
|
||||||
|
this.centerX += dx;
|
||||||
|
this.centerY += dy;
|
||||||
|
node.setX(centerX);
|
||||||
|
node.setY(centerY);
|
||||||
|
recalculateDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(int x, int y) {
|
||||||
|
this.centerX = x;
|
||||||
|
this.centerY = y;
|
||||||
|
node.setX(x);
|
||||||
|
node.setY(y);
|
||||||
|
recalculateDimensions();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gettery
|
||||||
|
public Node getNode() { return node; }
|
||||||
|
public Image getIcon() { return icon; }
|
||||||
|
public int getCenterX() { return centerX; }
|
||||||
|
public int getCenterY() { return centerY; }
|
||||||
|
public int getWidth() { return width; }
|
||||||
|
public int getHeight() { return height; }
|
||||||
|
public boolean isSelected() { return selected; }
|
||||||
|
public void setSelected(boolean selected) { this.selected = selected; }
|
||||||
|
public Rectangle getBounds() {
|
||||||
|
Shape s = getShape();
|
||||||
|
if (s != null) return s.getBounds();
|
||||||
|
return new Rectangle(centerX, centerY, 0, 0);
|
||||||
|
}
|
||||||
|
public FontMetrics getFontMetricsBold() { return fmBold; }
|
||||||
|
public FontMetrics getFontMetricsNormal() { return fmNormal; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,152 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.RoundRectangle2D;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import jnet.lib.object.DeviceType;
|
||||||
|
|
||||||
|
public class PaintSiteObject {
|
||||||
|
|
||||||
|
private Node node;
|
||||||
|
private BufferedImage icon;
|
||||||
|
private boolean selected = false;
|
||||||
|
|
||||||
|
// Cache ikon podle typu
|
||||||
|
private static final Map<Integer, BufferedImage> iconCache = new HashMap<>();
|
||||||
|
|
||||||
|
// Fonty
|
||||||
|
private static final Font FONT_BOLD_12 = new Font("Arial", Font.BOLD, 12);
|
||||||
|
private static final Font FONT_NORMAL_12 = new Font("Arial", Font.PLAIN, 12);
|
||||||
|
|
||||||
|
// Geometrie (vypočítá se při paint)
|
||||||
|
private int centerX, centerY;
|
||||||
|
private int width, height;
|
||||||
|
private RoundRectangle2D shape;
|
||||||
|
|
||||||
|
public PaintSiteObject(Node node) {
|
||||||
|
this.node = node;
|
||||||
|
this.icon = loadIcon(node.getIcon());
|
||||||
|
}
|
||||||
|
|
||||||
|
private BufferedImage loadIcon(int typeId) {
|
||||||
|
return iconCache.computeIfAbsent(typeId, id -> {
|
||||||
|
for (DeviceType devicType : Client.deviceType) {
|
||||||
|
if (devicType.getId() == id) {
|
||||||
|
try {
|
||||||
|
byte[] decoded = Base64.getDecoder().decode(devicType.getImgStr());
|
||||||
|
ByteArrayInputStream bis = new ByteArrayInputStream(decoded);
|
||||||
|
return ImageIO.read(bis);
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Failed to load icon for type " + id + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void paint(Graphics2D g2) {
|
||||||
|
centerX = node.getX();
|
||||||
|
centerY = node.getY();
|
||||||
|
|
||||||
|
FontMetrics fmBold = g2.getFontMetrics(FONT_BOLD_12);
|
||||||
|
FontMetrics fmNormal = g2.getFontMetrics(FONT_NORMAL_12);
|
||||||
|
|
||||||
|
// Výpočet šířky
|
||||||
|
int nameWidth = fmBold.stringWidth(node.getName());
|
||||||
|
int ipWidth = fmNormal.stringWidth(node.getIp());
|
||||||
|
int maxTextWidth = Math.max(nameWidth, ipWidth);
|
||||||
|
int padding = 20;
|
||||||
|
width = Math.max(maxTextWidth + padding, icon != null ? icon.getWidth() + padding : 60);
|
||||||
|
|
||||||
|
// Výpočet výšky
|
||||||
|
height = 5; // horní padding
|
||||||
|
if (icon != null) {
|
||||||
|
height += icon.getHeight() + 5;
|
||||||
|
}
|
||||||
|
height += fmBold.getHeight() + 5;
|
||||||
|
height += fmNormal.getHeight() + 5;
|
||||||
|
height += 5; // dolní padding
|
||||||
|
|
||||||
|
// Pozice boxu
|
||||||
|
int boxX = centerX - width / 2;
|
||||||
|
int boxY = centerY - height / 2;
|
||||||
|
|
||||||
|
// Barva pozadí podle statusu
|
||||||
|
Color bgColor;
|
||||||
|
switch (node.getStatus()) {
|
||||||
|
case 1: bgColor = new Color(83, 241, 83); break; // online
|
||||||
|
case 2: bgColor = new Color(255, 131, 0); break; // warning
|
||||||
|
case 3: bgColor = new Color(221, 63, 63); break; // offline
|
||||||
|
default: bgColor = new Color(172, 172, 172);
|
||||||
|
}
|
||||||
|
g2.setColor(bgColor);
|
||||||
|
shape = new RoundRectangle2D.Double(boxX, boxY, width, height, 10, 10);
|
||||||
|
g2.fill(shape);
|
||||||
|
|
||||||
|
// Ohraničení pokud vybráno
|
||||||
|
if (selected) {
|
||||||
|
g2.setStroke(new BasicStroke(1.5f));
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.draw(shape);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ikona
|
||||||
|
int currentY = boxY + 5;
|
||||||
|
if (icon != null) {
|
||||||
|
int imgX = boxX + (width - icon.getWidth()) / 2;
|
||||||
|
g2.drawImage(icon, imgX, currentY, null);
|
||||||
|
currentY += icon.getHeight() + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Název
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.setFont(FONT_BOLD_12);
|
||||||
|
int textX = boxX + (width - nameWidth) / 2;
|
||||||
|
int textY = currentY + fmBold.getAscent();
|
||||||
|
g2.drawString(node.getName(), textX, textY);
|
||||||
|
|
||||||
|
// IP adresa
|
||||||
|
currentY += fmBold.getHeight() + 5;
|
||||||
|
g2.setFont(FONT_NORMAL_12);
|
||||||
|
textX = boxX + (width - ipWidth) / 2;
|
||||||
|
textY = currentY + fmNormal.getAscent();
|
||||||
|
g2.drawString(node.getIp(), textX, textY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test kolize s bodem (pro výběr)
|
||||||
|
public boolean contains(Point p) {
|
||||||
|
return shape != null && shape.contains(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Posun uzlu
|
||||||
|
public void setPosition(Point newCenter) {
|
||||||
|
this.centerX = newCenter.x;
|
||||||
|
this.centerY = newCenter.y;
|
||||||
|
node.setX(newCenter.x);
|
||||||
|
node.setY(newCenter.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gettery
|
||||||
|
public Node getNode() { return node; }
|
||||||
|
public int getId() { return node.getId(); }
|
||||||
|
public Point getCenter() { return new Point(centerX, centerY); }
|
||||||
|
public Rectangle getBounds() {
|
||||||
|
if (shape != null) {
|
||||||
|
return shape.getBounds();
|
||||||
|
}
|
||||||
|
return new Rectangle(centerX - width/2, centerY - height/2, width, height);
|
||||||
|
}
|
||||||
|
public void setSelected(boolean selected) { this.selected = selected; }
|
||||||
|
public boolean isSelected() { return selected; }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.BasicStroke;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Stroke;
|
||||||
|
import java.awt.geom.Ellipse2D;
|
||||||
|
|
||||||
|
public class StaticNodeRenderer implements NodeRenderer {
|
||||||
|
|
||||||
|
private static final Stroke THIN_STROKE = new BasicStroke(1.0f);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void paint(Graphics2D g2, NodeView nodeView) {
|
||||||
|
int cx = nodeView.getCenterX();
|
||||||
|
int cy = nodeView.getCenterY();
|
||||||
|
int size = nodeView.getWidth();
|
||||||
|
|
||||||
|
Ellipse2D circle = new Ellipse2D.Double(cx - size/2, cy - size/2, size, size);
|
||||||
|
g2.setColor(new Color(211, 211, 211));
|
||||||
|
g2.fill(circle);
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
g2.setStroke(THIN_STROKE);
|
||||||
|
g2.draw(circle);
|
||||||
|
|
||||||
|
TextUtils.drawCenteredText(g2,
|
||||||
|
nodeView.getNode().getName(),
|
||||||
|
nodeView.getNode().getIp(),
|
||||||
|
cx, cy,
|
||||||
|
nodeView.getFontMetricsBold(),
|
||||||
|
nodeView.getFontMetricsNormal());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,133 @@
|
||||||
|
package jnet.client.gui.mapview;
|
||||||
|
|
||||||
|
import java.awt.FontMetrics;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.util.List;
|
||||||
|
import jnet.lib.object.Node;
|
||||||
|
import jnet.lib.object.NodeProbe;
|
||||||
|
import jnet.client.SnmpResponseParser;
|
||||||
|
|
||||||
|
public class TextUtils {
|
||||||
|
|
||||||
|
public static void drawCenteredText(Graphics2D g2, String name, String ip, int cx, int cy,
|
||||||
|
FontMetrics fmBold, FontMetrics fmNormal) {
|
||||||
|
if (name == null) name = "";
|
||||||
|
if (ip == null) ip = "";
|
||||||
|
|
||||||
|
if (name.isEmpty() && ip.isEmpty()) return;
|
||||||
|
|
||||||
|
int nameWidth = name.isEmpty() ? 0 : fmBold.stringWidth(name);
|
||||||
|
int ipWidth = ip.isEmpty() ? 0 : fmNormal.stringWidth(ip);
|
||||||
|
int boldHeight = fmBold.getHeight();
|
||||||
|
int normalHeight = fmNormal.getHeight();
|
||||||
|
|
||||||
|
int totalHeight;
|
||||||
|
if (!name.isEmpty() && !ip.isEmpty()) {
|
||||||
|
totalHeight = boldHeight + 5 + normalHeight;
|
||||||
|
} else if (!name.isEmpty()) {
|
||||||
|
totalHeight = boldHeight;
|
||||||
|
} else {
|
||||||
|
totalHeight = normalHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
int startY;
|
||||||
|
if (!name.isEmpty() && !ip.isEmpty()) {
|
||||||
|
startY = cy - totalHeight / 2 + fmBold.getAscent();
|
||||||
|
} else if (!name.isEmpty()) {
|
||||||
|
startY = cy + fmBold.getAscent() / 2 - fmBold.getDescent() / 2;
|
||||||
|
} else {
|
||||||
|
startY = cy + fmNormal.getAscent() / 2 - fmNormal.getDescent() / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
g2.setColor(java.awt.Color.BLACK);
|
||||||
|
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
g2.setFont(NodeView.FONT_BOLD_12);
|
||||||
|
int x = cx - nameWidth / 2;
|
||||||
|
g2.drawString(name, x, startY);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ip.isEmpty()) {
|
||||||
|
g2.setFont(NodeView.FONT_NORMAL_12);
|
||||||
|
int ipY = startY + boldHeight + 5;
|
||||||
|
if (name.isEmpty()) {
|
||||||
|
ipY = startY;
|
||||||
|
}
|
||||||
|
int x = cx - ipWidth / 2;
|
||||||
|
g2.drawString(ip, x, ipY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawTextFromY(Graphics2D g2, String name, String ip, int cx, int startY,
|
||||||
|
FontMetrics fmBold, FontMetrics fmNormal) {
|
||||||
|
if (name == null) name = "";
|
||||||
|
if (ip == null) ip = "";
|
||||||
|
|
||||||
|
if (name.isEmpty() && ip.isEmpty()) return;
|
||||||
|
|
||||||
|
int nameWidth = name.isEmpty() ? 0 : fmBold.stringWidth(name);
|
||||||
|
int ipWidth = ip.isEmpty() ? 0 : fmNormal.stringWidth(ip);
|
||||||
|
|
||||||
|
g2.setColor(java.awt.Color.BLACK);
|
||||||
|
|
||||||
|
int y = startY;
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
g2.setFont(NodeView.FONT_BOLD_12);
|
||||||
|
int x = cx - nameWidth / 2;
|
||||||
|
g2.drawString(name, x, y + fmBold.getAscent());
|
||||||
|
y += fmBold.getHeight() + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ip.isEmpty()) {
|
||||||
|
g2.setFont(NodeView.FONT_NORMAL_12);
|
||||||
|
int x = cx - ipWidth / 2;
|
||||||
|
g2.drawString(ip, x, y + fmNormal.getAscent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ZMĚNA: nová metoda pro vykreslení jména, IP a viditelných sond
|
||||||
|
public static int drawNodeInfo(Graphics2D g2, Node node, int cx, int startY,
|
||||||
|
FontMetrics fmBold, FontMetrics fmNormal) {
|
||||||
|
String name = node.getName() != null ? node.getName() : "";
|
||||||
|
String ip = node.getIp() != null ? node.getIp() : "";
|
||||||
|
|
||||||
|
int y = startY;
|
||||||
|
g2.setColor(java.awt.Color.BLACK);
|
||||||
|
|
||||||
|
// Jméno (tučné)
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
g2.setFont(NodeView.FONT_BOLD_12);
|
||||||
|
int nameWidth = fmBold.stringWidth(name);
|
||||||
|
int x = cx - nameWidth / 2;
|
||||||
|
g2.drawString(name, x, y + fmBold.getAscent());
|
||||||
|
y += fmBold.getHeight() + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IP (normální)
|
||||||
|
if (!ip.isEmpty()) {
|
||||||
|
g2.setFont(NodeView.FONT_NORMAL_12);
|
||||||
|
int ipWidth = fmNormal.stringWidth(ip);
|
||||||
|
int x = cx - ipWidth / 2;
|
||||||
|
g2.drawString(ip, x, y + fmNormal.getAscent());
|
||||||
|
y += fmNormal.getHeight() + 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sondy (pouze viewOnMap = true)
|
||||||
|
List<NodeProbe> visibleProbes = node.getProbe() != null
|
||||||
|
? node.getProbe().stream().filter(NodeProbe::isViewOnMap).collect(java.util.stream.Collectors.toList())
|
||||||
|
: java.util.Collections.emptyList();
|
||||||
|
|
||||||
|
g2.setFont(NodeView.FONT_NORMAL_12);
|
||||||
|
for (NodeProbe probe : visibleProbes) {
|
||||||
|
String probeName = probe.getName() != null ? probe.getName() : "";
|
||||||
|
String value = probe.getValue() != null ? SnmpResponseParser.parse(probe) + " " + probe.getUnit() : "?";
|
||||||
|
String text = probeName + ": " + value;
|
||||||
|
int textWidth = fmNormal.stringWidth(text);
|
||||||
|
int x = cx - textWidth / 2;
|
||||||
|
g2.drawString(text, x, y + fmNormal.getAscent());
|
||||||
|
y += fmNormal.getHeight() + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return y; // vrátí novou Y pozici
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,238 @@
|
||||||
|
package jnet.client.gui.serversettings;
|
||||||
|
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import static jnet.client.Client.user;
|
||||||
|
import jnet.client.gui.dialog.DialogSnmpProfile;
|
||||||
|
import jnet.client.gui.dialog.DialogSnmpTemplate;
|
||||||
|
import jnet.client.gui.dialog.DialogSnmpValueMap;
|
||||||
|
import jnet.client.gui.dialog.DialogUser;
|
||||||
|
import jnet.lib.object.SnmpTemplate;
|
||||||
|
|
||||||
|
public class ServerSettingsPanel extends JTabbedPane {
|
||||||
|
|
||||||
|
public static final int TAB_DEFAULT = 0;
|
||||||
|
public static final int TAB_DEVICE_TYPE = 1;
|
||||||
|
public static final int TAB_USERS = 2;
|
||||||
|
public static final int TAB_SNMP_PROFILE = 3;
|
||||||
|
public static final int TAB_SNMP_TEMPLATE = 4;
|
||||||
|
public static final int TAB_SNMP_VALUE_MAP = 5;
|
||||||
|
public static final int TAB_LOG = 6;
|
||||||
|
|
||||||
|
private TableDeviceType tableDeviceType;
|
||||||
|
private TableUsers tableUsers;
|
||||||
|
private TableSnmpProfile tableSnmpProfile;
|
||||||
|
private TableSnmpTemplate tableSnmpTemplate;
|
||||||
|
private TabLog tabLog;
|
||||||
|
private TableValueMap tableValueMap;
|
||||||
|
|
||||||
|
public ServerSettingsPanel() {
|
||||||
|
addTab("Základní", tabZakladni());
|
||||||
|
addTab("Typy zařízení", tabZarizeni());
|
||||||
|
addTab("Uživatelé", tabUsers());
|
||||||
|
addTab("SNMP profily", tabSnmpProfile());
|
||||||
|
addTab("SNMP šablony", tabSnmpTemplate());
|
||||||
|
addTab("SNMP mapování hodnot", tabSnmpValueMap());
|
||||||
|
addTab("Log serveru", tabServerLog());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTable(int tab) {
|
||||||
|
setSelectedIndex(tab);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Základní nastavení (původní styl s null layout)
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private Component tabZakladni() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BorderLayout());
|
||||||
|
|
||||||
|
TabSettings tabSettings = new TabSettings();
|
||||||
|
JScrollPane scrollPane = new JScrollPane(tabSettings);
|
||||||
|
scrollPane.getVerticalScrollBar().setUnitIncrement(25);
|
||||||
|
panel.add(scrollPane,BorderLayout.CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Typy zařízení
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private JPanel tabZarizeni() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
tableDeviceType = new TableDeviceType();
|
||||||
|
JScrollPane scrollPane = new JScrollPane(tableDeviceType);
|
||||||
|
panel.add(scrollPane);
|
||||||
|
|
||||||
|
JButton button = new JButton("Přidat typ");
|
||||||
|
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SwingUtilities.invokeLater(() -> new DialogUser(user, true).setVisible(true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshDeviceTypes() {
|
||||||
|
if (tableDeviceType != null) {
|
||||||
|
SwingUtilities.invokeLater(() -> tableDeviceType.refreshTable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// Uživatelé
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private JPanel tabUsers() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
tableUsers = new TableUsers();
|
||||||
|
panel.add(new JScrollPane(tableUsers));
|
||||||
|
|
||||||
|
JButton button = new JButton("Přidat uživatele");
|
||||||
|
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SwingUtilities.invokeLater(() -> new DialogUser(null, true).setVisible(true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshUsers() {
|
||||||
|
if (tableUsers != null) {
|
||||||
|
SwingUtilities.invokeLater(() -> tableUsers.refreshTable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// SNMP profily
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private Component tabSnmpProfile() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
tableSnmpProfile = new TableSnmpProfile();
|
||||||
|
JScrollPane scrollPane = new JScrollPane(tableSnmpProfile);
|
||||||
|
panel.add(scrollPane);
|
||||||
|
|
||||||
|
JButton button = new JButton("Přidat profil");
|
||||||
|
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SwingUtilities.invokeLater(() -> new DialogSnmpProfile(null, true).setVisible(true));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshSnmpProfiles() {
|
||||||
|
if (tableUsers != null) {
|
||||||
|
SwingUtilities.invokeLater(() -> tableSnmpProfile.refreshTable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// SNMP profily
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private Component tabSnmpTemplate() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
tableSnmpTemplate = new TableSnmpTemplate();
|
||||||
|
JScrollPane scrollPane = new JScrollPane(tableSnmpTemplate);
|
||||||
|
panel.add(scrollPane);
|
||||||
|
|
||||||
|
JButton button = new JButton("Přidat sablonu");
|
||||||
|
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
SwingUtilities.invokeLater(() -> new DialogSnmpTemplate(new SnmpTemplate(), true).show());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshSnmpTemplates() {
|
||||||
|
if (tableUsers != null) {
|
||||||
|
SwingUtilities.invokeLater(() -> tableSnmpTemplate.refreshTable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// server log
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private Component tabServerLog() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
tabLog = new TabLog();
|
||||||
|
panel.add(tabLog);
|
||||||
|
|
||||||
|
JButton button = new JButton("Obnovit");
|
||||||
|
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
NettyClientManager.sendMessage(Message.SERVER_LOG, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putLog(String[] log) {
|
||||||
|
tabLog.putLog(log);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// snmp mapovani hodnot
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
private Component tabSnmpValueMap() {
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
|
|
||||||
|
tableValueMap = new TableValueMap();
|
||||||
|
panel.add(new JScrollPane(tableValueMap));
|
||||||
|
|
||||||
|
JButton button = new JButton("Přidat mapování");
|
||||||
|
button.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||||
|
button.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
new DialogSnmpValueMap(null).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
panel.add(button);
|
||||||
|
|
||||||
|
return panel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshValueMap() {
|
||||||
|
if (tableValueMap != null) {
|
||||||
|
SwingUtilities.invokeLater(() -> tableValueMap.refreshTable());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package jnet.client.gui.serversettings;
|
||||||
|
|
||||||
|
import java.awt.BorderLayout;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JScrollPane;
|
||||||
|
import javax.swing.JTextArea;
|
||||||
|
|
||||||
|
public class TabLog extends JPanel {
|
||||||
|
|
||||||
|
private JTextArea logArea = new JTextArea();
|
||||||
|
|
||||||
|
public TabLog() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setLayout(null);
|
||||||
|
|
||||||
|
setLayout(new BorderLayout()); // místo null
|
||||||
|
logArea.setEditable(false); // uživatel nemůže měnit obsah
|
||||||
|
logArea.setLineWrap(true);
|
||||||
|
logArea.setWrapStyleWord(true);
|
||||||
|
logArea.setMargin(new Insets(10, 15, 10, 15));
|
||||||
|
add(new JScrollPane(logArea), BorderLayout.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void appendLine(String text) {
|
||||||
|
logArea.append(text + "\n\n");
|
||||||
|
logArea.setCaretPosition(logArea.getDocument().getLength());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void putLog(String[] text) {
|
||||||
|
for (String record : text) {
|
||||||
|
appendLine(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,203 @@
|
||||||
|
package jnet.client.gui.serversettings;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import javax.swing.JButton;
|
||||||
|
import javax.swing.JCheckBox;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.JTextField;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
|
||||||
|
public class TabSettings extends JPanel {
|
||||||
|
|
||||||
|
private int X1 = 80;
|
||||||
|
private int X2 = 150;
|
||||||
|
|
||||||
|
public TabSettings() {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init() {
|
||||||
|
setLayout(null);
|
||||||
|
|
||||||
|
// Nadpis - obecne
|
||||||
|
JLabel obecneLabel = new JLabel("Obecné");
|
||||||
|
obecneLabel.setFont(obecneLabel.getFont().deriveFont(20f));
|
||||||
|
obecneLabel.setBounds(20, 20, 150, 25);
|
||||||
|
add(obecneLabel);
|
||||||
|
|
||||||
|
// debug mode
|
||||||
|
JCheckBox debugCheckBox = new JCheckBox();
|
||||||
|
debugCheckBox.setSelected(Client.serverConfig.isDebug());
|
||||||
|
debugCheckBox.setBounds(X1, getNextY(obecneLabel), 50, 25);
|
||||||
|
add(debugCheckBox);
|
||||||
|
|
||||||
|
JLabel debugLabel = new JLabel("Debug mode");
|
||||||
|
debugLabel.setBounds(X2, getNextY(obecneLabel), 300, 25);
|
||||||
|
add(debugLabel);
|
||||||
|
|
||||||
|
// Nadpis - ping
|
||||||
|
JLabel pingLabel = new JLabel("Ping");
|
||||||
|
pingLabel.setFont(pingLabel.getFont().deriveFont(20f));
|
||||||
|
pingLabel.setBounds(20, getNextY(debugCheckBox) + 50, 150, 25);
|
||||||
|
add(pingLabel);
|
||||||
|
|
||||||
|
// interval opakovani pingu
|
||||||
|
JTextField repeateField = new JTextField(String.valueOf(Client.serverConfig.getPingRepeat()));
|
||||||
|
repeateField.setBounds(X1, getNextY(pingLabel), 50, 25);
|
||||||
|
add(repeateField);
|
||||||
|
|
||||||
|
JLabel repeateLabel = new JLabel("Opakovat ping každých ... sekund");
|
||||||
|
repeateLabel.setBounds(X2, getNextY(pingLabel), 300, 25);
|
||||||
|
add(repeateLabel);
|
||||||
|
|
||||||
|
// pocet pokusu pingu
|
||||||
|
JTextField pokusuField = new JTextField(String.valueOf(Client.serverConfig.getPingAttempt()));
|
||||||
|
pokusuField.setBounds(X1, getNextY(repeateField), 50, 25);
|
||||||
|
add(pokusuField);
|
||||||
|
|
||||||
|
JLabel pokusuLabel = new JLabel("Počet pokusů před vyhodnocením offline");
|
||||||
|
pokusuLabel.setBounds(X2, getNextY(repeateField), 300, 25);
|
||||||
|
add(pokusuLabel);
|
||||||
|
|
||||||
|
// uroven timeout
|
||||||
|
JTextField timeoutField = new JTextField(String.valueOf(Client.serverConfig.getPingTimeout()));
|
||||||
|
timeoutField.setBounds(X1, getNextY(pokusuField), 50, 25);
|
||||||
|
add(timeoutField);
|
||||||
|
|
||||||
|
JLabel timeoutLabel = new JLabel("Úroveň timeout (s)");
|
||||||
|
timeoutLabel.setBounds(X2, getNextY(pokusuField), 300, 25);
|
||||||
|
add(timeoutLabel);
|
||||||
|
|
||||||
|
// pocet pokusu nestability
|
||||||
|
JTextField pokusuNestField = new JTextField(String.valueOf(Client.serverConfig.getInstabilityAttempt()));
|
||||||
|
pokusuNestField.setBounds(X1, getNextY(timeoutField), 50, 25);
|
||||||
|
add(pokusuNestField);
|
||||||
|
|
||||||
|
JLabel pokusuNestLabel = new JLabel("Počet pokusů před vyhodnocením nestability");
|
||||||
|
pokusuNestLabel.setBounds(X2, getNextY(timeoutField), 300, 25);
|
||||||
|
add(pokusuNestLabel);
|
||||||
|
|
||||||
|
// uroven nestability
|
||||||
|
JTextField nestField = new JTextField(String.valueOf(Client.serverConfig.getInstabilityLimit()));
|
||||||
|
nestField.setBounds(X1, getNextY(pokusuNestField), 50, 25);
|
||||||
|
add(nestField);
|
||||||
|
|
||||||
|
JLabel nestLabel = new JLabel("Úroveň nestability (s)");
|
||||||
|
nestLabel.setBounds(X2, getNextY(pokusuNestField), 300, 25);
|
||||||
|
add(nestLabel);
|
||||||
|
|
||||||
|
// Nadpis - traffic monitor
|
||||||
|
JLabel trafficLabel = new JLabel("Traffic monitor");
|
||||||
|
trafficLabel.setFont(pingLabel.getFont().deriveFont(20f));
|
||||||
|
trafficLabel.setBounds(20, getNextY(nestField) + 50, 150, 25);
|
||||||
|
add(trafficLabel);
|
||||||
|
|
||||||
|
JTextField trafficIntervalField = new JTextField(String.valueOf(Client.serverConfig.getTrafficInterval()));
|
||||||
|
trafficIntervalField.setBounds(X1, getNextY(trafficLabel), 50, 25);
|
||||||
|
add(trafficIntervalField);
|
||||||
|
|
||||||
|
JLabel trafficIntervalLabel = new JLabel("Internval dotazování (s)");
|
||||||
|
trafficIntervalLabel.setBounds(X2, getNextY(trafficLabel), 300, 25);
|
||||||
|
add(trafficIntervalLabel);
|
||||||
|
|
||||||
|
JTextField trafficBatchIntervalField = new JTextField(String.valueOf(Client.serverConfig.getTrafficBatchInterval()));
|
||||||
|
trafficBatchIntervalField.setBounds(X1, getNextY(trafficIntervalField), 50, 25);
|
||||||
|
add(trafficBatchIntervalField);
|
||||||
|
|
||||||
|
JLabel trafficBatchIntervalLabel = new JLabel("interval odesílání výsledku (s)");
|
||||||
|
trafficBatchIntervalLabel.setBounds(X2, getNextY(trafficIntervalField), 300, 25);
|
||||||
|
add(trafficBatchIntervalLabel);
|
||||||
|
|
||||||
|
// Nadpis - sondy
|
||||||
|
JLabel probeLabel = new JLabel("Traffic monitor");
|
||||||
|
probeLabel.setFont(pingLabel.getFont().deriveFont(20f));
|
||||||
|
probeLabel.setBounds(20, getNextY(trafficBatchIntervalField) + 50, 150, 25);
|
||||||
|
add(probeLabel);
|
||||||
|
|
||||||
|
JTextField probeBatchIntervalField = new JTextField(String.valueOf(Client.serverConfig.getProbeBatchInterval()));
|
||||||
|
probeBatchIntervalField.setBounds(X1, getNextY(probeLabel), 50, 25);
|
||||||
|
add(probeBatchIntervalField);
|
||||||
|
|
||||||
|
JLabel probeBatchIntervalLabel = new JLabel("Interval odesílání výsledu (s)");
|
||||||
|
probeBatchIntervalLabel.setBounds(X2, getNextY(probeLabel), 300, 25);
|
||||||
|
add(probeBatchIntervalLabel);
|
||||||
|
|
||||||
|
// Tlačítko Uložit
|
||||||
|
JButton buttonSave = new JButton("Uložit");
|
||||||
|
buttonSave.setBounds(X1, getNextY(probeBatchIntervalField) + 100, 100, 40);
|
||||||
|
buttonSave.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
try {
|
||||||
|
Client.serverConfig.setDebug(debugCheckBox.isSelected());
|
||||||
|
Client.serverConfig.setPingRepeat(Integer.valueOf(repeateField.getText()));
|
||||||
|
Client.serverConfig.setPingAttempt(Integer.valueOf(pokusuField.getText()));
|
||||||
|
Client.serverConfig.setPingTimeout(Integer.valueOf(timeoutField.getText()));
|
||||||
|
Client.serverConfig.setInstabilityAttempt(Integer.valueOf(pokusuNestField.getText()));
|
||||||
|
Client.serverConfig.setInstabilityLimit(Integer.valueOf(nestField.getText()));
|
||||||
|
Client.serverConfig.setTrafficInterval(Integer.valueOf(trafficIntervalField.getText()));
|
||||||
|
Client.serverConfig.setTrafficBatchInterval(Integer.valueOf(trafficBatchIntervalField.getText()));
|
||||||
|
Client.serverConfig.setProbeBatchInterval(Integer.valueOf(probeBatchIntervalField.getText()));
|
||||||
|
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.SERVER_CONFIG_EDIT, Client.serverConfig));
|
||||||
|
JOptionPane.showMessageDialog(TabSettings.this, "Nastavení uloženo.");
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
JOptionPane.showMessageDialog(TabSettings.this, "Zadejte platná čísla.", "Chyba", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(buttonSave);
|
||||||
|
|
||||||
|
// Tlačítko Restartovat server
|
||||||
|
JButton buttonRestart = new JButton("Restartovat server");
|
||||||
|
buttonRestart.setBounds(X2 + 100, getNextY(probeBatchIntervalField) + 100, 150, 40);
|
||||||
|
buttonRestart.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
int result = JOptionPane.showConfirmDialog(null,
|
||||||
|
"Opravdu chceš pokračovat?",
|
||||||
|
"Restart serveru",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
|
||||||
|
if (result == JOptionPane.YES_OPTION) {
|
||||||
|
LogFile.printInfo("Odeslan pozadavek na restart serveru");
|
||||||
|
NettyClientManager.sendMessage(new Message(Message.SERVER_RESTART, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
add(buttonRestart);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getNextY(Component prevComponent) {
|
||||||
|
int prevY = prevComponent.getY();
|
||||||
|
return prevY + 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension getPreferredSize() {
|
||||||
|
int maxX = 0;
|
||||||
|
int maxY = 0;
|
||||||
|
for (Component comp : getComponents()) {
|
||||||
|
// Použijeme preferované velikosti, nikoliv aktuální (které mohou být 0)
|
||||||
|
Dimension pref = comp.getPreferredSize();
|
||||||
|
int x = comp.getX();
|
||||||
|
int y = comp.getY();
|
||||||
|
int right = x + pref.width;
|
||||||
|
int bottom = y + pref.height;
|
||||||
|
if (right > maxX) maxX = right;
|
||||||
|
if (bottom > maxY) maxY = bottom;
|
||||||
|
}
|
||||||
|
// přidáme okraj (padding) – 20 pixelů ze všech stran
|
||||||
|
return new Dimension(maxX + 20, maxY + 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,205 @@
|
||||||
|
package jnet.client.gui.serversettings;
|
||||||
|
|
||||||
|
import jnet.client.Client;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import javax.swing.table.TableColumn;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Base64;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.object.DeviceType;
|
||||||
|
|
||||||
|
public class TableDeviceType extends JTable {
|
||||||
|
|
||||||
|
private static final ConcurrentHashMap<String, ImageIcon> iconCache = new ConcurrentHashMap<>();
|
||||||
|
private JPopupMenu popupMenu;
|
||||||
|
|
||||||
|
private static final String[] COLUMN_NAMES = {"ID", "Ikona", "Název zařízení"};
|
||||||
|
|
||||||
|
private DefaultTableModel model;
|
||||||
|
|
||||||
|
public TableDeviceType() {
|
||||||
|
initTable();
|
||||||
|
initPopupMenu();
|
||||||
|
addMouseListener(new TableMouseAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getColumnClass(int column) {
|
||||||
|
return column == 1 ? ImageIcon.class : String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTable() {
|
||||||
|
model = new DefaultTableModel(COLUMN_NAMES, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
setModel(model);
|
||||||
|
setDefaultRenderer(String.class, new CenteredRenderer());
|
||||||
|
setRowHeight(50);
|
||||||
|
|
||||||
|
// Skryjeme sloupec ID (index 0)
|
||||||
|
getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
|
getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
|
getColumnModel().getColumn(0).setPreferredWidth(0);
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
|
||||||
|
// Nastavení šířky sloupců
|
||||||
|
for (int i = 0; i < COLUMN_NAMES.length; i++) {
|
||||||
|
TableColumn col = getColumnModel().getColumn(i);
|
||||||
|
col.setPreferredWidth(col.getPreferredWidth() + 80);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData() {
|
||||||
|
model.setRowCount(0);
|
||||||
|
|
||||||
|
for (DeviceType obj : Client.deviceType) {
|
||||||
|
model.addRow(new Object[]{obj.getId(), getIcon(obj), obj.getName()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Získání vybraného zarizeni --------
|
||||||
|
private DeviceType getSelectedDeviceType() {
|
||||||
|
int viewRow = getSelectedRow();
|
||||||
|
if (viewRow == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int modelRow = convertRowIndexToModel(viewRow);
|
||||||
|
int id = (int) model.getValueAt(modelRow, 0);
|
||||||
|
return Client.deviceType.stream()
|
||||||
|
.filter(st -> st.getId() == id)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Kontextové menu --------
|
||||||
|
private void initPopupMenu() {
|
||||||
|
|
||||||
|
popupMenu = new JPopupMenu();
|
||||||
|
|
||||||
|
// JMenuItem editItem = new JMenuItem("Upravit");
|
||||||
|
// editItem.addActionListener(e -> {
|
||||||
|
// devicType st = getSelectedDeviceType();
|
||||||
|
// if (st != null) {
|
||||||
|
// // Zde zavolejte metodu pro otevření editace
|
||||||
|
// new DialogSnmpProfile(st, false).show();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// popupMenu.add(editItem);
|
||||||
|
try {
|
||||||
|
JMenuItem deleteItem = new JMenuItem("Smazat", new ImageIcon(ImageIO.read(ResourceLoader.getFile("img/trash.png"))));
|
||||||
|
deleteItem.addActionListener(e -> {
|
||||||
|
DeviceType ot = getSelectedDeviceType();
|
||||||
|
if (ot != null) {
|
||||||
|
// Zde zavolejte metodu pro smazání
|
||||||
|
if (ot.getId() != 1) {
|
||||||
|
int option = JOptionPane.showConfirmDialog(
|
||||||
|
null,
|
||||||
|
"Smazat object " + ot.getName() + " ?",
|
||||||
|
"Potvrzení akce",
|
||||||
|
JOptionPane.YES_NO_OPTION
|
||||||
|
);
|
||||||
|
|
||||||
|
if (option == JOptionPane.YES_OPTION) {
|
||||||
|
NettyClientManager.sendMessage(Message.DEVICE_TYPE_DELETE, ot.getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nelze smazat výchozí zařízení");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(deleteItem);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("TableDeviceType error: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Myší listener --------
|
||||||
|
private class TableMouseAdapter extends MouseAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
|
||||||
|
DeviceType st = getSelectedDeviceType();
|
||||||
|
if (st != null) {
|
||||||
|
// Dvojklik = editace
|
||||||
|
// new DialogSnmpProfile(st, false).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger()) {
|
||||||
|
showPopup(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger()) {
|
||||||
|
showPopup(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPopup(MouseEvent e) {
|
||||||
|
int row = rowAtPoint(e.getPoint());
|
||||||
|
if (row >= 0 && row < getRowCount()) {
|
||||||
|
setRowSelectionInterval(row, row);
|
||||||
|
}
|
||||||
|
popupMenu.show(TableDeviceType.this, e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshTable() {
|
||||||
|
SwingUtilities.invokeLater(this::loadData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ImageIcon getIcon(DeviceType obj) {
|
||||||
|
return iconCache.computeIfAbsent(obj.getImgStr(), key -> {
|
||||||
|
try {
|
||||||
|
byte[] decoded = Base64.getDecoder().decode(key);
|
||||||
|
var img = ImageIO.read(new ByteArrayInputStream(decoded));
|
||||||
|
if (img != null) {
|
||||||
|
// Zmenšení obrázku na 32x32
|
||||||
|
Image scaled = img.getScaledInstance(32, 32, Image.SCALE_SMOOTH);
|
||||||
|
return new ImageIcon(scaled);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogFile.printErr("Failed to decode image for: " + obj.getName() + " " + e.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class CenteredRenderer extends DefaultTableCellRenderer {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||||
|
boolean isSelected, boolean hasFocus,
|
||||||
|
int row, int column) {
|
||||||
|
Component c = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||||
|
if (c instanceof JLabel) {
|
||||||
|
((JLabel) c).setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
}
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,178 @@
|
||||||
|
package jnet.client.gui.serversettings;
|
||||||
|
|
||||||
|
import java.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.ImageIcon;
|
||||||
|
import javax.swing.JMenuItem;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
|
import javax.swing.JPopupMenu;
|
||||||
|
import javax.swing.JTable;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
import javax.swing.table.DefaultTableModel;
|
||||||
|
import jnet.client.Client;
|
||||||
|
import jnet.client.client.NettyClientManager;
|
||||||
|
import jnet.client.gui.dialog.DialogSnmpProfile;
|
||||||
|
import jnet.lib.LogFile;
|
||||||
|
import jnet.lib.Message;
|
||||||
|
import jnet.lib.ResourceLoader;
|
||||||
|
import jnet.lib.object.SnmpProfile;
|
||||||
|
import org.snmp4j.mp.SnmpConstants;
|
||||||
|
|
||||||
|
public class TableSnmpProfile extends JTable {
|
||||||
|
|
||||||
|
private DefaultTableModel model;
|
||||||
|
private JPopupMenu popupMenu;
|
||||||
|
private static final String[] COLUMN_NAMES = {"ID", "Název", "Verze", "Community Read", "Port"};
|
||||||
|
|
||||||
|
public TableSnmpProfile() {
|
||||||
|
initTable();
|
||||||
|
initPopupMenu();
|
||||||
|
addMouseListener(new TableMouseAdapter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initTable() {
|
||||||
|
model = new DefaultTableModel(COLUMN_NAMES, 0) {
|
||||||
|
@Override
|
||||||
|
public boolean isCellEditable(int row, int column) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
setModel(model);
|
||||||
|
setRowHeight(25);
|
||||||
|
|
||||||
|
// Skryjeme sloupec ID (index 0)
|
||||||
|
getColumnModel().getColumn(0).setMinWidth(0);
|
||||||
|
getColumnModel().getColumn(0).setMaxWidth(0);
|
||||||
|
getColumnModel().getColumn(0).setPreferredWidth(0);
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Získání vybraného profilu --------
|
||||||
|
private SnmpProfile getSelectedSnmpProfile() {
|
||||||
|
int viewRow = getSelectedRow();
|
||||||
|
if (viewRow == -1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int modelRow = convertRowIndexToModel(viewRow);
|
||||||
|
int id = (int) model.getValueAt(modelRow, 0);
|
||||||
|
return Client.snmpProfile.stream()
|
||||||
|
.filter(st -> st.getId() == id)
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Kontextové menu --------
|
||||||
|
private void initPopupMenu() {
|
||||||
|
popupMenu = new JPopupMenu();
|
||||||
|
try {
|
||||||
|
JMenuItem editItem = new JMenuItem("Upravit", new ImageIcon(ImageIO.read(ResourceLoader.getFile("img/edit.png"))));
|
||||||
|
editItem.addActionListener(e -> {
|
||||||
|
SnmpProfile profile = getSelectedSnmpProfile();
|
||||||
|
|
||||||
|
// Zde zavolejte metodu pro otevření editace
|
||||||
|
new DialogSnmpProfile(profile, false).show();
|
||||||
|
});
|
||||||
|
popupMenu.add(editItem);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("TableSnmpProfile error: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JMenuItem deleteItem = new JMenuItem("Smazat", new ImageIcon(ImageIO.read(ResourceLoader.getFile("img/trash.png"))));
|
||||||
|
deleteItem.addActionListener(e -> {
|
||||||
|
SnmpProfile profile = getSelectedSnmpProfile();
|
||||||
|
// Zde zavolejte metodu pro smazání
|
||||||
|
if (profile.getId() != 1) {
|
||||||
|
int option = JOptionPane.showConfirmDialog(
|
||||||
|
null,
|
||||||
|
"Smazat profil " + profile.getName() + " ?",
|
||||||
|
"Potvrzení akce",
|
||||||
|
JOptionPane.YES_NO_OPTION
|
||||||
|
);
|
||||||
|
|
||||||
|
if (option == JOptionPane.YES_OPTION) {
|
||||||
|
NettyClientManager.sendMessage(Message.SNMP_PROFILE_DELETE, profile.getId());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
JOptionPane.showMessageDialog(null, "Nelze smazat výchozí profil");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
popupMenu.add(deleteItem);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
LogFile.printErr("TableSnmpProfile error: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------- Myší listener --------
|
||||||
|
private class TableMouseAdapter extends MouseAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
|
||||||
|
SnmpProfile st = getSelectedSnmpProfile();
|
||||||
|
if (st != null) {
|
||||||
|
// Dvojklik = editace
|
||||||
|
new DialogSnmpProfile(st, false).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mousePressed(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger()) {
|
||||||
|
showPopup(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseReleased(MouseEvent e) {
|
||||||
|
if (e.isPopupTrigger()) {
|
||||||
|
showPopup(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPopup(MouseEvent e) {
|
||||||
|
int row = rowAtPoint(e.getPoint());
|
||||||
|
if (row >= 0 && row < getRowCount()) {
|
||||||
|
setRowSelectionInterval(row, row);
|
||||||
|
}
|
||||||
|
popupMenu.show(TableSnmpProfile.this, e.getX(), e.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadData() {
|
||||||
|
model.setRowCount(0);
|
||||||
|
|
||||||
|
for (SnmpProfile sp : Client.snmpProfile) {
|
||||||
|
model.addRow(new Object[]{
|
||||||
|
sp.getId(),
|
||||||
|
sp.getName(),
|
||||||
|
getSnmpVersion(sp.getVersion()),
|
||||||
|
sp.getCommunityRead(),
|
||||||
|
sp.getPort()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getSnmpVersion(int version) {
|
||||||
|
switch (version) {
|
||||||
|
case SnmpConstants.version1:
|
||||||
|
return "verze 1";
|
||||||
|
case SnmpConstants.version2c:
|
||||||
|
return "verze 2c";
|
||||||
|
case SnmpConstants.version3:
|
||||||
|
return "verze 3";
|
||||||
|
}
|
||||||
|
return "n/a";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshTable() {
|
||||||
|
SwingUtilities.invokeLater(this::loadData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue