don't use mains primarystage, disabled column resizeing

This commit is contained in:
Jannik 2019-01-08 19:02:00 +01:00
parent d3d22db7a8
commit 3e80354d88
3 changed files with 32 additions and 23 deletions

View File

@ -59,7 +59,6 @@ public class Main extends Application {
LOGGER.info("User: " + XMLController.getUserName() + " " + XMLController.getUserHome());
this.primaryStage = primaryStage;
mainWindowController = new MainWindowController(this);
mainWindow();
}
@ -72,7 +71,6 @@ public class Main extends Application {
try {
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/fxml/MainWindow.fxml"));
loader.setController(mainWindowController);
pane = (AnchorPane) loader.load();
primaryStage.setMinHeight(600.00);
primaryStage.setMinWidth(1000.00);
@ -100,6 +98,7 @@ public class Main extends Application {
XMLController.getPosterCache().mkdir();
}
mainWindowController = loader.getController(); //Link of FXMLController and controller class
mainWindowController.init();
} catch (IOException e) {
LOGGER.error(e);

View File

@ -82,6 +82,7 @@ import javafx.scene.text.Font;
import javafx.scene.text.TextFlow;
import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javafx.util.Duration;
import kellerkinder.HomeFlix.controller.DBController;
import kellerkinder.HomeFlix.controller.OMDbAPIController;
@ -155,11 +156,11 @@ public class MainWindowController {
// poster-mode
// @FXML private AnchorPane posterModeAnchorPane;
private Main main;
private MainWindowController mainWindowController;
private UpdateController updateController;
private DBController dbController;
private XMLController xmlController;
private Stage primaryStage;
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
private boolean menuTrue = false;
@ -187,17 +188,16 @@ public class MainWindowController {
private MenuItem dislike = new MenuItem("dislike"); // TODO one option (like or dislike)
private ContextMenu menu = new ContextMenu(like, dislike);
/**
* Initialize other objects: Updater, dbController and ApiQuery
* @param main the main object
*/
public MainWindowController(Main main) {
this.main = main;
mainWindowController = this;
xmlController = new XMLController(); // TODO pass it over from main?
dbController = new DBController(this);
public MainWindowController() {
// the constructor
}
@FXML
public void initialize() {
mainWindowController = this;
xmlController = new XMLController();
dbController = new DBController(this);
}
public void init() {
LOGGER.info("Initializing Project-HomeFlix build " + buildNumber);
@ -206,6 +206,7 @@ public class MainWindowController {
checkAutoUpdate();
// initialize the GUI and the DBController
primaryStage = (Stage) mainAnchorPane.getScene().getWindow(); // set primary stage for dialogs
initTabel();
initUI();
initActions();
@ -244,10 +245,21 @@ public class MainWindowController {
// film Table
columnStreamUrl.setMaxWidth(0);
columnTitle.setMaxWidth(190);
columnTitle.setMaxWidth(182);
columnFavorite.setMaxWidth(80);
columnSeason.setMaxWidth(73);
columnEpisode.setMaxWidth(77);
columnSeason.setMaxWidth(70);
columnEpisode.setMaxWidth(70);
columnTitle.setMinWidth(182);
columnFavorite.setMinWidth(80);
columnSeason.setMinWidth(70);
columnEpisode.setMinWidth(70);
columnTitle.setResizable(false);
columnFavorite.setResizable(false);
columnSeason.setResizable(false);
columnEpisode.setResizable(false);
columnFavorite.setStyle("-fx-alignment: CENTER;");
filmsTreeTable.setRoot(filmRoot);
@ -298,7 +310,6 @@ public class MainWindowController {
}
if (settingsTrue) {
settingsScrollPane.setVisible(false);
xmlController.saveSettings();
settingsTrue = false;
}
});
@ -476,7 +487,7 @@ public class MainWindowController {
e1.printStackTrace();
}
if (output.contains("which: no vlc") || output == "") {
JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info", getBundle().getString("vlcNotInstalled"), btnStyle, main.getPrimaryStage());
JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info", getBundle().getString("vlcNotInstalled"), btnStyle, primaryStage);
vlcInfoAlert.showAndWait();
} else {
try {
@ -525,7 +536,7 @@ public class MainWindowController {
private void aboutBtnAction() {
String bodyText = "Project HomeFlix \nVersion: " + version + " (Build: " + buildNumber + ") \""
+ versionName + "\" \n" + getBundle().getString("infoText");
JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, btnStyle, main.getPrimaryStage());
JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, btnStyle, primaryStage);
infoAlert.showAndWait();
}
@ -533,7 +544,6 @@ public class MainWindowController {
private void settingsBtnclicked() {
if (settingsTrue) {
settingsScrollPane.setVisible(false);
xmlController.saveSettings();
settingsTrue = false;
} else {
settingsScrollPane.setVisible(true);
@ -545,7 +555,7 @@ public class MainWindowController {
private void addDirectoryBtnAction(){
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setTitle(bundle.getString("addDirectory"));
File selectedFolder = directoryChooser.showDialog(main.getPrimaryStage());
File selectedFolder = directoryChooser.showDialog(primaryStage);
if (selectedFolder != null && selectedFolder.exists()) {
addSource(selectedFolder.getPath(), "local");
} else {
@ -556,8 +566,8 @@ public class MainWindowController {
@FXML
private void addStreamSourceBtnAction(){
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("addStreamSource");
File selectedFile = fileChooser.showOpenDialog(main.getPrimaryStage());
fileChooser.setTitle(bundle.getString("addStreamSource"));
File selectedFile = fileChooser.showOpenDialog(primaryStage);
if (selectedFile != null && selectedFile.exists()) {
addSource(selectedFile.getPath(), "stream");
} else {

View File

@ -22,7 +22,7 @@
<?import javafx.scene.text.Font?>
<?import javafx.scene.text.TextFlow?>
<AnchorPane fx:id="mainAnchorPane" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1">
<AnchorPane fx:id="mainAnchorPane" prefHeight="600.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="kellerkinder.HomeFlix.application.MainWindowController">
<children>
<AnchorPane fx:id="tableModeAnchorPane" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="32.0">
<children>