Search in sources :

Example 1 with TabViewPane

use of jgnash.uifx.control.TabViewPane in project jgnash by ccavanaugh.

the class MainView method start.

public void start(final Stage stage, @Nullable final File dataFile, final char[] password, @Nullable final String host, final int port) throws Exception {
    ThemeManager.restoreLastUsedTheme();
    primaryStage = stage;
    busyPane = new BusyPane();
    try {
        final FXMLLoader fxmlLoader = new FXMLLoader(MenuBarController.class.getResource("MainMenuBar.fxml"), resources);
        menuBar = fxmlLoader.load();
    } catch (final Exception e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    final ToolBar mainToolBar = FXMLLoader.load(Objects.requireNonNull(MainToolBarController.class.getResource("MainToolBar.fxml")), resources);
    tabViewPane = new TabViewPane();
    final VBox top = new VBox();
    top.getChildren().addAll(menuBar, mainToolBar);
    top.setFillWidth(true);
    statusBar = new StatusBar();
    final BorderPane borderPane = new BorderPane();
    borderPane.setTop(top);
    borderPane.setCenter(tabViewPane);
    borderPane.setBottom(statusBar);
    final StackPane stackPane = new StackPane();
    stackPane.getChildren().addAll(borderPane, busyPane);
    final Scene scene = new Scene(stackPane, 640, 480);
    ThemeManager.applyStyleSheets(scene);
    scene.getRoot().styleProperty().bind(ThemeManager.styleProperty());
    stage.setTitle(TITLE);
    stage.getIcons().add(StaticUIMethods.getApplicationIcon());
    stage.setScene(scene);
    stage.setResizable(true);
    // enforce a min width to prevent it from disappearing with a bad click and drag
    stage.setMinWidth(640);
    stage.setMinHeight(480);
    installHandlers();
    MessageBus.getInstance().registerListener(this, MessageChannel.SYSTEM);
    StageUtils.addBoundsListener(stage, MainView.class);
    stage.show();
    Engine.addLogHandler(statusBarLogHandler);
    EngineFactory.addLogHandler(statusBarLogHandler);
    UpdateFactory.addLogHandler(statusBarLogHandler);
    // listen to my own logger
    logger.addHandler(statusBarLogHandler);
    stage.toFront();
    stage.requestFocus();
    if (host != null) {
        // connect to a remote server instead of loading a local file
        new Thread(() -> {
            try {
                Thread.sleep(BootEngineTask.FORCED_DELAY);
                backgroundExecutor.execute(() -> JavaFXUtils.runLater(() -> BootEngineTask.initiateBoot(null, password, true, host, port)));
            } catch (InterruptedException e) {
                logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
                Thread.currentThread().interrupt();
            }
        }).start();
    } else if (dataFile != null) {
        // Load the specified file, this overrides the last open file
        new Thread(() -> {
            try {
                Thread.sleep(BootEngineTask.FORCED_DELAY);
                backgroundExecutor.execute(() -> JavaFXUtils.runLater(() -> BootEngineTask.initiateBoot(dataFile.getAbsolutePath(), password, false, null, 0)));
            } catch (InterruptedException e) {
                logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
                Thread.currentThread().interrupt();
            }
        }).start();
    } else if (Options.openLastProperty().get()) {
        // Load the last open file if enabled
        new Thread(() -> {
            try {
                Thread.sleep(BootEngineTask.FORCED_DELAY);
                backgroundExecutor.execute(() -> JavaFXUtils.runLater(BootEngineTask::openLast));
            } catch (InterruptedException e) {
                logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
                Thread.currentThread().interrupt();
            }
        }).start();
    }
    loadPlugins();
    checkForLatestRelease();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Scene(javafx.scene.Scene) FXMLLoader(javafx.fxml.FXMLLoader) StatusBar(jgnash.uifx.control.StatusBar) TabViewPane(jgnash.uifx.control.TabViewPane) BusyPane(jgnash.uifx.control.BusyPane) BootEngineTask(jgnash.uifx.tasks.BootEngineTask) ToolBar(javafx.scene.control.ToolBar) VBox(javafx.scene.layout.VBox) StackPane(javafx.scene.layout.StackPane)

Aggregations

FXMLLoader (javafx.fxml.FXMLLoader)1 Scene (javafx.scene.Scene)1 ToolBar (javafx.scene.control.ToolBar)1 BorderPane (javafx.scene.layout.BorderPane)1 StackPane (javafx.scene.layout.StackPane)1 VBox (javafx.scene.layout.VBox)1 BusyPane (jgnash.uifx.control.BusyPane)1 StatusBar (jgnash.uifx.control.StatusBar)1 TabViewPane (jgnash.uifx.control.TabViewPane)1 BootEngineTask (jgnash.uifx.tasks.BootEngineTask)1