trying to fix MVC
This commit is contained in:
parent
a75d3466ef
commit
28376f1242
|
@ -7,6 +7,7 @@ import ch.zhaw.pm2.multichat.protocol.NetworkHandler;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
|
import javafx.collections.FXCollections;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
@ -25,21 +26,33 @@ public class ChatWindowController {
|
||||||
|
|
||||||
private final WindowCloseHandler windowCloseHandler = new WindowCloseHandler();
|
private final WindowCloseHandler windowCloseHandler = new WindowCloseHandler();
|
||||||
|
|
||||||
@FXML private Pane rootPane;
|
@FXML
|
||||||
@FXML private TextField serverAddressField;
|
private Pane rootPane;
|
||||||
@FXML private TextField serverPortField;
|
@FXML
|
||||||
@FXML private TextField userNameField;
|
private TextField serverAddressField;
|
||||||
@FXML private TextField messageField;
|
@FXML
|
||||||
@FXML private TextArea messageArea;
|
private TextField serverPortField;
|
||||||
@FXML private Button connectButton;
|
@FXML
|
||||||
@FXML private Button sendButton;
|
private TextField userNameField;
|
||||||
@FXML private TextField filterValue;
|
@FXML
|
||||||
|
private TextField messageField;
|
||||||
|
@FXML
|
||||||
|
private TextArea messageArea;
|
||||||
|
@FXML
|
||||||
|
private Button connectButton;
|
||||||
|
@FXML
|
||||||
|
private Button sendButton;
|
||||||
|
@FXML
|
||||||
|
private TextField filterValue;
|
||||||
|
|
||||||
|
private ChatWindowModel model = new ChatWindowModel();
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
serverAddressField.setText(NetworkHandler.DEFAULT_ADDRESS.getCanonicalHostName());
|
serverAddressField.setText(model.getServerAddress()); // binding server address to view
|
||||||
serverPortField.setText(String.valueOf(NetworkHandler.DEFAULT_PORT));
|
model.setServerAddress(NetworkHandler.DEFAULT_ADDRESS.getCanonicalHostName()); // sets modell adress
|
||||||
|
serverPortField.setText(model.getServerPort());
|
||||||
|
model.setServerPort(String.valueOf(NetworkHandler.DEFAULT_PORT));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMessages(ClientMessageList messages) {
|
public void setMessages(ClientMessageList messages) {
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package ch.zhaw.pm2.multichat.client;
|
||||||
|
|
||||||
|
import javafx.beans.value.ObservableStringValue;
|
||||||
|
|
||||||
|
public class ChatWindowModel {
|
||||||
|
private ClientConnectionHandler connectionHandler;
|
||||||
|
private ClientMessageList messages;
|
||||||
|
ObservableStringValue serverAddress;
|
||||||
|
ObservableStringValue serverPort;
|
||||||
|
|
||||||
|
|
||||||
|
public String getServerAddress() {
|
||||||
|
return serverAddress.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerAddress(String address) {
|
||||||
|
setServerAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerPort() {
|
||||||
|
return getServerPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerPort(String address) {
|
||||||
|
setServerPort(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue