
package com.caci.highview.imaging.client.integrated;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Set;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import sun.awt.AppContext;

public class RedactionTool extends Application {
    
    public static RedactionTool theApp = null;
    {
        theApp = this;
    }
    
    public static Stage stage;

    public static String fxmlPath = "/fxml/RedactionTool.fxml";
   
    // app context debugging information 
    private static void reviewAppContextInfo(String caller)
    {
        Set<AppContext> contexts = AppContext.getAppContexts();
        
        if (null == AppContext.getAppContext())
        {
            System.out.println("LORI: " + caller + "; AppContext.getAppContext is returning null, trouble is brewing");
        }
        else
        {
            System.out.println("LORI: " + caller + "; AppContext.getAppContext is returning a value as expected.");
        }
        
        if (contexts.isEmpty())
        {
            System.out.println("LORI: " + caller + "; the appcontexts set is empty");
        }
        else 
        {
           System.out.println("LORI: " + caller + "; the appcontexts set has " + contexts.size() + " elements");
           Iterator<AppContext> e = contexts.iterator();
           int i = 0;
           while (e.hasNext()) 
           {
               i++;
               AppContext a = e.next();
               System.out.println("LORI: " + caller + "; app Context " + a);
           }
        }        
    }
    
    public RedactionTool() {
        super();
        reviewAppContextInfo("RedactionTool constructor");
    }
    
    @Override public void init() throws Exception {
        reviewAppContextInfo("RedactionTool.init");
    }
    
    @Override public void start(Stage stage) throws Exception {

        RedactionTool.stage = stage;

        FXMLLoader loader = new FXMLLoader();
        loader.load(getClass().getResourceAsStream(fxmlPath));

        Parent root = loader.getRoot();
        Scene scene = new Scene(root);
        stage.setScene(scene);

        stage.show();
    }
        
}
