|
| 1 | +package com.funkylogclient; |
| 2 | + |
| 3 | +import java.io.File; |
| 4 | +import java.util.LinkedList; |
| 5 | + |
| 6 | +import javafx.application.Application; |
| 7 | +import javafx.application.Platform; |
| 8 | +import javafx.concurrent.Task; |
| 9 | +import javafx.geometry.*; |
| 10 | +import javafx.scene.Scene; |
| 11 | +import javafx.scene.control.ScrollPane; |
| 12 | +import javafx.scene.control.TextField; |
| 13 | +import javafx.scene.layout.BorderPane; |
| 14 | +import javafx.scene.layout.HBox; |
| 15 | +import javafx.scene.layout.VBox; |
| 16 | +import javafx.scene.paint.Color; |
| 17 | +import javafx.stage.Popup; |
| 18 | +import javafx.stage.Stage; |
| 19 | +import javafx.stage.StageStyle; |
| 20 | +import javafx.scene.Cursor; |
| 21 | +import javafx.scene.text.*; |
| 22 | + |
| 23 | +public class SavedFunkyLogs { |
| 24 | + |
| 25 | + private static VBox messageZone; |
| 26 | + |
| 27 | + private static boolean auto_scroll = true; |
| 28 | + |
| 29 | + private static Stage popupStage; |
| 30 | + |
| 31 | + public static void displaySavedLogs(LinkedList<Message> messages) { |
| 32 | + popupStage = new Stage(); |
| 33 | + popupStage.setTitle("Saved Logs"); |
| 34 | + |
| 35 | + BorderPane root = new BorderPane(); |
| 36 | + root.getStyleClass().add("root"); |
| 37 | + |
| 38 | + VBox center = new VBox(); |
| 39 | + center.setStyle(Styles.CENTER); |
| 40 | + center.setPadding(new Insets(10, 10, 10, 10)); |
| 41 | + |
| 42 | + |
| 43 | + messageZone = new VBox(); |
| 44 | + messageZone.setPrefSize(100000, 100000); |
| 45 | + messageZone.setPadding(new Insets(5, 20, 5, 20)); |
| 46 | + messageZone.setSpacing(2.0); |
| 47 | + messageZone.setStyle(Styles.SCROLL_PANE_STYLE); |
| 48 | + |
| 49 | + ScrollPane mScrollPane = new ScrollPane(messageZone); |
| 50 | + mScrollPane.setFitToWidth(true); |
| 51 | + mScrollPane.setFitToHeight(true); |
| 52 | + messageZone.heightProperty().addListener((observable, oldValue, newValue) -> { |
| 53 | + if (SavedFunkyLogs.auto_scroll) mScrollPane.setVvalue(1.0); |
| 54 | + }); |
| 55 | + mScrollPane.setStyle(Styles.SCROLL_PANE_STYLE); |
| 56 | + |
| 57 | + center.getChildren().add(mScrollPane); |
| 58 | + |
| 59 | + root.setCenter(center); |
| 60 | + |
| 61 | + Scene scene = new Scene(root, Color.TRANSPARENT); |
| 62 | + popupStage.initStyle(StageStyle.TRANSPARENT); |
| 63 | + popupStage.setScene(scene); |
| 64 | + popupStage.show(); |
| 65 | + |
| 66 | + SavedFunkyLogs.setStageSize(popupStage); |
| 67 | + |
| 68 | + root.setStyle("-fx-background-radius: 10; -fx-background-color: #1E1E1E;"); |
| 69 | + |
| 70 | + displayMessages(messages); |
| 71 | + } |
| 72 | + |
| 73 | + private static void displayMessages(LinkedList<Message> messages){ |
| 74 | + Platform.runLater(() -> { |
| 75 | + messageZone.getChildren().clear(); |
| 76 | + for (Message msg : messages) { |
| 77 | + messageZone.getChildren().add(msg.getComponent()); |
| 78 | + } |
| 79 | + }); |
| 80 | + } |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + private static void setStageSize(Stage stage) { |
| 85 | + popupStage.setX(stage.getX() + stage.getWidth() / 2 - 400); |
| 86 | + popupStage.setY(stage.getY() + stage.getHeight() / 2 - 300); |
| 87 | + |
| 88 | + stage.setWidth((800)); |
| 89 | + stage.setHeight(600); |
| 90 | + } |
| 91 | +} |
0 commit comments