Random as - not sure what's in this submit
This commit is contained in:
@@ -2,6 +2,7 @@ package com.example.bricklog.view;
|
|||||||
|
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.CheckBox;
|
import javafx.scene.control.CheckBox;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
@@ -9,17 +10,22 @@ import javafx.scene.control.TextField;
|
|||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import static javafx.scene.paint.Color.WHITE;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class SettingsWindow extends BorderPane {
|
public class SettingsWindow extends BorderPane {
|
||||||
|
|
||||||
private final StackPane contentPane;
|
private final StackPane contentPane;
|
||||||
private final VBox generalSettings;
|
private final VBox generalSettings;
|
||||||
private final VBox serverSettings;
|
private final VBox serverSettings;
|
||||||
private final Label connectionStatus;
|
private final Label connectionStatus;
|
||||||
|
private final Scene currentScene; // Reference to the main scene for applying styles dynamically
|
||||||
|
|
||||||
|
public SettingsWindow(Scene scene) {
|
||||||
|
this.currentScene = scene; // Pass the main scene
|
||||||
|
|
||||||
public SettingsWindow() {
|
|
||||||
// Menu on the left side for navigation
|
// Menu on the left side for navigation
|
||||||
VBox menu = new VBox();
|
VBox menu = new VBox();
|
||||||
menu.setSpacing(10);
|
menu.setSpacing(10);
|
||||||
@@ -48,6 +54,7 @@ public class SettingsWindow extends BorderPane {
|
|||||||
generalSettings.setAlignment(Pos.TOP_LEFT);
|
generalSettings.setAlignment(Pos.TOP_LEFT);
|
||||||
Label themeLabel = new Label("Theme:");
|
Label themeLabel = new Label("Theme:");
|
||||||
CheckBox darkTheme = new CheckBox("Dark Theme");
|
CheckBox darkTheme = new CheckBox("Dark Theme");
|
||||||
|
darkTheme.setOnAction(event -> toggleTheme(darkTheme.isSelected()));
|
||||||
|
|
||||||
Label layoutLabel = new Label("Layout:");
|
Label layoutLabel = new Label("Layout:");
|
||||||
CheckBox compactLayout = new CheckBox("Compact Layout");
|
CheckBox compactLayout = new CheckBox("Compact Layout");
|
||||||
@@ -62,7 +69,7 @@ public class SettingsWindow extends BorderPane {
|
|||||||
// Connection Status Label
|
// Connection Status Label
|
||||||
connectionStatus = new Label("Server Status: Not Connected");
|
connectionStatus = new Label("Server Status: Not Connected");
|
||||||
connectionStatus.setFont(new Font("Arial", 14));
|
connectionStatus.setFont(new Font("Arial", 14));
|
||||||
connectionStatus.setTextFill(WHITE);
|
connectionStatus.setTextFill(Color.WHITE);
|
||||||
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
|
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
|
||||||
connectionStatus.setAlignment(Pos.CENTER);
|
connectionStatus.setAlignment(Pos.CENTER);
|
||||||
connectionStatus.setMaxWidth(Double.MAX_VALUE);
|
connectionStatus.setMaxWidth(Double.MAX_VALUE);
|
||||||
@@ -77,7 +84,6 @@ public class SettingsWindow extends BorderPane {
|
|||||||
|
|
||||||
serverSettings.getChildren().addAll(connectionStatus, ipLabel, ipField, connectButton);
|
serverSettings.getChildren().addAll(connectionStatus, ipLabel, ipField, connectButton);
|
||||||
|
|
||||||
|
|
||||||
// Add panels to contentPane and show the default panel
|
// Add panels to contentPane and show the default panel
|
||||||
contentPane.getChildren().addAll(generalSettings, serverSettings);
|
contentPane.getChildren().addAll(generalSettings, serverSettings);
|
||||||
showGeneralSettings(); // Default to showing the general settings
|
showGeneralSettings(); // Default to showing the general settings
|
||||||
@@ -97,56 +103,41 @@ public class SettingsWindow extends BorderPane {
|
|||||||
generalSettings.setVisible(false);
|
generalSettings.setVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Method to connect to the server
|
// Method to toggle themes
|
||||||
private void connectToServer(String ipAddress) {
|
private void toggleTheme(boolean isDarkTheme) {
|
||||||
if (!isValidIPAddress(ipAddress)) {
|
String theme = isDarkTheme ? "/css/dark-theme.css" : "/css/light-theme.css";
|
||||||
connectionStatus.setText("Invalid IP Address");
|
currentScene.getStylesheets().clear(); // Clear existing stylesheets
|
||||||
connectionStatus.setStyle("-fx-background-color: orange; -fx-padding: 5;");
|
currentScene.getStylesheets().add(Objects.requireNonNull(getClass().getResource(theme)).toExternalForm());
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
boolean isConnected = simulateServerConnection(ipAddress);
|
// Method to connect to the server
|
||||||
|
private void connectToServer(String ipAddress) {
|
||||||
if (isConnected) {
|
if (!isValidIPAddress(ipAddress)) {
|
||||||
connectionStatus.setText("Connected");
|
connectionStatus.setText("Invalid IP Address");
|
||||||
connectionStatus.setStyle("-fx-background-color: lightgreen; -fx-padding: 5;");
|
connectionStatus.setStyle("-fx-background-color: orange; -fx-padding: 5;");
|
||||||
} else {
|
return;
|
||||||
connectionStatus.setText("Not Connected");
|
|
||||||
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Utility method to validate IP addresses
|
boolean isConnected = simulateServerConnection(ipAddress);
|
||||||
private boolean isValidIPAddress(String ipAddress) {
|
|
||||||
return ipAddress.matches(
|
|
||||||
"^((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DEMO PURPOSES ONLY [Commented out when in production]
|
if (isConnected) {
|
||||||
// Simulated connection logic for demonstration purposes
|
connectionStatus.setText("Connected");
|
||||||
private boolean simulateServerConnection(String ipAddress) {
|
connectionStatus.setStyle("-fx-background-color: lightgreen; -fx-padding: 5;");
|
||||||
if (ipAddress == null || ipAddress.isEmpty()) {
|
} else {
|
||||||
return false; // IP address is invalid
|
connectionStatus.setText("Not Connected");
|
||||||
}
|
connectionStatus.setStyle("-fx-background-color: lightpink; -fx-padding: 5;");
|
||||||
|
|
||||||
|
|
||||||
// Simulate connection by checking for a specific IP pattern (e.g., localhost)
|
|
||||||
return ipAddress.equals("127.0.0.1") || ipAddress.startsWith("192.168.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
//PRODUCTION _ UNCOMmENT When Needed for true Server Connectivity
|
|
||||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
||||||
private boolean simulateServerConnection(String ipAddress) {
|
|
||||||
int port = 12345; // Replace with your server's port
|
|
||||||
try (Socket socket = new Socket()) {
|
|
||||||
socket.connect(new InetSocketAddress(ipAddress, port), 3000); // 3-second timeout
|
|
||||||
return true; // Connection successful
|
|
||||||
} catch (IOException e) {
|
|
||||||
return false; // Connection failed
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
====================================================================================================== */
|
|
||||||
|
|
||||||
|
// Utility method to validate IP addresses
|
||||||
|
private boolean isValidIPAddress(String ipAddress) {
|
||||||
|
return ipAddress.matches(
|
||||||
|
"^((25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simulated connection logic for demonstration purposes
|
||||||
|
private boolean simulateServerConnection(String ipAddress) {
|
||||||
|
return ipAddress.equals("127.0.0.1") || ipAddress.startsWith("192.168.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,19 +0,0 @@
|
|||||||
.root {
|
|
||||||
-fx-background-color: #161616;
|
|
||||||
background-color: #161616; /* Compatibility fix */
|
|
||||||
}
|
|
||||||
|
|
||||||
.label.title {
|
|
||||||
-fx-text-fill: #B22222;
|
|
||||||
-fx-effect: dropshadow(gaussian, white, 2, 0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.table-view {
|
|
||||||
-fx-font-size: 14px;
|
|
||||||
font-size: 14px;/* Compatibility fix */
|
|
||||||
-fx-text-fill: #E0FFFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
.caption {
|
|
||||||
-fx-text-fill: #C0C0C0;
|
|
||||||
}
|
|
@@ -1,22 +0,0 @@
|
|||||||
.toggle-button {
|
|
||||||
-fx-background-color: #444;
|
|
||||||
-fx-text-fill: white;
|
|
||||||
-fx-padding: 5 10;
|
|
||||||
-fx-border-radius: 5;
|
|
||||||
-fx-background-radius: 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-button:selected {
|
|
||||||
-fx-background-color: #666;
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid-pane {
|
|
||||||
-fx-background-color: #f0f0f0;
|
|
||||||
-fx-padding: 10;
|
|
||||||
-fx-hgap: 15;
|
|
||||||
-fx-vgap: 15;
|
|
||||||
}
|
|
||||||
|
|
||||||
.list-view {
|
|
||||||
-fx-background-color: #f9f9f9;
|
|
||||||
}
|
|
@@ -1,4 +1,7 @@
|
|||||||
|
com\example\bricklog\model\Build.class
|
||||||
com\example\bricklog\BrickLogClientApplication.class
|
com\example\bricklog\BrickLogClientApplication.class
|
||||||
com\example\bricklog\view\MainLayout.class
|
com\example\bricklog\view\MainLayout.class
|
||||||
|
com\example\bricklog\view\MocPage.class
|
||||||
com\example\bricklog\view\SettingsWindow.class
|
com\example\bricklog\view\SettingsWindow.class
|
||||||
|
com\example\bricklog\view\KitsetPage.class
|
||||||
com\example\bricklog\view\GalleryLayout.class
|
com\example\bricklog\view\GalleryLayout.class
|
||||||
|
@@ -2,4 +2,7 @@ C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\
|
|||||||
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\controller\SettingsController.java
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\controller\SettingsController.java
|
||||||
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\MainLayout.java
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\MainLayout.java
|
||||||
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\SettingsWindow.java
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\SettingsWindow.java
|
||||||
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\KitsetPage.java
|
||||||
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\GalleryLayout.java
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\GalleryLayout.java
|
||||||
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\view\MocPage.java
|
||||||
|
C:\Users\bryce\Documents\Git\BrickLog\BrickLog-Client\src\main\java\com\example\bricklog\model\Build.java
|
||||||
|
Reference in New Issue
Block a user