Improved Backend
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
25
QuickLaunchUpdateServer/src/customNodes/LogTextArea.java
Normal file
25
QuickLaunchUpdateServer/src/customNodes/LogTextArea.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package customNodes;
|
||||
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.TextArea;
|
||||
|
||||
public class LogTextArea extends TextArea{
|
||||
|
||||
private final int WIDTH = 500;
|
||||
private final int HEIGHT = 515;
|
||||
|
||||
public LogTextArea() {
|
||||
this.setLayoutX(25);
|
||||
this.setLayoutY(65);
|
||||
this.setEditable(false);
|
||||
this.setMinWidth(WIDTH);
|
||||
this.setMaxWidth(WIDTH);
|
||||
this.setPadding(new Insets(0,0,0,-10));
|
||||
this.setMinHeight(HEIGHT);
|
||||
this.setMaxHeight(HEIGHT);
|
||||
this.setStyle("-fx-background-color: transparent;"
|
||||
+ "-fx-control-inner-background: white;"
|
||||
+ "-fx-text-fill: black");
|
||||
}
|
||||
|
||||
}
|
||||
16
QuickLaunchUpdateServer/src/customNodes/NewUpdateButton.java
Normal file
16
QuickLaunchUpdateServer/src/customNodes/NewUpdateButton.java
Normal file
@@ -0,0 +1,16 @@
|
||||
package customNodes;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class NewUpdateButton extends Button{
|
||||
|
||||
public NewUpdateButton(String text) {
|
||||
this.setText(text);
|
||||
this.setLayoutX(550);
|
||||
this.setLayoutY(400);
|
||||
this.setTextFill(Color.WHITE);
|
||||
this.setStyle("-fx-background-color: blue");
|
||||
}
|
||||
|
||||
}
|
||||
5
QuickLaunchUpdateServer/src/data/ServerData.java
Normal file
5
QuickLaunchUpdateServer/src/data/ServerData.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package data;
|
||||
|
||||
public class ServerData {
|
||||
public static float version = 0.0f;
|
||||
}
|
||||
@@ -1,20 +1,26 @@
|
||||
package run;
|
||||
package network;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import run.Start;
|
||||
|
||||
import scenes.LogScene;
|
||||
|
||||
public class ServerThread
|
||||
implements Runnable {
|
||||
int PORT;
|
||||
|
||||
public ServerThread(int port) {
|
||||
this.PORT = port;
|
||||
|
||||
private final int PORT = 9999;
|
||||
public static float version = -1.0f;
|
||||
|
||||
LogScene display;
|
||||
|
||||
public ServerThread(LogScene scene) {
|
||||
display = scene;
|
||||
}
|
||||
|
||||
|
||||
ServerSocket ses;
|
||||
Socket s;
|
||||
DataOutputStream out;
|
||||
@@ -29,8 +35,11 @@ implements Runnable {
|
||||
System.out.println("Connected with: " + s.getInetAddress());
|
||||
out = new DataOutputStream(s.getOutputStream());
|
||||
in = new DataInputStream(s.getInputStream());
|
||||
System.out.println(in.readUTF());
|
||||
out.writeUTF("VERSION="+Start.version);
|
||||
String data = in.readUTF();
|
||||
display.appendText(data);
|
||||
System.out.println(data);
|
||||
|
||||
out.writeUTF("VERSION="+version);
|
||||
|
||||
out.close();
|
||||
in.close();
|
||||
@@ -1,23 +1,12 @@
|
||||
package run;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import run.ServerThread;
|
||||
import run.UpdateThread;
|
||||
import javafx.application.Application;
|
||||
import stages.AppStage;
|
||||
|
||||
public class Start {
|
||||
public static float version = -1.0f;
|
||||
|
||||
private static final int PORT = 9999;
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version:"));
|
||||
Thread ut = new Thread(new UpdateThread());
|
||||
ut.start();
|
||||
System.out.println("Update thread started");
|
||||
Thread st = new Thread(new ServerThread(PORT));
|
||||
st.start();
|
||||
System.out.println("Server listening");
|
||||
Application.launch(AppStage.class);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package run;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import run.Start;
|
||||
|
||||
public class UpdateThread
|
||||
implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
do {
|
||||
Start.version = Float.parseFloat(JOptionPane.showInputDialog("QuickLaunch version (" + Start.version + "): "));
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
25
QuickLaunchUpdateServer/src/stages/AppStage.java
Normal file
25
QuickLaunchUpdateServer/src/stages/AppStage.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package stages;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import network.ServerThread;
|
||||
import scenes.LogScene;
|
||||
|
||||
public class AppStage extends Application{
|
||||
|
||||
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
primaryStage.setOnCloseRequest(event -> {
|
||||
System.exit(0);
|
||||
});
|
||||
LogScene ls = new LogScene(primaryStage);
|
||||
Thread st = new Thread(new ServerThread(ls));
|
||||
st.start();
|
||||
primaryStage.setScene(new Scene(ls));
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user