Logik von Controller -> ViewModel verschoben
This commit is contained in:
parent
5d860eed3c
commit
0b8f8f996d
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
@ -8,3 +8,5 @@
|
||||
2021-03-18 23:05:00 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 23:11:45 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-18 23:14:55 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-19 11:56:22 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
2021-03-19 22:35:19 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!
|
||||
|
@ -1,7 +1,5 @@
|
||||
package tourplaner.data;
|
||||
|
||||
import tourplaner.business.PostgresHelper;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package tourplaner.business;
|
||||
package tourplaner.data;
|
||||
|
||||
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.Statement;
|
@ -1,4 +1,4 @@
|
||||
package tourplaner.business;
|
||||
package tourplaner.ui;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
@ -6,13 +6,12 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextArea;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.layout.*;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -9,7 +9,6 @@ import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import tourplaner.business.AlertHelper;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
import tourplaner.object.Log;
|
||||
@ -28,7 +27,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class TourplanerController implements Initializable {
|
||||
//VM
|
||||
public ViewModel viewModel = new ViewModel();
|
||||
private final ViewModel viewModel = new ViewModel();
|
||||
//Tour list -> links
|
||||
public ListView<String> TourListView = new ListView<>();
|
||||
//Tabs zu Tour -> rechts oben
|
||||
@ -47,7 +46,7 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void gitWebBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "gitrepo"), "Git");
|
||||
this.viewModel.gitWebBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +55,7 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void javaDocBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "javadoc"), "JavaDoc");
|
||||
this.viewModel.javaDocBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,27 +64,10 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void doxygenDocBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "doxygendoc"), "Doxygen");
|
||||
this.viewModel.doxygenDocBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnet einen link im Standart Browser
|
||||
* @param uriString
|
||||
* @param appname
|
||||
*/
|
||||
private void openBrowser(String uriString, String appname){
|
||||
Desktop desktop = java.awt.Desktop.getDesktop();
|
||||
try {
|
||||
URI oURL = new URI(
|
||||
uriString);
|
||||
desktop.browse(oURL);
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
LogHelper.error(e.getMessage(), ConfigHelper.getLangIniString("openbrowsererror") + appname);
|
||||
AlertHelper.exerror(ConfigHelper.getLangIniString("browserexception"),
|
||||
ConfigHelper.getLangIniString("openbrowsererror") + appname,
|
||||
ConfigHelper.getLangIniString("browserexceptionmsg"), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wird gestartet wenn eine Tour in der Tour listView ausgewählt wird
|
||||
@ -139,7 +121,6 @@ public class TourplanerController implements Initializable {
|
||||
this.beschreibungTableView.getItems().removeIf(s -> true); //löscht alles aus der tabelle
|
||||
this.titleTextView.setText(ConfigHelper.getLangIniString("keinetourselected"));
|
||||
this.viewModel.delTour();
|
||||
this.viewModel.setSelectedTour(null);
|
||||
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
|
||||
}
|
||||
|
||||
@ -149,14 +130,7 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void suche(){
|
||||
String sucheInput = this.sucheInput.getText();
|
||||
if(sucheInput.isEmpty()){
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("suchfeldleer"),
|
||||
ConfigHelper.getLangIniString("suchtextzuerst"));
|
||||
}else {
|
||||
this.viewModel.suche(sucheInput);
|
||||
}
|
||||
this.viewModel.suche(this.sucheInput.getText());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -165,54 +139,13 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void addLog(){
|
||||
Tour selectedTour = this.viewModel.getSelectedTour();
|
||||
if (selectedTour == null){
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("logtournotselectedmsg"));
|
||||
}else {
|
||||
ObservableList<Tour> tourData = this.viewModel.getTourData();
|
||||
tourData.forEach(s -> {
|
||||
if (s.getName().equals(selectedTour.getName())) {
|
||||
ObservableList<Log> logData = this.viewModel.getLogData();
|
||||
AtomicReference<String> newId = new AtomicReference<>();
|
||||
newId.set(UUID.randomUUID().toString());
|
||||
logData.forEach(ss -> {
|
||||
if (ss.getId().equals(newId.get())) {
|
||||
newId.set(UUID.randomUUID().toString());
|
||||
}
|
||||
});
|
||||
LocalDate neuesDatum = null;
|
||||
while (neuesDatum == null) {
|
||||
neuesDatum = AlertHelper.datePicker(ConfigHelper.getLangIniString("datum"));
|
||||
}
|
||||
double neueDauer = AlertHelper.inputNumber(ConfigHelper.getLangIniString("dauer"),
|
||||
ConfigHelper.getLangIniString("dauermsg"),
|
||||
ConfigHelper.getLangIniString("dauer") +
|
||||
ConfigHelper.getLangIniString("doppelpunkt"));
|
||||
double neueStrecke = AlertHelper.inputNumber(ConfigHelper.getLangIniString("strecke"),
|
||||
ConfigHelper.getLangIniString("streckemsg"),
|
||||
ConfigHelper.getLangIniString("strecke") +
|
||||
ConfigHelper.getLangIniString("doppelpunkt"));
|
||||
|
||||
Log newLog = new Log(newId.get(), neueDauer + "", neuesDatum, neueStrecke);
|
||||
logData.add(newLog);
|
||||
s.addLog(newLog);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.viewModel.addLog();
|
||||
}
|
||||
|
||||
@FXML
|
||||
private void delLog(){
|
||||
Log selectedLog = this.viewModel.getSelectedLog();
|
||||
if(selectedLog != null) {
|
||||
this.viewModel.delLog(selectedLog.getId());
|
||||
}else{
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("deltournoselectmsg"));
|
||||
}
|
||||
this.viewModel.delLog();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,9 +154,7 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void logItemSelected(MouseEvent mouseEvent){
|
||||
String selectedItem = logTableView.getSelectionModel().getSelectedItem().getId();
|
||||
this.viewModel.selectLog(selectedItem);
|
||||
System.out.println(selectedItem);
|
||||
this.viewModel.selectLog(logTableView.getSelectionModel().getSelectedItem().getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -249,10 +180,8 @@ public class TourplanerController implements Initializable {
|
||||
* Funktion für noch nicht implementierte sachen wie im Menu der 'Bearbeiten' und 'Optionen' Knopf
|
||||
*/
|
||||
@FXML
|
||||
public void nimpButton(){
|
||||
AlertHelper.inform(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("fktnichtimplementiert"),
|
||||
ConfigHelper.getLangIniString("vergessenodernochnichtsoweit"));
|
||||
private void nimpButton(){
|
||||
this.viewModel.nimpButton();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,19 @@ package tourplaner.viewmodels;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import tourplaner.business.AlertHelper;
|
||||
import javafx.fxml.FXML;
|
||||
import tourplaner.ui.AlertHelper;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class ViewModel {
|
||||
@ -22,6 +28,48 @@ public class ViewModel {
|
||||
private Log selectedLog;
|
||||
|
||||
|
||||
/**
|
||||
* Fügt einen Log eintrag zu einer Tour hinzu.
|
||||
* Ist keine Tour ausgewählt, dann kommt eine Warnung an den User!
|
||||
*/
|
||||
@FXML
|
||||
public void addLog(){
|
||||
if (this.selectedTour == null){
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("logtournotselectedmsg"));
|
||||
}else {
|
||||
this.tourData.forEach(s -> {
|
||||
if (s.getName().equals(this.selectedTour.getName())) {
|
||||
AtomicReference<String> newId = new AtomicReference<>();
|
||||
newId.set(UUID.randomUUID().toString());
|
||||
this.logData.forEach(ss -> {
|
||||
if (ss.getId().equals(newId.get())) {
|
||||
newId.set(UUID.randomUUID().toString());
|
||||
}
|
||||
});
|
||||
LocalDate neuesDatum = null;
|
||||
while (neuesDatum == null) {
|
||||
neuesDatum = AlertHelper.datePicker(ConfigHelper.getLangIniString("datum"));
|
||||
}
|
||||
double neueDauer = AlertHelper.inputNumber(ConfigHelper.getLangIniString("dauer"),
|
||||
ConfigHelper.getLangIniString("dauermsg"),
|
||||
ConfigHelper.getLangIniString("dauer") +
|
||||
ConfigHelper.getLangIniString("doppelpunkt"));
|
||||
double neueStrecke = AlertHelper.inputNumber(ConfigHelper.getLangIniString("strecke"),
|
||||
ConfigHelper.getLangIniString("streckemsg"),
|
||||
ConfigHelper.getLangIniString("strecke") +
|
||||
ConfigHelper.getLangIniString("doppelpunkt"));
|
||||
|
||||
Log newLog = new Log(newId.get(), neueDauer + "", neuesDatum, neueStrecke);
|
||||
this.logData.add(newLog);
|
||||
s.addLog(newLog);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fügt eine neue Tour hinzu
|
||||
*/
|
||||
@ -59,27 +107,33 @@ public class ViewModel {
|
||||
}
|
||||
|
||||
/**
|
||||
* Entfernt ein Log anhand dessen Id
|
||||
* @param id Id des Logs welches entfernt werden soll
|
||||
* Entfernt ein Log anhand des selectierten Logs
|
||||
*/
|
||||
public void delLog(String id){
|
||||
this.logData.removeIf(s -> s.getId().equals(id));
|
||||
AtomicReference<Tour> tourToEdit = new AtomicReference<>();
|
||||
this.tourData.forEach(s -> {
|
||||
if (s.getLogs() != null) {
|
||||
s.getLogs().forEach(ss -> {
|
||||
if (ss.getId().equals(id)) {
|
||||
tourToEdit.set(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
public void delLog(){
|
||||
if(this.selectedLog != null) {
|
||||
this.logData.removeIf(s -> s.getId().equals(this.selectedLog.getId()));
|
||||
AtomicReference<Tour> tourToEdit = new AtomicReference<>();
|
||||
this.tourData.forEach(s -> {
|
||||
if (s.getLogs() != null) {
|
||||
s.getLogs().forEach(ss -> {
|
||||
if (ss.getId().equals(this.selectedLog.getId())) {
|
||||
tourToEdit.set(s);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (tourToEdit.get() != null){
|
||||
Tour toEdit = tourToEdit.get();
|
||||
toEdit.delLog(id);
|
||||
this.tourData.removeIf(s -> s.getName().equals(toEdit.getName()));
|
||||
this.tourData.add(toEdit);
|
||||
if (tourToEdit.get() != null){
|
||||
Tour toEdit = tourToEdit.get();
|
||||
toEdit.delLog(this.selectedLog.getId());
|
||||
this.tourData.removeIf(s -> s.getName().equals(toEdit.getName()));
|
||||
this.tourData.add(toEdit);
|
||||
this.selectedLog = null;
|
||||
}
|
||||
}else{
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("deltournoselectmsg"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,6 +255,7 @@ public class ViewModel {
|
||||
tourData.removeIf(s -> s.getName().equals(tourname));
|
||||
tourNamen.removeIf(s -> s.equals(tourname));
|
||||
logData.removeIf(s -> true);
|
||||
setSelectedTour(null);
|
||||
}catch (NullPointerException e){
|
||||
LogHelper.error(ConfigHelper.getLangIniString("keinetourselected"),
|
||||
ConfigHelper.getLangIniString("deltournoselect"));
|
||||
@ -212,8 +267,66 @@ public class ViewModel {
|
||||
|
||||
/**
|
||||
* Sucht eine Tour
|
||||
* @param sucheInput Text nach dem gesucht werden soll
|
||||
*/
|
||||
public void suche(String suchString){
|
||||
public void suche(String sucheInput){
|
||||
if(sucheInput.isEmpty()){
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("suchfeldleer"),
|
||||
ConfigHelper.getLangIniString("suchtextzuerst"));
|
||||
}
|
||||
// TODO: 19.03.2021 Suchlogik
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnet github im standart browser
|
||||
*
|
||||
*/
|
||||
public void gitWebBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "gitrepo"), "Git");
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnet Java Doc im standart browser
|
||||
*
|
||||
*/
|
||||
public void javaDocBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "javadoc"), "JavaDoc");
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnet Doxygen Doc im standart browser
|
||||
*
|
||||
*/
|
||||
public void doxygenDocBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "doxygendoc"), "Doxygen");
|
||||
}
|
||||
|
||||
/**
|
||||
* Öffnet einen link im Standart Browser
|
||||
* @param uriString
|
||||
* @param appname
|
||||
*/
|
||||
private void openBrowser(String uriString, String appname){
|
||||
Desktop desktop = java.awt.Desktop.getDesktop();
|
||||
try {
|
||||
URI oURL = new URI(
|
||||
uriString);
|
||||
desktop.browse(oURL);
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
LogHelper.error(e.getMessage(), ConfigHelper.getLangIniString("openbrowsererror") + appname);
|
||||
AlertHelper.exerror(ConfigHelper.getLangIniString("browserexception"),
|
||||
ConfigHelper.getLangIniString("openbrowsererror") + appname,
|
||||
ConfigHelper.getLangIniString("browserexceptionmsg"), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Funktion für noch nicht implementierte sachen wie im Menu der 'Bearbeiten' und 'Optionen' Knopf
|
||||
*/
|
||||
public void nimpButton(){
|
||||
AlertHelper.inform(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("fktnichtimplementiert"),
|
||||
ConfigHelper.getLangIniString("vergessenodernochnichtsoweit"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user