Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bb1c567 authored by Frank Preel's avatar Frank Preel
Browse files

Macos menu (to be continued)

parent a27f92bf
Loading
Loading
Loading
Loading
+55 −6
Original line number Diff line number Diff line
@@ -18,20 +18,36 @@ package ecorp.easy.installer;

import static ecorp.easy.installer.AppConstants.JavaHome;
import static ecorp.easy.installer.AppConstants.OsName;
import ecorp.easy.installer.controllers.MainWindowController;

import java.net.URL;
import java.nio.file.Paths;
import java.util.Locale;
import java.util.ResourceBundle;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ecorp.easy.installer.controllers.MainWindowController;
import ecorp.easy.installer.exceptions.TooManyDevicesException;
import ecorp.easy.installer.models.Command;
import ecorp.easy.installer.models.Phone;
import ecorp.easy.installer.models.steps.CommandExecutionResult;
import ecorp.easy.installer.tasks.CommandExecutionTask;
import ecorp.easy.installer.tasks.DeviceDetectionTask;
import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.concurrent.WorkerStateEvent;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Screen;
import javafx.stage.Stage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * this is the entry point of the software
@@ -50,6 +66,21 @@ public class EasyInstaller extends Application {
     */
    @Override
    public void start(Stage stage) throws Exception {
    	
    	/* DEBUG FP
		TODO Remove
    	Command command = new Command("/Users/frankpreel/Documents/ESPRI/git_repos/Easy  Installer/bin/adb/adb");
        command.addParameter("1", "devices");
        command.addParameter("2", "-l");
        
        CommandExecutionTask task = new CommandExecutionTask(command);

        task.run(); //I feel like it lacks something... but it work in test
        
        CommandExecutionResult result = task.get();
        */
        
    	
    	logger.debug("\nOS name = {}\nJava Home = {}\nCurrent working dir = {}\nADB folder path = {}", OsName, JavaHome, Paths.get("").toAbsolutePath().toString(), AppConstants.getADBFolderPath());
        
        Locale currentLocale= Locale.getDefault();
@@ -58,14 +89,32 @@ public class EasyInstaller extends Application {
        logger.debug("language = {}, country = {} ", currentLocale.getLanguage(), currentLocale.getCountry());
        
       //Load main view
        FXMLLoader loader = new FXMLLoader(getClass().getResource(FXML_PATH+"mainWindow.fxml"));
        URL r = getClass().getResource(FXML_PATH+"mainWindow.fxml");
        FXMLLoader loader = new FXMLLoader(r);
        loader.setResources(i18n);
        Parent root = loader.load() ;
        controller = loader.getController();
        

        
        //Defines some properties
        Scene scene = new Scene(root);
        
        stage.setTitle(i18n.getString("appTitle")+AppConstants.APP_VERSION);
        
        try {
			MenuBar mb = (MenuBar) root.getChildrenUnmodifiable().get(1);
			if( System.getProperty("os.name","UNKNOWN").equals("Mac OS X")) {
				logger.debug("Detected Mac OS.");
		        mb.setUseSystemMenuBar(true);
		        
			} else {
				mb.setVisible(false);
			}
		} catch (Exception e) {
			logger.debug("Error - cannot find menu bar");
		}
        
        stage.setScene(scene);

        stage.setResizable(true);