/* Studio for kdb+ by Charles Skelton
   is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Germany License
   http://creativecommons.org/licenses/by-nc-sa/3.0
   except for the netbeans components which retain their original copyright notice
*/

package studio.core;

import studio.kdb.Config;
import studio.kdb.Lm;
import studio.ui.ExceptionGroup;
import studio.ui.LicensePanel;
import studio.ui.Studio;

import java.util.TimeZone;
import javax.swing.JOptionPane;

public class EntryPoint {
    public static void main(String[] args) {
        TimeZone.setDefault(TimeZone.getTimeZone("GMT"));

        if (System.getProperty("mrj.version") != null) {
            System.setProperty("apple.laf.useScreenMenuBar","true");
            //     System.setProperty("apple.awt.brushMetalLook", "true");
            System.setProperty("apple.awt.showGrowBox","true");
            System.setProperty("com.apple.mrj.application.apple.menu.about.name","Studio for kdb+");
            System.setProperty("com.apple.mrj.application.live-resize","true");
            System.setProperty("com.apple.macos.smallTabs","true");
            System.setProperty("com.apple.mrj.application.growbox.intrudes","false");
        }

        if (!Config.getInstance().getAcceptedLicense()) {
            LicensePanel panel = new LicensePanel();
            Object[] options = new String[]{
                "Accept","Do Not Accept"
            };
            int answer = JOptionPane.showOptionDialog(null,
                                                      panel,"Studio for kdb+",
                                                      JOptionPane.YES_NO_OPTION,
                                                      JOptionPane.QUESTION_MESSAGE,
                                                      Studio.getImage(Config.imageBase + "32x32/question.png"), //do not use a custom Icon
                                                      options, //the titles of buttons
                                                      options[1]); //default button title

            if (answer == JOptionPane.NO_OPTION)
                System.exit(0);

            Config.getInstance().setAcceptedLicense(Lm.buildDate);
        }
//otherwise input has been canceled
     /*   
        LicenseInformationDialog license = new LicenseInformationDialog(null);
        // license.setStartLocation(MainFrame.this);
        license.setTitle("Studio for kdb+ :: License information");
        license.setModal(true);
        license.pack();
        license.show();
         */

        ThreadGroup exceptionThreadGroup = new ExceptionGroup();

        new Thread(exceptionThreadGroup,"Init thread") {
            public void run() {
                Studio.init();
            }
        }.start();


    /*        final UncaughtExceptionHandler eh=new UncaughtExceptionHandler()
    {
    public void uncaughtException(Thread t,Throwable e)
    {
    CharArrayWriter caw=new CharArrayWriter();

    e.printStackTrace(new PrintWriter(caw));

    JOptionPane.showMessageDialog(null,
    "An uncaught exception occurred\n\nDetails - \n\n"+caw.toString(),
    "Studio for kdb+",
    JOptionPane.ERROR_MESSAGE);
    }
    };



    Runnable runner=new Runnable()
    {
    public void run()
    {
    Thread.setDefaultUncaughtExceptionHandler(eh);
    Studio.init();
    }
    };
    try
    {
    SwingUtilities.invokeAndWait(runner);
    }
    catch(InterruptedException ex)
    {
    ex.printStackTrace();
    }
    catch(InvocationTargetException ex)
    {
    ex.printStackTrace();
    }
     */
    }
}

@@ -386,40 +386,8 @@
 p;%0D%0A
-import studio.ui.LicensePanel;%0D%0A
 impo
@@ -470,16 +470,79 @@
 onPane;%0D
+%0Aimport javax.swing.UIManager;%0D%0Aimport studio.ui.LicensePanel;%0D
 %0A%0D%0Apubli
@@ -591,16 +591,22 @@
 id main(
+final 
 String%5B%5D
@@ -1293,24 +1293,331 @@
        %7D%0D%0A%0D%0A
+        if(Config.getInstance().getLookAndFeel()!=null)%7B%0D%0A            try %7B%0D%0A                UIManager.setLookAndFeel(Config.getInstance().getLookAndFeel());%0D%0A            %7D catch (Exception ex) %7B%0D%0A                // go on with default one%0D%0A                ex.printStackTrace();%0D%0A            %7D%0D%0A        %7D%0D%0A%0D%0A
         if (
@@ -2618,1011 +2618,209 @@
  %7D%0D%0A
-//otherwise input has been canceled%0D%0A     /*   %0D%0A        LicenseInformationDialog license = new LicenseInformationDialog(null);%0D%0A        // license.setStartLocation(MainFrame.this);%0D%0A        license.setTitle(%22Studio for kdb+ :: License information%22);%0D%0A        license.setModal(true);%0D%0A        license.pack();%0D%0A        license.show();%0D%0A         */%0D%0A%0D%0A        ThreadGroup exceptionThreadGroup = new ExceptionGroup();%0D%0A%0D%0A        new Thread(exceptionThreadGroup,%22Init thread%22) %7B%0D%0A            public void run() %7B%0D%0A                Studio.init();%0D%0A            %7D%0D%0A        %7D.start();%0D%0A%0D%0A%0D%0A    /*        final UncaughtExceptionHandler eh=new UncaughtExceptionHandler()%0D%0A    %7B%0D%0A    public void uncaughtException(Thread t,Throwable e)%0D%0A    %7B%0D%0A    CharArrayWriter caw=new CharArrayWriter();%0D%0A%0D%0A    e.printStackTrace(new PrintWriter(caw));%0D%0A%0D%0A    JOptionPane.showMessageDialog(null,%0D%0A    %22An uncaught exception occurred%5Cn%5CnDetails - %5Cn%5Cn%22+caw.toString(),%0D%0A    %22Studio for kdb+%22,%0D%0A    JOptionPane.ERROR_MESSAGE
+%0D%0A        ThreadGroup exceptionThreadGroup = new ExceptionGroup();%0D%0A%0D%0A        new Thread(exceptionThreadGroup,%22Init thread%22) %7B%0D%0A            public void run() %7B%0D%0A                Studio.init(args
 );%0D%0A    
 %7D%0D%0A 
@@ -2819,417 +2819,39 @@
     
-%7D%0D%0A
     
-%7D;%0D%0A%0D%0A%0D%0A%0D%0A    Runnable runner=new Runnable()%0D%0A    %7B%0D%0A    public void run()%0D%0A    %7B%0D%0A    Thread.setDefaultUncaughtExceptionHandler(eh);%0D%0A    Studio.init();%0D%0A    %7D%0D%0A    %7D;%0D%0A    try%0D%0A    %7B%0D%0A    SwingUtilities.invokeAndWait(runner);%0D%0A    %7D%0D%0A    catch(InterruptedException ex)%0D%0A    %7B%0D%0A    ex.printStackTrace();%0D%0A    %7D%0D%0A    catch(InvocationTargetException ex)%0D%0A    %7B%0D%0A    ex.printStackTrace();%0D%0A    %7D%0D%0A     */
+    %7D%0D%0A        %7D.start();%0D%0A
 %0D%0A  

add support of seting up l&f from config