From b36dc74e90ce31098ba3ffcf807fbeb6d5c940e8 Mon Sep 17 00:00:00 2001
From: fabiantheblind <fabiantheblind@googlemail.com>
Date: Thu, 4 Aug 2011 22:53:39 +0200
Subject: [PATCH] added a lot of scripts removed duplicated code

---
 MPOLnchActionComponent.cpp   | 253 +----------------------------------
 MPOLnchEyeballObserver.cpp   |  25 +---
 MPOLnchHelper.cpp            | 207 ++++++++++++++++++++++++----
 MPOLnchHelper.h              |  53 +++++---
 MPOLnchID.h                  |   6 +-
 MPOLnchPenObserver.cpp       |  28 +---
 MPOLnchTreeViewWidgetMgr.cpp |  10 +-
 MPOLnch_deDE.fr              |   1 +
 MPOLnch_enUS.fr              |   2 +
 MPOLnch_jaJP.fr              |   2 +
 10 files changed, 235 insertions(+), 352 deletions(-)

diff --git a/MPOLnchActionComponent.cpp b/MPOLnchActionComponent.cpp
index a1a0303..b49939d 100644
--- a/MPOLnchActionComponent.cpp
+++ b/MPOLnchActionComponent.cpp
@@ -91,12 +91,6 @@ class MPOLnchActionComponent : public CActionComponent
 	
 		void DoStoreFCQueries();
 	
-		/** This copys the query files to the right preference folder */
-	
-		void CopyQueryFilesToPrefsFolder(PMString fcfilename, PMString fctype);
-	
-	void CopyFilesToLauncherFolder(PMString filename , PMString foldername, bool16 subfolder);
-
 	
 		/** Encapsulates functionality for the AddItem menu item. 
 			
@@ -104,11 +98,6 @@ class MPOLnchActionComponent : public CActionComponent
 		*/
 		void DoAddItem(IPMUnknown *invokedWidget);
 	
-	
-		/* My personal copyFile
-		 * until i get FileUtils::CopyFile() to work
-		 */
-	//	bool copyFile (const char SRC[], const char DEST[]);
 
 
 		/** Encapsulates functionality for the RemoveItem menu item. 
@@ -244,154 +233,10 @@ void MPOLnchActionComponent::DoAbout()
 void MPOLnchActionComponent::DoStoreFCQueries()
 {
 	MPOLnchHelper helper;
-	
-	for (int i = 0; i < helper.FCGREPMAXITEMS ; i++) {
-		
-		CopyQueryFilesToPrefsFolder(helper.GetGrepFCFile(i), PMString("GREP"));
-
-	//	IDFile theGRPSource = helper.GetInternalResourceFolder();
-//		
-//		FileUtils::AppendPath(&theGRPSource, PMString(helper.GetGrepFCFile(i)));
-//		PMString grpFileStringUrl = FileUtils::SysFileToFileURL(theGRPSource);
-//		if(!FileUtils::DoesFileExist(theGRPSource)){
-//			CAlert::InformationAlert(" could not find the Source File. I am Here-> " + grpFileStringUrl 
-//									 +"\n"+
-//									 " Please report this bug to: info@the-moron.net");
-//			break;
-//		}
-//		
-//		// this gets the GREP folder within the Library/Preferences/Adobe InDesign/ ...
-//		IDFile theGRPTarget;
-//		FileUtils::GetAppRoamingDataFolder(&theGRPTarget, "Find-Change Queries");
-//		FileUtils::AppendPath(&theGRPTarget,"GREP");
-//		FileUtils::CreateFolderIfNeeded(theGRPTarget,kTrue);
-//		PMString fngrp(helper.GetGrepFCFile(i));
-//		FileUtils::AppendPath(&theGRPTarget, fngrp);
-//		
-//		if(!FileUtils::DoesFileExist(theGRPTarget)){
-//			CAlert::InformationAlert("I will try to copy "+fngrp+ " to your Preferences");
-//			if(!FileUtils::CopyFile(theGRPSource, theGRPTarget)){
-//				CAlert::InformationAlert("Could not copy "+fngrp+". Sorry");
-//			}
-//		}
-//
-
-
-		
-	} // end of for FCGREPMAXITEMS
-
-	for (int j = 0; j < helper.FCTEXTMAXITEMS ; j++) {
-		
-		//IDFile theFCTXTSource = helper.GetInternalResourceFolder();
-		CopyQueryFilesToPrefsFolder(helper.GetTextFCFile(j), PMString("Text"));
-
-		
-	} // end of for FCTEXTMAXITEMS	
-	
-	for (int k = 0; k < helper.FCOBJECTMAXITEMS ; k++) {
-		
-		//IDFile theFCOBJSource = helper.GetInternalResourceFolder();
-		CopyQueryFilesToPrefsFolder(helper.GetObjectFCFile(k), PMString("Object"));
-		
-	} // end of for FCGREPMAXITEMS
+	helper.RestoreFCQueries();
 
 } // end of DoStoreFCQueries
 
-/* A Helper For copying files
-*/
-
-void MPOLnchActionComponent::CopyQueryFilesToPrefsFolder(PMString fcfilename, PMString fctype){
-
-	MPOLnchHelper helper;
-
-	IDFile theGRPSource = helper.GetInternalResourceFolder();
-	
-	FileUtils::AppendPath(&theGRPSource, fcfilename);
-	PMString grpFileStringUrl = FileUtils::SysFileToFileURL(theGRPSource);
-	if(!FileUtils::DoesFileExist(theGRPSource)){
-		CAlert::InformationAlert(" could not find the Source File. I am Here-> " + grpFileStringUrl 
-								 +"\n"+
-								 " Please report this bug to: info@the-moron.net");
-		return;
-	}
-	
-	// this gets the GREP folder within the Library/Preferences/Adobe InDesign/ ...
-	IDFile theGRPTarget;
-	FileUtils::GetAppRoamingDataFolder(&theGRPTarget, "Find-Change Queries");
-	FileUtils::AppendPath(&theGRPTarget,fctype);
-	FileUtils::CreateFolderIfNeeded(theGRPTarget,kTrue);
-	PMString fngrp(fcfilename);
-	FileUtils::AppendPath(&theGRPTarget, fngrp);
-	
-	if(!FileUtils::DoesFileExist(theGRPTarget)){
-		CAlert::InformationAlert("I will try to copy "+fngrp+ " to your Preferences");
-		if(!FileUtils::CopyFile(theGRPSource, theGRPTarget)){
-			CAlert::InformationAlert("Could not copy "+fngrp+". Sorry");
-		}
-	}
-}
-
-/* A Helper For copying files
- */
-
-
-void MPOLnchActionComponent::CopyFilesToLauncherFolder(PMString filename , PMString foldername, bool16 subfolder){
-	
-	MPOLnchHelper helper;
-	
-	IDFile source = helper.GetInternalResourceFolder();
-	
-	FileUtils::AppendPath(&source, filename);
-	PMString fileStringUrl = FileUtils::SysFileToFileURL(source);
-	if(!FileUtils::DoesFileExist(source)){
-		CAlert::InformationAlert(" could not find the Source File. I am Here-> " + fileStringUrl 
-								 +"\n"+
-								 " Please report this bug to: info@the-moron.net");
-		return;
-	}
-	
-	IDFile target = helper.GetScriptFilesFolder();
-	if (subfolder) {
-		
-		FileUtils::AppendPath(&target, foldername);
-		FileUtils::CreateFolderIfNeeded(target,kTrue);
-
-	}
-
-	PMString fn(filename);
-	
-	FileUtils::AppendPath(&target, fn);
-	
-	if(!FileUtils::DoesFileExist(target)){
-		if (subfolder) {
-			CAlert::InformationAlert("I will try to copy "+fn
-									 + " to the folder: Scripts Panel/MPO Launcher/"
-									 +foldername);
-		}else{
-		CAlert::InformationAlert("I will try to copy "+fn
-								 + " to the folder: Scripts Panel/MPO Launcher");
-		}
-		if(!FileUtils::CopyFile(source, target)){
-			CAlert::InformationAlert("Could not copy "+fn
-									 +". Sorry");
-		}
-	}
-	
-	// this gets the GREP folder within the Library/Preferences/Adobe InDesign/ ...
-//	IDFile target;
-//	FileUtils::GetAppRoamingDataFolder(&target, "Find-Change Queries");
-//	FileUtils::AppendPath(&target,fctype);
-//	FileUtils::CreateFolderIfNeeded(target,kTrue);
-//	PMString fngrp(fcfilename);
-//	FileUtils::AppendPath(&theGRPTarget, fn);
-//	
-//	if(!FileUtils::DoesFileExist(target)){
-//		CAlert::InformationAlert("I will try to copy "+fn+ " to your Preferences");
-//		if(!FileUtils::CopyFile(source, target)){
-//			CAlert::InformationAlert("Could not copy "+fn+". Sorry");
-//		}
-//	}
-}
 
 /* DoAddItem
 */
@@ -400,102 +245,8 @@ void MPOLnchActionComponent::DoAddItem(IPMUnknown *invokedWidget)
 	// building the scripts
 	
 	MPOLnchHelper helper;
-	
-		
-		for (int i = 0; i < helper.MAXITEMS ; i++) {
+	helper.RestoreMPOLnchScrpts();
 			
-
-		//	// the script files
-//			//
-//			//
-//			IDFile theSource = helper.GetInternalResourceFolder();//scriptfiles[i];
-//			FileUtils::AppendPath(&theSource, PMString(helper.GetScriptFile(i)));
-//			PMString sourceFileStringUrl = FileUtils::SysFileToFileURL(theSource);
-//			if(!FileUtils::DoesFileExist(theSource)){
-//				CAlert::InformationAlert(" could not find the Source File. I am Here-> " + sourceFileStringUrl 
-//										 +"\n"+
-//										 " Please report this bug to: fabiantheblind@the-moron.net");
-//				break;
-//			}
-//			IDFile theTarget = helper.GetScriptFilesFolder();
-//			PMString fn(helper.GetScriptFile(i));
-//			
-//			FileUtils::AppendPath(&theTarget, fn);
-//
-//			if(!FileUtils::DoesFileExist(theTarget)){
-//				CAlert::InformationAlert("I will try to copy "+fn+ " to the folder: Scripts Panel/MPO Launcher");
-//				if(!FileUtils::CopyFile(theSource, theTarget)){
-//					CAlert::InformationAlert("Could not copy "+fn+". Sorry");
-//				}
-//			}
-
-			CopyFilesToLauncherFolder(helper.GetScriptFile(i) , "NOFOLDER",false);
-			CopyFilesToLauncherFolder(helper.GetHelpFile(i) , "help",true);
-
-			// the help files
-			//
-			//
-			//IDFile theHelpSource = helper.GetInternalResourceFolder();//scriptfiles[i];
-//			
-//			
-//			FileUtils::AppendPath(&theHelpSource, PMString(helper.GetHelpFile(i)));
-//			
-//			PMString sourceHelpFileStringUrl = FileUtils::SysFileToFileURL(theHelpSource);
-//
-//			if(!FileUtils::DoesFileExist(theHelpSource)){
-//				CAlert::InformationAlert(" could not find the Help File. I am Here-> " + sourceHelpFileStringUrl 
-//										 +"\n"+
-//										 " Please report this bug to: fabiantheblind@the-moron.net");
-//				break;
-//			}
-//							
-//
-//			IDFile theHelpTarget = helper.GetScriptFilesFolder(); 
-//			FileUtils::AppendPath(&theHelpTarget, PMString("help"));
-//			FileUtils::CreateFolderIfNeeded(theHelpTarget,kTrue);
-//			PMString fnh(helper.GetHelpFile(i));
-//			FileUtils::AppendPath(&theHelpTarget, fnh);
-//
-//			
-//			if(!FileUtils::DoesFileExist(theHelpTarget)){
-//				CAlert::InformationAlert("I will try to copy "+fnh+ " to the folder: Scripts Panel/MPO Launcher/help");
-//					if(!FileUtils::CopyFile(theHelpSource, theHelpTarget)){
-//						CAlert::InformationAlert("Could not copy "+fnh+". Sorry");
-//					}
-//				}			
-			}// end for MAXITEMS
-	
-	
-	//THE META FILES
-	//
-		
-	for(int j = 0; j < helper.METAMAXITEMS; j++){
-	
-		IDFile theMetaSource = helper.GetInternalResourceFolder();//scriptfiles[i];
-		FileUtils::AppendPath(&theMetaSource, PMString(helper.GetMetaFile(j)));
-		
-		PMString metaSourceFileStringUrl = FileUtils::SysFileToFileURL(theMetaSource);
-		
-		if(!FileUtils::DoesFileExist(theMetaSource)){
-			CAlert::InformationAlert(" could not find the Source File. I am Here-> " + metaSourceFileStringUrl 
-									 +"\n"+
-									 " Please report this bug to: info@the-moron.net");
-			break;
-		}
-		// this gets the MPO Launcher folder within the scripts panel
-		IDFile theMetaTarget = helper.GetScriptFilesFolder();
-		FileUtils::AppendPath(&theMetaTarget, PMString("meta"));
-		FileUtils::CreateFolderIfNeeded(theMetaTarget,kTrue);
-		PMString fnm(helper.GetMetaFile(j));
-		FileUtils::AppendPath(&theMetaTarget, fnm);
-		if(!FileUtils::DoesFileExist(theMetaTarget)){
-			CAlert::InformationAlert("I will try to copy "+fnm+ " to the folder: Scripts Panel/MPO Launcher/meta");
-			if(!FileUtils::CopyFile(theMetaSource, theMetaTarget)){
-				CAlert::InformationAlert("Could not copy "+fnm+". Sorry");
-			}
-		}
-		
-	}		
 	
 }
 
diff --git a/MPOLnchEyeballObserver.cpp b/MPOLnchEyeballObserver.cpp
index 8fb7c58..d205062 100644
--- a/MPOLnchEyeballObserver.cpp
+++ b/MPOLnchEyeballObserver.cpp
@@ -196,33 +196,17 @@ void MPOLnchEyeballObserver::Update
 			
 			PMString nodeName(textControlData->GetString());
 			
-			// Show it only for debug
-			//nodeName.SetTranslatable(kFalse);	// only for debug- not real code
-			//CAlert::InformationAlert(nodeName);
 			MPOLnchHelper helper;
 			IDFile scriptFile = helper.GetScriptFilesFolder();
 			
-			//FileUtils::GetAppInstallationFolder(&scriptFile);                    //application folder path
-//			FileUtils::AppendPath(&scriptFile, PMString("Scripts"));                
-//			FileUtils::AppendPath(&scriptFile, PMString("Scripts Panel"));
-//			FileUtils::AppendPath(&scriptFile, PMString("MPO Launcher"));
-				
 				PMString fn(nodeName);
 				PMString ext(".jsx");
 				
 				
 				FileUtils::AppendPath(&scriptFile, fn + ext);
-			
 		
-			
-	
-			
-			
 			if (FileUtils::DoesFileExist(scriptFile)) {
 				
-				
-
-					
 				// for debug
 				//FileUtils::OpenFile(scriptFile);
 				InterfacePtr<IScriptRunner>scriptRunner(Utils<IScriptUtils>()->QueryScriptRunner(scriptFile));	
@@ -239,17 +223,10 @@ void MPOLnchEyeballObserver::Update
 					scriptRunner->RunFile(scriptFile,scriptParams);
 				}// close filestatus
 			}else {
-				CAlert::InformationAlert("Got an error. You need the MPO Launcher Scripts Folder in the Scripts Panel");
+				CAlert::InformationAlert(helper.MissingScrptFileStr(nodeName));
 			}
 			
 			
-		
-		
-			//	PMString dbgInfoString("MPOLnchEyeballObserver::Update() ");
-//				dbgInfoString.SetTranslatable(kFalse);	// only for debug- not real code
-//				CAlert::InformationAlert(dbgInfoString);
-			
-			
 		} while(0);
 	}
 		
diff --git a/MPOLnchHelper.cpp b/MPOLnchHelper.cpp
index d56a029..e615f90 100644
--- a/MPOLnchHelper.cpp
+++ b/MPOLnchHelper.cpp
@@ -10,34 +10,45 @@
 #include "MPOLnchHelper.h"
 
 //  constructor
-MPOLnchHelper::MPOLnchHelper();
-//{
-//}
+MPOLnchHelper::MPOLnchHelper(){
+}
+int MPOLnchHelper::MAXITEMS = 12;
+int MPOLnchHelper::METAMAXITEMS = 3;
+int MPOLnchHelper::FCGREPMAXITEMS = 19;
+int MPOLnchHelper::FCOBJECTMAXITEMS = 1;
+int MPOLnchHelper::FCTEXTMAXITEMS = 1;
+int MPOLnchHelper::MISCMAXITEMS = 5;
 
-// Helpfile function
 
-int MPOLnchHelper::MAXITEMS = 12;
+PMString MPOLnchHelper::MissingScrptFileStr(PMString fn){
+	PMString s("Got an error reading in the "+fn 
+			   + " function. You need the MPO Launcher Scripts in the Scripts Panel. Use the scriptfile restore option");
+	return s;
+}
 
-int MPOLnchHelper::METAMAXITEMS = 1;
+PMString MPOLnchHelper::MissingHelpFileStr(PMString fn){
 
-int MPOLnchHelper::FCGREPMAXITEMS = 19;
-int MPOLnchHelper::FCOBJECTMAXITEMS = 1;
+	PMString s("Got an error reading in the "+fn
+	+" help. Something went terribly wrong."+
+			 " Contact info@themoron.net for more help");
+	
+	return s;
+}
 
-int MPOLnchHelper::FCTEXTMAXITEMS = 1;
 
 PMString MPOLnchHelper::GetScriptFile(int i){
 	
 	PMString theFileName[12] = {
+		"importXML.jsx",
 		"theNumbers.jsx",
+		"theFindChange.jsx",
+		"theLinkButton.jsx",
+		"theImagePlacer.jsx",
 		"clearStructure.jsx",
 		"color_KEY.jsx",
 		"color_PAPER.jsx",
 		"color_XXX.jsx",
-		"theFindChange.jsx",
-		"newscriptfile07.jsx",
-		"newscriptfile08.jsx",
-		"newscriptfile09.jsx",
-		"newscriptfile10.jsx",
+		"color_MIXEDBLACK.jsx",
 		"newscriptfile11.jsx",
 		"QUICKY.jsx"};
 	
@@ -51,16 +62,16 @@ PMString MPOLnchHelper::GetScriptFile(int i){
 PMString MPOLnchHelper::GetHelpFile(int i){
 	
 	PMString theFileName[12] = {
+		"importXML.txt",
 		"theNumbers.txt",
+		"theFindChange.txt",
+		"theLinkButton.txt",
+		"theImagePlacer",
 		"clearStructure.txt",
 		"color_KEY.txt",
 		"color_PAPER.txt",
 		"color_XXX.txt",
-		"theFindChange.txt",
-		"newscriptfile07.txt",
-		"newscriptfile08.txt",
-		"newscriptfile09.txt",
-		"newscriptfile10.txt",
+		"color_MIXEDBLACK.jsx",
 		"newscriptfile11.txt",
 		"QUICKY.txt"};
 	
@@ -134,17 +145,37 @@ PMString MPOLnchHelper::GetTextFCFile(int i){
 
 PMString MPOLnchHelper::GetMetaFile(int i){
 	
-	PMString theFileName[1] = {
-		"glue code.jsx"};
+	PMString theFileName[3] = {
+		"glue code.jsx",
+		"processXML.jsx",
+		"setupStyles.jsx"};
 	
 	
 	
-	if (i > 1) {
-		i = 1; 
+	if (i > 3) {
+		i = 3; 
+	}
+	return theFileName[i];
+}
+
+PMString MPOLnchHelper::GetMiscFile(int i){
+	
+	PMString theFileName[5] = {
+		"change100k.jsx",
+		"changeFooterText.jsx",
+		"createOutlineSchwarz.jsx",
+		"removeGroupLabel.jsx",
+		"specsCleanerFindChange.jsx"};
+	
+	
+	
+	if (i > 3) {
+		i = 3; 
 	}
 	return theFileName[i];
 }
 
+
 PMString MPOLnchHelper::ReadAllAsText(IPMStream *s)
 {
 	PMString text;
@@ -167,7 +198,7 @@ IDFile MPOLnchHelper::GetInternalResourceFolder(){
 	
 	FileUtils::GetAppInstallationFolder(&theSource); 
 	FileUtils::AppendPath(&theSource, PMString("Plug-Ins"));                
-	FileUtils::AppendPath(&theSource, PMString("tmn"));                
+	FileUtils::AppendPath(&theSource, PMString("mpo"));                
 	FileUtils::AppendPath(&theSource, PMString("MPOLauncher.InDesignPlugin"));                
 	//			
 	FileUtils::AppendPath(&theSource, PMString("Versions"));                
@@ -191,4 +222,132 @@ IDFile MPOLnchHelper::GetScriptFilesFolder(){
 
 }
 
+void MPOLnchHelper::CopyQueryFilesToPrefsFolder(PMString fcfilename, PMString fctype){
+	
+	//MPOLnchHelper helper;
+	
+	IDFile theGRPSource = this->GetInternalResourceFolder();
+	
+	FileUtils::AppendPath(&theGRPSource, fcfilename);
+	PMString grpFileStringUrl = FileUtils::SysFileToFileURL(theGRPSource);
+	if(!FileUtils::DoesFileExist(theGRPSource)){
+		CAlert::InformationAlert(" could not find the Source File. I am Here-> " + grpFileStringUrl 
+								 +"\n"+
+								 " Please report this bug to: info@the-moron.net");
+		return;
+	}
+	
+	// this gets the GREP folder within the Library/Preferences/Adobe InDesign/ ...
+	IDFile theGRPTarget;
+	FileUtils::GetAppRoamingDataFolder(&theGRPTarget, "Find-Change Queries");
+	FileUtils::AppendPath(&theGRPTarget,fctype);
+	FileUtils::CreateFolderIfNeeded(theGRPTarget,kTrue);
+	PMString fngrp(fcfilename);
+	FileUtils::AppendPath(&theGRPTarget, fngrp);
+	
+	if(!FileUtils::DoesFileExist(theGRPTarget)){
+		CAlert::InformationAlert("I will try to copy "+fngrp+ " to your Preferences");
+		if(!FileUtils::CopyFile(theGRPSource, theGRPTarget)){
+			CAlert::InformationAlert("Could not copy "+fngrp+". Sorry");
+		}
+	}
+}
+
 
+void MPOLnchHelper::CopyFilesToLauncherFolder(PMString filename , PMString foldername, bool16 subfolder){
+	
+	//MPOLnchHelper helper;
+	
+	IDFile source = this->GetInternalResourceFolder();
+	
+	FileUtils::AppendPath(&source, filename);
+	PMString fileStringUrl = FileUtils::SysFileToFileURL(source);
+	if(!FileUtils::DoesFileExist(source)){
+		CAlert::InformationAlert(" could not find the Source File. I am Here-> " + fileStringUrl 
+								 +"\n"+
+								 " Please report this bug to: info@the-moron.net");
+		return;
+	}
+	
+	IDFile target = this->GetScriptFilesFolder();
+	if (subfolder) {
+		
+		FileUtils::AppendPath(&target, foldername);
+		FileUtils::CreateFolderIfNeeded(target,kTrue);
+		
+	}
+	
+	PMString fn(filename);
+	
+	FileUtils::AppendPath(&target, fn);
+	
+	if(!FileUtils::DoesFileExist(target)){
+		if (subfolder) {
+			CAlert::InformationAlert("I will try to copy "+fn
+									 + " to the folder: Scripts Panel/MPO Launcher/"
+									 +foldername);
+		}else{
+			CAlert::InformationAlert("I will try to copy "+fn
+									 + " to the folder: Scripts Panel/MPO Launcher");
+		}
+		if(!FileUtils::CopyFile(source, target)){
+			CAlert::InformationAlert("Could not copy "+fn
+									 +". Sorry");
+		}
+	}
+	
+}
+
+void MPOLnchHelper::RestoreFCQueries(){
+
+	for (int i = 0; i < this->FCGREPMAXITEMS ; i++) {
+		
+		this->CopyQueryFilesToPrefsFolder(this->GetGrepFCFile(i), PMString("GREP"));
+		
+	} // end of for FCGREPMAXITEMS
+	
+	for (int j = 0; j < this->FCTEXTMAXITEMS ; j++) {
+		
+		this->CopyQueryFilesToPrefsFolder(this->GetTextFCFile(j), PMString("Text"));
+		
+		
+	} // end of for FCTEXTMAXITEMS	
+	
+	for (int k = 0; k < this->FCOBJECTMAXITEMS ; k++) {
+		
+		this->CopyQueryFilesToPrefsFolder(this->GetObjectFCFile(k), PMString("Object"));
+		
+	} // end of for FCGREPMAXITEMS
+}
+
+void MPOLnchHelper::RestoreMPOLnchScrpts(){
+	
+	for (int i = 0; i < this->MAXITEMS ; i++) {
+		
+		// The Scriptfiles
+		this->CopyFilesToLauncherFolder(this->GetScriptFile(i) , "NOFOLDER",kFalse);
+		// the helper files
+		this->CopyFilesToLauncherFolder(this->GetHelpFile(i) , "help",kTrue);
+		
+		
+	}// end for MAXITEMS
+	
+	
+	//THE META FILES
+	//
+	
+	for(int j = 0; j < this->METAMAXITEMS; j++){
+		
+		this->CopyFilesToLauncherFolder(this->GetMetaFile(j) , "meta",kTrue);
+		
+	}	
+
+	//THE MISC FILES
+	//
+	
+	for(int k = 0; k < this->METAMAXITEMS; k++){
+		
+		this->CopyFilesToLauncherFolder(this->GetMiscFile(k) , "misc",kTrue);
+		
+	}
+}
diff --git a/MPOLnchHelper.h b/MPOLnchHelper.h
index c3b9251..b0087af 100644
--- a/MPOLnchHelper.h
+++ b/MPOLnchHelper.h
@@ -12,6 +12,7 @@
 
 #include "IPMStream.h"
 #include "FileUtils.h"
+#include "CAlert.h"
 
 
 class MPOLnchHelper
@@ -19,30 +20,50 @@ class MPOLnchHelper
 public:
 
 	
-    MPOLnchHelper() { }; //  default constructor
+    MPOLnchHelper();//  default constructor
 	
-	PMString ReadAllAsText(IPMStream *s);
+	static int MAXITEMS;
+	static int METAMAXITEMS;
+	static int FCGREPMAXITEMS;
+	static int FCOBJECTMAXITEMS;
+	static int FCTEXTMAXITEMS;
+	static int MISCMAXITEMS;
 
-	PMString GetScriptFile(int i);
-	PMString GetHelpFile(int i);
-	PMString GetMetaFile(int i);
-	PMString GetFCFile(int i);
-	PMString GetTextFCFile(int i);
-	PMString GetGrepFCFile(int i);
-	PMString GetObjectFCFile(int i);
 
-	IDFile GetInternalResourceFolder();
+	void RestoreFCQueries(); // copy the FCQueries to the Preferences
+	void RestoreMPOLnchScrpts(); // copy the scripts to the Scripts Panel
+	PMString GetScriptFile(int i); // holds also the nodenames
+
+
+	// these should be private
+	// but for that the Scriptrunnner in 
+	// EyeballObserver and PenObserver file action has to move into the MPOLnchHelper
 	
-	IDFile GetScriptFilesFolder();
+	PMString ReadAllAsText(IPMStream *s);// Read a filestream to a PMString
 	
+	IDFile GetInternalResourceFolder(); // this is within the plugin
+	IDFile GetScriptFilesFolder(); // this is in the ScriptsPanel the "MPO Launcher" folder
+	PMString MissingScrptFileStr(PMString fn); // Error warning
+	PMString MissingHelpFileStr(PMString fn); // Error warning
 	
-	static int MAXITEMS;
-	static int METAMAXITEMS;
-	static int FCGREPMAXITEMS;
-	static int FCOBJECTMAXITEMS;
 	
-	static int FCTEXTMAXITEMS;
+private:
+
+	PMString GetHelpFile(int i); // filenames
+	PMString GetMetaFile(int i); // filenames
+	PMString GetTextFCFile(int i); // filenames
+	PMString GetMiscFile(int i); // filenames
+	PMString GetGrepFCFile(int i); // filenames
+	PMString GetObjectFCFile(int i); // filenames
+
+	void CopyQueryFilesToPrefsFolder(PMString fcfilename, PMString fctype);
+	void CopyFilesToLauncherFolder(PMString filename , PMString foldername, bool16 subfolder);
+
 	
+
+	
+
+
 };
 
 #endif
\ No newline at end of file
diff --git a/MPOLnchID.h b/MPOLnchID.h
index 6ab3efb..8dbe4ef 100644
--- a/MPOLnchID.h
+++ b/MPOLnchID.h
@@ -94,12 +94,16 @@ DECLARE_PMID(kWidgetIDSpace, kMPOLnchListElementPenWidgetID,	kMPOLnchPrefix + 5)
 // Menu item keys:
 #define kMPOLnchAddItemMenuItemKey			kMPOLnchStringPrefix "kMPOLnchAddItemMenuItemKey"
 #define kMPOLnchRemoveItemMenuItemKey		kMPOLnchStringPrefix "kMPOLnchRemoveItemMenuItemKey"
-#define kMPOLnchFCQueriesMenuItemKey		kMPOLnchStringPrefix "kMPOLnchFCQueriesMenuItemStringKey"
+#define kMPOLnchFCQueriesMenuItemKey		kMPOLnchStringPrefix "kMPOLnchFCQueriesMenuItemKey"
 
 // Other StringKeys:
 #define kMPOLnchAboutBoxStringKey			kMPOLnchStringPrefix "kMPOLnchAboutBoxStringKey"
 #define kMPOLnchAddItemStringKey				kMPOLnchStringPrefix "kMPOLnchAddItemStringKey"
 #define kMPOLnchRemoveItemStringKey			kMPOLnchStringPrefix "kMPOLnchRemoveItemStringKey"
+#define kMPOLnchFCQueriesItemStringKey		kMPOLnchStringPrefix "kMPOLnchFCQueriesItemStringKey"
+
+#define kMPOLnchMissingScriptItemStringKey		kMPOLnchStringPrefix "kMPOLnchMissingScriptItemStringKey"
+
 #define kMPOLnchPanelTitleKey				kMPOLnchStringPrefix	"kMPOLnchPanelTitleKey"
 #define kMPOLnchInternalPopupMenuNameKey		kMPOLnchStringPrefix	"kMPOLnchInternalPopupMenuNameKey"
 #define kMPOLnchTargetMenuPath kMPOLnchInternalPopupMenuNameKey
diff --git a/MPOLnchPenObserver.cpp b/MPOLnchPenObserver.cpp
index 596559e..0d68455 100644
--- a/MPOLnchPenObserver.cpp
+++ b/MPOLnchPenObserver.cpp
@@ -241,38 +241,12 @@ void MPOLnchPenObserver::Update
 				
 
 			}else {
-				CAlert::InformationAlert("Got an error reading in the "+nodeName
-										 +" help. Something went teribly wrong."+
-										 " Contact info@themoron.net for more help");
+				CAlert::InformationAlert(helper.MissingHelpFileStr(nodeName));
 			}
-			
-			
-			
-			
-				//PMString dbgInfoString("MPOLnchPenObserver::Update() ");
-//				dbgInfoString.SetTranslatable(kFalse);	// only for debug- not real code
-//				CAlert::InformationAlert(dbgInfoString);
 		
 		} while(0);
 	}
 }
 
 
-//PMString MPOLnchPenObserver::ReadAllAsText(IPMStream *s)
-//{
-//	PMString text;
-//	uchar oneChar;
-//	s->XferByte(oneChar);
-//	while (s->GetStreamState() == kStreamStateGood)
-//	{
-//		text.Append((char)oneChar);        
-//		
-//		// Read the next character
-//		s->XferByte(oneChar);
-//		
-//    } // end while streamstategood
-//	
-//    return text; 
-//}
-
 
diff --git a/MPOLnchTreeViewWidgetMgr.cpp b/MPOLnchTreeViewWidgetMgr.cpp
index a349a60..c34b640 100644
--- a/MPOLnchTreeViewWidgetMgr.cpp
+++ b/MPOLnchTreeViewWidgetMgr.cpp
@@ -74,27 +74,19 @@ bool16 MPOLnchTVWidgetMgr::ApplyDataToWidget(const NodeID& node,
 	      
 		IControlView* nameView = widgetList->FindWidget(kMPOLnchTextWidgetID);
 		
-		IControlView* myNameView = widgetList->FindWidget(kMPOLnchListElementEyeballWidgetID);
 	        
 		InterfacePtr<ITextControlData>	textControlData( nameView, UseDefaultIID() );
-		InterfacePtr<ITextControlData>	myTextControlData( myNameView, UseDefaultIID() );
 		
 
 		ASSERT(textControlData);
-		ASSERT(myTextControlData);
 		
 		if( (textControlData== nil)) {
 			break;
 		}
 		
 		textControlData->SetString(listName);
-		
-		if( (myTextControlData== nil)) {
-			break;
-		}		
-		
-		myTextControlData->SetString(listName);
 
+//
 	} while (false);
 
 	return kTrue;
diff --git a/MPOLnch_deDE.fr b/MPOLnch_deDE.fr
index 4873875..5a0bf2c 100644
--- a/MPOLnch_deDE.fr
+++ b/MPOLnch_deDE.fr
@@ -75,6 +75,7 @@ resource StringTable (kSDKDefStringsResourceID + index_deDE)
 		kMPOLnchItemBaseKey "11",					"THIS IS NOT RIGHT",
 		kMPOLnchItemBaseKey "12",					"THIS IS NOT RIGHT",
 		kMPOLnchAddedElementKey,						"  + Added Element",
+		kMPOLnchMissingScriptItemStringKey,				"Leider fehlen die MPO Launcher Scripts im Scripts Panel. benutze die Option " kMPOLnchAddItemMenuItemKey,
 	}
 
 };
diff --git a/MPOLnch_enUS.fr b/MPOLnch_enUS.fr
index a0b8d75..2c6d283 100644
--- a/MPOLnch_enUS.fr
+++ b/MPOLnch_enUS.fr
@@ -75,6 +75,8 @@ resource StringTable (kSDKDefStringsResourceID + index_enUS)
 			kMPOLnchItemBaseKey "11",					"THIS IS NOT RIGHT",
 			kMPOLnchItemBaseKey "12",					"THIS IS NOT RIGHT",
 		kMPOLnchAddedElementKey,						"  + Added Element",
+		kMPOLnchMissingScriptItemStringKey,				"The MPO Launcher Scripts in the Scripts Panel are missing. Use the option " kMPOLnchAddItemMenuItemKey,
+
 	}
 
 };
diff --git a/MPOLnch_jaJP.fr b/MPOLnch_jaJP.fr
index 44cd286..8e6bb2f 100644
--- a/MPOLnch_jaJP.fr
+++ b/MPOLnch_jaJP.fr
@@ -75,6 +75,8 @@ resource StringTable (kSDKDefStringsResourceID + index_jaJP)
 			kMPOLnchItemBaseKey "11",					"THIS IS NOT RIGHT",
 			kMPOLnchItemBaseKey "12",					"THIS IS NOT RIGHT",
 		kMPOLnchAddedElementKey,				"  + ’ljÁ—v‘f",	
+		kMPOLnchMissingScriptItemStringKey,				"The MPO Launcher Scripts in the Scripts Panel are missing. Use the option " kMPOLnchAddItemMenuItemKey,
+
 	}
 
 };