Commit 94a0d3a4 authored by Stefan Michel's avatar Stefan Michel

networking hinzugefuegt noch nicht getestet

parent b4cc1f26
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/classes/production/StefanHamster" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
......
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
......@@ -70,4 +70,5 @@ public class PropertiesManager {
public String getString(String key) {
return prop.getProperty(key);
}
}
......@@ -77,6 +77,11 @@ public class TerrainController {
}
}
public String getXMLString() {
parseXML(terrain.getName());
return loadXMLToString(terrain.getName());
}
public void parseXMLAndGetTerrainName() {
String terrainName = new SetTerrainNameDialogBox().setTerrainNameDialogBox();
parseXML(terrainName);
......
......@@ -20,8 +20,8 @@ public class NetworkManager {
private NetworkManager() {
String role = propertiesManager.getString("role");
String host = propertiesManager.getString("host");
int port = Integer.parseInt(propertiesManager.getString("port"));
String host = propertiesManager.getString("tutorhost");
int port = Integer.parseInt(propertiesManager.getString("tutorport"));
setUpNetwork(role, host, port);
}
......
......@@ -14,6 +14,8 @@ import javafx.stage.FileChooser;
import javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.Stage;
import model.*;
import network.CodeTerrain;
import network.NetworkManager;
import java.io.File;
import java.io.IOException;
......@@ -47,6 +49,7 @@ public class MainViewCreationFX extends VBox implements Observer {
private MenuItem start, pause, stop;
private Slider slider;
private PropertiesManager propertiesManager = PropertiesManager.getInstance();
private NetworkManager networkManager = NetworkManager.getInstance();
public MainViewCreationFX(Terrain terrain, TerrainController terrainController, IOController ioController,
HamsterController hamsterController, ThreadManager threadManager, DatabaseManager databaseManager) {
......@@ -198,14 +201,34 @@ public class MainViewCreationFX extends VBox implements Observer {
private Menu buildTutorMenu() {
MenuItem anfrageLaden = new MenuItem("Anfrage _laden");
anfrageLaden.setOnAction(event -> {
CodeTerrain codeTerrain = networkManager.getRequest();
textArea.setText(codeTerrain.getCode());
terrainController.loadTerrainFromString(codeTerrain.getTerrain());
});
MenuItem anfrageBeantworten = new MenuItem("Anfrage _beantworten");
anfrageBeantworten.setOnAction(event -> {
String terrain = terrainController.getXMLString();
String code = getInputText();
networkManager.addAnswer(code, terrain);
});
return new Menu("T_utor", null, anfrageLaden, anfrageBeantworten);
}
private Menu buildStudentMenu() {
MenuItem anfrageSchicken = new MenuItem("Anfrage _schicken");
anfrageSchicken.setOnAction(event -> {
String terrain = terrainController.getXMLString();
String code = getInputText();
networkManager.sendRequest(code, terrain);
});
MenuItem anfrageHolen = new MenuItem("Anfrage _holen");
anfrageHolen.setOnAction(event -> {
CodeTerrain codeTerrain = networkManager.getRequest();
textArea.setText(codeTerrain.getCode());
terrainController.loadTerrainFromString(codeTerrain.getTerrain());
});
return new Menu("St_udent", null, anfrageSchicken, anfrageHolen);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment