Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
100da38493 | |||
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,6 @@
|
||||
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!
|
||||
2021-03-19 23:23:36 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;
|
@ -32,26 +32,13 @@
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
-->
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.ListView?>
|
||||
<?import javafx.scene.control.Menu?>
|
||||
<?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?>
|
||||
<?import javafx.geometry.*?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import javafx.scene.paint.*?>
|
||||
<?import javafx.scene.text.*?>
|
||||
|
||||
<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>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
@ -86,6 +73,7 @@
|
||||
<Button fx:id="tourAdd" layoutX="58.0" mnemonicParsing="false" onAction="#addTour" text="+" />
|
||||
<Label layoutX="14.0" layoutY="4.0" text="Tours" />
|
||||
<Button fx:id="tourDel" layoutX="89.0" mnemonicParsing="false" onAction="#delTour" text="-" />
|
||||
<Button layoutX="117.0" mnemonicParsing="false" onAction="#editTourBtn" text="Edit" />
|
||||
</children></AnchorPane>
|
||||
<TextField fx:id="sucheInput" promptText="Suche..." />
|
||||
<Button fx:id="sucheButton" mnemonicParsing="false" onAction="#suche" text="Suchen" />
|
||||
@ -156,7 +144,7 @@
|
||||
<children>
|
||||
<AnchorPane prefWidth="676.0">
|
||||
<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>
|
||||
<Label text="Logs:">
|
||||
<HBox.margin>
|
||||
@ -170,9 +158,10 @@
|
||||
</Button>
|
||||
<Button fx:id="logDel" mnemonicParsing="false" onAction="#delLog" prefWidth="21.0" text="-" textAlignment="CENTER">
|
||||
<HBox.margin>
|
||||
<Insets right="10.0" />
|
||||
<Insets />
|
||||
</HBox.margin>
|
||||
</Button>
|
||||
<Button mnemonicParsing="false" onAction="#editLogBtn" text="Edit" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
|
||||
|
@ -1,18 +1,19 @@
|
||||
package tourplaner.business;
|
||||
package tourplaner.ui;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
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 javafx.stage.WindowEvent;
|
||||
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;
|
||||
|
||||
@ -114,10 +115,10 @@ public class AlertHelper {
|
||||
* @param msg Nachricht des Dialogs
|
||||
* @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 = "";
|
||||
while (returnStr.isEmpty()) {
|
||||
Optional<String> result = inputHelper(title, header, msg);
|
||||
Optional<String> result = inputHelper(title, header, msg, content);
|
||||
AtomicReference<String> returnText = new AtomicReference<>("");
|
||||
result.ifPresent(returnText::set);
|
||||
returnStr = returnText.get();
|
||||
@ -137,11 +138,12 @@ public class AlertHelper {
|
||||
* @param msg Nachricht des Dialogs
|
||||
* @return Result des Inputs
|
||||
*/
|
||||
private static Optional<String> inputHelper(String title, String header, String msg){
|
||||
TextInputDialog dialog = new TextInputDialog();
|
||||
private static Optional<String> inputHelper(String title, String header, String msg, String content){
|
||||
TextInputDialog dialog = new TextInputDialog(content);
|
||||
dialog.setTitle(title);
|
||||
dialog.setHeaderText(header);
|
||||
dialog.setContentText(msg);
|
||||
|
||||
Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow();
|
||||
stage.getIcons().add(
|
||||
new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
|
||||
@ -150,48 +152,53 @@ public class AlertHelper {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Positive Nummer eingabe. Wenn Convertierung zu int nicht klappt -> -1
|
||||
* @param title Title des Dialogs
|
||||
* @param header Header 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) {
|
||||
int returnInt = -2;
|
||||
while (returnInt <= 0 ) {
|
||||
Optional<String> result = inputHelper(title, header, msg);
|
||||
AtomicReference<Integer> returnText = new AtomicReference<Integer>(-1);
|
||||
public static double inputNumber(String title, String header, String msg, String content) {
|
||||
double returnDouble = -2.0;
|
||||
while (returnDouble < -1.0) {
|
||||
Optional<String> result = inputHelper(title, header, msg, content);
|
||||
AtomicReference<Double> returnText = new AtomicReference<Double>(-1.0);
|
||||
result.ifPresent(s -> {
|
||||
try {
|
||||
int resultInt = Integer.parseInt(result.get());
|
||||
returnText.set(resultInt);
|
||||
if (resultInt < 0){
|
||||
double resultDouble = Double.parseDouble(result.get());
|
||||
// int resultInt = Integer.parseInt(result.get());
|
||||
returnText.set(resultDouble);
|
||||
if (resultDouble < 0){
|
||||
AlertHelper.warn(title, ConfigHelper.getLangIniString("achtung"), ConfigHelper.getLangIniString("nurpositivezahlen"));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
AlertHelper.warn(title, ConfigHelper.getLangIniString("achtung"), ConfigHelper.getLangIniString("nurzahlen"));
|
||||
returnText.set(-1);
|
||||
returnText.set(-2.0);
|
||||
}
|
||||
|
||||
});
|
||||
returnInt = returnText.get();
|
||||
returnDouble = returnText.get();
|
||||
}
|
||||
|
||||
return returnInt;
|
||||
return returnDouble;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public static LocalDate datePicker(String title){
|
||||
final DatePicker datePicker = new DatePicker(LocalDate.now());
|
||||
public static LocalDate datePicker(LocalDate content){
|
||||
final DatePicker datePicker = new DatePicker(content);
|
||||
final Stage stage = new Stage();
|
||||
stage.getIcons().add(
|
||||
new Image("file:"+ ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "start", "logo")));
|
||||
AtomicReference<LocalDate> selectedDate = new AtomicReference<>();
|
||||
stage.setOnCloseRequest(ev -> {
|
||||
stage.close();
|
||||
});
|
||||
|
||||
datePicker.setOnAction(event -> {
|
||||
LocalDate date = datePicker.getValue();
|
||||
System.out.println("Selected date: " + date);
|
@ -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
|
||||
@ -41,13 +40,23 @@ public class TourplanerController implements Initializable {
|
||||
public TableView<Log> logTableView;
|
||||
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
|
||||
*
|
||||
*/
|
||||
@FXML
|
||||
private void gitWebBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "gitrepo"), "Git");
|
||||
this.viewModel.gitWebBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -56,7 +65,7 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void javaDocBrowser(){
|
||||
openBrowser(ConfigHelper.getIniString(ConfigHelper.getStandartConfig(), "hilfe", "javadoc"), "JavaDoc");
|
||||
this.viewModel.javaDocBrowser();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,27 +74,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 +131,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 +140,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 +149,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 +164,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 +190,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,12 +2,18 @@ package tourplaner.viewmodels;
|
||||
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import tourplaner.business.AlertHelper;
|
||||
import tourplaner.ui.AlertHelper;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
import tourplaner.business.LogHelper;
|
||||
import tourplaner.object.Log;
|
||||
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.AtomicReference;
|
||||
|
||||
@ -22,14 +28,53 @@ public class ViewModel {
|
||||
private Log selectedLog;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fügt eine neue Tour hinzu
|
||||
* Bearbeitet eine bereits bestehende Tour
|
||||
*/
|
||||
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){
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
private void tourNameInput(String content){
|
||||
while(this.neueTourName == null) {
|
||||
this.neueTourName = AlertHelper.inputText(ConfigHelper.getLangIniString("tournametitle"),
|
||||
ConfigHelper.getLangIniString("tournameheader"),
|
||||
ConfigHelper.getLangIniString("tournamemsg"));
|
||||
ConfigHelper.getLangIniString("tournamemsg"), content);
|
||||
if (getTour(this.neueTourName) != null) {
|
||||
AlertHelper.warn(ConfigHelper.getLangIniString("achtung"),
|
||||
ConfigHelper.getLangIniString("namevergebenheader"),
|
||||
@ -39,16 +84,40 @@ public class ViewModel {
|
||||
this.neueTourName = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Input der Startpunkt der Tour
|
||||
* Wird erst beendet wenn die eingabe erfolgreich war
|
||||
*/
|
||||
private void tourStartInput(String content){
|
||||
while(this.neueTourStart == null){
|
||||
this.neueTourStart = AlertHelper.inputText(ConfigHelper.getLangIniString("startpunkttitle"),
|
||||
ConfigHelper.getLangIniString("startpunktheader"),
|
||||
ConfigHelper.getLangIniString("startpunktmsg"));
|
||||
ConfigHelper.getLangIniString("startpunktmsg"), content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Input des Zielpunktes der Tour
|
||||
* Wird erst beendet wenn die eingabe erfolgreich war
|
||||
*/
|
||||
private void tourZielInput(String content){
|
||||
while(this.neueTourZiel == null){
|
||||
this.neueTourZiel = AlertHelper.inputText(ConfigHelper.getLangIniString("zielpunkttitle"),
|
||||
ConfigHelper.getLangIniString("zielpunktheader"),
|
||||
ConfigHelper.getLangIniString("zielpunktmsg"));
|
||||
ConfigHelper.getLangIniString("zielpunktmsg"), content);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fügt eine neue Tour hinzu
|
||||
*/
|
||||
public void addTour(){
|
||||
tourNameInput("");
|
||||
tourStartInput("");
|
||||
tourZielInput("");
|
||||
if (getTour(this.neueTourName) == null) {
|
||||
tourData.add(new Tour(this.neueTourName, "TBD", "TBD", 0, this.neueTourStart, this.neueTourZiel));
|
||||
tourNamen.add(this.neueTourName);
|
||||
@ -58,28 +127,151 @@ public class ViewModel {
|
||||
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
|
||||
* @param id Id des Logs welches entfernt werden soll
|
||||
* Bearbeitet einen gewählten Log eintrag
|
||||
*/
|
||||
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 editLog(){
|
||||
AtomicReference<Tour> tourAkt = new AtomicReference<>();
|
||||
AtomicReference<Log> logAkt = new AtomicReference<>();
|
||||
this.tourData.forEach(tourd -> {
|
||||
if(tourd.getName().equals(this.selectedTour.getName())) {
|
||||
tourd.getLogs().forEach(log -> {
|
||||
if(this.selectedLog.getId().equals(log.getId())){
|
||||
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();
|
||||
toEdit.delLog(id);
|
||||
this.tourData.removeIf(s -> s.getName().equals(toEdit.getName()));
|
||||
this.tourData.add(toEdit);
|
||||
/**
|
||||
* Eingabe der Strecke bis diese Korrekt ist
|
||||
* @return Korrekte eingegebene Strecke
|
||||
*/
|
||||
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 +393,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 +405,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"));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user