17
17
package pl .koder95 .eme ;
18
18
19
19
import javafx .application .Application ;
20
- import javafx .application .Platform ;
21
20
import javafx .fxml .FXMLLoader ;
22
21
import javafx .geometry .Pos ;
23
22
import javafx .scene .Parent ;
24
23
import javafx .scene .Scene ;
25
24
import javafx .scene .control .Label ;
26
- import javafx .scene .control .ProgressIndicator ;
25
+ import javafx .scene .control .ProgressBar ;
27
26
import javafx .scene .image .Image ;
28
- import javafx .scene .layout .Background ;
29
- import javafx .scene .layout .HBox ;
30
27
import javafx .scene .layout .VBox ;
31
- import javafx .scene .paint .Color ;
32
- import javafx .stage .Modality ;
33
28
import javafx .stage .Stage ;
34
29
import javafx .stage .StageStyle ;
35
- import pl .koder95 .eme .au .AutoUpdateTask ;
30
+ import pl .koder95 .eme .au .SelfUpdateTask ;
36
31
import pl .koder95 .eme .core .*;
37
32
import pl .koder95 .eme .core .spi .CabinetAnalyzer ;
38
33
import pl .koder95 .eme .core .spi .FilingCabinet ;
46
41
import java .util .regex .Pattern ;
47
42
48
43
/**
49
- * Klasa uruchamiająca i inicjalizująca podstawowe elementy aplikacji.
44
+ * Klasa uruchamiająca i inicjująca podstawowe elementy aplikacji.
45
+ *
50
46
* @author Kamil Jan Mularski [@koder95]
51
- * @version 0.4.1, 2021-11-05
47
+ * @version 0.4.1, 2021-11-07
52
48
* @since 0.0.201
53
49
*/
54
50
public class Main extends Application {
@@ -76,13 +72,20 @@ public class Main extends Application {
76
72
*/
77
73
public static final Pattern DIGITS_STRING_PATTERN
78
74
= 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" );
79
79
80
80
public static void main (String [] args ) {
81
81
if (args .length == 1 ) {
82
82
if (args [0 ].equals ("-v" )) {
83
83
System .out .println (Version .get ());
84
84
System .exit (0 );
85
85
}
86
+ else if (args [0 ].equals ("-u" )) {
87
+
88
+ }
86
89
}
87
90
Main .launch (args );
88
91
}
@@ -96,13 +99,15 @@ public static void releaseMemory() {
96
99
}
97
100
98
101
private Parent root = null ;
99
- private AutoUpdateTask task = null ;
102
+ private SelfUpdateTask task = null ;
100
103
101
104
@ Override
102
105
public void init () throws Exception {
103
- RepositoryInfo .get ().reload ();
104
106
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
+ }
106
111
107
112
FilingCabinet cabinet = new TreeFilingCabinet ();
108
113
IndexListDataSource source = new IndexListDataSource ();
@@ -113,37 +118,35 @@ public void init() throws Exception {
113
118
worker .load ();
114
119
115
120
root = FXMLLoader .load (ClassLoader .getSystemResource ("pl/koder95/eme/fx/PersonalDataView.fxml" ));
116
- task = new AutoUpdateTask ();
121
+ task = new SelfUpdateTask ();
117
122
}
118
123
119
124
@ Override
120
125
public void start (Stage primaryStage ) {
121
126
primaryStage .getIcons ().add (new Image (FAVICON_PATH ));
122
127
primaryStage .setTitle ("eMetrykant " + Version .get ());
123
128
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 ();
128
131
Label title = new Label ();
129
132
Label message = new Label ();
133
+ VBox root = new VBox (5d , title , updating , message );
134
+
135
+ updating .setMinSize (400d , 35d );
130
136
updating .progressProperty ().bind (task .progressProperty ());
131
137
title .textProperty ().bind (task .titleProperty ());
132
138
message .textProperty ().bind (task .messageProperty ());
133
139
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 );
139
140
root .setAlignment (Pos .CENTER );
140
141
142
+ primaryStage .initStyle (StageStyle .UTILITY );
141
143
primaryStage .setScene (new Scene (root ));
142
144
primaryStage .setAlwaysOnTop (true );
143
- primaryStage .setMinWidth (300 );
144
- primaryStage .setMinHeight (150 );
145
+ primaryStage .setResizable (false );
146
+ primaryStage .setMinWidth (400 );
147
+ primaryStage .setMinHeight (100 );
145
148
primaryStage .show ();
146
- Platform . runLater (task );
149
+ new Thread (task ). start ( );
147
150
}
148
151
else {
149
152
primaryStage .setScene (new Scene (root ));
0 commit comments