Add showing list of servers
This commit is contained in:
parent
b9f43a39d3
commit
78db490916
@ -1,6 +1,5 @@
|
||||
package ftp.sar;
|
||||
|
||||
import ftp.sar.view.ResourceLoader;
|
||||
import javafx.application.Application;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
@ -11,17 +10,12 @@ public class Main extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception{
|
||||
|
||||
Object o = getClass();
|
||||
|
||||
ResourceLoader loader = ResourceLoader.getInstance();
|
||||
Object c = loader.getResource("main_page.fxml");
|
||||
Object a = getClass().getClassLoader().getResource("resources/main_page.fxml");
|
||||
Object b = getClass().getClassLoader().getResource("main_page.fxml");
|
||||
|
||||
Parent root = FXMLLoader.load(loader.getResource("main_page.fxml"));
|
||||
primaryStage.setTitle("FTP SAR");
|
||||
primaryStage.setScene(new Scene(root));
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
package ftp.sar;
|
||||
|
||||
|
||||
import ftp.sar.view.ResourceLoader;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ftp.sar.view;
|
||||
package ftp.sar;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
47
src/main/java/ftp/sar/controller/MainPageController.java
Normal file
47
src/main/java/ftp/sar/controller/MainPageController.java
Normal file
@ -0,0 +1,47 @@
|
||||
package ftp.sar.controller;
|
||||
|
||||
import ftp.sar.ResourceLoader;
|
||||
import ftp.sar.server.Server;
|
||||
import ftp.sar.server.ServerFactory;
|
||||
import javafx.event.Event;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.VBox;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
|
||||
public class MainPageController {
|
||||
|
||||
@FXML public TextField ipField;
|
||||
@FXML public VBox serverContainer;
|
||||
|
||||
public MainPageController() {
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void tryAddServer(Event e) {
|
||||
ServerFactory serverFactory = new ServerFactory();
|
||||
|
||||
Server server = serverFactory.create(ipField.getText(), 7332);
|
||||
ResourceLoader resourceLoader = ResourceLoader.getInstance();
|
||||
try {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(resourceLoader.getResource("server_panel.fxml"));
|
||||
Pane panel = fxmlLoader.load();
|
||||
ServerPanelController serverPanelController = fxmlLoader.getController();
|
||||
serverPanelController.setData(server);
|
||||
this.serverContainer.getChildren().add(panel);
|
||||
|
||||
// FXMLLoader fxmlLoader = new FXMLLoader();
|
||||
// Pane panel = fxmlLoader.load(loader.getResource("server_panel.fxml"));
|
||||
// ServerPanelController serverPanelController = (ServerPanelController) fxmlLoader.getController();
|
||||
// serverPanelController.printHi();
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
28
src/main/java/ftp/sar/controller/ServerPanelController.java
Normal file
28
src/main/java/ftp/sar/controller/ServerPanelController.java
Normal file
@ -0,0 +1,28 @@
|
||||
package ftp.sar.controller;
|
||||
|
||||
import ftp.sar.server.Server;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ServerPanelController implements Initializable {
|
||||
private Server server;
|
||||
|
||||
@FXML
|
||||
Label serverPort;
|
||||
@FXML
|
||||
Label serverIp;
|
||||
|
||||
public void setData(Server server) {
|
||||
this.server = server;
|
||||
this.serverPort.setText(Integer.toString(server.getPort()));
|
||||
this.serverIp.setText(server.getIp());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
package ftp.sar.view.mainPage;
|
||||
|
||||
import ftp.sar.server.ServerFactory;
|
||||
import javafx.event.Event;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.TextField;
|
||||
|
||||
public class MainPageController {
|
||||
|
||||
@FXML public TextField ipField;
|
||||
|
||||
public MainPageController() {
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void tryAddServer(Event e) {
|
||||
ServerFactory serverFactory = new ServerFactory();
|
||||
|
||||
serverFactory.create(ipField.getText(), 7332);
|
||||
}
|
||||
}
|
@ -2,13 +2,16 @@
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ftp.sar.view.mainPage.MainPageController">
|
||||
<children>
|
||||
<Pane prefHeight="70.0" prefWidth="640.0">
|
||||
|
||||
<BorderPane minHeight="-Infinity" prefHeight="400.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ftp.sar.controller.MainPageController">
|
||||
<top>
|
||||
<Pane prefHeight="70.0" prefWidth="640.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Button layoutX="529.0" layoutY="22.0" mnemonicParsing="false" onAction="#tryAddServer" text="Add server" />
|
||||
<TextField fx:id="ipField" layoutX="344.0" layoutY="22.0" />
|
||||
@ -16,5 +19,12 @@
|
||||
<Label alignment="CENTER" layoutX="345.0" layoutY="48.0" prefHeight="16.0" prefWidth="170.0" textAlignment="JUSTIFY" textFill="RED" />
|
||||
</children>
|
||||
</Pane>
|
||||
</children>
|
||||
</VBox>
|
||||
</top>
|
||||
<center>
|
||||
<ScrollPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<content>
|
||||
<VBox fx:id="serverContainer" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefHeight="200.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</center>
|
||||
</BorderPane>
|
||||
|
13
src/main/resources/server_panel.fxml
Normal file
13
src/main/resources/server_panel.fxml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ftp.sar.controller.ServerPanelController">
|
||||
<children>
|
||||
<Label layoutX="22.0" layoutY="-1.0" prefHeight="30.0" text="IP Addres: " />
|
||||
<Label fx:id="serverIp" layoutX="88.0" layoutY="5.0" text="xxx.xxx.xxx.xxx" />
|
||||
<Label layoutX="200.0" layoutY="6.0" text="Port:" />
|
||||
<Label fx:id="serverPort" layoutX="236.0" layoutY="6.0" text="xxxx" />
|
||||
</children>
|
||||
</Pane>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,13 +2,16 @@
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ScrollPane?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.BorderPane?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ftp.sar.view.mainPage.MainPageController">
|
||||
<children>
|
||||
<Pane prefHeight="70.0" prefWidth="640.0">
|
||||
|
||||
<BorderPane minHeight="-Infinity" prefHeight="400.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="ftp.sar.controller.MainPageController">
|
||||
<top>
|
||||
<Pane prefHeight="70.0" prefWidth="640.0" BorderPane.alignment="CENTER">
|
||||
<children>
|
||||
<Button layoutX="529.0" layoutY="22.0" mnemonicParsing="false" onAction="#tryAddServer" text="Add server" />
|
||||
<TextField fx:id="ipField" layoutX="344.0" layoutY="22.0" />
|
||||
@ -16,5 +19,12 @@
|
||||
<Label alignment="CENTER" layoutX="345.0" layoutY="48.0" prefHeight="16.0" prefWidth="170.0" textAlignment="JUSTIFY" textFill="RED" />
|
||||
</children>
|
||||
</Pane>
|
||||
</children>
|
||||
</VBox>
|
||||
</top>
|
||||
<center>
|
||||
<ScrollPane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<content>
|
||||
<VBox fx:id="serverContainer" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefHeight="200.0" />
|
||||
</content>
|
||||
</ScrollPane>
|
||||
</center>
|
||||
</BorderPane>
|
||||
|
Loading…
Reference in New Issue
Block a user