add close connection
This commit is contained in:
parent
0e815cb905
commit
127f000183
@ -30,7 +30,8 @@ public class MainPageController {
|
|||||||
FXMLLoader fxmlLoader = new FXMLLoader(resourceLoader.getResource("server_panel.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(resourceLoader.getResource("server_panel.fxml"));
|
||||||
Pane panel = fxmlLoader.load();
|
Pane panel = fxmlLoader.load();
|
||||||
ServerPanelController serverPanelController = fxmlLoader.getController();
|
ServerPanelController serverPanelController = fxmlLoader.getController();
|
||||||
serverPanelController.setData(server);
|
serverPanelController.setData(server, this);
|
||||||
|
server.setServerPanel(serverPanelController);
|
||||||
this.serverContainer.getChildren().add(panel);
|
this.serverContainer.getChildren().add(panel);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
|
@ -8,6 +8,7 @@ import javafx.fxml.Initializable;
|
|||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.layout.FlowPane;
|
import javafx.scene.layout.FlowPane;
|
||||||
|
import javafx.scene.layout.Pane;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
@ -15,7 +16,10 @@ import java.util.ResourceBundle;
|
|||||||
public class ServerPanelController implements Initializable {
|
public class ServerPanelController implements Initializable {
|
||||||
private Server server;
|
private Server server;
|
||||||
private FilePaneBuilder filePaneBuilder = new FilePaneBuilder();
|
private FilePaneBuilder filePaneBuilder = new FilePaneBuilder();
|
||||||
|
private MainPageController mainPageController;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
Pane serverPane;
|
||||||
@FXML
|
@FXML
|
||||||
Label serverPort;
|
Label serverPort;
|
||||||
@FXML
|
@FXML
|
||||||
@ -32,10 +36,11 @@ public class ServerPanelController implements Initializable {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void closeConnection(Event e) {
|
public void closeConnection(Event e) {
|
||||||
System.out.println("Close");
|
this.mainPageController.serverContainer.getChildren().remove(this.serverPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setData(Server server) {
|
public void setData(Server server, MainPageController mainPageController) {
|
||||||
|
this.mainPageController = mainPageController;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.serverPort.setText(Integer.toString(server.getPort()));
|
this.serverPort.setText(Integer.toString(server.getPort()));
|
||||||
this.serverIp.setText(server.getIp());
|
this.serverIp.setText(server.getIp());
|
||||||
@ -44,7 +49,7 @@ public class ServerPanelController implements Initializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setFileList() {
|
private void setFileList() {
|
||||||
for (String filename: this.server.getFileList()) {
|
for (String filename : this.server.getFileList()) {
|
||||||
var pane = this.filePaneBuilder.getPane(filename);
|
var pane = this.filePaneBuilder.getPane(filename);
|
||||||
|
|
||||||
this.fileContainer.getChildren().add(pane);
|
this.fileContainer.getChildren().add(pane);
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
package ftp.sar.server;
|
package ftp.sar.server;
|
||||||
|
|
||||||
|
import ftp.sar.controller.ServerPanelController;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Server {
|
public class Server {
|
||||||
private String ip;
|
private String ip;
|
||||||
private int port;
|
private int port;
|
||||||
private ArrayList<String> fileList = new ArrayList<>();
|
private ArrayList<String> fileList = new ArrayList<>();
|
||||||
|
private ServerPanelController serverPanelController;
|
||||||
|
|
||||||
public Server (String ip, int port) {
|
public Server (String ip, int port) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
@ -39,4 +42,8 @@ public class Server {
|
|||||||
public void addToFileList(String file) {
|
public void addToFileList(String file) {
|
||||||
this.fileList.add(file);
|
this.fileList.add(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setServerPanel(ServerPanelController serverPanelController) {
|
||||||
|
this.serverPanelController = serverPanelController;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.FlowPane?>
|
<?import javafx.scene.layout.FlowPane?>
|
||||||
<?import javafx.scene.layout.Pane?>
|
<?import javafx.scene.layout.Pane?>
|
||||||
|
|
||||||
<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">
|
<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" fx:id="serverPane" 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>
|
<children>
|
||||||
<Label layoutX="22.0" layoutY="-1.0" prefHeight="30.0" text="IP Addres: " />
|
<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 fx:id="serverIp" layoutX="88.0" layoutY="5.0" text="xxx.xxx.xxx.xxx" />
|
||||||
@ -13,6 +13,6 @@
|
|||||||
<Label fx:id="serverPort" layoutX="236.0" layoutY="6.0" text="xxxx" />
|
<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" />
|
<FlowPane fx:id="fileContainer" layoutY="30.0" maxWidth="1.7976931348623157E308" minWidth="-Infinity" prefWidth="780.0" />
|
||||||
<!-- <Button fx:id="refreshButton" layoutX="640.0" layoutY="0" mnemonicParsing="false" onAction="#refreshList" text="Refresh" />-->
|
<!-- <Button fx:id="refreshButton" layoutX="640.0" layoutY="0" mnemonicParsing="false" onAction="#refreshList" text="Refresh" />-->
|
||||||
<!-- <Button fx:id="closeButton" layoutX="720.0" layoutY="0" mnemonicParsing="false" onAction="#closeConnection" text="Close" />-->
|
<Button fx:id="closeButton" layoutX="720.0" layoutY="0" mnemonicParsing="false" onAction="#closeConnection" text="Close" />
|
||||||
</children>
|
</children>
|
||||||
</Pane>
|
</Pane>
|
||||||
|
Loading…
Reference in New Issue
Block a user