// Path: src/main/java/com/dcp/sm/config/io/json/JsonSimpleReader.java
// public class JsonSimpleReader
// {
//     private JSONParser parser;
//     private FileReader json_file;
//     private JSONObject obj;
//     
//     public JsonSimpleReader(String file_name) throws IOException, ParseException
//     {
//         parser = new JSONParser();
//         json_file = new FileReader(file_name);
//         obj = (JSONObject) parser.parse(json_file);
//     }
//     
//     public JsonSimpleReader(String file_name, String root_obj) throws IOException, ParseException
//     {
//         parser = new JSONParser();
//         json_file = new FileReader(file_name);
//         obj = (JSONObject) parser.parse(json_file);
//         obj = (JSONObject) obj.get(root_obj);
//     }
//     
//     public int readInt(String name) {
//         return (Integer) obj.get(name);
//     }
//     
//     public String readString(String name) {
//         return (String) obj.get(name);
//     }
//     
//     @SuppressWarnings("unchecked")
//     public List<String> readStringList(String name) {
//         JSONArray msg = (JSONArray) obj.get(name);
//         List<String> list = new ArrayList<String>();
//         Iterator<String> iterator = msg.iterator();
//         while(iterator.hasNext()) {
//             list.add(iterator.next());
//         }
//         return list;
//     }
//     @SuppressWarnings("unchecked")
//     public String[] readStringArray(String name) {
//         JSONArray msg = (JSONArray) obj.get(name);
//         String[] arr = new String[msg.size()];
//         Iterator<String> iterator = msg.iterator();
//         for(int i=0;iterator.hasNext();i++) {
//             arr[i] = iterator.next();
//         }
//         return arr;
//     }
//     
//     public void close() throws IOException {
//         json_file.close();
//     }
//     
// 
//     @SuppressWarnings("unchecked")
//     public static void main(String[] args)
//     {
//         JSONParser parser = new JSONParser();
//         
//         try {
//      
//             Object obj = parser.parse(new FileReader("src/dcp/config/io/json/test.txt"));
//      
//             JSONObject jsonObject = (JSONObject) obj;
//      
//             String name = (String) jsonObject.get("name");
//             System.out.println(name);
//      
//             long age = (Long) jsonObject.get("age");
//             System.out.println(age);
//      
//             // loop array
//             JSONArray msg = (JSONArray) jsonObject.get("messages");
//             Iterator<String> iterator = msg.iterator();
//             while (iterator.hasNext()) {
//                 System.out.println(iterator.next());
//             }
//      
//         } catch (FileNotFoundException e) {
//             e.printStackTrace();
//         } catch (IOException e) {
//             e.printStackTrace();
//         } catch (ParseException e) {
//             e.printStackTrace();
//         }
//     }
// 
// }
// 
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java
// public static enum FILE_TYPE {
//     File,
//     Folder,
//     Archive,
//     Executable,
//     Setup,
//     Document,
//     Image,
//     Web,
//     Sound,
//     Video,
//     Custom
// }


import java.io.File;
import java.io.IOException;
import org.apache.pivot.util.Filter;
import org.apache.pivot.util.concurrent.TaskExecutionException;
import org.apache.pivot.wtk.media.Image;
import org.json.simple.parser.ParseException;
import com.dcp.sm.config.io.json.JsonSimpleReader;
import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE;
    //public static String jarListeners;// = libPath+"/dcp-listeners.jar";
    public static String jarResources;// = libPath+"/dcp-resources.jar";
    //Ant build files
    public static String xmlIzpackAntBuild;// = antPath+"/izpack-target.xml";
    public static String xmlRunAntBuild;// = antPath+"/run-target.xml";
    public static String xmlDebugAntBuild;// = antPath+"/debug-target.xml";
    //Bat files
    public static String batClean;// = batPath+"/clean.bat";
    //izpack spec files
    public static String xmlProcessPanelSpec;// = xmlPath+"/ProcessPanelSpec.xml";
    public static String xmlShortcutPanelSpec;// = xmlPath+"/ShortcutPanelSpec.xml";
    public static String xmlRegistrySpec;// = xmlPath+"/RegistrySpec.xml";
    // chocolatey files
    public static String psChocolateyInstall;// = psPath+"/ChocolateyInstall.ps1"
    public static String psChocolateyUninstall;// = psPath+"/ChocolateyUninstall.ps1"
    
    public static String saveFile = "";//"save.dcp";
    public static void setSaveFile(String canonicalPath) {
        if (canonicalPath.length() > 0 && !canonicalPath.endsWith("."+IOFactory.dcpFileExt)) {//add file extension if not given
            canonicalPath = canonicalPath.concat("."+IOFactory.dcpFileExt);
        }
        saveFile = canonicalPath;
    }
    
    /**
     * Load settings from JSON file: settings.json
     * @throws ParseException 
     * @throws IOException 
     */
    private static boolean loadSettings(String json_file) throws IOException, ParseException {
// Path: src/main/java/com/dcp/sm/config/io/json/JsonSimpleReader.java
// public class JsonSimpleReader
// {
//     private JSONParser parser;
//     private FileReader json_file;
//     private JSONObject obj;
//     
//     public JsonSimpleReader(String file_name) throws IOException, ParseException
//     {
//         parser = new JSONParser();
//         json_file = new FileReader(file_name);
//         obj = (JSONObject) parser.parse(json_file);
//     }
//     
//     public JsonSimpleReader(String file_name, String root_obj) throws IOException, ParseException
//     {
//         parser = new JSONParser();
//         json_file = new FileReader(file_name);
//         obj = (JSONObject) parser.parse(json_file);
//         obj = (JSONObject) obj.get(root_obj);
//     }
//     
//     public int readInt(String name) {
//         return (Integer) obj.get(name);
//     }
//     
//     public String readString(String name) {
//         return (String) obj.get(name);
//     }
//     
//     @SuppressWarnings("unchecked")
//     public List<String> readStringList(String name) {
//         JSONArray msg = (JSONArray) obj.get(name);
//         List<String> list = new ArrayList<String>();
//         Iterator<String> iterator = msg.iterator();
//         while(iterator.hasNext()) {
//             list.add(iterator.next());
//         }
//         return list;
//     }
//     @SuppressWarnings("unchecked")
//     public String[] readStringArray(String name) {
//         JSONArray msg = (JSONArray) obj.get(name);
//         String[] arr = new String[msg.size()];
//         Iterator<String> iterator = msg.iterator();
//         for(int i=0;iterator.hasNext();i++) {
//             arr[i] = iterator.next();
//         }
//         return arr;
//     }
//     
//     public void close() throws IOException {
//         json_file.close();
//     }
//     
// 
//     @SuppressWarnings("unchecked")
//     public static void main(String[] args)
//     {
//         JSONParser parser = new JSONParser();
//         
//         try {
//      
//             Object obj = parser.parse(new FileReader("src/dcp/config/io/json/test.txt"));
//      
//             JSONObject jsonObject = (JSONObject) obj;
//      
//             String name = (String) jsonObject.get("name");
//             System.out.println(name);
//      
//             long age = (Long) jsonObject.get("age");
//             System.out.println(age);
//      
//             // loop array
//             JSONArray msg = (JSONArray) jsonObject.get("messages");
//             Iterator<String> iterator = msg.iterator();
//             while (iterator.hasNext()) {
//                 System.out.println(iterator.next());
//             }
//      
//         } catch (FileNotFoundException e) {
//             e.printStackTrace();
//         } catch (IOException e) {
//             e.printStackTrace();
//         } catch (ParseException e) {
//             e.printStackTrace();
//         }
//     }
// 
// }
// 
// Path: src/main/java/com/dcp/sm/logic/factory/TypeFactory.java
// public static enum FILE_TYPE {
//     File,
//     Folder,
//     Archive,
//     Executable,
//     Setup,
//     Document,
//     Image,
//     Web,
//     Sound,
//     Video,
//     Custom
// }


// Path: src/main/java/com/dcp/sm/config/io/IOFactory.java
import java.io.File;
import java.io.IOException;
import org.apache.pivot.util.Filter;
import org.apache.pivot.util.concurrent.TaskExecutionException;
import org.apache.pivot.wtk.media.Image;
import org.json.simple.parser.ParseException;
import com.dcp.sm.config.io.json.JsonSimpleReader;
import com.dcp.sm.logic.factory.TypeFactory.FILE_TYPE;

    //public static String jarListeners;// = libPath+"/dcp-listeners.jar";
    public static String jarResources;// = libPath+"/dcp-resources.jar";
    //Ant build files
    public static String xmlIzpackAntBuild;// = antPath+"/izpack-target.xml";
    public static String xmlRunAntBuild;// = antPath+"/run-target.xml";
    public static String xmlDebugAntBuild;// = antPath+"/debug-target.xml";
    //Bat files
    public static String batClean;// = batPath+"/clean.bat";
    //izpack spec files
    public static String xmlProcessPanelSpec;// = xmlPath+"/ProcessPanelSpec.xml";
    public static String xmlShortcutPanelSpec;// = xmlPath+"/ShortcutPanelSpec.xml";
    public static String xmlRegistrySpec;// = xmlPath+"/RegistrySpec.xml";
    // chocolatey files
    public static String psChocolateyInstall;// = psPath+"/ChocolateyInstall.ps1"
    public static String psChocolateyUninstall;// = psPath+"/ChocolateyUninstall.ps1"
    
    public static String saveFile = "";//"save.dcp";
    public static void setSaveFile(String canonicalPath) {
        if (canonicalPath.length() > 0 && !canonicalPath.endsWith("."+IOFactory.dcpFileExt)) {//add file extension if not given
            canonicalPath = canonicalPath.concat("."+IOFactory.dcpFileExt);
        }
        saveFile = canonicalPath;
    }
    
    /**
     * Load settings from JSON file: settings.json
     * @throws ParseException 
     * @throws IOException 
     */
    private static boolean loadSettings(String json_file) throws IOException, ParseException {
        JsonSimpleReader json_ext = new JsonSimpleReader(json_file, "extensions");