package kiyut.alkitab.core;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import kiyut.alkitab.Application;
import org.crosswire.jsword.book.sword.SwordBookPath;
import org.openide.modules.ModuleInstall;

/**
 * Core Module Install for Netbeans Platform
 * 
 */
public class CoreModuleInstall extends ModuleInstall {
    
    @Override
    public  void restored() {
        super.restored();
        
        //System.setProperty("netbeans.buildnumber", Application.VERSION);
        System.setProperty("alkitab.buildnumber", Application.getBuildNumber());
        System.setProperty("alkitab.version", Application.getVersion());
        
        //TODO set this when on windows [HOME]/.sword
        //SwordBookPath.setAugmentPath(arg0)
        //setAugmentPath(File[] theNewDirs) throws BookException
        
        //System.out.println(System.getProperty ("user.home"));
        //System.out.println(System.getProperty ("netbeans.user"));
        
        StringBuilder sb = new StringBuilder();
        
        File[] files;
        File file;
        
        sb.append("AugmentPath:\n");
        files = SwordBookPath.getAugmentPath();
        for (int i=0; i<files.length; i++) {
            sb.append("\t" + files[i].toString() + "\n");
        }
        
        sb.append("SwordPath:\n");
        files = SwordBookPath.getSwordPath();
        for (int i=0; i<files.length; i++) {
            sb.append("\t" + files[i].toString() + "\n");
        }
        
        sb.append("DownloadDir:\n");
        file = SwordBookPath.getDownloadDir();
        sb.append("\t" + (file != null ? file.toString() : "") + "\n");
        
        sb.append("SwordDownloadDir:\n");
        file = SwordBookPath.getSwordDownloadDir();
        sb.append("\t" + (file != null ? file.toString() : "") + "\n");
        
        sb.append("-----------------------------------------------------------------\n");
        
        Logger logger = Logger.getLogger(this.getClass().getName());
        logger.log(Level.INFO,"Sword Path");
        logger.log(Level.INFO,sb.toString());
    }
}
