Tour Listview onclick + Tour Beschreibung Daten Laden
This commit is contained in:
parent
18aa9ffce6
commit
33aaaebe89
@ -79,3 +79,15 @@ App started
|
||||
2021-03-17 13:13:25 INFO PostgresHelper:15 - User Table created
|
||||
2021-03-17 13:13:27 ERROR PSQLException:33 - Connection to 192.168.1.116:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
|
||||
2021-03-17 13:13:27 ERROR NullPointerException:33 -
|
||||
2021-03-17 14:39:16 INFO TourPlaner:15 - Tour Planer App gestartet
|
||||
2021-03-17 14:39:16 INFO PostgresHelper:15 - User Table created
|
||||
2021-03-17 14:39:18 ERROR PSQLException:33 - Connection to 192.168.1.116:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
|
||||
2021-03-17 14:39:18 ERROR NullPointerException:33 -
|
||||
2021-03-17 14:46:45 INFO TourPlaner:15 - Tour Planer App gestartet
|
||||
2021-03-17 14:46:45 INFO PostgresHelper:15 - User Table created
|
||||
2021-03-17 14:46:47 ERROR PSQLException:33 - Connection to 192.168.1.116:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
|
||||
2021-03-17 14:46:47 ERROR NullPointerException:33 -
|
||||
2021-03-17 14:48:46 INFO TourPlaner:15 - Tour Planer App gestartet
|
||||
2021-03-17 14:48:46 INFO PostgresHelper:15 - User Table created
|
||||
2021-03-17 14:48:48 ERROR PSQLException:33 - Connection to 192.168.1.116:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
|
||||
2021-03-17 14:48:48 ERROR NullPointerException:33 -
|
||||
|
@ -6,22 +6,18 @@ package tourplaner.object;
|
||||
public class Tour {
|
||||
private String dauer;
|
||||
private String mapJson;
|
||||
private double distanz;
|
||||
private double strecke;
|
||||
private String name;
|
||||
private String start;
|
||||
private String ziel;
|
||||
|
||||
public Tour(String name, String dauer, String mapJson, double distanz) {
|
||||
public Tour(String name, String dauer, String mapJson, double strecke, String start, String ziel) {
|
||||
this.dauer = dauer;
|
||||
this.mapJson = mapJson;
|
||||
this.distanz = distanz;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.strecke = strecke;
|
||||
this.name = name;
|
||||
this.start = start;
|
||||
this.ziel = ziel;
|
||||
}
|
||||
|
||||
public String getDauer() {
|
||||
@ -40,11 +36,35 @@ public class Tour {
|
||||
this.mapJson = mapJson;
|
||||
}
|
||||
|
||||
public double getDistanz() {
|
||||
return distanz;
|
||||
public double getStrecke() {
|
||||
return strecke;
|
||||
}
|
||||
|
||||
public void setDistanz(double distanz) {
|
||||
this.distanz = distanz;
|
||||
public void setStrecke(double strecke) {
|
||||
this.strecke = strecke;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(String start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public String getZiel() {
|
||||
return ziel;
|
||||
}
|
||||
|
||||
public void setZiel(String ziel) {
|
||||
this.ziel = ziel;
|
||||
}
|
||||
}
|
||||
|
@ -32,14 +32,27 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-->
|
||||
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
<?import javafx.scene.web.*?>
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.Menu?>
|
||||
<?import javafx.scene.control.MenuBar?>
|
||||
<?import javafx.scene.control.MenuItem?>
|
||||
<?import javafx.scene.control.SeparatorMenuItem?>
|
||||
<?import javafx.scene.control.SplitPane?>
|
||||
<?import javafx.scene.control.Tab?>
|
||||
<?import javafx.scene.control.TabPane?>
|
||||
<?import javafx.scene.control.TableColumn?>
|
||||
<?import javafx.scene.control.TableView?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.paint.Color?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tourplaner.ui.TourplanerController">
|
||||
<VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/15.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tourplaner.ui.TourplanerController">
|
||||
<children>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
@ -133,7 +146,7 @@
|
||||
<Insets left="10.0" />
|
||||
</HBox.margin>
|
||||
</Label>
|
||||
<TextField fx:id="titleInput" />
|
||||
<TextField fx:id="titleTextView" editable="false" />
|
||||
</children>
|
||||
</HBox>
|
||||
</children>
|
||||
@ -142,17 +155,25 @@
|
||||
<children>
|
||||
<TabPane fx:id="viewTabPane" layoutX="1.0" layoutY="69.0" prefWidth="702.0" tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="-67.0" AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0" AnchorPane.topAnchor="0.0">
|
||||
<tabs>
|
||||
<Tab text="Route">
|
||||
<Tab fx:id="kartenTab" text="Karte">
|
||||
<content>
|
||||
<AnchorPane prefWidth="200.0">
|
||||
<AnchorPane />
|
||||
</content></Tab>
|
||||
<Tab fx:id="beschreibungTab" text="Beschreibung">
|
||||
<content>
|
||||
<AnchorPane>
|
||||
<children>
|
||||
<WebView id="mapView" prefHeight="-1.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
|
||||
<TableView fx:id="beschreibungTableView" prefHeight="200.0" prefWidth="200.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||
<columns>
|
||||
<TableColumn fx:id="nameCol" maxWidth="1.7976931348623157E308" minWidth="70.0" prefWidth="-1.0" text="Tourname" />
|
||||
<TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" minWidth="40.0" prefWidth="-1.0" text="Dauer" />
|
||||
<TableColumn fx:id="streckeCol" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="-1.0" text="Strecke" />
|
||||
<TableColumn fx:id="startCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Startpunk" />
|
||||
<TableColumn fx:id="zielCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Zielpunkt" />
|
||||
</columns>
|
||||
</TableView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</content></Tab>
|
||||
<Tab text="Description">
|
||||
<content>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefWidth="200.0" />
|
||||
</content>
|
||||
</Tab>
|
||||
</tabs>
|
||||
|
@ -1,14 +1,16 @@
|
||||
package tourplaner.ui;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.geometry.Orientation;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.web.WebView;
|
||||
import tourplaner.object.Tour;
|
||||
import tourplaner.viewmodels.ViewModel;
|
||||
|
||||
import java.net.URL;
|
||||
@ -20,10 +22,21 @@ public class TourplanerController implements Initializable {
|
||||
public ListView<String> TourListView = new ListView<>();
|
||||
public TabPane viewTabPane;
|
||||
public Tab kartenTab, beschreibungTab;
|
||||
public TableView<Tour> beschreibungTableView;
|
||||
public TableColumn<Tour, String> startCol, zielCol, dauerCol, streckeCol, nameCol;
|
||||
public TextField titleTextView;
|
||||
|
||||
@FXML
|
||||
private void tourListSelectedItem(MouseEvent mouseEvent){
|
||||
System.out.println(TourListView.getSelectionModel().getSelectedItem());
|
||||
String selectedItem = TourListView.getSelectionModel().getSelectedItem();
|
||||
titleTextView.setText(selectedItem);
|
||||
beschreibungTableView.getItems().removeIf(s -> true); //Leert die Table View komplett
|
||||
beschreibungTableView.getItems().add(this.viewModel.getTour(selectedItem));
|
||||
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
||||
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
||||
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
||||
streckeCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("strecke"));
|
||||
nameCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("name"));
|
||||
}
|
||||
|
||||
@FXML
|
||||
@ -49,11 +62,6 @@ public class TourplanerController implements Initializable {
|
||||
TourListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
TourListView.setOrientation(Orientation.VERTICAL);
|
||||
TourListView.setItems(this.viewModel.getTourNamen());
|
||||
TourListView.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
@Override
|
||||
public void handle(MouseEvent mouseEvent) {
|
||||
System.out.println(TourListView.getSelectionModel().getSelectedItem());
|
||||
}
|
||||
});
|
||||
this.beschreibungTableView.setPlaceholder(new Label("Keine Tour ausgewählt!"));
|
||||
}
|
||||
}
|
||||
|
@ -6,10 +6,12 @@ import javafx.scene.control.TextInputDialog;
|
||||
import tourplaner.business.TourPlaner;
|
||||
import tourplaner.object.Tour;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class ViewModel {
|
||||
private final ObservableList<Tour> tourData = FXCollections.observableArrayList(new Tour("Test 1", "120", "json dings", 22.3),new Tour("Test 2", "210", "json dings", 42.3));
|
||||
private final ObservableList<Tour> tourData = FXCollections.observableArrayList(new Tour("Test 1", "120", "json dings", 22.3, "Wien", "Graz"),new Tour("Test 2", "210", "json dings", 42.3, "Da", "Dort"));
|
||||
private final ObservableList<String> tourNamen = FXCollections.observableArrayList("Test 1", "Test 2");
|
||||
private final ObservableList<Tour> selectedTour = FXCollections.observableArrayList();
|
||||
private String neueTourName, neueTourStart, neueTourZiel;
|
||||
|
||||
public void addTour(){
|
||||
@ -34,13 +36,57 @@ public class ViewModel {
|
||||
Optional<String> resultZiel = dialogZiel.showAndWait();
|
||||
resultZiel.ifPresent(sziel -> {
|
||||
this.neueTourZiel = resultZiel.get();
|
||||
tourData.add(new Tour(this.neueTourName, "120", new TourPlaner().getMapJson(this.neueTourStart, this.neueTourZiel) , 22.3));
|
||||
tourNamen.add(this.neueTourName);
|
||||
if (getTour(this.neueTourName) == null) {
|
||||
tourData.add(new Tour(this.neueTourName, "120", new TourPlaner().getMapJson(this.neueTourStart, this.neueTourZiel), 22.3, this.neueTourStart, this.neueTourZiel));
|
||||
tourNamen.add(this.neueTourName);
|
||||
}else{
|
||||
// TODO: 17.03.2021 Warning das dieser Tourname bereits vergeben ist
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernt eine Tour anhand des Tournamens
|
||||
* @param tourname Name der zu entfernenden Tour
|
||||
*/
|
||||
public void removeTour(String tourname){
|
||||
tourData.removeIf(s -> s.getName().equals(tourname));
|
||||
tourNamen.removeIf(s -> s.equals(tourname));
|
||||
}
|
||||
|
||||
/**
|
||||
* Holt das Tourobjekt anhand des Namens
|
||||
* @param tourname Name der Tour
|
||||
* @return Gefundene Tour
|
||||
*/
|
||||
public Tour getTour(String tourname){
|
||||
AtomicReference<Tour> returnTour = new AtomicReference<>();
|
||||
tourData.forEach(s -> {
|
||||
if(s.getName().equals(tourname)){
|
||||
returnTour.set(s);
|
||||
}
|
||||
});
|
||||
return returnTour.get();
|
||||
}
|
||||
|
||||
// public void selectTour(String tourname){
|
||||
// this.selectedTour.removeIf(s -> true);//Alle deselect
|
||||
// this.selectedTour.add(getTour(tourname));
|
||||
// }
|
||||
|
||||
public ObservableList<Tour> getSelectedTour() {
|
||||
return selectedTour;
|
||||
}
|
||||
|
||||
public String getNeueTourZiel() {
|
||||
return neueTourZiel;
|
||||
}
|
||||
|
||||
public void setNeueTourZiel(String neueTourZiel) {
|
||||
this.neueTourZiel = neueTourZiel;
|
||||
}
|
||||
|
||||
public ObservableList<String> getTourNamen() {
|
||||
return tourNamen;
|
||||
|
Loading…
x
Reference in New Issue
Block a user