Edit Tour/Log Bugfixes
This commit is contained in:
		@@ -116,16 +116,21 @@ public class AlertHelper {
 | 
			
		||||
     * @return Null bei keiner eingabe
 | 
			
		||||
     */
 | 
			
		||||
    public static String inputText(String title, String header, String msg, String content) {
 | 
			
		||||
        String returnStr = "";
 | 
			
		||||
        while (returnStr.isEmpty()) {
 | 
			
		||||
        String returnStr = null;
 | 
			
		||||
        while (returnStr == null) {
 | 
			
		||||
            Optional<String> result = inputHelper(title, header, msg, content);
 | 
			
		||||
 | 
			
		||||
            AtomicReference<String> returnText = new AtomicReference<>("");
 | 
			
		||||
            result.ifPresent(returnText::set);
 | 
			
		||||
            returnStr = returnText.get();
 | 
			
		||||
            if (returnStr.isEmpty()) {
 | 
			
		||||
                AlertHelper.warn(ConfigHelper.getLangIniString("tournametitle"),
 | 
			
		||||
                        ConfigHelper.getLangIniString("achtung"),
 | 
			
		||||
                        ConfigHelper.getLangIniString("keintextimfeld"));
 | 
			
		||||
            if(result.isPresent()) {
 | 
			
		||||
                result.ifPresent(returnText::set);
 | 
			
		||||
                returnStr = returnText.get();
 | 
			
		||||
                if (returnStr.isEmpty()) {
 | 
			
		||||
                    AlertHelper.warn(ConfigHelper.getLangIniString("tournametitle"),
 | 
			
		||||
                            ConfigHelper.getLangIniString("achtung"),
 | 
			
		||||
                            ConfigHelper.getLangIniString("keintextimfeld"));
 | 
			
		||||
                }
 | 
			
		||||
            }else{
 | 
			
		||||
                return "";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return returnStr;
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ public class ViewModel {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Bearbeitet eine bereits bestehende Tour
 | 
			
		||||
     * prüft ob eine tour ausgewählt ist
 | 
			
		||||
     */
 | 
			
		||||
    public void editTour(){
 | 
			
		||||
        if (this.selectedTour == null){
 | 
			
		||||
@@ -47,35 +48,49 @@ public class ViewModel {
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            if(aktIndex.intValue() != -1){
 | 
			
		||||
                Tour tourToEdit = this.tourData.get(aktIndex.intValue());
 | 
			
		||||
                this.tourData.removeIf(tour -> tour.getName().equals(this.selectedTour.getName()));
 | 
			
		||||
                this.tourNamen.removeIf(tour -> tour.equals(this.selectedTour.getName()));
 | 
			
		||||
                System.out.println(tourToEdit.getLogs());
 | 
			
		||||
                tourNameInput(this.selectedTour.getName());
 | 
			
		||||
                tourToEdit.setName(this.neueTourName);
 | 
			
		||||
                tourStartInput(this.selectedTour.getStart());
 | 
			
		||||
                tourToEdit.setStart(this.neueTourStart);
 | 
			
		||||
                tourZielInput(this.selectedTour.getZiel());
 | 
			
		||||
                tourToEdit.setZiel(this.neueTourZiel);
 | 
			
		||||
                System.out.println(tourToEdit.getName());
 | 
			
		||||
 | 
			
		||||
                this.tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
 | 
			
		||||
                this.tourNamen.add(this.neueTourName);
 | 
			
		||||
//                this.tourData.add(tourToEdit);
 | 
			
		||||
                if(tourNameInputDuplicatCheck(this.selectedTour.getName(), false)) {
 | 
			
		||||
                    if (tourStartInput(this.selectedTour.getStart())) {
 | 
			
		||||
                        if (tourZielInput(this.selectedTour.getZiel())) {
 | 
			
		||||
 | 
			
		||||
                            this.tourData.removeIf(tour -> tour.getName().equals(this.selectedTour.getName()));
 | 
			
		||||
                            this.tourNamen.removeIf(tour -> tour.equals(this.selectedTour.getName()));
 | 
			
		||||
                            this.tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
 | 
			
		||||
                            this.tourNamen.add(this.neueTourName);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                this.neueTourName = null;
 | 
			
		||||
                this.neueTourStart = null;
 | 
			
		||||
                this.neueTourZiel = null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Input mit duplications check des Namens und ohne content im input feld
 | 
			
		||||
     */
 | 
			
		||||
    private void tourNameInput(){
 | 
			
		||||
        tourNameInputDuplicatCheck("", true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Input des Tour Namen wird so lange durchgeführt, bis er korrekt ist. Das heißt:
 | 
			
		||||
     * er darf nicht schon vorhanden sein und er darf nicht Null sein
 | 
			
		||||
     * @param checkDuplicate Prüft ob name bereits vorhanden ist
 | 
			
		||||
     * @param content inhalt des Input fields
 | 
			
		||||
     * @return false beim schließen des input dialogs
 | 
			
		||||
     */
 | 
			
		||||
    private void tourNameInput(String content){
 | 
			
		||||
    private boolean tourNameInputDuplicatCheck(String content, boolean checkDuplicate){
 | 
			
		||||
        while(this.neueTourName == null) {
 | 
			
		||||
            this.neueTourName = AlertHelper.inputText(ConfigHelper.getLangIniString("tournametitle"),
 | 
			
		||||
                    ConfigHelper.getLangIniString("tournameheader"),
 | 
			
		||||
                    ConfigHelper.getLangIniString("tournamemsg"), content);
 | 
			
		||||
            if (getTour(this.neueTourName) != null) {
 | 
			
		||||
            System.out.println(this.neueTourName);
 | 
			
		||||
            if(this.neueTourName.isEmpty()){
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
            if (getTour(this.neueTourName) != null && checkDuplicate) {
 | 
			
		||||
                AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
 | 
			
		||||
                        ConfigHelper.getLangIniString("namevergebenheader"),
 | 
			
		||||
                        ConfigHelper.getLangIniString("namevergebenmsg1")
 | 
			
		||||
@@ -84,30 +99,43 @@ public class ViewModel {
 | 
			
		||||
                this.neueTourName = null;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Input der Startpunkt der Tour
 | 
			
		||||
     * Wird erst beendet wenn die eingabe erfolgreich war
 | 
			
		||||
     * @param content inhalt des Input fields
 | 
			
		||||
     * @return false beim schließen des input dialogs
 | 
			
		||||
     */
 | 
			
		||||
    private void tourStartInput(String content){
 | 
			
		||||
    private boolean tourStartInput(String content){
 | 
			
		||||
        while(this.neueTourStart == null){
 | 
			
		||||
            this.neueTourStart = AlertHelper.inputText(ConfigHelper.getLangIniString("startpunkttitle"),
 | 
			
		||||
                    ConfigHelper.getLangIniString("startpunktheader"),
 | 
			
		||||
                    ConfigHelper.getLangIniString("startpunktmsg"), content);
 | 
			
		||||
            if(this.neueTourStart.isEmpty()){
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Input des Zielpunktes der Tour
 | 
			
		||||
     * Wird erst beendet wenn die eingabe erfolgreich war
 | 
			
		||||
     * @param content inhalt des Input fields
 | 
			
		||||
     * @return false beim schließen des input dialogs
 | 
			
		||||
     */
 | 
			
		||||
    private void tourZielInput(String content){
 | 
			
		||||
    private boolean tourZielInput(String content){
 | 
			
		||||
        while(this.neueTourZiel == null){
 | 
			
		||||
            this.neueTourZiel = AlertHelper.inputText(ConfigHelper.getLangIniString("zielpunkttitle"),
 | 
			
		||||
                    ConfigHelper.getLangIniString("zielpunktheader"),
 | 
			
		||||
                    ConfigHelper.getLangIniString("zielpunktmsg"), content);
 | 
			
		||||
            if(this.neueTourZiel.isEmpty()){
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -115,7 +143,7 @@ public class ViewModel {
 | 
			
		||||
     * Fügt eine neue Tour hinzu
 | 
			
		||||
     */
 | 
			
		||||
    public void addTour(){
 | 
			
		||||
        tourNameInput("");
 | 
			
		||||
        tourNameInput();
 | 
			
		||||
        tourStartInput("");
 | 
			
		||||
        tourZielInput("");
 | 
			
		||||
        if (getTour(this.neueTourName) == null) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user