V 10
1
LANG:1 8 (NoName)
PANEL,284 126 465 248 N "_3DFace" 0
"/**

fwInstallationSelectDirectory.pnl

This panel is run from the main panel if the installation directory is not set. 
It is used for choosing the installation directory. The user can either write the name of the directory 
( if it does not exist it will be created ) or he can choose the existing directory. 
If the chosen directory is not defined in proj_path in the config file - the file is then modified. 
The new installation directory is also stored in the data point element - 
“fwInstallationDirectory.installationDirectoryPath:_original.._value” of type “_FwInstallationInformation” .

Required $-parameters:

none

Panels called from this panel:

none

*/

main()
{
	//    
}" 0
EE E E 1 -1 -1 0  28 56
"" 0 1
E"
/** This function reads the config file and retrieves the list of
proj_paths

@param proj_paths: the return value with a list of proj_paths

@author M.Sliwinski
*/

int fwInstallation_loadProjPaths(dyn_string & proj_paths)
{
	
	dyn_string parameter_Value;
	dyn_string configLines;
	
	bool fileLoaded = false;
	
	string fileInString;

	string tempLine;
	string tempParameter;
	string tempValue;
	string tempString; 

	string configPath = getPath(CONFIG_REL_PATH);
	string configFile = configPath + \"config\";
	
	int i, j ;
	

	
	fileLoaded = fileToString(configFile, fileInString);
	
	if (! fileLoaded )
	{
	
		Debug(\"\\n Cannot load \" + configFile + \" file\");
		return -1;
	}
	else 
	{
		Debug(\"\\n\" + configFile + \" - file loaded\");
	}

	configLines = strsplit(fileInString, \"\\n\");
	
// each line is loaded in a row of dyn_string configLines
	
	for(i = 1; i <= dynlen(configLines); i++)
	{
		tempLine = strltrim(strrtrim(configLines[i]));
		
		if(tempLine == \"\")
		{
		}
		else
		{				
				parameter_Value = strsplit(tempLine, \"=\");
				
				tempParameter = strltrim(strrtrim(parameter_Value[1]));
				
				if(tempParameter == \"proj_path\")
				{  
				
					tempValue = strltrim(strrtrim(parameter_Value[2]));
				
					strreplace(tempValue, \"\\\"\" , \"\");

				
				  // now value is without quotation marks
					
					dynAppend(proj_paths, tempValue);
				}
		}	
	}		
	return 1;				
}


/** This function inserts the new proj_path into the config file

@param proj_paths: the return value with a list of proj_paths

@author M.Sliwinski
*/

int fwInstallation_addProjPath(string projPathValue)
{
	
	dyn_string parameter_Value;
	dyn_string configLines;
	
	bool fileLoaded = false;
	
	string fileInString;

	string tempLine;
	string tempParameter;
	string tempValue;
	string tempString; 

	string configPath = getPath(CONFIG_REL_PATH);
	string configFile = configPath + \"config\";
	string configFileEntry = \"proj_path = \\\"\" + projPathValue + \"\\\"\";
	
	
	int i, j ;
	int numberOfProjPaths = 0;
	int indexOfProjPath = 0;
	

	
	fileLoaded = fileToString(configFile, fileInString);
	
	if (! fileLoaded )
	{
	
		Debug(\"\\n Cannot load \" + configFile + \" file\");
		return -1;
	}
	else 
	{
		Debug(\"\\n\" + configFile + \" - file loaded\");
	}

	configLines = strsplit(fileInString, \"\\n\");
	
// each line is loaded in a row of dyn_string configLines
	
	for(i = 1; i <= dynlen(configLines); i++)
	{
		tempLine = strltrim(strrtrim(configLines[i]));
		
		if(tempLine == \"\")
		{
		}
		else
		{				
				parameter_Value = strsplit(tempLine, \"=\");
				
				tempParameter = strltrim(strrtrim(parameter_Value[1]));
				
				if(tempParameter == \"proj_path\")
				{  
			
					numberOfProjPaths++;
					
					if(indexOfProjPath == 0)
					{
						indexOfProjPath = i;
					}			
	
				}
		}	
	}		
	
	// insert the value into a string of config lines
	
	if(numberOfProjPaths > 8)
	{
	
		Debug(\"ERROR: cannot add the new proj_path - too many proj_paths defined in the config file: \" + numberOfProjPaths);
		
		return -1;
	}
	else
	{	
		dynInsertAt(configLines, configFileEntry , indexOfProjPath);
	
		fwInstallation_saveFile(configLines, configFile);
		
		return 1;
	}
	
}

/** This function saves the dyn_string into the file

@param configLines: the dyn_string with file lines
@param filename: the name of a destination file
@author M.Sliwinski
*/


int fwInstallation_saveFile( dyn_string & configLines, string filename)
{
	int i;
	string strLinesToSave;
	

	file fileHdlConfig;
	
	int writeResult;

//		Debug(\"saving everything to \" + configFile);


			fileHdlConfig = fopen(filename, \"w\");
			if(fileHdlConfig == 0)
			{
				Debug(\"\\n File \" + filename + \" could not opened ;-(\");
			}
			else
			{
					for(i = 1; i <= dynlen(configLines); i++)
					{
						strLinesToSave += configLines[i] + \"\\n\";
					}
					writeResult = fputs(strLinesToSave , fileHdlConfig);
			
					if (writeResult == 0)
					{
						Debug(\"\\n File \" + filename + \" - the file has been saved\");
					}
					
					fclose(fileHdlConfig);
			}
		
}" 0
 2
"CBRef""1"
"EClose"E
""
DISPLAY_LAYER, 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0
LAYER, 0 
1
LANG:1 6 Layer1
2 1
"Text12"
""
1 23 56 E E E 1 E 1 E N {0,0,0} E N "_Transparent" E E
 E E
2 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  0 E 25 24 197 46
0 2 0 "s" 0 0 0 192 0 0  25 24
 1
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-160-100-100-*-*-iso8859-1|-19,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 21 Destination directory
2 3
"Text2"
""
1 30 106 E E E 1 E 1 E N {0,0,0} E N "_Transparent" E E
 E E
4 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  0 E 32 82 372 98
0 2 0 "s" 0 0 0 192 0 0  32 82
 1
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 59 Select the directory where the components will be installed
2 11
"txtWarning"
""
1 30 75 E E E 1 E 0 E N {255,0,51} E N "_Transparent" E E
 E E
10 0 0 0 0 0
EE E
0
1
LANG:1 0 
1
"dashclr"N "_Transparent"
E E 0 1 1 0 1 E U  0 E 32 52 137 68
0 2 0 "s" 0 0 0 192 0 0  32 52
 1
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
1
LANG:1 15 Warning message
13 5
"btnOK"
""
1 280 190 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
6 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
278 188 352 222
T 
1
LANG:1 2 OK
"main()
{

	dyn_string proj_paths;
	string sPath;
	int i, x;
	string result;
	
	int directoryExists;
	bool state;
	string cmd, err = 0;
	shape shape_chckBox = getShape(\"checkCreateDirectory\");
	string logFile =  getPath(LOG_REL_PATH) + \"InstallationTool.log\";
	
	sPath = txtDestinationDir.text;

	strreplace( sPath , \"//\" , \"/\");

	Debug(\"\\n sPath : \" + sPath);

		directoryExists = access(sPath, F_OK);

	if(sPath == \"\")
	{
		txtWarning.text = \"Directory cannot be empty\";
		txtWarning.visible = true;
	}
	else if( directoryExists == -1)
	{
	
		
		if (shape_chckBox.state(0) == true)
		{
			// the user has chosen to create the directory
			
	//		Debug(\"create directory: \" + sPath);
			
			//trim the last backslash in the directory name
			
			sPath = strrtrim(sPath, \"/\\\\\");
			sPath = strrtrim(sPath, \"/\");
			
			if (_WIN32) 
			{
				if(strpos(sPath, \":\") >= 1)
				{		
					strreplace( sPath , \"/\" , \"\\\\\");

					cmd = \"mkdir \" + sPath + \" 2> \" + logFile;
					err = system(\"cmd /c \" + cmd);
					if(err != \"0\")
					{
					
						x = fileToString(logFile, result);
						Debug(\"\\n cmd: \" + cmd + \"  result: \" + result);
						txtWarning.text = result;
						txtWarning.visible = true;
					}
				}
				else
				{
					txtWarning.text = \"You should give the whole path\";
					txtWarning.visible = true;
				}
			}
			else // _LINUX
			{
				if(strpos(sPath, \"/\") == 0)
				{
					cmd = \"mkdir \" + sPath + \" 2> \" + logFile;
					err = system(cmd);
					if(err != \"0\")
					{
						x = fileToString(logFile, result);
						txtWarning.text = result;
						txtWarning.visible = true;
					}
				}
				else
				{
					txtWarning.text = \"You should give the whole path\";
					txtWarning.visible = true;
				}
			}
			
			//the directory has been created - add it into the config file
			if(err == 0)
			{
				result = fwInstallation_addProjPath(sPath);
				
				if (result == -1)  // the project path could not be updated - too many entries
				{
					txtWarning.text = \"Too many project directories defined in the config file \\n\" +
									\"Choose directory defined in the proj_path \\n\" + 
									\"in the project config file\";
					txtWarning.visible = true;
				}
				else  // the project path has been updated
				{
			
				  	dpCreate(\"fwInstallationInfo\" , \"_FwInstallationInformation\");
					dpSet(\"fwInstallationInfo.installationDirectoryPath:_original.._value\", sPath);
			
					PanelOff();
				}
			}
				
		}
		else // the user has not checked the option to create a new directory
		{
			txtWarning.text = \"Directory does not exist\";
			txtWarning.visible = true;
		}
	}
	else // the directory exists
	{
		 fwInstallation_loadProjPaths(proj_paths);

		if(dynContains(proj_paths, sPath))
		{
			// the config file contains the sPath in the proj_dir
			
			dpCreate(\"fwInstallationInfo\" , \"_FwInstallationInformation\");
			dpSet(\"fwInstallationInfo.installationDirectoryPath:_original.._value\", sPath);
		
			PanelOff();
		}
		else //the directory exists but it is not in the config gile
		{
			// update the config file
			// e.g. add line: proj_path = \"D:/msliwins/test/framework1.1/PVSS\"
			
			result = fwInstallation_addProjPath(sPath);
		 
		 	if (result == -1)  // the project path could not be updated - too many entries
			{
				txtWarning.text = \"Choose directory defined in the proj_path \\nin the project config file\";
				txtWarning.visible = true;
			}
			else  // the project path has been updated
			{
			
			  	dpCreate(\"fwInstallationInfo\" , \"_FwInstallationInformation\");
				dpSet(\"fwInstallationInfo.installationDirectoryPath:_original.._value\", sPath);
			
				PanelOff();
			}

	
		}
		
		
		}
	
}
" 0
 E E E
13 6
"btnCancel"
""
1 370 190 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
7 0 0 0 0 0
"main()
{
	txtWarning.text = \"The default directory will be set to your first project directory.\";

}" 0
E E
0
1
LANG:1 0 
0
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
368 188 442 222
T 
1
LANG:1 6 Cancel
"main()
{
  PanelOff();
}" 0
 E E E
13 9
"btnSelectSourceDir"
""
1 390 110 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
8 0 0 0 0 0
EE E
0
1
LANG:1 20 Select the directory
0
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
388 108 432 142
P 
13107
"pictures/fileselektor.xpm"
1
LANG:1 0 
"main()
{

string sPath;

int iErr;

	txtWarning.visible = false;
		
	sPath = txtDestinationDir.text;   // Content of textfield

	iErr = folderSelector( sPath );

	if(( iErr >= 1 ) && ( strlen( sPath ) > 0 ))
	{

	    if (_WIN32) 
	    	strreplace( sPath, \"/\", \"//\" ); 
		// if NT -> replace 
	
		strreplace( sPath, \"//\", \"/\" );
	
	    txtDestinationDir.text = sPath;  

  }
  
}" 0
 E E E
14 10
"txtDestinationDir"
""
1 30 110 E E E 1 E 1 E N "_WindowText" E N "_Window" E E
 E E
9 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 119 -microsoft windows-Courier New-normal-r-normal-*-*-110-100-100-*-*-iso8859-1|-12,0,0,0,400,0,0,0,0,3,2,1,49,Courier New
0 ""
28 108 372 134
3 "s" 0 0 0 0 0 0 
E
E
E
20 13
"checkCreateDirectory"
""
1 30 140 E E E 1 E 1 E N "_3DText" E N "_3DFace" E E
 E E
12 0 0 0 0 0
EE E
0
1
LANG:1 0 
0
1
LANG:1 107 -microsoft windows-Arial-normal-r-normal-*-*-120-100-100-*-*-iso8859-1|-13,0,0,0,400,0,0,0,0,3,2,1,34,Arial
0 ""
28 138 192 172
1
T 
1
LANG:1 18 Create directory ?
 1
1
LANG:1 0 
 E  E  0 0 0 0 0
1
E E 
EE0
LAYER, 1 
1
LANG:1 6 Layer2
0
LAYER, 2 
1
LANG:1 6 Layer3
0
LAYER, 3 
1
LANG:1 6 Layer4
0
LAYER, 4 
1
LANG:1 6 Layer5
0
LAYER, 5 
1
LANG:1 6 Layer6
0
LAYER, 6 
1
LANG:1 6 Layer7
0
LAYER, 7 
1
LANG:1 6 Layer8
0
0