Skip to content

Commit 44fa959

Browse files
committed
Poprawki błędów i uzupełnienie dokumentacji
1 parent 9c45b60 commit 44fa959

15 files changed

+475
-354
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<url>https://github.com/koder95/eMetrykant</url>
1010
<groupId>pl.koder95</groupId>
1111
<artifactId>eMetrykant</artifactId>
12-
<version>0.4.0</version>
12+
<version>0.4.1</version>
1313
<scm>
1414
<url>https://github.com/koder95/eMetrykant</url>
1515
<tag>search, metric, church</tag>

src/main/java/pl/koder95/eme/Files.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
package pl.koder95.eme;
1919

20-
import java.io.File;
2120
import java.nio.file.Path;
2221
import java.nio.file.Paths;
2322

@@ -49,10 +48,18 @@ public final class Files {
4948
* Plik, który przechowuje dane na temat indeksów.
5049
*/
5150
public static final Path INDICES_XML = XML_DIR.resolve("indices.xml");
52-
51+
/**
52+
* Folder tymczasowy eMetrykant, gdzie zapisywane są pliki pobrane z repozytorium.
53+
*/
5354
public static final Path TEMP_DIR = Paths.get(System.getProperty("java.io.tmpdir"), "eMetrykant");
54-
public static final Path UPDATE_WIN = Files.WORKDIR.resolve("update.bat");
55-
public static final Path UPDATE_UNIX = Files.WORKDIR.resolve("update");
55+
/**
56+
* Plik skryptu aktualizującego program, w formie bez rozszerzenia.
57+
*/
58+
public static final Path UPDATE_SCRIPT = Files.WORKDIR.resolve("update");
59+
/**
60+
* Ścieżka do archiwum JAR. Jeśli program jest uruchomiony standardowo, ścieżka wskazuje archiwum
61+
* uruchamiające.
62+
*/
5663
public static final Path SELF = WORKDIR.resolve("eMetrykant.jar");
5764

5865
private Files() {}

src/main/java/pl/koder95/eme/Main.java

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,17 @@
1717
package pl.koder95.eme;
1818

1919
import javafx.application.Application;
20-
import javafx.application.Platform;
2120
import javafx.fxml.FXMLLoader;
2221
import javafx.geometry.Pos;
2322
import javafx.scene.Parent;
2423
import javafx.scene.Scene;
2524
import javafx.scene.control.Label;
26-
import javafx.scene.control.ProgressIndicator;
25+
import javafx.scene.control.ProgressBar;
2726
import javafx.scene.image.Image;
28-
import javafx.scene.layout.Background;
29-
import javafx.scene.layout.HBox;
3027
import javafx.scene.layout.VBox;
31-
import javafx.scene.paint.Color;
32-
import javafx.stage.Modality;
3328
import javafx.stage.Stage;
3429
import javafx.stage.StageStyle;
35-
import pl.koder95.eme.au.AutoUpdateTask;
30+
import pl.koder95.eme.au.SelfUpdateTask;
3631
import pl.koder95.eme.core.*;
3732
import pl.koder95.eme.core.spi.CabinetAnalyzer;
3833
import pl.koder95.eme.core.spi.FilingCabinet;
@@ -46,9 +41,10 @@
4641
import java.util.regex.Pattern;
4742

4843
/**
49-
* Klasa uruchamiająca i inicjalizująca podstawowe elementy aplikacji.
44+
* Klasa uruchamiająca i inicjująca podstawowe elementy aplikacji.
45+
*
5046
* @author Kamil Jan Mularski [@koder95]
51-
* @version 0.4.1, 2021-11-05
47+
* @version 0.4.1, 2021-11-07
5248
* @since 0.0.201
5349
*/
5450
public class Main extends Application {
@@ -76,13 +72,20 @@ public class Main extends Application {
7672
*/
7773
public static final Pattern DIGITS_STRING_PATTERN
7874
= Pattern.compile("([0-9]*)");
75+
/**
76+
* Sprawdzenie, czy system operacyjny należy do rodziny "Windows".
77+
*/
78+
public static final boolean IS_WINDOWS_OS = System.getProperty("os.name").toLowerCase().contains("windows");
7979

8080
public static void main(String[] args) {
8181
if (args.length == 1) {
8282
if (args[0].equals("-v")) {
8383
System.out.println(Version.get());
8484
System.exit(0);
8585
}
86+
else if (args[0].equals("-u")) {
87+
88+
}
8689
}
8790
Main.launch(args);
8891
}
@@ -96,13 +99,15 @@ public static void releaseMemory() {
9699
}
97100

98101
private Parent root = null;
99-
private AutoUpdateTask task = null;
102+
private SelfUpdateTask task = null;
100103

101104
@Override
102105
public void init() throws Exception {
103-
RepositoryInfo.get().reload();
104106
super.init();
105-
Arrays.stream(IndexList.values()).forEach(IndexList::load);
107+
RepositoryInfo.get().reload();
108+
if (getParameters().getUnnamed().isEmpty()) {
109+
Arrays.stream(IndexList.values()).forEach(IndexList::load);
110+
}
106111

107112
FilingCabinet cabinet = new TreeFilingCabinet();
108113
IndexListDataSource source = new IndexListDataSource();
@@ -113,37 +118,35 @@ public void init() throws Exception {
113118
worker.load();
114119

115120
root = FXMLLoader.load(ClassLoader.getSystemResource("pl/koder95/eme/fx/PersonalDataView.fxml"));
116-
task = new AutoUpdateTask();
121+
task = new SelfUpdateTask();
117122
}
118123

119124
@Override
120125
public void start(Stage primaryStage) {
121126
primaryStage.getIcons().add(new Image(FAVICON_PATH));
122127
primaryStage.setTitle("eMetrykant " + Version.get());
123128
Version latestRelease = RepositoryInfo.get().getLatestReleaseVersion();
124-
if (latestRelease.compareTo(Version.get()) > 0) {
125-
primaryStage.initStyle(StageStyle.UNDECORATED);
126-
127-
ProgressIndicator updating = new ProgressIndicator();
129+
if (latestRelease.compareTo(Version.get()) > 0 || !getParameters().getUnnamed().isEmpty()) {
130+
ProgressBar updating = new ProgressBar();
128131
Label title = new Label();
129132
Label message = new Label();
133+
VBox root = new VBox(5d, title, updating, message);
134+
135+
updating.setMinSize(400d, 35d);
130136
updating.progressProperty().bind(task.progressProperty());
131137
title.textProperty().bind(task.titleProperty());
132138
message.textProperty().bind(task.messageProperty());
133139

134-
VBox texts = new VBox(5d, title, message);
135-
texts.setAlignment(Pos.CENTER_LEFT);
136-
VBox progressing = new VBox(updating);
137-
progressing.setAlignment(Pos.CENTER_RIGHT);
138-
HBox root = new HBox(5d, progressing, texts);
139140
root.setAlignment(Pos.CENTER);
140141

142+
primaryStage.initStyle(StageStyle.UTILITY);
141143
primaryStage.setScene(new Scene(root));
142144
primaryStage.setAlwaysOnTop(true);
143-
primaryStage.setMinWidth(300);
144-
primaryStage.setMinHeight(150);
145+
primaryStage.setResizable(false);
146+
primaryStage.setMinWidth(400);
147+
primaryStage.setMinHeight(100);
145148
primaryStage.show();
146-
Platform.runLater(task);
149+
new Thread(task).start();
147150
}
148151
else {
149152
primaryStage.setScene(new Scene(root));

src/main/java/pl/koder95/eme/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private static Version parse0(String str) {
261261
* @return wersja
262262
*/
263263
public static Version parse(String str) {
264-
return parse0(str.startsWith("v")? str.substring(1) : str);
264+
return parse0(str == null? "0.0.0" : str.startsWith("v")? str.substring(1) : str);
265265
}
266266

267267
/**

src/main/java/pl/koder95/eme/au/AutoUpdateService.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/java/pl/koder95/eme/au/AutoUpdateTask.java

Lines changed: 0 additions & 205 deletions
This file was deleted.

0 commit comments

Comments
 (0)