Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
ad5d7d98c4 | |||
d8c4680e16 | |||
49b6407ce6 |
@ -68,7 +68,10 @@ public class DirectionMap {
|
|||||||
* @throws IOException Fehler beim besorgen der infos über die Tour
|
* @throws IOException Fehler beim besorgen der infos über die Tour
|
||||||
*/
|
*/
|
||||||
private void getDirections(String start, String ende) throws IOException {
|
private void getDirections(String start, String ende) throws IOException {
|
||||||
|
System.out.println("LOCS: " + start + ende);
|
||||||
String json = HttpHelper.httpGetJsonString("https://www.mapquestapi.com/directions/v2/route?key="+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key")+"&from="+start+"&to="+ende+"&outFormat=json&ambiguities=ignore&routeType=fastest&doReverseGeocode=false&enhancedNarrative=false&avoidTimedConditions=false");
|
String json = HttpHelper.httpGetJsonString("https://www.mapquestapi.com/directions/v2/route?key="+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key")+"&from="+start+"&to="+ende+"&outFormat=json&ambiguities=ignore&routeType=fastest&doReverseGeocode=false&enhancedNarrative=false&avoidTimedConditions=false");
|
||||||
|
System.out.println("JSON: " + json);
|
||||||
|
System.out.println("URL https://www.mapquestapi.com/directions/v2/route?key="+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "map", "key")+"&from="+start+"&to="+ende+"&outFormat=json&ambiguities=ignore&routeType=fastest&doReverseGeocode=false&enhancedNarrative=false&avoidTimedConditions=false");
|
||||||
this.strecke = JsonHelper.getDoubleFromJson(json, "distance");
|
this.strecke = JsonHelper.getDoubleFromJson(json, "distance");
|
||||||
this.dauer = formatetTimeToMinutes(JsonHelper.getStingFromJson(json, "formattedTime"));
|
this.dauer = formatetTimeToMinutes(JsonHelper.getStingFromJson(json, "formattedTime"));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,10 @@ package tourplaner.business;
|
|||||||
import tourplaner.data.DbConnect;
|
import tourplaner.data.DbConnect;
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
import tourplaner.ui.AlertHelper;
|
||||||
|
import tourplaner.ui.ProgressBar;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -28,10 +31,16 @@ public class Exporter {
|
|||||||
* @throws IOException Fehler beim File erstellen
|
* @throws IOException Fehler beim File erstellen
|
||||||
*/
|
*/
|
||||||
public void doExport() throws IOException {
|
public void doExport() throws IOException {
|
||||||
|
ProgressBar progressBar = new ProgressBar("Export...");
|
||||||
|
int step = progressBar.getProgressSize(4, 100);
|
||||||
ArrayList<Tour> data = new DbConnect().getAllTouren();
|
ArrayList<Tour> data = new DbConnect().getAllTouren();
|
||||||
|
progressBar.addProgress(step);
|
||||||
FileWriter fileWriter = new FileWriter(path + ".json");
|
FileWriter fileWriter = new FileWriter(path + ".json");
|
||||||
|
progressBar.addProgress(step);
|
||||||
JsonHelper.getJsonFromObj(data, fileWriter);
|
JsonHelper.getJsonFromObj(data, fileWriter);
|
||||||
|
progressBar.addProgress(step);
|
||||||
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||||
|
progressBar.setProgress(100);
|
||||||
bufferedWriter.close();
|
bufferedWriter.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,17 +48,29 @@ public class Exporter {
|
|||||||
* Führt den Imput aus -> File holen, Daten in db erstellen
|
* Führt den Imput aus -> File holen, Daten in db erstellen
|
||||||
* @throws IOException Fehler beim File öffnen
|
* @throws IOException Fehler beim File öffnen
|
||||||
*/
|
*/
|
||||||
public void doImport() throws IOException {
|
public void doImport() {
|
||||||
this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path));
|
ProgressBar progressBar = new ProgressBar("Import...");
|
||||||
DbConnect dbConnect = new DbConnect();
|
try {
|
||||||
dbConnect.delAllData();
|
this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path));
|
||||||
for (Tour tour:this.touren) {
|
DbConnect dbConnect = new DbConnect();
|
||||||
new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
dbConnect.delAllData();
|
||||||
dbConnect.addTour(tour);
|
progressBar.addProgress(5);
|
||||||
ArrayList<Log> logs = tour.getLogs();
|
int size = progressBar.getProgressSize(this.touren.size() * 3, 100);
|
||||||
for (Log log:logs) {
|
for (Tour tour:this.touren) {
|
||||||
dbConnect.addLog(tour.getName(), log);
|
new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
||||||
|
progressBar.addProgress(size);
|
||||||
|
dbConnect.addTour(tour);
|
||||||
|
progressBar.addProgress(size);
|
||||||
|
ArrayList<Log> logs = tour.getLogs();
|
||||||
|
for (Log log:logs) {
|
||||||
|
dbConnect.addLog(tour.getName(), log);
|
||||||
|
}
|
||||||
|
progressBar.addProgress(size);
|
||||||
}
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
LogHelper.error(e);
|
||||||
|
progressBar.setProgress(100);
|
||||||
}
|
}
|
||||||
|
progressBar.setProgress(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import org.apache.log4j.Logger;
|
|||||||
import tourplaner.data.DbConnect;
|
import tourplaner.data.DbConnect;
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
import tourplaner.ui.ProgressBar;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -39,12 +40,18 @@ public class TourPlaner{
|
|||||||
* @return false bei error
|
* @return false bei error
|
||||||
*/
|
*/
|
||||||
public static boolean editTour(String oldname, Tour tour) throws IOException {
|
public static boolean editTour(String oldname, Tour tour) throws IOException {
|
||||||
|
ProgressBar progressBar = new ProgressBar("Edit...");
|
||||||
|
int step = progressBar.getProgressSize(3, 100);
|
||||||
FileHelper.delFile(new File(getImagePath(oldname)));
|
FileHelper.delFile(new File(getImagePath(oldname)));
|
||||||
FileHelper.delFile(new File(getImagePdfPath(oldname)));
|
FileHelper.delFile(new File(getImagePdfPath(oldname)));
|
||||||
|
progressBar.addProgress(step);
|
||||||
DirectionMap directionMap = new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
DirectionMap directionMap = new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
||||||
|
progressBar.addProgress(step);
|
||||||
tour.setDauer(directionMap.getDauer()+"");
|
tour.setDauer(directionMap.getDauer()+"");
|
||||||
tour.setStrecke(directionMap.getStrecke());
|
tour.setStrecke(directionMap.getStrecke());
|
||||||
return new DbConnect().editTour(oldname, tour);
|
boolean ret = new DbConnect().editTour(oldname, tour);
|
||||||
|
progressBar.setProgress(100);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,20 +60,30 @@ public class TourPlaner{
|
|||||||
* @return false bei error
|
* @return false bei error
|
||||||
*/
|
*/
|
||||||
public static boolean delTour(String tourname){
|
public static boolean delTour(String tourname){
|
||||||
|
ProgressBar progressBar = new ProgressBar("Del...");
|
||||||
|
int step = progressBar.getProgressSize(3, 100);
|
||||||
FileHelper.delFile(new File(getImagePath(tourname)));
|
FileHelper.delFile(new File(getImagePath(tourname)));
|
||||||
|
progressBar.addProgress(step);
|
||||||
FileHelper.delFile(new File(getImagePdfPath(tourname)));
|
FileHelper.delFile(new File(getImagePdfPath(tourname)));
|
||||||
return new DbConnect().delTour(tourname);
|
progressBar.addProgress(step);
|
||||||
|
boolean ret = new DbConnect().delTour(tourname);
|
||||||
|
progressBar.setProgress(100);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Fügt eine Tour hinzu
|
* Fügt eine Tour hinzu
|
||||||
* @param newTour Neue Tour
|
* @param newTour Neue Tour
|
||||||
* @return false bei error
|
* @return false bei error
|
||||||
*/
|
*/
|
||||||
public static boolean addTour(Tour newTour) throws IOException {
|
public static boolean addTour(Tour newTour, ProgressBar progressBar) throws IOException {
|
||||||
|
int step = progressBar.getProgressSize(2, 100);
|
||||||
DirectionMap directionMap = new DirectionMap(newTour.getStart(), newTour.getZiel(), newTour.getName());
|
DirectionMap directionMap = new DirectionMap(newTour.getStart(), newTour.getZiel(), newTour.getName());
|
||||||
|
progressBar.addProgress(step);
|
||||||
newTour.setDauer(directionMap.getDauer()+"");
|
newTour.setDauer(directionMap.getDauer()+"");
|
||||||
newTour.setStrecke(directionMap.getStrecke());
|
newTour.setStrecke(directionMap.getStrecke());
|
||||||
return new DbConnect().addTour(newTour);
|
boolean ret = new DbConnect().addTour(newTour);
|
||||||
|
progressBar.setProgress(100);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package tourplaner.data;
|
package tourplaner.data;
|
||||||
|
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
|
import tourplaner.business.LogHelper;
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
import tourplaner.ui.AlertHelper;
|
||||||
|
import tourplaner.ui.ProgressBar;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.*;
|
||||||
import java.sql.Date;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -155,21 +155,38 @@ public class DbConnect {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean delLog(String tourname, String id){
|
public boolean delLog(String tourname, String id){
|
||||||
System.out.println("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
|
||||||
return PostgresHelper.executeUpdate("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
return PostgresHelper.executeUpdate("DELETE FROM public.log WHERE tourname = '"+tourname+"' and id = '"+id+"'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getTourSize() throws SQLException {
|
||||||
|
Connection con = PostgresHelper.con();
|
||||||
|
Statement s = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||||
|
ResultSet rs = s.executeQuery("SELECT COUNT(*) FROM tour;");
|
||||||
|
int size =0;
|
||||||
|
if (rs != null)
|
||||||
|
{
|
||||||
|
rs.last(); // moves cursor to the last row
|
||||||
|
size = rs.getInt("count"); // get row id
|
||||||
|
con.close();
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
con.close();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holt alle Touren aus der Datenbank
|
* Holt alle Touren aus der Datenbank
|
||||||
* @return Null bei fehler, sonst eine List aus den IDs
|
* @return Null bei fehler, sonst eine List aus den IDs
|
||||||
*/
|
*/
|
||||||
public ArrayList<Tour> getAllTouren(){
|
public ArrayList<Tour> getAllTouren() {
|
||||||
this.c = PostgresHelper.con();
|
this.c = PostgresHelper.con();
|
||||||
String tourname, mapjson, start, ziel;
|
String tourname, mapjson, start, ziel;
|
||||||
double dauer, strecke;
|
double dauer, strecke;
|
||||||
|
|
||||||
ArrayList<Tour> touren = new ArrayList<>();
|
ArrayList<Tour> touren = new ArrayList<>();
|
||||||
|
ProgressBar progressBar = new ProgressBar("Get...");
|
||||||
try {
|
try {
|
||||||
|
int tourSize = getTourSize();
|
||||||
|
int step = progressBar.getProgressSize(tourSize, 100);
|
||||||
stmt = this.c.createStatement();
|
stmt = this.c.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("select * from tour;");
|
ResultSet rs = stmt.executeQuery("select * from tour;");
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
@ -181,16 +198,20 @@ public class DbConnect {
|
|||||||
strecke = rs.getDouble("strecke");
|
strecke = rs.getDouble("strecke");
|
||||||
if (!tourname.isEmpty()) {
|
if (!tourname.isEmpty()) {
|
||||||
touren.add(new Tour(tourname, dauer + "", mapjson, strecke, start, ziel, getLogs(tourname)));
|
touren.add(new Tour(tourname, dauer + "", mapjson, strecke, start, ziel, getLogs(tourname)));
|
||||||
|
progressBar.addProgress(step);
|
||||||
}else {
|
}else {
|
||||||
|
progressBar.setProgress(100);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
progressBar.setProgress(100);
|
||||||
rs.close();
|
rs.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
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);
|
||||||
|
progressBar.setProgress(100);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
<menus>
|
<menus>
|
||||||
<Menu fx:id="menueFile" mnemonicParsing="false" text="Datei">
|
<Menu fx:id="menueFile" mnemonicParsing="false" text="Datei">
|
||||||
<items>
|
<items>
|
||||||
|
<MenuItem mnemonicParsing="false" onAction="#reportSum" text="Report Summary" />
|
||||||
|
<MenuItem 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" />
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
@ -52,13 +54,18 @@
|
|||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#importBtn" text="Import" />
|
<MenuItem mnemonicParsing="false" onAction="#importBtn" text="Import" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#exportBtn" text="Export" />
|
<MenuItem mnemonicParsing="false" onAction="#exportBtn" text="Export" />
|
||||||
<MenuItem mnemonicParsing="false" onAction="#reportSum" text="Report alles" />
|
|
||||||
<MenuItem mnemonicParsing="false" onAction="#tourReport" text="Tour Report erstellen" />
|
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Optionen">
|
<Menu mnemonicParsing="false" text="Optionen">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#nimpButton" text="Keine Funktion" />
|
<CheckMenuItem mnemonicParsing="false" text="Map automatisch öffnen" />
|
||||||
|
<CheckMenuItem mnemonicParsing="false" text="Report automatisch öffnen" />
|
||||||
|
<Menu mnemonicParsing="false" text="Sprache">
|
||||||
|
<items>
|
||||||
|
<RadioMenuItem mnemonicParsing="false" text="Deutsch" />
|
||||||
|
<RadioMenuItem mnemonicParsing="false" text="Englisch" />
|
||||||
|
</items>
|
||||||
|
</Menu>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Menu mnemonicParsing="false" text="Hilfe">
|
<Menu mnemonicParsing="false" text="Hilfe">
|
||||||
|
@ -12,6 +12,10 @@ import javafx.stage.WindowEvent;
|
|||||||
import tourplaner.business.ConfigHelper;
|
import tourplaner.business.ConfigHelper;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
import java.awt.*;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
66
src/tourplaner/ui/ProgressBar.java
Normal file
66
src/tourplaner/ui/ProgressBar.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package tourplaner.ui;
|
||||||
|
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import tourplaner.business.ConfigHelper;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.border.TitledBorder;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ProgressBar {
|
||||||
|
private int status;
|
||||||
|
private JFrame frame;
|
||||||
|
private JProgressBar progressBar;
|
||||||
|
|
||||||
|
public ProgressBar(String title){
|
||||||
|
this.frame = new JFrame(title);
|
||||||
|
File pathToFile = new File(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo"));
|
||||||
|
try {
|
||||||
|
BufferedImage image = ImageIO.read(pathToFile);
|
||||||
|
this.frame.setIconImage(image);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
this.frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||||
|
Container content = this.frame.getContentPane();
|
||||||
|
this.progressBar = new JProgressBar();
|
||||||
|
this.progressBar.setValue(0);
|
||||||
|
this.progressBar.setStringPainted(true);
|
||||||
|
TitledBorder border = BorderFactory.createTitledBorder("Laden....");
|
||||||
|
this.progressBar.setBorder(border);
|
||||||
|
content.add(this.progressBar, BorderLayout.NORTH);
|
||||||
|
this.frame.setSize(300, 100);
|
||||||
|
this.frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProgress(int add){
|
||||||
|
this.status += add;
|
||||||
|
this.progressBar.setValue(this.status);
|
||||||
|
closeOnFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void closeOnFinish(){
|
||||||
|
if(this.status >= 100){
|
||||||
|
closeProgress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProgress(int set){
|
||||||
|
this.status = set;
|
||||||
|
closeOnFinish();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void closeProgress(){
|
||||||
|
this.frame.setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProgressSize(int todo, int maxLevel){
|
||||||
|
int steps = (progressBar.getValue() - maxLevel) / todo;
|
||||||
|
if(steps < 0) steps = steps*-1;
|
||||||
|
return steps;
|
||||||
|
}
|
||||||
|
}
|
@ -17,6 +17,7 @@ import tourplaner.object.Log;
|
|||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
import tourplaner.viewmodels.ViewModel;
|
import tourplaner.viewmodels.ViewModel;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -114,10 +115,13 @@ public class TourplanerController implements Initializable {
|
|||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void tourListSelectedItem(MouseEvent mouseEvent){
|
private void tourListSelectedItem(MouseEvent mouseEvent){
|
||||||
|
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);
|
||||||
titleTextView.setText(selectedItem);
|
titleTextView.setText(selectedItem);
|
||||||
|
progressBar.addProgress(10);
|
||||||
syncTour(selectedItem);
|
syncTour(selectedItem);
|
||||||
|
progressBar.addProgress(10);
|
||||||
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
||||||
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
||||||
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
||||||
@ -127,7 +131,9 @@ public class TourplanerController implements Initializable {
|
|||||||
//Log anzeigen
|
//Log anzeigen
|
||||||
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinelogsvorhanden")));
|
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinelogsvorhanden")));
|
||||||
logTableView.getItems().clear();
|
logTableView.getItems().clear();
|
||||||
|
progressBar.addProgress(10);
|
||||||
logTableView.setItems(this.viewModel.getLogData());
|
logTableView.setItems(this.viewModel.getLogData());
|
||||||
|
progressBar.addProgress(10);
|
||||||
logDauerCol.setCellValueFactory(new PropertyValueFactory<Log, String>("dauer"));
|
logDauerCol.setCellValueFactory(new PropertyValueFactory<Log, String>("dauer"));
|
||||||
logStreckeCol.setCellValueFactory(new PropertyValueFactory<Log, String>("strecke"));
|
logStreckeCol.setCellValueFactory(new PropertyValueFactory<Log, String>("strecke"));
|
||||||
logDatumCol.setCellValueFactory(new PropertyValueFactory<Log, String>("datum"));
|
logDatumCol.setCellValueFactory(new PropertyValueFactory<Log, String>("datum"));
|
||||||
@ -136,12 +142,16 @@ public class TourplanerController implements Initializable {
|
|||||||
logPauseCol.setCellValueFactory(new PropertyValueFactory<Log, String>("pause"));
|
logPauseCol.setCellValueFactory(new PropertyValueFactory<Log, String>("pause"));
|
||||||
logGegangenCol.setCellValueFactory(new PropertyValueFactory<Log, String>("gegangen"));
|
logGegangenCol.setCellValueFactory(new PropertyValueFactory<Log, String>("gegangen"));
|
||||||
logBemerkungCol.setCellValueFactory(new PropertyValueFactory<Log, String>("bemerkung"));
|
logBemerkungCol.setCellValueFactory(new PropertyValueFactory<Log, String>("bemerkung"));
|
||||||
|
progressBar.addProgress(10);
|
||||||
mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
||||||
if(this.viewModel.isSucheAktiv()){
|
if(this.viewModel.isSucheAktiv()){
|
||||||
this.viewModel.setSucheAktiv(false);
|
this.viewModel.setSucheAktiv(false);
|
||||||
|
progressBar.addProgress(10);
|
||||||
syncTourNamen();
|
syncTourNamen();
|
||||||
|
progressBar.addProgress(40);
|
||||||
|
this.sucheInput.setText("");
|
||||||
}
|
}
|
||||||
|
progressBar.addProgress(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,8 +169,7 @@ public class TourplanerController implements Initializable {
|
|||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void addTour(){
|
private void addTour(){
|
||||||
this.viewModel.addTour();
|
if(this.viewModel.addTour()) this.mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
||||||
this.mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,7 +191,10 @@ public class TourplanerController implements Initializable {
|
|||||||
*/
|
*/
|
||||||
@FXML
|
@FXML
|
||||||
private void suche(){
|
private void suche(){
|
||||||
|
ProgressBar progressBar = new ProgressBar("Suche");
|
||||||
this.viewModel.suche(this.sucheInput.getText());
|
this.viewModel.suche(this.sucheInput.getText());
|
||||||
|
progressBar.addProgress(100);
|
||||||
|
progressBar.closeProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,9 +7,9 @@ import tourplaner.business.*;
|
|||||||
import tourplaner.ui.AlertHelper;
|
import tourplaner.ui.AlertHelper;
|
||||||
import tourplaner.object.Log;
|
import tourplaner.object.Log;
|
||||||
import tourplaner.object.Tour;
|
import tourplaner.object.Tour;
|
||||||
|
import tourplaner.ui.ProgressBar;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@ -79,9 +79,10 @@ public class ViewModel {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Input mit duplications check des Namens und ohne content im input feld
|
* Input mit duplications check des Namens und ohne content im input feld
|
||||||
|
* @return false beim schließen
|
||||||
*/
|
*/
|
||||||
private void tourNameInput(){
|
private boolean tourNameInput(){
|
||||||
tourNameInputDuplicatCheck("", true);
|
return tourNameInputDuplicatCheck("", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,24 +153,31 @@ public class ViewModel {
|
|||||||
/**
|
/**
|
||||||
* Fügt eine neue Tour hinzu
|
* Fügt eine neue Tour hinzu
|
||||||
*/
|
*/
|
||||||
public void addTour(){
|
public boolean addTour(){
|
||||||
tourNameInput();
|
if(tourNameInput()) {
|
||||||
tourStartInput("");
|
if(tourStartInput("")) {
|
||||||
tourZielInput("");
|
if (tourZielInput("")) {
|
||||||
if (getTour(this.neueTourName) == null) {
|
if (getTour(this.neueTourName) == null) {
|
||||||
Tour newTour = new Tour(this.neueTourName, "1", "1", 0, this.neueTourStart, this.neueTourZiel);
|
ProgressBar progressBar = new ProgressBar("Add Tour...");
|
||||||
tourData.add(newTour);
|
Tour newTour = new Tour(this.neueTourName, "1", "1", 0, this.neueTourStart, this.neueTourZiel);
|
||||||
tourNamen.add(this.neueTourName);
|
tourData.add(newTour);
|
||||||
this.selectedTour = newTour;
|
tourNamen.add(this.neueTourName);
|
||||||
try {
|
this.selectedTour = newTour;
|
||||||
TourPlaner.addTour(newTour);
|
progressBar.addProgress(10);
|
||||||
} catch (IOException e) {
|
try {
|
||||||
e.printStackTrace();
|
TourPlaner.addTour(newTour, progressBar);
|
||||||
}
|
} catch (IOException e) {
|
||||||
}
|
LogHelper.error(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else return false;
|
||||||
|
}else return false;
|
||||||
|
}else return false;
|
||||||
this.neueTourStart = null;
|
this.neueTourStart = null;
|
||||||
this.neueTourZiel = null;
|
this.neueTourZiel = null;
|
||||||
this.neueTourName = null;
|
this.neueTourName = null;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean keineTourSelected(){
|
private boolean keineTourSelected(){
|
||||||
@ -208,11 +216,11 @@ public class ViewModel {
|
|||||||
if (dauer >= 0) {
|
if (dauer >= 0) {
|
||||||
strecke = streckeInput(this.selectedLog.getStrecke() + "");
|
strecke = streckeInput(this.selectedLog.getStrecke() + "");
|
||||||
if (strecke >= 0) {
|
if (strecke >= 0) {
|
||||||
pause = pauseInput("");
|
pause = pauseInput(this.selectedLog.getPause() + "");
|
||||||
if(pause >= 0.0) {
|
if(pause >= 0.0) {
|
||||||
hightmeter = hightmeterInput("");
|
hightmeter = hightmeterInput(this.selectedLog.getHightmeter() + "");
|
||||||
if (hightmeter >= 0.0) {
|
if (hightmeter >= 0.0) {
|
||||||
bemerkung = bemerkungInput("");
|
bemerkung = bemerkungInput(this.selectedLog.getBemerkung());
|
||||||
if (bemerkung) {
|
if (bemerkung) {
|
||||||
datum = dateInput(this.selectedLog.getDatum());
|
datum = dateInput(this.selectedLog.getDatum());
|
||||||
if (datum != null) {
|
if (datum != null) {
|
||||||
@ -481,7 +489,10 @@ public class ViewModel {
|
|||||||
|
|
||||||
public ObservableList<Tour> getTourData() {
|
public ObservableList<Tour> getTourData() {
|
||||||
tourData.clear();
|
tourData.clear();
|
||||||
tourData.addAll(TourPlaner.getAllTours());
|
ArrayList<Tour> touren = TourPlaner.getAllTours();
|
||||||
|
if(touren != null) {
|
||||||
|
tourData.addAll(touren);
|
||||||
|
}
|
||||||
return tourData;
|
return tourData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,15 +628,9 @@ public class ViewModel {
|
|||||||
*/
|
*/
|
||||||
public void importData() {
|
public void importData() {
|
||||||
String file = AlertHelper.fileChooser("Importiere");
|
String file = AlertHelper.fileChooser("Importiere");
|
||||||
System.out.println("IMPORT: " + file);
|
|
||||||
if (file != null){
|
if (file != null){
|
||||||
try {
|
this.tourNamen = FXCollections.observableArrayList();
|
||||||
this.tourNamen = FXCollections.observableArrayList();
|
new Exporter(file).doImport();
|
||||||
new Exporter(file).doImport();
|
|
||||||
} catch (IOException e) {
|
|
||||||
AlertHelper.error("Error", "Import Error", "Fehler beim Importieren");
|
|
||||||
LogHelper.error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user