Browse Source

code clean up and removed some unneeded mwc uses in DBController

Seil0 2 months ago
parent
commit
a80e077d47

+ 9
- 12
src/main/java/kellerkinder/HomeFlix/application/Main.java View File

@@ -85,6 +85,11 @@ public class Main extends Application {
85 85
 			primaryStage.setScene(scene); // append scene to stage
86 86
 			primaryStage.show(); // show stage
87 87
 			
88
+			
89
+			
90
+			mainWindowController = loader.getController();	//Link of FXMLController and controller class
91
+			mainWindowController.init();
92
+			
88 93
 			// startup checks
89 94
 			if (!XMLController.getConfigFile().exists()) {
90 95
 				XMLController.getDirHomeFlix().mkdir();
@@ -98,8 +103,7 @@ public class Main extends Application {
98 103
 				XMLController.getPosterCache().mkdir();
99 104
 			}
100 105
 			
101
-			mainWindowController = loader.getController();	//Link of FXMLController and controller class
102
-			mainWindowController.init();
106
+			
103 107
 		} catch (IOException e) {
104 108
 			LOGGER.error(e);
105 109
 		}
@@ -132,7 +136,7 @@ public class Main extends Application {
132 136
 	 * we need to get the path for the first source from the user and add it to 
133 137
 	 * sources.json, if the user ends the file-/directory-chooser the program will exit
134 138
 	 */
135
-	void addFirstSource() {
139
+	private void addFirstSource() {
136 140
 		switch (XMLController.getSysLocal()) {
137 141
 		case "en_US":
138 142
 			bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english
@@ -174,7 +178,7 @@ public class Main extends Application {
174 178
 			public void handle(ActionEvent event) {
175 179
 				FileChooser fileChooser = new FileChooser();
176 180
 				fileChooser.setTitle("addStreamSource");
177
-				File selectedFile = fileChooser.showOpenDialog(getPrimaryStage());
181
+				File selectedFile = fileChooser.showOpenDialog(primaryStage);
178 182
 				if (selectedFile != null && selectedFile.exists()) {
179 183
 					mainWindowController.addSource(selectedFile.getPath(), "stream");
180 184
 					selectFirstSource.getAlert().close();
@@ -189,12 +193,5 @@ public class Main extends Application {
189 193
 		selectFirstSource.setBtn2Action(btn2Action);
190 194
 		selectFirstSource.showAndWait();
191 195
 	}
192
-
193
-	public Stage getPrimaryStage() {
194
-		return primaryStage;
195
-	}
196
-
197
-	public AnchorPane getPane() {
198
-		return pane;
199
-	}
196
+	
200 197
 }

+ 31
- 36
src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java View File

@@ -167,7 +167,7 @@ public class MainWindowController {
167 167
 	private boolean settingsTrue = false;
168 168
 
169 169
 	private final String version = "0.7.0";
170
-	private final String buildNumber = "167";
170
+	private final String buildNumber = "169";
171 171
 	private final String versionName = "toothless dragon";
172 172
 	private String btnStyle;
173 173
 	
@@ -176,7 +176,6 @@ public class MainWindowController {
176 176
 	private int indexTable;
177 177
 	private int indexList;
178 178
 	private int next;
179
-	private ResourceBundle bundle;
180 179
 	private FilmTabelDataType currentTableFilm = new FilmTabelDataType("", "", "", "", false, false, null);
181 180
 	
182 181
 	private ObservableList<String> languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)");
@@ -487,7 +486,9 @@ public class MainWindowController {
487 486
 					e1.printStackTrace();
488 487
 				}
489 488
 				if (output.contains("which: no vlc") || output == "") {
490
-					JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info", getBundle().getString("vlcNotInstalled"), btnStyle, primaryStage);
489
+					JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info",
490
+							XMLController.getLocalBundle().getString("vlcNotInstalled"),
491
+							btnStyle, primaryStage);
491 492
 					vlcInfoAlert.showAndWait();
492 493
 				} else {
493 494
 					try {
@@ -535,7 +536,7 @@ public class MainWindowController {
535 536
 	@FXML
536 537
 	private void aboutBtnAction() {
537 538
 		String bodyText = "Project HomeFlix \nVersion: " + version + " (Build: " + buildNumber + ")  \""
538
-				+ versionName + "\" \n" + getBundle().getString("infoText");
539
+				+ versionName + "\" \n" + XMLController.getLocalBundle().getString("infoText");
539 540
 		JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, btnStyle, primaryStage);
540 541
 		infoAlert.showAndWait();
541 542
 	}
@@ -554,7 +555,7 @@ public class MainWindowController {
554 555
 	@FXML
555 556
 	private void addDirectoryBtnAction(){
556 557
 		DirectoryChooser directoryChooser = new DirectoryChooser();
557
-		directoryChooser.setTitle(bundle.getString("addDirectory"));
558
+		directoryChooser.setTitle(XMLController.getLocalBundle().getString("addDirectory"));
558 559
 		File selectedFolder = directoryChooser.showDialog(primaryStage);
559 560
 		if (selectedFolder != null && selectedFolder.exists()) {
560 561
 			addSource(selectedFolder.getPath(), "local");
@@ -566,7 +567,7 @@ public class MainWindowController {
566 567
 	@FXML
567 568
 	private void addStreamSourceBtnAction(){
568 569
 		FileChooser fileChooser = new FileChooser();
569
-		fileChooser.setTitle(bundle.getString("addStreamSource"));
570
+		fileChooser.setTitle(XMLController.getLocalBundle().getString("addStreamSource"));
570 571
 		File selectedFile = fileChooser.showOpenDialog(primaryStage);
571 572
 		if (selectedFile != null && selectedFile.exists()) {
572 573
 			addSource(selectedFile.getPath(), "stream");
@@ -677,8 +678,10 @@ public class MainWindowController {
677 678
 		// clear old sources list/table
678 679
 		getSourcesList().clear();
679 680
 		getSourceRoot().getChildren().clear();
681
+		
680 682
 		// update the database and all films from the database
681 683
 		dbController.refreshDataBase();
684
+		checkAllPosters(); // check if there is anything to cache
682 685
 	}
683 686
 	
684 687
 	/**
@@ -754,37 +757,37 @@ public class MainWindowController {
754 757
 	void setLocalUI() {
755 758
 		switch (XMLController.getUsrLocal()) {
756 759
 		case "en_US":
757
-			setBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US)); // us_English
760
+			XMLController.setLocalBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US)); // us_English
758 761
 			languageChoisBox.getSelectionModel().select(0);
759 762
 			break;
760 763
 		case "de_DE":
761
-			setBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.GERMAN)); // German
764
+			XMLController.setLocalBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.GERMAN)); // German
762 765
 			languageChoisBox.getSelectionModel().select(1);
763 766
 			break;
764 767
 		default:
765
-			setBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US)); // default local
768
+			XMLController.setLocalBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US)); // default local
766 769
 			languageChoisBox.getSelectionModel().select(0);
767 770
 			break;
768 771
 		}
769
-		aboutBtn.setText(getBundle().getString("info"));
770
-		settingsBtn.setText(getBundle().getString("settings"));
771
-		searchTextField.setPromptText(getBundle().getString("tfSearch"));
772
-		openfolderbtn.setText(getBundle().getString("openFolder"));
773
-		updateBtn.setText(getBundle().getString("checkUpdates"));
774
-		addDirectoryBtn.setText(getBundle().getString("addDirectory"));
775
-		addStreamSourceBtn.setText(getBundle().getString("addStreamSource"));
776
-		homeflixSettingsLbl.setText(getBundle().getString("homeflixSettingsLbl"));
777
-		mainColorLbl.setText(getBundle().getString("mainColorLbl"));
778
-		fontsizeLbl.setText(getBundle().getString("fontsizeLbl"));
779
-		languageLbl.setText(getBundle().getString("languageLbl"));
780
-		autoUpdateToggleBtn.setText(getBundle().getString("autoUpdate"));
781
-		autoplayToggleBtn.setText(getBundle().getString("autoplay"));
782
-		branchLbl.setText(getBundle().getString("branchLbl"));
783
-		columnStreamUrl.setText(getBundle().getString("columnStreamUrl"));
784
-		columnTitle.setText(getBundle().getString("columnName"));
785
-		columnSeason.setText(getBundle().getString("columnSeason"));
786
-		columnEpisode.setText(getBundle().getString("columnEpisode"));
787
-		columnFavorite.setText(getBundle().getString("columnFavorite"));
772
+		aboutBtn.setText(XMLController.getLocalBundle().getString("info"));
773
+		settingsBtn.setText(XMLController.getLocalBundle().getString("settings"));
774
+		searchTextField.setPromptText(XMLController.getLocalBundle().getString("tfSearch"));
775
+		openfolderbtn.setText(XMLController.getLocalBundle().getString("openFolder"));
776
+		updateBtn.setText(XMLController.getLocalBundle().getString("checkUpdates"));
777
+		addDirectoryBtn.setText(XMLController.getLocalBundle().getString("addDirectory"));
778
+		addStreamSourceBtn.setText(XMLController.getLocalBundle().getString("addStreamSource"));
779
+		homeflixSettingsLbl.setText(XMLController.getLocalBundle().getString("homeflixSettingsLbl"));
780
+		mainColorLbl.setText(XMLController.getLocalBundle().getString("mainColorLbl"));
781
+		fontsizeLbl.setText(XMLController.getLocalBundle().getString("fontsizeLbl"));
782
+		languageLbl.setText(XMLController.getLocalBundle().getString("languageLbl"));
783
+		autoUpdateToggleBtn.setText(XMLController.getLocalBundle().getString("autoUpdate"));
784
+		autoplayToggleBtn.setText(XMLController.getLocalBundle().getString("autoplay"));
785
+		branchLbl.setText(XMLController.getLocalBundle().getString("branchLbl"));
786
+		columnStreamUrl.setText(XMLController.getLocalBundle().getString("columnStreamUrl"));
787
+		columnTitle.setText(XMLController.getLocalBundle().getString("columnName"));
788
+		columnSeason.setText(XMLController.getLocalBundle().getString("columnSeason"));
789
+		columnEpisode.setText(XMLController.getLocalBundle().getString("columnEpisode"));
790
+		columnFavorite.setText(XMLController.getLocalBundle().getString("columnFavorite"));
788 791
 	}
789 792
 	
790 793
 	// if AutoUpdate, then check for updates
@@ -870,14 +873,6 @@ public class MainWindowController {
870 873
 		return sourcesList;
871 874
 	}
872 875
 
873
-	public ResourceBundle getBundle() {
874
-		return bundle;
875
-	}
876
-
877
-	public void setBundle(ResourceBundle bundle) {
878
-		this.bundle = bundle;
879
-	}
880
-
881 876
 	public TreeTableView<FilmTabelDataType> getFilmsTreeTable() {
882 877
 		return filmsTreeTable;
883 878
 	}

+ 20
- 20
src/main/java/kellerkinder/HomeFlix/controller/DBController.java View File

@@ -457,26 +457,26 @@ public class DBController {
457 457
 			ObservableList<Node> textFlow = mainWindowController.getTextFlow().getChildren();	
458 458
 			ArrayList<Text> nameText = new ArrayList<Text>();
459 459
 			
460
-			nameText.add(new Text(mainWindowController.getBundle().getString("title") + ": "));
461
-			nameText.add(new Text(mainWindowController.getBundle().getString("year") + ": "));
462
-			nameText.add(new Text(mainWindowController.getBundle().getString("rated") + ": "));
463
-			nameText.add(new Text(mainWindowController.getBundle().getString("released") + ": "));
464
-			nameText.add(new Text(mainWindowController.getBundle().getString("season") + ": "));
465
-			nameText.add(new Text(mainWindowController.getBundle().getString("episode") + ": "));
466
-			nameText.add(new Text(mainWindowController.getBundle().getString("runtime") + ": "));
467
-			nameText.add(new Text(mainWindowController.getBundle().getString("genre") + ": "));
468
-			nameText.add(new Text(mainWindowController.getBundle().getString("director") + ": "));
469
-			nameText.add(new Text(mainWindowController.getBundle().getString("writer") + ": "));
470
-			nameText.add(new Text(mainWindowController.getBundle().getString("actors") + ": "));
471
-			nameText.add(new Text(mainWindowController.getBundle().getString("plot") + ": "));
472
-			nameText.add(new Text(mainWindowController.getBundle().getString("language") + ": "));
473
-			nameText.add(new Text(mainWindowController.getBundle().getString("country") + ": "));
474
-			nameText.add(new Text(mainWindowController.getBundle().getString("awards") + ": "));
475
-			nameText.add(new Text(mainWindowController.getBundle().getString("metascore") + ": "));
476
-			nameText.add(new Text(mainWindowController.getBundle().getString("imdbRating") + ": "));
477
-			nameText.add(new Text(mainWindowController.getBundle().getString("type") + ": "));
478
-			nameText.add(new Text(mainWindowController.getBundle().getString("boxOffice") + ": "));
479
-			nameText.add(new Text(mainWindowController.getBundle().getString("website") + ": "));
460
+			nameText.add(new Text(XMLController.getLocalBundle().getString("title") + ": "));
461
+			nameText.add(new Text(XMLController.getLocalBundle().getString("year") + ": "));
462
+			nameText.add(new Text(XMLController.getLocalBundle().getString("rated") + ": "));
463
+			nameText.add(new Text(XMLController.getLocalBundle().getString("released") + ": "));
464
+			nameText.add(new Text(XMLController.getLocalBundle().getString("season") + ": "));
465
+			nameText.add(new Text(XMLController.getLocalBundle().getString("episode") + ": "));
466
+			nameText.add(new Text(XMLController.getLocalBundle().getString("runtime") + ": "));
467
+			nameText.add(new Text(XMLController.getLocalBundle().getString("genre") + ": "));
468
+			nameText.add(new Text(XMLController.getLocalBundle().getString("director") + ": "));
469
+			nameText.add(new Text(XMLController.getLocalBundle().getString("writer") + ": "));
470
+			nameText.add(new Text(XMLController.getLocalBundle().getString("actors") + ": "));
471
+			nameText.add(new Text(XMLController.getLocalBundle().getString("plot") + ": "));
472
+			nameText.add(new Text(XMLController.getLocalBundle().getString("language") + ": "));
473
+			nameText.add(new Text(XMLController.getLocalBundle().getString("country") + ": "));
474
+			nameText.add(new Text(XMLController.getLocalBundle().getString("awards") + ": "));
475
+			nameText.add(new Text(XMLController.getLocalBundle().getString("metascore") + ": "));
476
+			nameText.add(new Text(XMLController.getLocalBundle().getString("imdbRating") + ": "));
477
+			nameText.add(new Text(XMLController.getLocalBundle().getString("type") + ": "));
478
+			nameText.add(new Text(XMLController.getLocalBundle().getString("boxOffice") + ": "));
479
+			nameText.add(new Text(XMLController.getLocalBundle().getString("website") + ": "));
480 480
 			
481 481
 			// set the correct font for the  nameText
482 482
 			for (Text text : nameText) {

+ 3
- 3
src/main/java/kellerkinder/HomeFlix/controller/UpdateController.java View File

@@ -76,7 +76,7 @@ public class UpdateController implements Runnable {
76 76
 	public void run() {
77 77
 		LOGGER.info("beta:" + useBeta + "; checking for updates ...");
78 78
 		Platform.runLater(() -> {
79
-			mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnChecking"));
79
+			mainWindowController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnChecking"));
80 80
 		});
81 81
 		
82 82
 		try {
@@ -116,12 +116,12 @@ public class UpdateController implements Runnable {
116 116
 		 */
117 117
 		if (buildNumber >= updateBuildNumber) {
118 118
 			Platform.runLater(() -> {
119
-				mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnNoUpdateAvailable"));
119
+				mainWindowController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnNoUpdateAvailable"));
120 120
 			});
121 121
 			LOGGER.info("no update available");
122 122
 		} else {
123 123
 			Platform.runLater(() -> {
124
-				mainWindowController.getUpdateBtn().setText(mainWindowController.getBundle().getString("updateBtnUpdateAvailable"));
124
+				mainWindowController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnUpdateAvailable"));
125 125
 			});
126 126
 			LOGGER.info("update available");
127 127
 			browserDownloadUrl = objectAsset.getString("browser_download_url", "");

+ 12
- 0
src/main/java/kellerkinder/HomeFlix/controller/XMLController.java View File

@@ -30,7 +30,9 @@ import java.io.IOException;
30 30
 import java.io.InputStream;
31 31
 import java.io.InputStreamReader;
32 32
 import java.io.OutputStream;
33
+import java.util.Locale;
33 34
 import java.util.Properties;
35
+import java.util.ResourceBundle;
34 36
 
35 37
 import org.apache.logging.log4j.LogManager;
36 38
 import org.apache.logging.log4j.Logger;
@@ -60,6 +62,7 @@ public class XMLController {
60 62
 	private static boolean useBeta = false;
61 63
 	private static boolean autoplay = false;
62 64
 	private static double fontSize = 17;
65
+	private static ResourceBundle localBundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US);
63 66
 	
64 67
 	// user settings
65 68
 	private static String omdbAPIKey;
@@ -281,6 +284,15 @@ public class XMLController {
281 284
 	public static void setFontSize(double fontSize) {
282 285
 		XMLController.fontSize = fontSize;
283 286
 	}
287
+	
288
+	public static ResourceBundle getLocalBundle() {
289
+		return localBundle;
290
+	}
291
+
292
+	public static void setLocalBundle(ResourceBundle localBundle) {
293
+		XMLController.localBundle = localBundle;
294
+	}
295
+
284 296
 
285 297
 	// getters for APIs
286 298
 	

+ 0
- 5
src/main/java/kellerkinder/HomeFlix/player/Player.java View File

@@ -24,7 +24,6 @@ package kellerkinder.HomeFlix.player;
24 24
 
25 25
 import javafx.event.EventHandler;
26 26
 import javafx.fxml.FXMLLoader;
27
-import javafx.scene.Parent;
28 27
 import javafx.scene.Scene;
29 28
 import javafx.scene.image.Image;
30 29
 import javafx.scene.layout.AnchorPane;
@@ -78,10 +77,6 @@ public class Player {
78 77
 	public Stage getStage() {
79 78
 		return stage;
80 79
 	}
81
-
82
-	public Parent getPane() {
83
-		return pane;
84
-	}
85 80
 	
86 81
 	public Scene getScene() {
87 82
 		return scene;

Loading…
Cancel
Save