add showing files on server
This commit is contained in:
parent
78db490916
commit
294af83412
36
src/main/java/ftp/sar/builder/FilePaneBuilder.java
Normal file
36
src/main/java/ftp/sar/builder/FilePaneBuilder.java
Normal file
@ -0,0 +1,36 @@
|
||||
package ftp.sar.builder;
|
||||
|
||||
import javafx.geometry.HPos;
|
||||
import javafx.geometry.VPos;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.scene.text.TextAlignment;
|
||||
|
||||
public class FilePaneBuilder {
|
||||
|
||||
public Pane getPane(String fileName) {
|
||||
Pane pane = new Pane();
|
||||
pane.setPrefWidth(130);
|
||||
pane.setPrefHeight(50);
|
||||
pane.setStyle("-fx-border-color: black");
|
||||
Text text = new Text();
|
||||
text.setLayoutY(25);
|
||||
text.prefWidth(130);
|
||||
text.setTextAlignment(TextAlignment.CENTER);
|
||||
|
||||
text.setText(this.getName(fileName));
|
||||
|
||||
pane.getChildren().add(text);
|
||||
|
||||
return pane;
|
||||
}
|
||||
|
||||
private String getName(String fileName) {
|
||||
if (fileName.length() > 120) {
|
||||
fileName = fileName.substring(0, 120);
|
||||
}
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +1,45 @@
|
||||
package ftp.sar.controller;
|
||||
|
||||
import ftp.sar.builder.FilePaneBuilder;
|
||||
import ftp.sar.server.Server;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.FlowPane;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
public class ServerPanelController implements Initializable {
|
||||
private Server server;
|
||||
private FilePaneBuilder filePaneBuilder = new FilePaneBuilder();
|
||||
|
||||
@FXML
|
||||
Label serverPort;
|
||||
@FXML
|
||||
Label serverIp;
|
||||
@FXML
|
||||
FlowPane fileContainer;
|
||||
|
||||
|
||||
public void setData(Server server) {
|
||||
this.server = server;
|
||||
this.serverPort.setText(Integer.toString(server.getPort()));
|
||||
this.serverIp.setText(server.getIp());
|
||||
|
||||
this.setFileList();
|
||||
}
|
||||
|
||||
private void setFileList() {
|
||||
for (String filename: this.server.getFileList()) {
|
||||
var pane = this.filePaneBuilder.getPane(filename);
|
||||
|
||||
this.fileContainer.getChildren().add(pane);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initialize(URL url, ResourceBundle resourceBundle) {
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,14 +8,13 @@
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
|
||||
<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">
|
||||
<BorderPane minHeight="-Infinity" prefHeight="400.0" prefWidth="800.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" />
|
||||
<Label layoutX="65.0" layoutY="27.0" text="SAR - Send and Revice" />
|
||||
<Button layoutX="686.0" layoutY="21.0" mnemonicParsing="false" onAction="#tryAddServer" text="Add server" />
|
||||
<TextField fx:id="ipField" layoutX="506.0" layoutY="21.0" />
|
||||
<Label layoutX="37.0" layoutY="26.0" text="SAR - Send and Revice" />
|
||||
<Label alignment="CENTER" layoutX="345.0" layoutY="48.0" prefHeight="16.0" prefWidth="170.0" textAlignment="JUSTIFY" textFill="RED" />
|
||||
</children>
|
||||
</Pane>
|
||||
|
@ -1,13 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.FlowPane?>
|
||||
<?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">
|
||||
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefWidth="780.0" style="border: black;" 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" />
|
||||
<FlowPane fx:id="fileContainer" layoutY="30.0" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefWidth="780.0" />
|
||||
</children>
|
||||
</Pane>
|
||||
|
Loading…
Reference in New Issue
Block a user