Search in sources :

Example 1 with VersionChecker

use of net.sf.latexdraw.util.VersionChecker in project latexdraw by arnobl.

the class LaTeXDraw method start.

@Override
public void start(final Stage stage) {
    final Task<Void> task = new Task<Void>() {

        @Override
        protected Void call() throws IOException {
            updateProgress(0.1, 1d);
            Platform.runLater(() -> {
                mainStage = new Stage(StageStyle.DECORATED);
                mainStage.setIconified(true);
                mainStage.setTitle(LABEL_APP);
            });
            final Parent root = // NON-NLS
            FXMLLoader.load(// NON-NLS
            getClass().getResource("/fxml/UI.fxml"), // NON-NLS
            LangTool.INSTANCE.getBundle(), new LatexdrawBuilderFactory(injector), instanceCallBack);
            updateProgress(0.6, 1d);
            final Scene scene = new Scene(root);
            updateProgress(0.7, 1d);
            // NON-NLS
            scene.getStylesheets().add("css/style.css");
            updateProgress(0.8, 1d);
            Platform.runLater(() -> {
                mainStage.setScene(scene);
                updateProgress(0.9, 1d);
                mainStage.show();
                registerScene(scene);
                final PreferencesSetter prefSetter = injector.getInstance(PreferencesSetter.class);
                prefSetter.readXMLPreferences();
                // Preventing the stage to close automatically.
                mainStage.addEventHandler(WindowEvent.WINDOW_CLOSE_REQUEST, WindowEvent::consume);
                // NON-NLS
                mainStage.getIcons().add(new Image("/res/LaTeXDrawIcon.png"));
                mainStage.centerOnScreen();
                injector.getInstance(MagneticGrid.class).update();
                injector.getInstance(TabSelector.class).centreViewport();
                injector.getInstance(Canvas.class).requestFocus();
                // Checking a new version if required.
                if (VersionChecker.WITH_UPDATE && injector.getInstance(PreferencesSetter.class).isVersionCheckEnable()) {
                    new Thread(new VersionChecker(injector.getInstance(StatusBarController.class))).start();
                }
                setModified(false);
            });
            return null;
        }
    };
    task.setOnFailed(BadaboomCollector.INSTANCE);
    showSplash(stage, task);
    new Thread(task).start();
}
Also used : Task(javafx.concurrent.Task) Parent(javafx.scene.Parent) PreferencesSetter(net.sf.latexdraw.instruments.PreferencesSetter) TabSelector(net.sf.latexdraw.instruments.TabSelector) Canvas(net.sf.latexdraw.view.jfx.Canvas) StatusBarController(net.sf.latexdraw.instruments.StatusBarController) Scene(javafx.scene.Scene) Image(javafx.scene.image.Image) VersionChecker(net.sf.latexdraw.util.VersionChecker) WindowEvent(javafx.stage.WindowEvent) Stage(javafx.stage.Stage) MagneticGrid(net.sf.latexdraw.view.MagneticGrid)

Aggregations

Task (javafx.concurrent.Task)1 Parent (javafx.scene.Parent)1 Scene (javafx.scene.Scene)1 Image (javafx.scene.image.Image)1 Stage (javafx.stage.Stage)1 WindowEvent (javafx.stage.WindowEvent)1 PreferencesSetter (net.sf.latexdraw.instruments.PreferencesSetter)1 StatusBarController (net.sf.latexdraw.instruments.StatusBarController)1 TabSelector (net.sf.latexdraw.instruments.TabSelector)1 VersionChecker (net.sf.latexdraw.util.VersionChecker)1 MagneticGrid (net.sf.latexdraw.view.MagneticGrid)1 Canvas (net.sf.latexdraw.view.jfx.Canvas)1