1 |
03a2d08f
|
Michal Horký
|
import java.io.File;
|
2 |
98da6ab0
|
horkmi
|
import java.util.Properties;
|
3 |
03a2d08f
|
Michal Horký
|
|
4 |
7e0b699a
|
horkmi
|
import io.Database.DB_Messenger;
|
5 |
49fd8648
|
Michal Horký
|
import io.FileWorker;
|
6 |
03a2d08f
|
Michal Horký
|
import javafx.application.Application;
|
7 |
49fd8648
|
Michal Horký
|
import javafx.application.Platform;
|
8 |
7e0b699a
|
horkmi
|
import javafx.collections.FXCollections;
|
9 |
98da6ab0
|
horkmi
|
import javafx.collections.ObservableList;
|
10 |
03a2d08f
|
Michal Horký
|
import javafx.geometry.Insets;
|
11 |
|
|
import javafx.geometry.Pos;
|
12 |
49fd8648
|
Michal Horký
|
import javafx.scene.Node;
|
13 |
03a2d08f
|
Michal Horký
|
import javafx.scene.Parent;
|
14 |
|
|
import javafx.scene.Scene;
|
15 |
|
|
import javafx.scene.control.Button;
|
16 |
5ae26965
|
horkmi
|
import javafx.scene.control.ComboBox;
|
17 |
03a2d08f
|
Michal Horký
|
import javafx.scene.control.Label;
|
18 |
49fd8648
|
Michal Horký
|
import javafx.scene.control.Menu;
|
19 |
|
|
import javafx.scene.control.MenuBar;
|
20 |
|
|
import javafx.scene.control.MenuItem;
|
21 |
7e0b699a
|
horkmi
|
import javafx.scene.control.PasswordField;
|
22 |
49fd8648
|
Michal Horký
|
import javafx.scene.control.Separator;
|
23 |
|
|
import javafx.scene.control.SeparatorMenuItem;
|
24 |
5ae26965
|
horkmi
|
import javafx.scene.control.Tab;
|
25 |
|
|
import javafx.scene.control.TabPane;
|
26 |
|
|
import javafx.scene.control.TabPane.TabClosingPolicy;
|
27 |
7e0b699a
|
horkmi
|
import javafx.scene.control.TextField;
|
28 |
49fd8648
|
Michal Horký
|
import javafx.scene.image.Image;
|
29 |
|
|
import javafx.scene.image.ImageView;
|
30 |
|
|
import javafx.scene.input.KeyCode;
|
31 |
|
|
import javafx.scene.input.KeyCodeCombination;
|
32 |
|
|
import javafx.scene.input.KeyCombination;
|
33 |
|
|
import javafx.scene.layout.BorderPane;
|
34 |
03a2d08f
|
Michal Horký
|
import javafx.scene.layout.HBox;
|
35 |
49fd8648
|
Michal Horký
|
import javafx.scene.layout.Priority;
|
36 |
03a2d08f
|
Michal Horký
|
import javafx.scene.layout.VBox;
|
37 |
|
|
import javafx.stage.FileChooser;
|
38 |
|
|
import javafx.stage.Stage;
|
39 |
|
|
|
40 |
49fd8648
|
Michal Horký
|
/**
|
41 |
|
|
* VM arguments for Java 11: --module-path libs\javafx-sdk-11.0.2\lib --add-modules=javafx.controls
|
42 |
|
|
*/
|
43 |
d2be23a3
|
horkmi
|
public class Window extends Application implements IConversionResults {
|
44 |
03a2d08f
|
Michal Horký
|
|
45 |
|
|
private Stage stage;
|
46 |
49fd8648
|
Michal Horký
|
private Label fullScreen;
|
47 |
a5d16f0a
|
horkmi
|
|
48 |
5ae26965
|
horkmi
|
private Editor editor;
|
49 |
49fd8648
|
Michal Horký
|
private VBox outputLayout;
|
50 |
03a2d08f
|
Michal Horký
|
|
51 |
49fd8648
|
Michal Horký
|
private Converter converter;
|
52 |
98da6ab0
|
horkmi
|
private Properties properties;
|
53 |
03a2d08f
|
Michal Horký
|
|
54 |
|
|
@Override
|
55 |
|
|
public void init() throws Exception {
|
56 |
|
|
super.init();
|
57 |
49fd8648
|
Michal Horký
|
converter = new Converter(this);
|
58 |
|
|
converter.start();
|
59 |
98da6ab0
|
horkmi
|
properties = FileWorker.getConfig();
|
60 |
49fd8648
|
Michal Horký
|
}
|
61 |
|
|
|
62 |
|
|
@Override
|
63 |
|
|
public void stop() throws Exception {
|
64 |
|
|
super.stop();
|
65 |
|
|
converter.end();
|
66 |
|
|
converter.join();
|
67 |
98da6ab0
|
horkmi
|
FileWorker.saveConfig(properties);
|
68 |
efc1d63e
|
@havlijan17
|
Platform.exit();
|
69 |
03a2d08f
|
Michal Horký
|
}
|
70 |
|
|
|
71 |
|
|
@Override
|
72 |
|
|
public void start(Stage stage) throws Exception {
|
73 |
|
|
this.stage = stage;
|
74 |
98da6ab0
|
horkmi
|
stage.getIcons().add(new Image(FileWorker.getResource("/logo.png")));
|
75 |
49fd8648
|
Michal Horký
|
stage.setTitle("Java Object Universal Deserializer");
|
76 |
03a2d08f
|
Michal Horký
|
stage.setScene(createScene());
|
77 |
|
|
stage.show();
|
78 |
5ae26965
|
horkmi
|
|
79 |
|
|
stage.setMinWidth(stage.getWidth());
|
80 |
|
|
stage.setMinHeight(stage.getHeight());
|
81 |
efc1d63e
|
@havlijan17
|
|
82 |
49fd8648
|
Michal Horký
|
stage.fullScreenProperty().addListener((obs, oldState, newState) -> {
|
83 |
|
|
changeFullScreenMenuItem();
|
84 |
|
|
});
|
85 |
03a2d08f
|
Michal Horký
|
}
|
86 |
|
|
|
87 |
|
|
private Scene createScene() {
|
88 |
49fd8648
|
Michal Horký
|
createMenu();
|
89 |
|
|
Scene scene = new Scene(createLayout());
|
90 |
98da6ab0
|
horkmi
|
scene.getStylesheets().add(FileWorker.getResource("/main.css"));
|
91 |
49fd8648
|
Michal Horký
|
return scene;
|
92 |
03a2d08f
|
Michal Horký
|
}
|
93 |
|
|
|
94 |
|
|
private Parent createLayout() {
|
95 |
49fd8648
|
Michal Horký
|
BorderPane layout = new BorderPane();
|
96 |
|
|
|
97 |
|
|
layout.setTop(createMenu());
|
98 |
|
|
layout.setCenter(createBodyLayout());
|
99 |
03a2d08f
|
Michal Horký
|
|
100 |
49fd8648
|
Michal Horký
|
return layout;
|
101 |
|
|
}
|
102 |
|
|
|
103 |
5ae26965
|
horkmi
|
private Node createBodyLayout() {
|
104 |
|
|
TabPane header = new TabPane();
|
105 |
|
|
header.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
|
106 |
|
|
header.getTabs().add(createInputFileTab());
|
107 |
7e0b699a
|
horkmi
|
header.getTabs().add(createQueryTab());
|
108 |
5ae26965
|
horkmi
|
|
109 |
|
|
|
110 |
|
|
editor = new Editor();
|
111 |
|
|
|
112 |
98da6ab0
|
horkmi
|
String propMode = properties.getProperty(FileWorker.ACE_MODE);
|
113 |
|
|
String propTheme = properties.getProperty(FileWorker.ACE_THEME);
|
114 |
|
|
|
115 |
|
|
ObservableList<String> aceModes = FXCollections.observableArrayList();
|
116 |
|
|
ObservableList<String> aceThemes = FXCollections.observableArrayList();
|
117 |
|
|
FileWorker.getAceModesAndThemes(aceModes, aceThemes);
|
118 |
|
|
|
119 |
5ae26965
|
horkmi
|
ComboBox<String> modeBox = new ComboBox<String>();
|
120 |
98da6ab0
|
horkmi
|
modeBox.setItems(aceModes);
|
121 |
|
|
modeBox.getSelectionModel().select(propMode == null ? Editor.DEFAULT_MODE : propMode);
|
122 |
5ae26965
|
horkmi
|
modeBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
123 |
98da6ab0
|
horkmi
|
if (modeBox.getValue() != null) {
|
124 |
|
|
properties.setProperty(FileWorker.ACE_MODE, modeBox.getValue());
|
125 |
5ae26965
|
horkmi
|
editor.setMode(modeBox.getValue());
|
126 |
|
|
}
|
127 |
|
|
});
|
128 |
|
|
|
129 |
|
|
ComboBox<String> themeBox = new ComboBox<String>();
|
130 |
98da6ab0
|
horkmi
|
themeBox.setItems(aceThemes);
|
131 |
|
|
themeBox.getSelectionModel().select(propTheme == null ? Editor.DEFAULT_THEME : propTheme);
|
132 |
5ae26965
|
horkmi
|
themeBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
133 |
98da6ab0
|
horkmi
|
if (themeBox.getValue() != null) {
|
134 |
|
|
properties.setProperty(FileWorker.ACE_THEME, themeBox.getValue());
|
135 |
5ae26965
|
horkmi
|
editor.setTheme(themeBox.getValue());
|
136 |
|
|
}
|
137 |
|
|
});
|
138 |
|
|
|
139 |
|
|
HBox aceSettings = new HBox();
|
140 |
|
|
aceSettings.setPadding(new Insets(0, 10, 0, 0));
|
141 |
|
|
aceSettings.setSpacing(10.0);
|
142 |
|
|
aceSettings.setAlignment(Pos.CENTER_RIGHT);
|
143 |
|
|
aceSettings.getChildren().addAll(new Label("Nastavení editoru (režim / téma):"), modeBox, new Label("/"), themeBox);
|
144 |
|
|
|
145 |
|
|
VBox editorLayout = new VBox();
|
146 |
|
|
editorLayout.setSpacing(5.0);
|
147 |
ba652858
|
horkmi
|
VBox.setVgrow(editor.getView(), Priority.ALWAYS);
|
148 |
5ae26965
|
horkmi
|
editorLayout.getChildren().addAll(editor.getView(), aceSettings);
|
149 |
|
|
|
150 |
|
|
|
151 |
49fd8648
|
Michal Horký
|
Label forOutputFile = new Label("Výstupní soubor:");
|
152 |
5ae26965
|
horkmi
|
Label outputFile = new Label(" Ještě nebyl vybrán žádný soubor...");
|
153 |
|
|
outputFile.setStyle("-fx-font-style: italic;");
|
154 |
49fd8648
|
Michal Horký
|
|
155 |
5ae26965
|
horkmi
|
Button save = new Button("Uložit");
|
156 |
|
|
save.setOnAction(event -> {
|
157 |
49fd8648
|
Michal Horký
|
File jsonFile = null;
|
158 |
|
|
|
159 |
5ae26965
|
horkmi
|
FileChooser fCh = new FileChooser();
|
160 |
|
|
fCh.setInitialDirectory(new File("."));
|
161 |
|
|
fCh.getExtensionFilters().add(new FileChooser.ExtensionFilter("JSON Files", "*.json"));
|
162 |
|
|
File file = fCh.showSaveDialog(stage);
|
163 |
|
|
if (file != null) {
|
164 |
|
|
jsonFile = file;
|
165 |
|
|
outputFile.setText(file.getAbsolutePath());
|
166 |
|
|
outputFile.setStyle("-fx-font-weight: bold;");
|
167 |
49fd8648
|
Michal Horký
|
}
|
168 |
|
|
|
169 |
5ae26965
|
horkmi
|
if (jsonFile != null) {
|
170 |
49fd8648
|
Michal Horký
|
String title = "Uložení JSON";
|
171 |
|
|
try {
|
172 |
5ae26965
|
horkmi
|
FileWorker.saveJson(jsonFile, editor.getJson());
|
173 |
49fd8648
|
Michal Horký
|
Report.info(title, null, "Uložení JSON souboru proběhlo v pořádku.");
|
174 |
|
|
} catch (Exception e) {
|
175 |
|
|
Report.error(title, null, "Při ukládání JSON souboru nastala chyba.");
|
176 |
|
|
}
|
177 |
03a2d08f
|
Michal Horký
|
}
|
178 |
|
|
});
|
179 |
|
|
|
180 |
49fd8648
|
Michal Horký
|
HBox bOF = new HBox();
|
181 |
|
|
bOF.setAlignment(Pos.CENTER_RIGHT);
|
182 |
5ae26965
|
horkmi
|
bOF.getChildren().add(save);
|
183 |
49fd8648
|
Michal Horký
|
|
184 |
|
|
outputLayout = new VBox();
|
185 |
5ae26965
|
horkmi
|
outputLayout.setPadding(new Insets(0, 10, 10, 10));
|
186 |
49fd8648
|
Michal Horký
|
outputLayout.setSpacing(5.0);
|
187 |
|
|
outputLayout.getChildren().add(forOutputFile);
|
188 |
|
|
outputLayout.getChildren().add(outputFile);
|
189 |
|
|
outputLayout.getChildren().add(bOF);
|
190 |
|
|
setOutputLayoutDisabled(true);
|
191 |
|
|
|
192 |
|
|
|
193 |
5ae26965
|
horkmi
|
VBox layout = new VBox();
|
194 |
|
|
layout.setSpacing(10.0);
|
195 |
ba652858
|
horkmi
|
VBox.setVgrow(editorLayout, Priority.ALWAYS);
|
196 |
5ae26965
|
horkmi
|
layout.getChildren().addAll(header, new Separator(), editorLayout, new Separator(), outputLayout);
|
197 |
49fd8648
|
Michal Horký
|
|
198 |
5ae26965
|
horkmi
|
return layout;
|
199 |
|
|
}
|
200 |
|
|
|
201 |
7e0b699a
|
horkmi
|
private Tab createQueryTab() {
|
202 |
98da6ab0
|
horkmi
|
String propType = properties.getProperty(FileWorker.DB_TYPE);
|
203 |
|
|
String propUrl = properties.getProperty(FileWorker.DB_URL);
|
204 |
|
|
String propUser = properties.getProperty(FileWorker.DB_USER);
|
205 |
|
|
|
206 |
|
|
|
207 |
ba652858
|
horkmi
|
String promptTexts[] = new String[] { "jdbc:oracle:thin:@server:port:nazevDB", "jdbc:sqlserver://server:port;databaseName=nazevDB;", "jdbc:mysql://server:port/nazevDB" };
|
208 |
|
|
String dbTypeTexts[] = new String[] { "ORACLE", "MS-SQL", "MySQL" };
|
209 |
|
|
String dbDriverClasses[] = new String[] { "oracle.jdbc.driver.OracleDriver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "com.mysql.cj.jdbc.Driver" };
|
210 |
7e0b699a
|
horkmi
|
|
211 |
|
|
Label rdbmsLabel = new Label("Typ DB");
|
212 |
|
|
Label urlLabel = new Label("URL");
|
213 |
ba652858
|
horkmi
|
ComboBox<String> rdbms = new ComboBox<String>(FXCollections.observableArrayList(dbTypeTexts));
|
214 |
98da6ab0
|
horkmi
|
TextField url = new TextField(propUrl == null ? "" : propUrl);
|
215 |
|
|
|
216 |
|
|
if (propType == null) {
|
217 |
|
|
rdbms.getSelectionModel().selectFirst();
|
218 |
|
|
url.setPromptText(promptTexts[0]);
|
219 |
|
|
} else {
|
220 |
|
|
rdbms.getSelectionModel().select(propType);
|
221 |
|
|
url.setPromptText(promptTexts[rdbms.getItems().indexOf(propType)]);
|
222 |
|
|
}
|
223 |
7e0b699a
|
horkmi
|
rdbms.setOnAction(event -> {
|
224 |
|
|
url.setPromptText(promptTexts[rdbms.getSelectionModel().getSelectedIndex()]);
|
225 |
|
|
});
|
226 |
|
|
|
227 |
98da6ab0
|
horkmi
|
|
228 |
7e0b699a
|
horkmi
|
Label userLabel = new Label("Uživatel");
|
229 |
|
|
Label passwordLabel = new Label("Heslo");
|
230 |
98da6ab0
|
horkmi
|
TextField user = new TextField(propUser == null ? "" : propUser);
|
231 |
7e0b699a
|
horkmi
|
PasswordField password = new PasswordField();
|
232 |
|
|
|
233 |
|
|
VBox rdbmsLayout = new VBox();
|
234 |
|
|
rdbmsLayout.getChildren().addAll(rdbmsLabel, rdbms);
|
235 |
|
|
VBox urlLayout = new VBox();
|
236 |
|
|
urlLayout.getChildren().addAll(urlLabel, url);
|
237 |
|
|
VBox userLayout = new VBox();
|
238 |
|
|
userLayout.getChildren().addAll(userLabel, user);
|
239 |
|
|
VBox passwordLayout = new VBox();
|
240 |
|
|
passwordLayout.getChildren().addAll(passwordLabel, password);
|
241 |
|
|
|
242 |
|
|
rdbmsLabel.setStyle("-fx-font-weight: bold;");
|
243 |
|
|
urlLabel.setStyle("-fx-font-weight: bold;");
|
244 |
|
|
userLabel.setStyle("-fx-font-weight: bold;");
|
245 |
|
|
passwordLabel.setStyle("-fx-font-weight: bold;");
|
246 |
|
|
|
247 |
|
|
url.setMinWidth(400);
|
248 |
|
|
user.setMinWidth(100);
|
249 |
|
|
user.setPrefWidth(200);
|
250 |
|
|
user.setMaxWidth(300);
|
251 |
|
|
password.setMinWidth(100);
|
252 |
|
|
password.setPrefWidth(200);
|
253 |
|
|
password.setMaxWidth(300);
|
254 |
|
|
|
255 |
|
|
HBox.setHgrow(urlLayout, Priority.ALWAYS);
|
256 |
|
|
|
257 |
|
|
HBox connLayout = new HBox();
|
258 |
|
|
connLayout.setSpacing(10);
|
259 |
|
|
connLayout.getChildren().addAll(rdbmsLayout, urlLayout, userLayout, passwordLayout);
|
260 |
|
|
|
261 |
|
|
|
262 |
|
|
Label select = new Label("SELECT"), from = new Label("FROM"), where = new Label("WHERE"), queryEnd = new Label(";");
|
263 |
|
|
TextField column = new TextField(), table = new TextField(), cond = new TextField();
|
264 |
|
|
|
265 |
|
|
select.setStyle("-fx-font-weight: bold;");
|
266 |
|
|
from.setStyle("-fx-font-weight: bold;");
|
267 |
|
|
where.setStyle("-fx-font-weight: bold;");
|
268 |
|
|
queryEnd.setStyle("-fx-font-weight: bold;");
|
269 |
|
|
|
270 |
|
|
column.setPromptText("sloupec");
|
271 |
|
|
table.setPromptText("tabulka");
|
272 |
|
|
cond.setPromptText("podminka");
|
273 |
|
|
|
274 |
|
|
HBox.setHgrow(column, Priority.ALWAYS);
|
275 |
|
|
HBox.setHgrow(table, Priority.ALWAYS);
|
276 |
|
|
HBox.setHgrow(cond, Priority.ALWAYS);
|
277 |
|
|
|
278 |
|
|
HBox queryLayout = new HBox();
|
279 |
|
|
queryLayout.setAlignment(Pos.CENTER);
|
280 |
|
|
queryLayout.setSpacing(5.0);
|
281 |
|
|
queryLayout.getChildren().addAll(select, column, from, table, where, cond, queryEnd);
|
282 |
|
|
|
283 |
|
|
Button setQuery = new Button("Spustit");
|
284 |
|
|
setQuery.setOnAction(event -> {
|
285 |
98da6ab0
|
horkmi
|
String urlStr = url.getText().trim();
|
286 |
|
|
String userStr = user.getText().trim();
|
287 |
|
|
properties.setProperty(FileWorker.DB_TYPE, rdbms.getValue());
|
288 |
|
|
properties.setProperty(FileWorker.DB_URL, urlStr);
|
289 |
|
|
properties.setProperty(FileWorker.DB_USER, userStr);
|
290 |
|
|
|
291 |
ba652858
|
horkmi
|
String driver = dbDriverClasses[rdbms.getItems().indexOf(rdbms.getValue())];
|
292 |
98da6ab0
|
horkmi
|
converter.setInput(null, new DB_Messenger(driver, urlStr, userStr, password.getText().trim(),
|
293 |
7e0b699a
|
horkmi
|
table.getText().trim(), cond.getText().trim(), column.getText().trim()));
|
294 |
|
|
});
|
295 |
|
|
|
296 |
|
|
HBox bIF = new HBox();
|
297 |
|
|
bIF.setAlignment(Pos.CENTER_RIGHT);
|
298 |
|
|
bIF.getChildren().add(setQuery);
|
299 |
|
|
|
300 |
|
|
VBox forInput = new VBox();
|
301 |
|
|
forInput.setPadding(new Insets(10, 10, 0, 10));
|
302 |
|
|
forInput.setSpacing(5.0);
|
303 |
|
|
forInput.getChildren().addAll(connLayout, queryLayout, bIF);
|
304 |
|
|
|
305 |
|
|
return new Tab("SQL", forInput);
|
306 |
|
|
}
|
307 |
|
|
|
308 |
5ae26965
|
horkmi
|
private Tab createInputFileTab() {
|
309 |
|
|
Label forInputFile = new Label("Soubor k deserializaci:");
|
310 |
|
|
Label inputFile = new Label(" Ještě nebyl vybrán žádný soubor...");
|
311 |
|
|
inputFile.setStyle("-fx-font-style: italic;");
|
312 |
|
|
inputFile.setPrefWidth(500); // Value to cut the text.
|
313 |
|
|
inputFile.setMaxWidth(Double.MAX_VALUE);
|
314 |
49fd8648
|
Michal Horký
|
|
315 |
5ae26965
|
horkmi
|
Button setInputFile = new Button("Vstupní soubor");
|
316 |
|
|
setInputFile.setOnAction(event -> {
|
317 |
|
|
FileChooser fCh = new FileChooser();
|
318 |
|
|
fCh.setInitialDirectory(new File("."));
|
319 |
|
|
// The input can be a zip file or file without a specific extension -> file chooser without extension filters...
|
320 |
|
|
// fCh.getExtensionFilters().add(new FileChooser.ExtensionFilter("Binary Files", "*.out"));
|
321 |
a5557143
|
horkmi
|
|
322 |
|
|
String inputDir = properties.getProperty(FileWorker.INPUT_DIR);
|
323 |
|
|
if (inputDir != null) {
|
324 |
|
|
File initDir = new File(inputDir);
|
325 |
|
|
if (initDir.exists()) {
|
326 |
|
|
fCh.setInitialDirectory(initDir);
|
327 |
|
|
}
|
328 |
|
|
}
|
329 |
|
|
|
330 |
5ae26965
|
horkmi
|
File file = fCh.showOpenDialog(stage);
|
331 |
|
|
if (file != null) {
|
332 |
a5557143
|
horkmi
|
properties.setProperty(FileWorker.INPUT_DIR, file.getAbsoluteFile().getParent());
|
333 |
5ae26965
|
horkmi
|
setOutputLayoutDisabled(true);
|
334 |
|
|
|
335 |
|
|
inputFile.setText(file.getAbsolutePath());
|
336 |
|
|
inputFile.setStyle("-fx-font-weight: bold;");
|
337 |
|
|
|
338 |
7e0b699a
|
horkmi
|
converter.setInput(file, null);
|
339 |
5ae26965
|
horkmi
|
}
|
340 |
|
|
});
|
341 |
49fd8648
|
Michal Horký
|
|
342 |
5ae26965
|
horkmi
|
HBox bIF = new HBox();
|
343 |
|
|
bIF.setAlignment(Pos.CENTER_RIGHT);
|
344 |
|
|
bIF.getChildren().add(setInputFile);
|
345 |
49fd8648
|
Michal Horký
|
|
346 |
5ae26965
|
horkmi
|
VBox forInput = new VBox();
|
347 |
|
|
forInput.setAlignment(Pos.CENTER_LEFT);
|
348 |
|
|
forInput.setPadding(new Insets(10, 10, 0, 10));
|
349 |
|
|
forInput.setSpacing(5.0);
|
350 |
|
|
forInput.getChildren().addAll(forInputFile, inputFile, bIF);
|
351 |
03a2d08f
|
Michal Horký
|
|
352 |
5ae26965
|
horkmi
|
return new Tab("Soubor", forInput);
|
353 |
03a2d08f
|
Michal Horký
|
}
|
354 |
|
|
|
355 |
49fd8648
|
Michal Horký
|
private Node createMenu() {
|
356 |
|
|
Menu menu = new Menu("Aplikace");
|
357 |
|
|
|
358 |
|
|
MenuItem fullScreen = createMenuItem(null, null, new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN));
|
359 |
|
|
fullScreen.setOnAction(event -> {
|
360 |
|
|
stage.setFullScreen(!stage.isFullScreen());
|
361 |
|
|
});
|
362 |
|
|
this.fullScreen = (Label) fullScreen.getGraphic();
|
363 |
|
|
changeFullScreenMenuItem();
|
364 |
|
|
|
365 |
98da6ab0
|
horkmi
|
MenuItem close = createMenuItem("Ukončit", FileWorker.getResource("/close.png"), new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN));
|
366 |
49fd8648
|
Michal Horký
|
close.setOnAction(event -> {
|
367 |
|
|
Platform.exit();
|
368 |
|
|
});
|
369 |
|
|
|
370 |
|
|
menu.getItems().addAll(fullScreen, new SeparatorMenuItem(), close);
|
371 |
|
|
|
372 |
|
|
MenuBar bar = new MenuBar();
|
373 |
|
|
bar.getMenus().add(menu);
|
374 |
|
|
return bar;
|
375 |
|
|
}
|
376 |
|
|
|
377 |
|
|
private void changeFullScreenMenuItem() {
|
378 |
|
|
fullScreen.setText(stage.isFullScreen() ? "Normální zobrazení" : "Plné zobrazení");
|
379 |
98da6ab0
|
horkmi
|
fullScreen.setGraphic(new ImageView(stage.isFullScreen() ? FileWorker.getResource("/normal.png") : FileWorker.getResource("/full.png")));
|
380 |
49fd8648
|
Michal Horký
|
}
|
381 |
|
|
|
382 |
|
|
private MenuItem createMenuItem(String name, String icon, KeyCodeCombination keyCodeComb) {
|
383 |
|
|
Label label = new Label(name);
|
384 |
|
|
label.setGraphicTextGap(10);
|
385 |
|
|
label.getStyleClass().add("menu-graphics");
|
386 |
|
|
label.setMinWidth(175);
|
387 |
|
|
label.setMaxWidth(175);
|
388 |
|
|
if (icon != null)
|
389 |
|
|
label.setGraphic(new ImageView(new Image(icon)));
|
390 |
|
|
|
391 |
|
|
MenuItem menuItem = new MenuItem();
|
392 |
|
|
menuItem.setGraphic(label);
|
393 |
|
|
menuItem.setAccelerator(keyCodeComb);
|
394 |
|
|
return menuItem;
|
395 |
|
|
}
|
396 |
|
|
|
397 |
|
|
private void setOutputLayoutDisabled(boolean disable) {
|
398 |
5ae26965
|
horkmi
|
outputLayout.setDisable(disable);
|
399 |
a5d16f0a
|
horkmi
|
}
|
400 |
|
|
|
401 |
49fd8648
|
Michal Horký
|
@Override
|
402 |
|
|
public void loadingInputFileError() {
|
403 |
|
|
Platform.runLater(()->{
|
404 |
|
|
Report.error("Načítání souboru", null, "Při načítání souboru došlo k chybě.");
|
405 |
|
|
});
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
@Override
|
409 |
c670fa2f
|
@havlijan17
|
public void completed(String json, String loaded) {
|
410 |
5ae26965
|
horkmi
|
Platform.runLater(() -> {
|
411 |
c670fa2f
|
@havlijan17
|
String _json = json;
|
412 |
5ae26965
|
horkmi
|
|
413 |
c670fa2f
|
@havlijan17
|
boolean showData = json != null;
|
414 |
5ae26965
|
horkmi
|
|
415 |
e608f492
|
horkmi
|
if (!showData && loaded != null &&
|
416 |
98da6ab0
|
horkmi
|
Report.confirm("Výsledek deserializace", null, "Při deserializaci došlo k chybě. "
|
417 |
|
|
+ "Je ale možné, že nejde o serializovaná data. Chcete zobrazit, co bylo načteno?")) {
|
418 |
c670fa2f
|
@havlijan17
|
|
419 |
|
|
_json = loaded.trim();
|
420 |
5ae26965
|
horkmi
|
showData = true;
|
421 |
|
|
}
|
422 |
|
|
|
423 |
|
|
if (showData) {
|
424 |
c670fa2f
|
@havlijan17
|
editor.setContent(_json);
|
425 |
5ae26965
|
horkmi
|
setOutputLayoutDisabled(false);
|
426 |
49fd8648
|
Michal Horký
|
}
|
427 |
|
|
});
|
428 |
03a2d08f
|
Michal Horký
|
}
|
429 |
|
|
|
430 |
|
|
}
|