Progress Bar
This commit is contained in:
parent
9472a5537a
commit
49b6407ce6
@ -3,7 +3,10 @@ package tourplaner.business;
|
||||
import tourplaner.data.DbConnect;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
import tourplaner.ui.AlertHelper;
|
||||
import tourplaner.ui.ProgressBar;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -28,10 +31,16 @@ public class Exporter {
|
||||
* @throws IOException Fehler beim File erstellen
|
||||
*/
|
||||
public void doExport() throws IOException {
|
||||
ProgressBar progressBar = new ProgressBar("Exportieren");
|
||||
int step = progressBar.getProgressSize(4, 100);
|
||||
ArrayList<Tour> data = new DbConnect().getAllTouren();
|
||||
progressBar.addProgress(step);
|
||||
FileWriter fileWriter = new FileWriter(path + ".json");
|
||||
progressBar.addProgress(step);
|
||||
JsonHelper.getJsonFromObj(data, fileWriter);
|
||||
progressBar.addProgress(step);
|
||||
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
|
||||
progressBar.addProgress(step);
|
||||
bufferedWriter.close();
|
||||
}
|
||||
|
||||
@ -41,15 +50,23 @@ public class Exporter {
|
||||
*/
|
||||
public void doImport() throws IOException {
|
||||
this.touren = JsonHelper.getTourenFromJson(new FileReader(this.path));
|
||||
ProgressBar progressBar = new ProgressBar("Importiere Daten");
|
||||
DbConnect dbConnect = new DbConnect();
|
||||
progressBar.addProgress(5);
|
||||
dbConnect.delAllData();
|
||||
progressBar.addProgress(5);
|
||||
int size = progressBar.getProgressSize(this.touren.size() * 3, 100);
|
||||
for (Tour tour:this.touren) {
|
||||
new DirectionMap(tour.getStart(), tour.getZiel(), tour.getName());
|
||||
progressBar.addProgress(size);
|
||||
dbConnect.addTour(tour);
|
||||
progressBar.addProgress(size);
|
||||
ArrayList<Log> logs = tour.getLogs();
|
||||
for (Log log:logs) {
|
||||
dbConnect.addLog(tour.getName(), log);
|
||||
}
|
||||
progressBar.addProgress(size);
|
||||
}
|
||||
progressBar.addProgress(size);
|
||||
}
|
||||
}
|
||||
|
@ -46,19 +46,27 @@
|
||||
<Menu fx:id="menueFile" mnemonicParsing="false" text="Datei">
|
||||
<items>
|
||||
<MenuItem fx:id="beendenButton" mnemonicParsing="false" onAction="#quitApp" text="Beenden" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#reportSum" text="Report alles" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#tourReport" text="Tour Report erstellen" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Bearbeiten">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#importBtn" text="Import" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#exportBtn" text="Export" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#reportSum" text="Report alles" />
|
||||
<MenuItem mnemonicParsing="false" onAction="#tourReport" text="Tour Report erstellen" />
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Optionen">
|
||||
<items>
|
||||
<MenuItem mnemonicParsing="false" onAction="#nimpButton" text="Keine Funktion" />
|
||||
<CheckMenuItem mnemonicParsing="false" text="Map automatisch öffnen" />
|
||||
<CheckMenuItem mnemonicParsing="false" text="Report automatisch öffnen" />
|
||||
<Menu mnemonicParsing="false" text="Sprache">
|
||||
<items>
|
||||
<RadioMenuItem mnemonicParsing="false" text="Deutsch" />
|
||||
<RadioMenuItem mnemonicParsing="false" text="Englisch" />
|
||||
</items>
|
||||
</Menu>
|
||||
</items>
|
||||
</Menu>
|
||||
<Menu mnemonicParsing="false" text="Hilfe">
|
||||
|
@ -12,6 +12,10 @@ import javafx.stage.WindowEvent;
|
||||
import tourplaner.business.ConfigHelper;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import java.awt.*;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.time.LocalDate;
|
||||
|
45
src/tourplaner/ui/ProgressBar.java
Normal file
45
src/tourplaner/ui/ProgressBar.java
Normal file
@ -0,0 +1,45 @@
|
||||
package tourplaner.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import java.awt.*;
|
||||
|
||||
public class ProgressBar {
|
||||
private int status;
|
||||
private JFrame frame;
|
||||
private JProgressBar progressBar;
|
||||
|
||||
public ProgressBar(String title){
|
||||
this.frame = new JFrame(title);
|
||||
this.frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
Container content = this.frame.getContentPane();
|
||||
this.progressBar = new JProgressBar();
|
||||
this.progressBar.setValue(0);
|
||||
this.progressBar.setStringPainted(true);
|
||||
TitledBorder border = BorderFactory.createTitledBorder("Laden....");
|
||||
this.progressBar.setBorder(border);
|
||||
content.add(this.progressBar, BorderLayout.NORTH);
|
||||
this.frame.setSize(300, 100);
|
||||
this.frame.setVisible(true);
|
||||
}
|
||||
|
||||
public void addProgress(int add){
|
||||
this.status += add;
|
||||
System.out.println("PROGRESS: " + this.status);
|
||||
this.progressBar.setValue(this.status);
|
||||
if(this.status == 100){
|
||||
frame.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void closeProgress(){
|
||||
this.frame.setVisible(false);
|
||||
}
|
||||
|
||||
public int getProgressSize(int todo, int maxLevel){
|
||||
int steps = (progressBar.getValue() - maxLevel) / todo;
|
||||
if(steps < 0) steps = steps*-1;
|
||||
System.out.println("STEPS: " + steps);
|
||||
return steps;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
import tourplaner.viewmodels.ViewModel;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
@ -114,10 +115,13 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void tourListSelectedItem(MouseEvent mouseEvent){
|
||||
ProgressBar progressBar = new ProgressBar("Tour auswählen...");
|
||||
String selectedItem = TourListView.getSelectionModel().getSelectedItem();
|
||||
this.viewModel.selectTour(selectedItem);
|
||||
titleTextView.setText(selectedItem);
|
||||
progressBar.addProgress(10);
|
||||
syncTour(selectedItem);
|
||||
progressBar.addProgress(10);
|
||||
startCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("start"));
|
||||
zielCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("ziel"));
|
||||
dauerCol.setCellValueFactory(new PropertyValueFactory<Tour, String>("dauer"));
|
||||
@ -127,7 +131,9 @@ public class TourplanerController implements Initializable {
|
||||
//Log anzeigen
|
||||
logTableView.setPlaceholder(new Label( ConfigHelper.getLangIniString("keinelogsvorhanden")));
|
||||
logTableView.getItems().clear();
|
||||
progressBar.addProgress(10);
|
||||
logTableView.setItems(this.viewModel.getLogData());
|
||||
progressBar.addProgress(10);
|
||||
logDauerCol.setCellValueFactory(new PropertyValueFactory<Log, String>("dauer"));
|
||||
logStreckeCol.setCellValueFactory(new PropertyValueFactory<Log, String>("strecke"));
|
||||
logDatumCol.setCellValueFactory(new PropertyValueFactory<Log, String>("datum"));
|
||||
@ -136,12 +142,16 @@ public class TourplanerController implements Initializable {
|
||||
logPauseCol.setCellValueFactory(new PropertyValueFactory<Log, String>("pause"));
|
||||
logGegangenCol.setCellValueFactory(new PropertyValueFactory<Log, String>("gegangen"));
|
||||
logBemerkungCol.setCellValueFactory(new PropertyValueFactory<Log, String>("bemerkung"));
|
||||
|
||||
progressBar.addProgress(10);
|
||||
mapImageView.setImage(this.viewModel.getImage(this.viewModel.getSelectedTour().getName()));
|
||||
if(this.viewModel.isSucheAktiv()){
|
||||
this.viewModel.setSucheAktiv(false);
|
||||
progressBar.addProgress(10);
|
||||
syncTourNamen();
|
||||
progressBar.addProgress(40);
|
||||
this.sucheInput.setText("");
|
||||
}
|
||||
progressBar.addProgress(50);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +192,10 @@ public class TourplanerController implements Initializable {
|
||||
*/
|
||||
@FXML
|
||||
private void suche(){
|
||||
ProgressBar progressBar = new ProgressBar("Suche");
|
||||
this.viewModel.suche(this.sucheInput.getText());
|
||||
progressBar.addProgress(100);
|
||||
progressBar.closeProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ import tourplaner.ui.AlertHelper;
|
||||
import tourplaner.object.Log;
|
||||
import tourplaner.object.Tour;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
@ -617,7 +618,6 @@ public class ViewModel {
|
||||
*/
|
||||
public void importData() {
|
||||
String file = AlertHelper.fileChooser("Importiere");
|
||||
System.out.println("IMPORT: " + file);
|
||||
if (file != null){
|
||||
try {
|
||||
this.tourNamen = FXCollections.observableArrayList();
|
||||
|
Loading…
x
Reference in New Issue
Block a user