Skip to content

Commit 5343a80

Browse files
committed
fix: #main path fix
1 parent 4f13eef commit 5343a80

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

src/main/java/pl/bator/lso_list_generator/controller/NavbarController.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import javax.swing.*;
88
import java.awt.*;
9+
import java.nio.file.Path;
910
import java.text.DateFormatSymbols;
1011
import java.time.Year;
1112
import java.util.Arrays;
@@ -15,7 +16,7 @@ public class NavbarController {
1516
private JComboBox<String> monthComboBox;
1617
private JComboBox<Integer> yearComboBox;
1718
private JLabel pathLabel;
18-
private String pdfSavePath = System.getProperty("user.home") + "\\Desktop";
19+
private Path pdfSavePath = Path.of(System.getProperty("user.home"), "Desktop");
1920

2021
private final PDFGenerationService pdfGenerationService;
2122
private final Component parent;
@@ -72,13 +73,13 @@ private void initializeButtons(@NotNull JPanel buttonPanel) {
7273
}
7374

7475
private void changeSavePath() {
75-
JFileChooser fileChooser = new JFileChooser(pdfSavePath);
76+
JFileChooser fileChooser = new JFileChooser(pdfSavePath.toString());
7677
fileChooser.setDialogTitle("Wybierz folder zapisu");
7778
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
7879
int userSelection = fileChooser.showSaveDialog(parent);
7980

8081
if (userSelection == JFileChooser.APPROVE_OPTION) {
81-
pdfSavePath = fileChooser.getSelectedFile().getAbsolutePath();
82+
pdfSavePath = Path.of(fileChooser.getSelectedFile().getAbsolutePath());
8283
pathLabel.setText("Aktualna ścieżka: " + pdfSavePath);
8384
}
8485
}

src/main/java/pl/bator/lso_list_generator/service/PDFGenerationService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import pl.bator.lso_list_generator.util.PDFUtil;
66

77
import java.io.IOException;
8+
import java.nio.file.Path;
89
import java.text.DateFormatSymbols;
910
import java.time.Month;
1011
import java.time.Year;
@@ -18,7 +19,7 @@ public PDFGenerationService(GroupJSONRepository groupJSONRepository) {
1819
this.groupJSONRepository = groupJSONRepository;
1920
}
2021

21-
public void handleGenerateClick(String selectedMonth, int selectedYear, String savePath) throws NotFoundException, IOException {
22+
public void handleGenerateClick(String selectedMonth, int selectedYear, Path savePath) throws NotFoundException, IOException {
2223

2324
int monthIndex = -1;
2425
String[] polishMonths = new DateFormatSymbols(new Locale("pl")).getMonths();

src/main/java/pl/bator/lso_list_generator/util/PDFUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
import java.io.FileOutputStream;
1414
import java.io.IOException;
1515
import java.io.OutputStream;
16+
import java.nio.file.Path;
1617
import java.time.*;
1718
import java.time.format.TextStyle;
1819
import java.util.ArrayList;
1920
import java.util.List;
2021
import java.util.Locale;
2122

2223
public class PDFUtil {
23-
public void generatePdf(Group group, Month month, Year year, String path) throws IOException {
24+
public void generatePdf(Group group, Month month, Year year, Path path) throws IOException {
2425
String html = parseThymeleafTemplate(group, month, year);
2526

2627
String outputFolder = path + "/lista_" + month.getDisplayName(TextStyle.FULL_STANDALONE, new Locale("PL")) + "_" + year + "_grupa_" + group.getNumber() + ".pdf";

src/main/resources/list_template.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<html xmlns:th="http://www.thymeleaf.org">
1+
<html xmlns:th="http://www.thymeleaf.org" lang="pl">
22
<head>
33
<meta charset="UTF-8"/>
44
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
@@ -23,7 +23,7 @@
2323
margin: 0;
2424
padding: 2px 5px;
2525
min-width: 15px;
26-
text-wrap: none;
26+
text-wrap: nowrap;
2727
text-align: center;
2828
}
2929

0 commit comments

Comments
 (0)