Compare commits

...

3 Commits
0.2.1 ... 0.2.4

Author SHA1 Message Date
2265014db3 Edit Tour/Log Bugfixes 2021-04-13 14:52:36 +02:00
100da38493 Edit Log + Tour 2021-04-13 14:16:07 +02:00
0b8f8f996d Logik von Controller -> ViewModel verschoben 2021-03-19 22:40:30 +01:00
8 changed files with 508 additions and 161 deletions

124
.idea/uiDesigner.xml generated Normal file
View 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>

View File

@ -8,3 +8,6 @@
2021-03-18 23:05:00 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt! 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: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-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!
2021-03-19 23:23:36 ERROR ViewModel -> DelTour:33 - Keine Tour ausgewählt!

View File

@ -1,7 +1,5 @@
package tourplaner.data; package tourplaner.data;
import tourplaner.business.PostgresHelper;
import java.sql.Connection; import java.sql.Connection;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;

View File

@ -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.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.Statement; import java.sql.Statement;

View File

@ -32,26 +32,13 @@
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--> -->
<?import javafx.geometry.Insets?> <?import javafx.geometry.*?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.*?>
<?import javafx.scene.control.Label?> <?import javafx.scene.layout.*?>
<?import javafx.scene.control.ListView?> <?import javafx.scene.paint.*?>
<?import javafx.scene.control.Menu?> <?import javafx.scene.text.*?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?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.2" xmlns:fx="http://javafx.com/fxml/1" fx:controller="tourplaner.ui.TourplanerController"> <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">
<children> <children>
<MenuBar VBox.vgrow="NEVER"> <MenuBar VBox.vgrow="NEVER">
<menus> <menus>
@ -86,6 +73,7 @@
<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 layoutX="117.0" mnemonicParsing="false" onAction="#editTourBtn" text="Edit" />
</children></AnchorPane> </children></AnchorPane>
<TextField fx:id="sucheInput" promptText="Suche..." /> <TextField fx:id="sucheInput" promptText="Suche..." />
<Button fx:id="sucheButton" mnemonicParsing="false" onAction="#suche" text="Suchen" /> <Button fx:id="sucheButton" mnemonicParsing="false" onAction="#suche" text="Suchen" />
@ -156,7 +144,7 @@
<children> <children>
<AnchorPane prefWidth="676.0"> <AnchorPane prefWidth="676.0">
<children> <children>
<HBox id="HBox" alignment="CENTER_LEFT" prefWidth="702.0" spacing="5.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.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">
<children> <children>
<Label text="Logs:"> <Label text="Logs:">
<HBox.margin> <HBox.margin>
@ -170,9 +158,10 @@
</Button> </Button>
<Button fx:id="logDel" mnemonicParsing="false" onAction="#delLog" prefWidth="21.0" text="-" textAlignment="CENTER"> <Button fx:id="logDel" mnemonicParsing="false" onAction="#delLog" prefWidth="21.0" text="-" textAlignment="CENTER">
<HBox.margin> <HBox.margin>
<Insets right="10.0" /> <Insets />
</HBox.margin> </HBox.margin>
</Button> </Button>
<Button mnemonicParsing="false" onAction="#editLogBtn" text="Edit" />
</children> </children>
<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" />

View File

@ -1,18 +1,19 @@
package tourplaner.business; package tourplaner.ui;
import javafx.event.EventHandler;
import javafx.scene.Scene; import javafx.scene.Scene;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextArea; import javafx.scene.control.TextArea;
import javafx.scene.image.Image; import javafx.scene.image.Image;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.text.Text;
import javafx.stage.Stage; import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import tourplaner.business.ConfigHelper;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.StringWriter; import java.io.StringWriter;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -114,17 +115,22 @@ public class AlertHelper {
* @param msg Nachricht des Dialogs * @param msg Nachricht des Dialogs
* @return Null bei keiner eingabe * @return Null bei keiner eingabe
*/ */
public static String inputText(String title, String header, String msg) { public static String inputText(String title, String header, String msg, String content) {
String returnStr = ""; String returnStr = null;
while (returnStr.isEmpty()) { while (returnStr == null) {
Optional<String> result = inputHelper(title, header, msg); Optional<String> result = inputHelper(title, header, msg, content);
AtomicReference<String> returnText = new AtomicReference<>(""); AtomicReference<String> returnText = new AtomicReference<>("");
result.ifPresent(returnText::set); if(result.isPresent()) {
returnStr = returnText.get(); result.ifPresent(returnText::set);
if (returnStr.isEmpty()) { returnStr = returnText.get();
AlertHelper.warn(ConfigHelper.getLangIniString("tournametitle"), if (returnStr.isEmpty()) {
ConfigHelper.getLangIniString("achtung"), AlertHelper.warn(ConfigHelper.getLangIniString("tournametitle"),
ConfigHelper.getLangIniString("keintextimfeld")); ConfigHelper.getLangIniString("achtung"),
ConfigHelper.getLangIniString("keintextimfeld"));
}
}else{
return "";
} }
} }
return returnStr; return returnStr;
@ -137,11 +143,12 @@ public class AlertHelper {
* @param msg Nachricht des Dialogs * @param msg Nachricht des Dialogs
* @return Result des Inputs * @return Result des Inputs
*/ */
private static Optional<String> inputHelper(String title, String header, String msg){ private static Optional<String> inputHelper(String title, String header, String msg, String content){
TextInputDialog dialog = new TextInputDialog(); TextInputDialog dialog = new TextInputDialog(content);
dialog.setTitle(title); dialog.setTitle(title);
dialog.setHeaderText(header); dialog.setHeaderText(header);
dialog.setContentText(msg); dialog.setContentText(msg);
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
stage.getIcons().add( stage.getIcons().add(
new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo"))); new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
@ -150,48 +157,53 @@ public class AlertHelper {
} }
/** /**
* Positive Nummer eingabe. Wenn Convertierung zu int nicht klappt -> -1 * Positive Nummer eingabe. Wenn Convertierung zu int nicht klappt -> -1
* @param title Title des Dialogs * @param title Title des Dialogs
* @param header Header des Dialogs * @param header Header des Dialogs
* @param msg Nachricht des Dialogs * @param msg Nachricht des Dialogs
* @return -1 bei error sonst ein Int * @return -1.0 bei error sonst ein double
*/ */
public static int inputNumber(String title, String header, String msg) { public static double inputNumber(String title, String header, String msg, String content) {
int returnInt = -2; double returnDouble = -2.0;
while (returnInt <= 0 ) { while (returnDouble < -1.0) {
Optional<String> result = inputHelper(title, header, msg); Optional<String> result = inputHelper(title, header, msg, content);
AtomicReference<Integer> returnText = new AtomicReference<Integer>(-1); AtomicReference<Double> returnText = new AtomicReference<Double>(-1.0);
result.ifPresent(s -> { result.ifPresent(s -> {
try { try {
int resultInt = Integer.parseInt(result.get()); double resultDouble = Double.parseDouble(result.get());
returnText.set(resultInt); // int resultInt = Integer.parseInt(result.get());
if (resultInt < 0){ returnText.set(resultDouble);
if (resultDouble < 0){
AlertHelper.warn(title, ConfigHelper.getLangIniString("achtung"), ConfigHelper.getLangIniString("nurpositivezahlen")); AlertHelper.warn(title, ConfigHelper.getLangIniString("achtung"), ConfigHelper.getLangIniString("nurpositivezahlen"));
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
AlertHelper.warn(title, ConfigHelper.getLangIniString("achtung"), ConfigHelper.getLangIniString("nurzahlen")); AlertHelper.warn(title, ConfigHelper.getLangIniString("achtung"), ConfigHelper.getLangIniString("nurzahlen"));
returnText.set(-1); returnText.set(-2.0);
} }
}); });
returnInt = returnText.get(); returnDouble = returnText.get();
} }
return returnDouble;
return returnInt;
} }
/** /**
* Date Picker Dialog, sobald ein Datum ausgewählt wurde, wird es automatisch bestätigt und der dialog geschlossen * Date Picker Dialog, sobald ein Datum ausgewählt wurde, wird es automatisch bestätigt und der dialog geschlossen
* @param title Name des Dialogs * @param content Aktuelles datum
* @return Gewähltes datum * @return Gewähltes datum
*/ */
public static LocalDate datePicker(String title){ public static LocalDate datePicker(LocalDate content){
final DatePicker datePicker = new DatePicker(LocalDate.now()); final DatePicker datePicker = new DatePicker(content);
final Stage stage = new Stage(); final Stage stage = new Stage();
stage.getIcons().add( stage.getIcons().add(
new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo"))); new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
AtomicReference<LocalDate> selectedDate = new AtomicReference<>(); AtomicReference<LocalDate> selectedDate = new AtomicReference<>();
stage.setOnCloseRequest(ev -> {
stage.close();
});
datePicker.setOnAction(event -> { datePicker.setOnAction(event -> {
LocalDate date = datePicker.getValue(); LocalDate date = datePicker.getValue();
System.out.println("Selected date: " + date); System.out.println("Selected date: " + date);

View File

@ -9,7 +9,6 @@ import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent; import javafx.scene.input.MouseEvent;
import tourplaner.business.AlertHelper;
import tourplaner.business.ConfigHelper; import tourplaner.business.ConfigHelper;
import tourplaner.business.LogHelper; import tourplaner.business.LogHelper;
import tourplaner.object.Log; import tourplaner.object.Log;
@ -28,7 +27,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class TourplanerController implements Initializable { public class TourplanerController implements Initializable {
//VM //VM
public ViewModel viewModel = new ViewModel(); private final ViewModel viewModel = new ViewModel();
//Tour list -> links //Tour list -> links
public ListView<String> TourListView = new ListView<>(); public ListView<String> TourListView = new ListView<>();
//Tabs zu Tour -> rechts oben //Tabs zu Tour -> rechts oben
@ -41,13 +40,23 @@ public class TourplanerController implements Initializable {
public TableView<Log> logTableView; public TableView<Log> logTableView;
public TableColumn<Log, String> logDauerCol, logStreckeCol, logDatumCol; public TableColumn<Log, String> logDauerCol, logStreckeCol, logDatumCol;
@FXML
private void editTourBtn(){
this.viewModel.editTour();
}
@FXML
private void editLogBtn(){
this.viewModel.editLog();
}
/** /**
* Öffnet github im standart browser * Öffnet github im standart browser
* *
*/ */
@FXML @FXML
private void gitWebBrowser(){ private void gitWebBrowser(){
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "gitrepo"), "Git"); this.viewModel.gitWebBrowser();
} }
/** /**
@ -56,7 +65,7 @@ public class TourplanerController implements Initializable {
*/ */
@FXML @FXML
private void javaDocBrowser(){ private void javaDocBrowser(){
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "javadoc"), "JavaDoc"); this.viewModel.javaDocBrowser();
} }
/** /**
@ -65,27 +74,10 @@ public class TourplanerController implements Initializable {
*/ */
@FXML @FXML
private void doxygenDocBrowser(){ 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 * Wird gestartet wenn eine Tour in der Tour listView ausgewählt wird
@ -139,7 +131,6 @@ public class TourplanerController implements Initializable {
this.beschreibungTableView.getItems().removeIf(s -> true); //löscht alles aus der tabelle this.beschreibungTableView.getItems().removeIf(s -> true); //löscht alles aus der tabelle
this.titleTextView.setText(ConfigHelper.getLangIniString("keinetourselected")); this.titleTextView.setText(ConfigHelper.getLangIniString("keinetourselected"));
this.viewModel.delTour(); this.viewModel.delTour();
this.viewModel.setSelectedTour(null);
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected"))); logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinetourselected")));
} }
@ -149,14 +140,7 @@ public class TourplanerController implements Initializable {
*/ */
@FXML @FXML
private void suche(){ private void suche(){
String sucheInput = this.sucheInput.getText(); this.viewModel.suche(this.sucheInput.getText());
if(sucheInput.isEmpty()){
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
ConfigHelper.getLangIniString("suchfeldleer"),
ConfigHelper.getLangIniString("suchtextzuerst"));
}else {
this.viewModel.suche(sucheInput);
}
} }
/** /**
@ -165,54 +149,13 @@ public class TourplanerController implements Initializable {
*/ */
@FXML @FXML
private void addLog(){ private void addLog(){
Tour selectedTour = this.viewModel.getSelectedTour(); this.viewModel.addLog();
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);
}
});
}
} }
@FXML @FXML
private void delLog(){ private void delLog(){
Log selectedLog = this.viewModel.getSelectedLog(); this.viewModel.delLog();
if(selectedLog != null) {
this.viewModel.delLog(selectedLog.getId());
}else{
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
ConfigHelper.getLangIniString("keinetourselected"),
ConfigHelper.getLangIniString("deltournoselectmsg"));
}
} }
/** /**
@ -221,9 +164,7 @@ public class TourplanerController implements Initializable {
*/ */
@FXML @FXML
private void logItemSelected(MouseEvent mouseEvent){ private void logItemSelected(MouseEvent mouseEvent){
String selectedItem = logTableView.getSelectionModel().getSelectedItem().getId(); this.viewModel.selectLog(logTableView.getSelectionModel().getSelectedItem().getId());
this.viewModel.selectLog(selectedItem);
System.out.println(selectedItem);
} }
/** /**
@ -249,10 +190,8 @@ public class TourplanerController implements Initializable {
* Funktion für noch nicht implementierte sachen wie im Menu der 'Bearbeiten' und 'Optionen' Knopf * Funktion für noch nicht implementierte sachen wie im Menu der 'Bearbeiten' und 'Optionen' Knopf
*/ */
@FXML @FXML
public void nimpButton(){ private void nimpButton(){
AlertHelper.inform(ConfigHelper.getLangIniString("achtung"), this.viewModel.nimpButton();
ConfigHelper.getLangIniString("fktnichtimplementiert"),
ConfigHelper.getLangIniString("vergessenodernochnichtsoweit"));
} }
} }

View File

@ -2,12 +2,18 @@ package tourplaner.viewmodels;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import tourplaner.business.AlertHelper; import tourplaner.ui.AlertHelper;
import tourplaner.business.ConfigHelper; import tourplaner.business.ConfigHelper;
import tourplaner.business.LogHelper; import tourplaner.business.LogHelper;
import tourplaner.object.Log; import tourplaner.object.Log;
import tourplaner.object.Tour; import tourplaner.object.Tour;
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.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -22,15 +28,69 @@ public class ViewModel {
private Log selectedLog; private Log selectedLog;
/** /**
* Fügt eine neue Tour hinzu * Bearbeitet eine bereits bestehende Tour
* prüft ob eine tour ausgewählt ist
*/ */
public void addTour(){ public void editTour(){
if (this.selectedTour == null){
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
ConfigHelper.getLangIniString("keinetourselected"),
ConfigHelper.getLangIniString("logtournotselectedmsg"));
}else {
AtomicInteger index = new AtomicInteger(-1);
AtomicInteger aktIndex = new AtomicInteger(-1);
this.tourData.forEach(s -> {
index.getAndIncrement();
if (s.getName().equals(this.selectedTour.getName())) {
aktIndex.set(index.intValue());
}
});
if(aktIndex.intValue() != -1){
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 boolean tourNameInputDuplicatCheck(String content, boolean checkDuplicate){
while(this.neueTourName == null) { while(this.neueTourName == null) {
this.neueTourName = AlertHelper.inputText(ConfigHelper.getLangIniString("tournametitle"), this.neueTourName = AlertHelper.inputText(ConfigHelper.getLangIniString("tournametitle"),
ConfigHelper.getLangIniString("tournameheader"), ConfigHelper.getLangIniString("tournameheader"),
ConfigHelper.getLangIniString("tournamemsg")); 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"), AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
ConfigHelper.getLangIniString("namevergebenheader"), ConfigHelper.getLangIniString("namevergebenheader"),
ConfigHelper.getLangIniString("namevergebenmsg1") ConfigHelper.getLangIniString("namevergebenmsg1")
@ -39,16 +99,53 @@ public class ViewModel {
this.neueTourName = null; 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 boolean tourStartInput(String content){
while(this.neueTourStart == null){ while(this.neueTourStart == null){
this.neueTourStart = AlertHelper.inputText(ConfigHelper.getLangIniString("startpunkttitle"), this.neueTourStart = AlertHelper.inputText(ConfigHelper.getLangIniString("startpunkttitle"),
ConfigHelper.getLangIniString("startpunktheader"), ConfigHelper.getLangIniString("startpunktheader"),
ConfigHelper.getLangIniString("startpunktmsg")); 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 boolean tourZielInput(String content){
while(this.neueTourZiel == null){ while(this.neueTourZiel == null){
this.neueTourZiel = AlertHelper.inputText(ConfigHelper.getLangIniString("zielpunkttitle"), this.neueTourZiel = AlertHelper.inputText(ConfigHelper.getLangIniString("zielpunkttitle"),
ConfigHelper.getLangIniString("zielpunktheader"), ConfigHelper.getLangIniString("zielpunktheader"),
ConfigHelper.getLangIniString("zielpunktmsg")); ConfigHelper.getLangIniString("zielpunktmsg"), content);
if(this.neueTourZiel.isEmpty()){
return false;
}
} }
return false;
}
/**
* Fügt eine neue Tour hinzu
*/
public void addTour(){
tourNameInput();
tourStartInput("");
tourZielInput("");
if (getTour(this.neueTourName) == null) { if (getTour(this.neueTourName) == null) {
tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel)); tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
tourNamen.add(this.neueTourName); tourNamen.add(this.neueTourName);
@ -58,28 +155,151 @@ public class ViewModel {
this.neueTourName = null; this.neueTourName = null;
} }
private boolean keineTourSelected(){
if (this.selectedTour == null){
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
ConfigHelper.getLangIniString("keinetourselected"),
ConfigHelper.getLangIniString("logtournotselectedmsg"));
return true;
}else {
return false;
}
}
/** /**
* Entfernt ein Log anhand dessen Id * Bearbeitet einen gewählten Log eintrag
* @param id Id des Logs welches entfernt werden soll
*/ */
public void delLog(String id){ public void editLog(){
this.logData.removeIf(s -> s.getId().equals(id)); AtomicReference<Tour> tourAkt = new AtomicReference<>();
AtomicReference<Tour> tourToEdit = new AtomicReference<>(); AtomicReference<Log> logAkt = new AtomicReference<>();
this.tourData.forEach(s -> { this.tourData.forEach(tourd -> {
if (s.getLogs() != null) { if(tourd.getName().equals(this.selectedTour.getName())) {
s.getLogs().forEach(ss -> { tourd.getLogs().forEach(log -> {
if (ss.getId().equals(id)) { if(this.selectedLog.getId().equals(log.getId())){
tourToEdit.set(s); logAkt.set(log);
tourAkt.set(tourd);
} }
}); });
} }
}); });
double dauer = dauerInput(this.selectedLog.getDauer());
double strecke = -1;
LocalDate datum = null;
if (dauer >= 0) {
strecke = streckeInput(this.selectedLog.getStrecke() + "");
if (strecke >= 0) {
datum = dateInput(this.selectedLog.getDatum());
if(datum != null){
Log newLog = new Log(this.selectedLog.getId(), dauer + "", datum,strecke);
this.logData.removeIf(ld -> ld.getId().equals(this.selectedLog.getId()));
this.logData.add(newLog);
tourAkt.get().delLog(this.selectedLog.getId());
tourAkt.get().addLog(newLog);
this.tourData.removeIf(td -> td.getName().equals(this.selectedTour.getName()));
this.tourData.add(tourAkt.get());
}
}
}
}
if (tourToEdit.get() != null){ /**
Tour toEdit = tourToEdit.get(); * Eingabe der Strecke bis diese Korrekt ist
toEdit.delLog(id); * @return Korrekte eingegebene Strecke
this.tourData.removeIf(s -> s.getName().equals(toEdit.getName())); */
this.tourData.add(toEdit); private double streckeInput(String content){
return AlertHelper.inputNumber(ConfigHelper.getLangIniString("strecke"),
ConfigHelper.getLangIniString("streckemsg"),
ConfigHelper.getLangIniString("strecke") +
ConfigHelper.getLangIniString("doppelpunkt"), content);
}
/**
* Eingabe der Dauer bis sie korrekt ist
* @return Die eingegebene Dauer
*/
private double dauerInput(String content){
return AlertHelper.inputNumber(ConfigHelper.getLangIniString("dauer"),
ConfigHelper.getLangIniString("dauermsg"),
ConfigHelper.getLangIniString("dauer") +
ConfigHelper.getLangIniString("doppelpunkt"), content);
}
/**
* Datum eingabe bis diese Korrekt ist
* @return Das eingegebene korekte Datum
*/
private LocalDate dateInput(LocalDate date){
LocalDate neuesDatum = null;
neuesDatum = AlertHelper.datePicker(date);
System.out.println(neuesDatum);
return neuesDatum;
}
/**
* Fügt einen Log eintrag zu einer Tour hinzu.
* Ist keine Tour ausgewählt, dann kommt eine Warnung an den User!
*/
public void addLog(){
if (!keineTourSelected()){
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());
}
});
double dauer = dauerInput("");
double strecke;
LocalDate date = null;
if(dauer >= 0) {
strecke = streckeInput("");
if (strecke >= 0.0) {
date = dateInput(LocalDate.now());
if (date != null){
Log newLog = new Log(newId.get(), dauer + "", date, strecke);
this.logData.add(newLog);
s.addLog(newLog);
}
}
}
}
});
}
}
/**
* Entfernt ein Log anhand des selectierten Logs
*/
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(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 +421,7 @@ public class ViewModel {
tourData.removeIf(s -> s.getName().equals(tourname)); tourData.removeIf(s -> s.getName().equals(tourname));
tourNamen.removeIf(s -> s.equals(tourname)); tourNamen.removeIf(s -> s.equals(tourname));
logData.removeIf(s -> true); logData.removeIf(s -> true);
setSelectedTour(null);
}catch (NullPointerException e){ }catch (NullPointerException e){
LogHelper.error(ConfigHelper.getLangIniString("keinetourselected"), LogHelper.error(ConfigHelper.getLangIniString("keinetourselected"),
ConfigHelper.getLangIniString("deltournoselect")); ConfigHelper.getLangIniString("deltournoselect"));
@ -212,8 +433,66 @@ public class ViewModel {
/** /**
* Sucht eine Tour * 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"));
} }
} }