package org.sikuli.slides.guis;

import java.io.File;

import org.sikuli.slides.utils.Constants;
import org.sikuli.slides.utils.Utils;
import org.sikuli.slides.core.SikuliPowerPoint;


/**
 * 
 * @author Khalid Alharbi
 * Khalid.Alharbi@Colorado.edu
 *
 */

public class Main{
	
	  
	private void intiProject(){
		// create the project working directory directory
		if(!Utils.createWorkingDirectory()){
			System.err.println("Failed to create sikuli-slides working directory in +"+System.getProperty("java.io.tmpdir"));
			System.exit(1);
		}
		//TODO: remove this
		/*else{
			System.out.println("created working directory in: "+Constants.workingDirectoryPath);
		}*/
	}

	/**
	 * starts processing the work
	 */
	public void doSikuliPowerPoint(File file){	
		Constants.Execution_Start_Time=System.currentTimeMillis();
		if(file!=null){
			// display Tutorial Controller UI when tutorial mode is running
			if(Constants.TUTORIAL_MODE){
				System.out.println("Running in tutorial mode...");
				TutorialConrollerUI.runUI();
			}
			// run sikuli-slides work
			SikuliPowerPoint sikuliPowerPoint=new SikuliPowerPoint(file);
			sikuliPowerPoint.runSikuliPowerPoint();
		}
	}
	
	public static void main(String[]args){
		Main main=new Main();
		main.intiProject();
		
		// if no arguments are passed, run the GUI mode
		if(args.length==0){
			MainUI.runGuiTool();
		}
		// Otherwise, run the command line tool and get the file name
		else{			
			String FileName=MainCommandLine.runCommandLineTool(args);
			if(FileName!=null){
				main.doSikuliPowerPoint(new File(FileName));
			}
		}
	}
	
}
@@ -47,16 +47,97 @@
 o.File;%0A
+import javax.swing.UIManager;%0Aimport javax.swing.UnsupportedLookAndFeelException;
 %0Aimport 
@@ -1290,16 +1290,844 @@
 %5Dargs)%7B%0A
+%09%09// Set the application name in Mac OS X title bar%0A%09%09if (System.getProperty(%22os.name%22).contains(%22Mac%22))%7B%0A%09%09%09System.setProperty(%22apple.laf.useScreenMenuBar%22, %22true%22);%0A%09%09%09// set the name of the application menu item%0A%09%09%09System.setProperty(%22com.apple.mrj.application.apple.menu.about.name%22, %22Sikuli-Slides%22);%0A%09        // set the look and feel%0A%09        try %7B%0A%09        %09UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());%0A%09        %7D %0A%09        catch (ClassNotFoundException e) %7B%0A%09                e.printStackTrace();%0A%09        %7D%0A%09        catch (InstantiationException e) %7B%0A%09                e.printStackTrace();%0A%09        %7D%0A%09        catch (IllegalAccessException e) %7B%0A%09                e.printStackTrace();%0A%09        %7D %0A%09        catch (UnsupportedLookAndFeelException e) %7B%0A%09        %09e.printStackTrace();%0A%09        %7D%0A%09%09%7D%0A%09%09%0A
 %09%09Main m

set the application name in Mac OS X menu bar