/**
 *
 * Copyright (c) 2006-2017, Speedment, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); You may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.speedment.tool.core.internal.controller;

import com.speedment.common.injector.annotation.Inject;
import com.speedment.common.logger.Logger;
import com.speedment.common.logger.LoggerManager;
import com.speedment.runtime.core.component.InfoComponent;
import com.speedment.runtime.core.internal.util.Statistics;
import com.speedment.tool.core.component.UserInterfaceComponent;
import com.speedment.tool.core.component.VersionComponent;
import com.speedment.tool.core.internal.util.InjectionLoader;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.VBox;

import java.net.URL;
import java.util.ResourceBundle;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static javafx.application.Platform.runLater;

/**
 *
 * @author Emil Forslund
 */
public final class SceneController implements Initializable {
    
    private final static Logger LOGGER = LoggerManager.getLogger(SceneController.class);
    
    private @Inject UserInterfaceComponent ui;
    private @Inject InfoComponent info;
    private @Inject InjectionLoader loader;
    private @Inject VersionComponent version;
    private @Inject InfoComponent infoComponent;
    
    private @FXML VBox top;
    private @FXML SplitPane horizontal;
    private @FXML SplitPane vertical;
    
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        runLater(() -> {
            top.getChildren().add(loader.load("Menubar"));
            top.getChildren().add(loader.load("Toolbar"));
            horizontal.getItems().add(0, loader.load("ProjectTree"));
            vertical.getItems().add(loader.load("Workspace"));
            vertical.getItems().add(loader.load("Output"));
            
            horizontal.setDividerPositions(0.2, 0.7);
            vertical.setDividerPositions(0.7, 0.3);
            
            Statistics.onGuiProjectLoaded(infoComponent);
            
            CompletableFuture.runAsync(() -> {
                try {
                    version.latestVersion()
                        .thenAcceptAsync(release -> {
                            runLater(() -> {
                                final int compare = release.compareTo(info.getImplementationVersion());
                                if (compare == 0) {
                                    ui.showNotification(
                                        "Your version of " + info.getTitle() + " is up to date."
                                    );
                                } else if (compare > 0) {
                                    ui.showNotification(
                                        "A new version " + release +
                                            " of " + info.getTitle() + " is available."
                                    );
                                } else {
                                    ui.showNotification(
                                        "Your version " + info.getImplementationVersion() +
                                            " of " + info.getTitle() + " is newer than the released " +
                                            release + "."
                                    );
                                }
                            });
                        }).get(3, TimeUnit.SECONDS);
                } catch (final InterruptedException | ExecutionException ex) {
                    LOGGER.debug(ex, "Error loading last released version.");
                } catch (final TimeoutException ex) {
                    LOGGER.debug(ex, "Request for latest released version timed out.");
                }
            });
        });
    }
}
@@ -878,32 +878,94 @@
 .InfoComponent;%0A
+import com.speedment.runtime.core.component.ProjectComponent;%0A
 import com.speed
@@ -1008,16 +1008,16 @@
 istics;%0A
-
 import c
@@ -1560,16 +1560,108 @@
 ption;%0A%0A
+import static com.speedment.runtime.core.internal.util.Statistics.Event.GUI_PROJECT_LOADED;%0A
 import s
@@ -2091,36 +2091,39 @@
 private @Inject 
-Info
+Project
 Component infoCo
@@ -2120,27 +2120,18 @@
 ent 
-infoComponent;%0A    
+projects;%0A
 %0A   
@@ -2776,28 +2776,16 @@
 , 0.3);%0A
-            
 %0A       
@@ -2804,40 +2804,49 @@
 ics.
-onGuiProjectLoaded(infoComponent
+report(info, projects, GUI_PROJECT_LOADED
 );%0A 
@@ -3025,38 +3025,8 @@
 e -%3E
- %7B%0A                           
  run
@@ -3067,20 +3067,16 @@
         
-   
- 
 final in
@@ -3167,20 +3167,16 @@
         
-    
 if (comp
@@ -3211,36 +3211,32 @@
                 
-   
- 
 ui.showNotificat
@@ -3232,36 +3232,32 @@
 owNotification(%0A
-    
                 
@@ -3361,35 +3361,27 @@
             
-   
- 
 );%0A
-    
             
@@ -3446,36 +3446,32 @@
                 
-   
- 
 ui.showNotificat
@@ -3467,36 +3467,32 @@
 owNotification(%0A
-    
                 
@@ -3572,36 +3572,32 @@
                 
-   
- 
 %22 of %22 + info.ge
@@ -3652,34 +3652,27 @@
             
-    );%0A   
+);%0A
             
@@ -3683,25 +3683,24 @@
             
- 
 %7D else %7B%0A   
@@ -3696,20 +3696,16 @@
  else %7B%0A
-    
         
@@ -3777,36 +3777,32 @@
                 
-   
- 
 %22Your version %22 
@@ -3837,20 +3837,16 @@
 ion() +%0A
-    
         
@@ -3977,20 +3977,16 @@
         
-    
 release 
@@ -4019,34 +4019,27 @@
             
-    );%0A   
+);%0A
             
@@ -4046,39 +4046,34 @@
                 
- 
 %7D%0A
-    
                 
@@ -4086,35 +4086,8 @@
   %7D)
-;%0A                        %7D
 ).ge

Replace Google Analytics with api.speedment.com/stat