Compare commits

...

2 Commits

8 changed files with 129 additions and 128 deletions

View File

@ -56,7 +56,6 @@ public class DirectionMap {
* @throws IOException Fehler beim Get der Map * @throws IOException Fehler beim Get der Map
*/ */
private Image getMap(String size) throws IOException { private Image getMap(String size) throws IOException {
System.out.println("URL: " + "https://www.mapquestapi.com/staticmap/v5/map?session="+this.sessionId+"&size="+size+"&key="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key"));
return HttpHelper.httpGetImage("https://www.mapquestapi.com/staticmap/v5/map?session="+this.sessionId+"&size="+size+"&key="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key")); return HttpHelper.httpGetImage("https://www.mapquestapi.com/staticmap/v5/map?session="+this.sessionId+"&size="+size+"&key="+ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key"));
} }

View File

@ -168,8 +168,20 @@ public class TourPlaner{
public static ArrayList<Tour> sucheTour(String tourname){ public static ArrayList<Tour> sucheTour(String tourname){
ArrayList<Tour> touren = new ArrayList<>(); ArrayList<Tour> touren = new ArrayList<>();
getAllTours().forEach(t ->{ getAllTours().forEach(t ->{
if(t.getName().toLowerCase(Locale.ROOT).contains(tourname.toLowerCase())){ ArrayList<Log> logs = t.getLogs();
touren.add(t); ArrayList<String> bemerkungen = new ArrayList<>();
for (Log l:logs) {
bemerkungen.add(l.getBemerkung().toLowerCase(Locale.ROOT));
}
bemerkungen.forEach(b -> {
if(b.contains(tourname.toLowerCase(Locale.ROOT))){
touren.add(t);
}
});
if(bemerkungen.contains(tourname.toLowerCase()) || t.getZiel().toLowerCase(Locale.ROOT).contains(tourname.toLowerCase()) || t.getName().toLowerCase(Locale.ROOT).contains(tourname.toLowerCase()) || t.getStart().toLowerCase(Locale.ROOT).contains(tourname.toLowerCase())){
if(!touren.contains(t)) {
touren.add(t);
}
} }
}); });
return touren; return touren;

View File

@ -27,15 +27,12 @@ public class DbConnect {
/** /**
* Erstellt alle Tabellen die für den Betrieb der Software bennötigt werden * Erstellt alle Tabellen die für den Betrieb der Software bennötigt werden
* @return True bei erfolg, sonst error
*/ */
public boolean init() { public void init() {
ArrayList<Boolean> errors = new ArrayList<>(); PostgresHelper.executeUpdateNoLog("create table tour ( tourname varchar not null, dauer decimal, mapjson varchar, start varchar, ziel varchar, strecke decimal);");
errors.add(PostgresHelper.executeUpdateMessage("create table tour ( tourname varchar not null, dauer decimal, mapjson varchar, start varchar, ziel varchar, strecke decimal);", "Tour Table created")); PostgresHelper.executeUpdateNoLog("create unique index tour_tourname_uindex on tour (tourname);");
errors.add(PostgresHelper.executeUpdateMessage("create unique index tour_tourname_uindex on tour (tourname);", "Tour Table unique created")); PostgresHelper.executeUpdateNoLog("alter table tour add constraint tour_pk primary key (tourname);");
errors.add(PostgresHelper.executeUpdateMessage("alter table tour add constraint tour_pk primary key (tourname);", "Tour Table primary created")); PostgresHelper.executeUpdateNoLog("create table log(tourname varchar constraint log_tour_tourname_fk references tour,id varchar,bemerkung varchar,datum date,strecke decimal,avg decimal,hightmeter decimal,pause decimal,gegangen decimal,dauer decimal,rating varchar);");
errors.add(PostgresHelper.executeUpdateMessage("create table log(tourname varchar constraint log_tour_tourname_fk references tour,id varchar,bemerkung varchar,datum date,strecke decimal,avg decimal,hightmeter decimal,pause decimal,gegangen decimal,dauer decimal,rating varchar);", "Log Table created"));
return !errors.contains(false);
} }
@ -125,7 +122,7 @@ public class DbConnect {
this.c.close(); this.c.close();
return logs; return logs;
} catch (Exception e) { } catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage()); LogHelper.error(e);
return null; return null;
} }
} }
@ -139,8 +136,6 @@ public class DbConnect {
*/ */
public boolean addLog(String tourname, Log log){ public boolean addLog(String tourname, Log log){
if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0); if(Double.isInfinite(log.getAvgspeed())) log.setAvgspeed(-1.0);
System.out.println("INSERT INTO public.log (tourname, id, bemerkung, datum, strecke, avg, hightmeter, pause, gegangen, dauer, rating) VALUES ('"+tourname+"', '"+log.getId()+"', '"+log.getBemerkung()+"', '"+log.getDatum()+"', "
+log.getStrecke()+", "+log.getAvgspeed()+", "+log.getHightmeter()+", "+log.getPause()+", "+log.getGegangen()+", "+log.getDauer()+",'"+log.getRating()+"')");
return PostgresHelper.executeUpdate("INSERT INTO public.log (tourname, id, bemerkung, datum, strecke, avg, hightmeter, pause, gegangen, dauer, rating) VALUES ('"+tourname+"', '"+log.getId()+"', '"+log.getBemerkung()+"', '"+log.getDatum()+"', " return PostgresHelper.executeUpdate("INSERT INTO public.log (tourname, id, bemerkung, datum, strecke, avg, hightmeter, pause, gegangen, dauer, rating) VALUES ('"+tourname+"', '"+log.getId()+"', '"+log.getBemerkung()+"', '"+log.getDatum()+"', "
+log.getStrecke()+", "+log.getAvgspeed()+", "+log.getHightmeter()+", "+log.getPause()+", "+log.getGegangen()+", "+log.getDauer()+",'"+log.getRating()+"')"); +log.getStrecke()+", "+log.getAvgspeed()+", "+log.getHightmeter()+", "+log.getPause()+", "+log.getGegangen()+", "+log.getDauer()+",'"+log.getRating()+"')");
} }
@ -244,7 +239,7 @@ public class DbConnect {
this.c.close(); this.c.close();
return touren; return touren;
} catch (Exception e) { } catch (Exception e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage()); LogHelper.error(e);
return null; return null;
} }
} }

View File

@ -6,6 +6,7 @@ import tourplaner.business.LogHelper;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
/** /**
@ -20,8 +21,6 @@ public class PostgresHelper {
Connection c = null; Connection c = null;
try { try {
Class.forName("org.postgresql.Driver"); Class.forName("org.postgresql.Driver");
System.out.println("jdbc:postgresql://" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "url") + ":" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "port") + "/" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "dbname")+
ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "user")+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "pw"));
c = DriverManager c = DriverManager
.getConnection("jdbc:postgresql://" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "url") + ":" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "port") + "/" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "dbname"), .getConnection("jdbc:postgresql://" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "url") + ":" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "port") + "/" + ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "dbname"),
ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "user"), ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "pw")); ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "user"), ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "db", "pw"));
@ -48,17 +47,38 @@ public class PostgresHelper {
* @return True bei erfolg, sonst false * @return True bei erfolg, sonst false
*/ */
public static boolean executeUpdate(String sql){ public static boolean executeUpdate(String sql){
Connection c = con();
Statement stmt;
try { try {
stmt = c.createStatement(); exUpdate(sql);
stmt.executeUpdate(sql); } catch (SQLException e) {
stmt.close();
c.close();
} catch (Exception e) {
LogHelper.error(e.getMessage(), e.getClass().getName()); LogHelper.error(e.getMessage(), e.getClass().getName());
return false; return false;
} }
return true; return true;
} }
/**
* Führt ein Sql statement ohne rückgabe aus
* @param sql Sql command
* @return True bei erfolg, sonst false
* @throws SQLException Fehler beim ausführen
*/
private static boolean exUpdate(String sql) throws SQLException {
Connection c = con();
Statement stmt;
stmt = c.createStatement();
stmt.executeUpdate(sql);
stmt.close();
c.close();
return true;
}
public static boolean executeUpdateNoLog(String sql){
try {
exUpdate(sql);
return true;
}catch (Exception e){
return false;
}
}
} }

View File

@ -39,101 +39,76 @@
<?import javafx.scene.paint.*?> <?import javafx.scene.paint.*?>
<?import javafx.scene.text.*?> <?import javafx.scene.text.*?>
<VBox prefHeight="600.0" prefWidth="900.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1" <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">
fx:controller="tourplaner.ui.TourplanerController">
<MenuBar VBox.vgrow="NEVER"> <MenuBar VBox.vgrow="NEVER">
<Menu fx:id="menueFile" mnemonicParsing="false" text="Datei"> <Menu fx:id="menueFile" mnemonicParsing="false" text="Datei">
<MenuItem fx:id="reportsummary" mnemonicParsing="false" onAction="#reportSum" text="Report Summary"/> <MenuItem fx:id="reportsummary" mnemonicParsing="false" onAction="#reportSum" text="Report Summary" />
<MenuItem fx:id="tourreport" mnemonicParsing="false" onAction="#tourReport" text="Tour Report"/> <MenuItem fx:id="tourreport" mnemonicParsing="false" onAction="#tourReport" text="Tour Report" />
<MenuItem fx:id="beendenButton" mnemonicParsing="false" onAction="#quitApp" text="Beenden"/> <MenuItem fx:id="beendenButton" mnemonicParsing="false" onAction="#quitApp" text="Beenden" />
</Menu> </Menu>
<Menu fx:id="menuebearbeiten" mnemonicParsing="false" text="Bearbeiten"> <Menu fx:id="menuebearbeiten" mnemonicParsing="false" text="Bearbeiten">
<MenuItem fx:id="menueimport" mnemonicParsing="false" onAction="#importBtn" text="Import"/> <MenuItem fx:id="menueimport" mnemonicParsing="false" onAction="#importBtn" text="Import" />
<MenuItem fx:id="menueexport" mnemonicParsing="false" onAction="#exportBtn" text="Export"/> <MenuItem fx:id="menueexport" mnemonicParsing="false" onAction="#exportBtn" text="Export" />
</Menu> </Menu>
<Menu fx:id="menueoptionen" mnemonicParsing="false" text="Optionen"> <Menu fx:id="menueoptionen" mnemonicParsing="false" text="Optionen">
<CheckMenuItem fx:id="openmap" mnemonicParsing="false" onAction="#openmapaction" <CheckMenuItem fx:id="openmap" mnemonicParsing="false" onAction="#openmapaction" text="Map automatisch öffnen" />
text="Map automatisch öffnen"/> <CheckMenuItem fx:id="openpdf" mnemonicParsing="false" onAction="#openpdfaction" text="Report automatisch öffnen" />
<CheckMenuItem fx:id="openpdf" mnemonicParsing="false" onAction="#openpdfaction"
text="Report automatisch öffnen"/>
<Menu fx:id="menuesprachen" mnemonicParsing="false" text="Sprache"> <Menu fx:id="menuesprachen" mnemonicParsing="false" text="Sprache">
<RadioMenuItem fx:id="langdeutsch" mnemonicParsing="false" onAction="#onlangdeutsch" <RadioMenuItem fx:id="langdeutsch" mnemonicParsing="false" onAction="#onlangdeutsch" text="Deutsch" />
text="Deutsch"/> <RadioMenuItem fx:id="langenglisch" mnemonicParsing="false" onAction="#onlangenglisch" text="Englisch" />
<RadioMenuItem fx:id="langenglisch" mnemonicParsing="false" onAction="#onlangenglisch"
text="Englisch"/>
</Menu> </Menu>
</Menu> </Menu>
<Menu fx:id="menuehilfe" mnemonicParsing="false" text="Hilfe"> <Menu fx:id="menuehilfe" mnemonicParsing="false" text="Hilfe">
<MenuItem mnemonicParsing="false" onAction="#gitWebBrowser" text="Git Repo"/> <MenuItem mnemonicParsing="false" onAction="#gitWebBrowser" text="Git Repo" />
<MenuItem mnemonicParsing="false" onAction="#javaDocBrowser" text="JavaDoc"/> <MenuItem mnemonicParsing="false" onAction="#javaDocBrowser" text="JavaDoc" />
<MenuItem mnemonicParsing="false" onAction="#doxygenDocBrowser" text="Doxygen Doc"/> <MenuItem mnemonicParsing="false" onAction="#doxygenDocBrowser" text="Doxygen Doc" />
</Menu> </Menu>
</MenuBar> </MenuBar>
<HBox id="HBox" alignment="CENTER_LEFT" layoutX="10.0" layoutY="588.0" spacing="5.0"> <HBox id="HBox" alignment="CENTER_LEFT" layoutX="10.0" layoutY="588.0" spacing="5.0">
<padding> <padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/> <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding> </padding>
<AnchorPane HBox.hgrow="ALWAYS"> <AnchorPane HBox.hgrow="ALWAYS">
<Button fx:id="tourAdd" layoutX="58.0" mnemonicParsing="false" onAction="#addTour" text="+"/> <Button fx:id="tourAdd" layoutX="58.0" mnemonicParsing="false" onAction="#addTour" text="+" />
<Label layoutX="14.0" layoutY="4.0" text="Tours"/> <Label layoutX="14.0" layoutY="4.0" text="Tours" />
<Button fx:id="tourDel" layoutX="89.0" mnemonicParsing="false" onAction="#delTour" text="-"/> <Button fx:id="tourDel" layoutX="89.0" mnemonicParsing="false" onAction="#delTour" text="-" />
<Button fx:id="editTourBtn" layoutX="117.0" mnemonicParsing="false" onAction="#editTourBtn" <Button fx:id="editTourBtn" layoutX="117.0" mnemonicParsing="false" onAction="#editTourBtn" text="Edit" />
text="Edit"/>
</AnchorPane> </AnchorPane>
<TextField fx:id="sucheInput" promptText="Suche..."/> <TextField fx:id="sucheInput" onKeyPressed="#sucheEnter" promptText="Suche..." />
<Button fx:id="sucheButton" mnemonicParsing="false" onAction="#suche" text="Suchen"/> <Button fx:id="sucheButton" mnemonicParsing="false" onAction="#suche" text="Suchen" />
</HBox> </HBox>
<SplitPane dividerPositions="0.060133630289532294" focusTraversable="true" prefHeight="522.0" prefWidth="300.0" <SplitPane dividerPositions="0.060133630289532294" focusTraversable="true" prefHeight="522.0" prefWidth="300.0" VBox.vgrow="ALWAYS">
VBox.vgrow="ALWAYS">
<AnchorPane prefWidth="239.0"> <AnchorPane prefWidth="239.0">
<ListView fx:id="TourListView" layoutX="-1.0" onMouseClicked="#tourListSelectedItem" prefHeight="520.0" <ListView fx:id="TourListView" layoutX="-1.0" onMouseClicked="#tourListSelectedItem" prefHeight="520.0" prefWidth="190.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
prefWidth="190.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</AnchorPane> </AnchorPane>
<SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="496.0" prefWidth="620.0"> <SplitPane dividerPositions="0.5" orientation="VERTICAL" prefHeight="496.0" prefWidth="620.0">
<VBox prefWidth="100.0"> <VBox prefWidth="100.0">
<AnchorPane prefWidth="676.0"> <AnchorPane prefWidth="676.0">
<HBox id="HBox" alignment="CENTER_LEFT" prefHeight="7.0" prefWidth="44.0" spacing="5.0" <HBox id="HBox" alignment="CENTER_LEFT" prefHeight="7.0" prefWidth="44.0" spacing="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<Label text="Title:"> <Label text="Title:">
<HBox.margin> <HBox.margin>
<Insets left="10.0"/> <Insets left="10.0" />
</HBox.margin> </HBox.margin>
</Label> </Label>
<TextField fx:id="titleTextView" editable="false"/> <TextField fx:id="titleTextView" editable="false" />
</HBox> </HBox>
</AnchorPane> </AnchorPane>
<AnchorPane prefWidth="200.0"> <AnchorPane prefWidth="200.0">
<TabPane fx:id="viewTabPane" layoutX="1.0" layoutY="69.0" prefWidth="702.0" <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">
tabClosingPolicy="UNAVAILABLE" AnchorPane.bottomAnchor="-67.0"
AnchorPane.leftAnchor="1.0" AnchorPane.rightAnchor="1.0"
AnchorPane.topAnchor="0.0">
<Tab fx:id="kartenTab" text="Karte"> <Tab fx:id="kartenTab" text="Karte">
<AnchorPane> <AnchorPane>
<ImageView fx:id="mapImageView" pickOnBounds="true" preserveRatio="true" <ImageView fx:id="mapImageView" pickOnBounds="true" preserveRatio="true" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0" />
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"/>
</AnchorPane> </AnchorPane>
</Tab> </Tab>
<Tab fx:id="beschreibungTab" text="Beschreibung"> <Tab fx:id="beschreibungTab" text="Beschreibung">
<AnchorPane> <AnchorPane>
<TableView fx:id="beschreibungTableView" <TableView fx:id="beschreibungTableView" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
maxHeight="1.7976931348623157E308"
maxWidth="1.7976931348623157E308"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns> <columns>
<TableColumn fx:id="nameCol" minWidth="100.0" prefWidth="-1.0" <TableColumn fx:id="nameCol" minWidth="100.0" prefWidth="-1.0" text="Tourname" />
text="Tourname"/> <TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Dauer" />
<TableColumn fx:id="dauerCol" maxWidth="1.7976931348623157E308" <TableColumn fx:id="streckeCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Strecke" />
minWidth="100.0" prefWidth="-1.0" text="Dauer"/> <TableColumn fx:id="startCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Startpunk" />
<TableColumn fx:id="streckeCol" maxWidth="1.7976931348623157E308" <TableColumn fx:id="zielCol" maxWidth="1.7976931348623157E308" minWidth="100.0" prefWidth="-1.0" text="Zielpunkt" />
minWidth="100.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> </columns>
</TableView> </TableView>
</AnchorPane> </AnchorPane>
@ -142,62 +117,45 @@
</AnchorPane> </AnchorPane>
</VBox> </VBox>
<AnchorPane prefWidth="200.0"> <AnchorPane prefWidth="200.0">
<VBox prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" <VBox prefWidth="100.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<AnchorPane> <AnchorPane>
<HBox id="HBox" alignment="CENTER_LEFT" layoutY="2.0" prefWidth="702.0" <HBox id="HBox" alignment="CENTER_LEFT" layoutY="2.0" prefWidth="702.0" spacing="5.0" AnchorPane.bottomAnchor="-2.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="2.0">
spacing="5.0" AnchorPane.bottomAnchor="-2.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="2.0">
<padding> <padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/> <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding> </padding>
<Label text="Logs:"> <Label text="Logs:">
<HBox.margin> <HBox.margin>
<Insets left="10.0"/> <Insets left="10.0" />
</HBox.margin> </HBox.margin>
</Label> </Label>
<Button mnemonicParsing="false" onAction="#addLog" text="+" <Button mnemonicParsing="false" onAction="#addLog" text="+" textAlignment="CENTER">
textAlignment="CENTER">
<HBox.margin> <HBox.margin>
<Insets/> <Insets />
</HBox.margin> </HBox.margin>
</Button> </Button>
<Button fx:id="logDel" mnemonicParsing="false" onAction="#delLog" <Button fx:id="logDel" mnemonicParsing="false" onAction="#delLog" prefWidth="21.0" text="-" textAlignment="CENTER">
prefWidth="21.0" text="-" textAlignment="CENTER">
<HBox.margin> <HBox.margin>
<Insets/> <Insets />
</HBox.margin> </HBox.margin>
</Button> </Button>
<Button fx:id="editBtn" mnemonicParsing="false" onAction="#editLogBtn" <Button fx:id="editBtn" mnemonicParsing="false" onAction="#editLogBtn" text="Edit" />
text="Edit"/>
</HBox> </HBox>
</AnchorPane> </AnchorPane>
<AnchorPane> <AnchorPane>
<TableView fx:id="logTableView" onMouseClicked="#logItemSelected" <TableView fx:id="logTableView" onMouseClicked="#logItemSelected" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<columns> <columns>
<TableColumn fx:id="logDatumCol" minWidth="-1.0" prefWidth="-1.0" <TableColumn fx:id="logDatumCol" minWidth="-1.0" prefWidth="-1.0" text="Datum" />
text="Datum"/> <TableColumn fx:id="logDauerCol" minWidth="-1.0" prefWidth="-1.0" text="Dauer" />
<TableColumn fx:id="logDauerCol" minWidth="-1.0" prefWidth="-1.0" <TableColumn fx:id="logStreckeCol" minWidth="-1.0" prefWidth="-1.0" text="Entfernung" />
text="Dauer"/> <TableColumn fx:id="logAvgCol" minWidth="-1.0" prefWidth="-1.0" text="AVG Geschwindigkeit" />
<TableColumn fx:id="logStreckeCol" minWidth="-1.0" prefWidth="-1.0" <TableColumn fx:id="logHightCol" minWidth="-1.0" prefWidth="75.0" text="Höhenmeter" />
text="Entfernung"/> <TableColumn fx:id="logPauseCol" minWidth="-1.0" prefWidth="-1.0" text="Davon Pause" />
<TableColumn fx:id="logAvgCol" minWidth="-1.0" prefWidth="-1.0" <TableColumn fx:id="logGegangenCol" minWidth="-1.0" prefWidth="-1.0" text="Davon Unterwegs" />
text="AVG Geschwindigkeit"/> <TableColumn fx:id="logBemerkungCol" minWidth="-1.0" prefWidth="-1.0" text="Bemerkung" />
<TableColumn fx:id="logHightCol" minWidth="-1.0" prefWidth="75.0" <TableColumn fx:id="logRatingCol1" minWidth="-1.0" prefWidth="-1.0" text="Rating" />
text="Höhenmeter"/>
<TableColumn fx:id="logPauseCol" minWidth="-1.0" prefWidth="-1.0"
text="Davon Pause"/>
<TableColumn fx:id="logGegangenCol" minWidth="-1.0" prefWidth="-1.0"
text="Davon Unterwegs"/>
<TableColumn fx:id="logBemerkungCol" minWidth="-1.0" prefWidth="-1.0"
text="Bemerkung"/>
<TableColumn fx:id="logRatingCol1" minWidth="-1.0" prefWidth="-1.0"
text="Rating"/>
</columns> </columns>
<columnResizePolicy> <columnResizePolicy>
<TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/> <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy> </columnResizePolicy>
</TableView> </TableView>
</AnchorPane> </AnchorPane>
@ -207,17 +165,17 @@
</SplitPane> </SplitPane>
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER"> <HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0" VBox.vgrow="NEVER">
<padding> <padding>
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/> <Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
</padding> </padding>
<Label maxHeight="1.7976931348623157E308" text="Tourplaner" HBox.hgrow="ALWAYS"> <Label maxHeight="1.7976931348623157E308" text="Tourplaner" HBox.hgrow="ALWAYS">
<font> <font>
<Font size="11.0" fx:id="x3"/> <Font size="11.0" fx:id="x3" />
</font> </font>
<textFill> <textFill>
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4"/> <Color red="0.625" green="0.625" blue="0.625" fx:id="x4" />
</textFill> </textFill>
</Label> </Label>
<AnchorPane HBox.hgrow="ALWAYS"/> <AnchorPane HBox.hgrow="ALWAYS" />
<Label font="$x3" text="Georg Reisinger" textFill="$x4" HBox.hgrow="NEVER"/> <Label font="$x3" text="Georg Reisinger" textFill="$x4" HBox.hgrow="NEVER" />
</HBox> </HBox>
</VBox> </VBox>

View File

@ -209,7 +209,6 @@ public class AlertHelper {
datePicker.setOnAction(event -> { datePicker.setOnAction(event -> {
LocalDate date = datePicker.getValue(); LocalDate date = datePicker.getValue();
System.out.println("Selected date: " + date);
selectedDate.set(date); selectedDate.set(date);
stage.close(); stage.close();
}); });

View File

@ -6,6 +6,8 @@ import javafx.geometry.Orientation;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import tourplaner.business.ConfigHelper; import tourplaner.business.ConfigHelper;
import tourplaner.business.LogHelper; import tourplaner.business.LogHelper;
@ -16,6 +18,7 @@ import tourplaner.viewmodels.ViewModel;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.concurrent.atomic.AtomicInteger;
public class TourplanerController implements Initializable { public class TourplanerController implements Initializable {
//VM //VM
@ -123,6 +126,7 @@ public class TourplanerController implements Initializable {
*/ */
@FXML @FXML
private void tourListSelectedItem(MouseEvent mouseEvent){ private void tourListSelectedItem(MouseEvent mouseEvent){
//Beschreibung
ProgressBar progressBar = new ProgressBar("Tour auswählen..."); ProgressBar progressBar = new ProgressBar("Tour auswählen...");
String selectedItem = TourListView.getSelectionModel().getSelectedItem(); String selectedItem = TourListView.getSelectionModel().getSelectedItem();
this.viewModel.selectTour(selectedItem); this.viewModel.selectTour(selectedItem);
@ -159,6 +163,16 @@ public class TourplanerController implements Initializable {
syncTourNamen(); syncTourNamen();
progressBar.setProgress(100); progressBar.setProgress(100);
this.sucheInput.setText(""); this.sucheInput.setText("");
//Tour namen select focus
AtomicInteger index = new AtomicInteger();
AtomicInteger indexF = new AtomicInteger();
this.viewModel.getTourNamen().forEach(tn -> {
index.getAndIncrement();
if(tn.equals(this.viewModel.getSelectedTour().getName())){
indexF.set(index.get());
}
});
TourListView.getFocusModel().focus(indexF.intValue() - 1);
} }
progressBar.setProgress(100); progressBar.setProgress(100);
} }
@ -206,6 +220,13 @@ public class TourplanerController implements Initializable {
progressBar.closeProgress(); progressBar.closeProgress();
} }
@FXML
private void sucheEnter(KeyEvent event){
if(event.getCode().equals(KeyCode.ENTER)) {
suche();
}
}
/** /**
* Fügt einen Log eintrag zu einer Tour hinzu. * Fügt einen Log eintrag zu einer Tour hinzu.
* Ist keine Tour ausgewählt, dann kommt eine Warnung an den User! * Ist keine Tour ausgewählt, dann kommt eine Warnung an den User!

View File

@ -98,7 +98,6 @@ public class ViewModel {
this.neueTourName = AlertHelper.inputText(ConfigHelper.getLangIniString("tournametitle"), this.neueTourName = AlertHelper.inputText(ConfigHelper.getLangIniString("tournametitle"),
ConfigHelper.getLangIniString("tournameheader"), ConfigHelper.getLangIniString("tournameheader"),
ConfigHelper.getLangIniString("tournamemsg"), content); ConfigHelper.getLangIniString("tournamemsg"), content);
System.out.println(this.neueTourName);
if(this.neueTourName.isEmpty()){ if(this.neueTourName.isEmpty()){
return false; return false;
} }
@ -197,7 +196,6 @@ public class ViewModel {
* Bearbeitet einen gewählten Log eintrag * Bearbeitet einen gewählten Log eintrag
*/ */
public void editLog(){ public void editLog(){
System.out.println(this.selectedLog);
if(this.selectedTour != null) { if(this.selectedTour != null) {
if(this.selectedLog != null) { if(this.selectedLog != null) {
AtomicReference<Tour> tourAkt = new AtomicReference<>(); AtomicReference<Tour> tourAkt = new AtomicReference<>();
@ -314,7 +312,6 @@ public class ViewModel {
private LocalDate dateInput(LocalDate date){ private LocalDate dateInput(LocalDate date){
LocalDate neuesDatum = null; LocalDate neuesDatum = null;
neuesDatum = AlertHelper.datePicker(date); neuesDatum = AlertHelper.datePicker(date);
System.out.println(neuesDatum);
return neuesDatum; return neuesDatum;
} }