Improved Backend
This commit is contained in:
78
QuickLaunchUpdateServer/src/scenes/LogScene.java
Normal file
78
QuickLaunchUpdateServer/src/scenes/LogScene.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package scenes;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import data.ServerData;
|
||||
import customNodes.LogTextArea;
|
||||
import customNodes.NewUpdateButton;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Side;
|
||||
import javafx.scene.chart.PieChart;
|
||||
import javafx.scene.chart.PieChart.Data;
|
||||
import javafx.scene.control.TextInputDialog;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public class LogScene extends AnchorPane{
|
||||
private NewUpdateButton mNewUpdate;
|
||||
private LogTextArea mLogView;
|
||||
private ObservableList<PieChart.Data> pieChartData;
|
||||
|
||||
|
||||
public LogScene(Stage primaryStage) {
|
||||
|
||||
this.setPrefWidth(800);
|
||||
this.setPrefHeight(600);
|
||||
this.setMaxHeight(600);
|
||||
|
||||
mNewUpdate = new NewUpdateButton("New update");
|
||||
mNewUpdate.setOnAction(new EventHandler<ActionEvent>() {
|
||||
|
||||
|
||||
public void handle(ActionEvent event) {
|
||||
TextInputDialog dialog = new TextInputDialog();
|
||||
dialog.setTitle("Create new update");
|
||||
dialog.setHeaderText("Realese new Update");
|
||||
dialog.setContentText("New version:");
|
||||
|
||||
Optional<String> result = dialog.showAndWait();
|
||||
if (result.isPresent()){
|
||||
ServerData.version = Float.parseFloat(result.get());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mLogView = new LogTextArea();
|
||||
pieChartData =
|
||||
FXCollections.observableArrayList(
|
||||
new PieChart.Data("Win 7", 0),
|
||||
new PieChart.Data("Win 10", 0),
|
||||
new PieChart.Data("Linux", 0));
|
||||
final PieChart chart = new PieChart(pieChartData);
|
||||
chart.setLayoutX(500);
|
||||
chart.setLayoutY(35);
|
||||
chart.setMaxHeight(200);
|
||||
chart.setMaxWidth(300);
|
||||
chart.setLabelsVisible(true);
|
||||
chart.setLegendSide(Side.RIGHT);
|
||||
chart.setLabelLineLength(10);
|
||||
chart.setStyle("-fx-font-size: 8pt");
|
||||
this.getChildren().add(mNewUpdate);
|
||||
this.getChildren().add(mLogView);
|
||||
this.getChildren().add(chart);
|
||||
}
|
||||
|
||||
public void appendText(String text) {
|
||||
for(Data d : pieChartData) {
|
||||
if(d.getName().equals("Linux")) {
|
||||
d.setPieValue(d.getPieValue()+1);
|
||||
}
|
||||
}
|
||||
mLogView.appendText(text+"\n");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user