示例#1
0
		bool KeyFileExistInProject(IOTAProject project)
		{
			for (int i = 0; i < project.ModuleCount; i++)
			{
				if (project.GetModuleFileName(i).EndsWith(".snk") || project.GetModuleFileName(i).EndsWith(".pfx"))
				{
					return true;
				}
			}
			return false;
		}
示例#2
0
		internal static IHandler GetHandlerFor(IOTAProject proj)
		{
			//parse dpr or dpk to find 1.x key file. return true if file exists.
			string realProjectFile = OtaUtils.GetDelphiProjectFileName(proj.FileName);
			if (File.Exists(realProjectFile))
			{
				string content1x = File.ReadAllText(realProjectFile);
				Match m = regex1x.Match(content1x);
				if (m.Success) //TODO: what if in comments??
				{
					//1.x key found. 1.x manner.
					string file = m.Groups["key_file"].Value;
					if (!File.Exists(file)) //TODO: what about relative path??
					{
						MessageService.Show("Key file is missing: " + file);
					}
					return new Manner1xHandler(proj.FileName);
				}
			}
			ProjectRecord record = new ProjectRecord();
			record.Interface = proj;
			//2.0+ manner
			//if no key entries found,
			//generate new key and add key to project.
			XmlDocument doc = new XmlDocument();
			doc.Load(proj.FileName);
			XmlElement project = doc.DocumentElement;
			XmlNodeList propnodes = project.GetElementsByTagName("PropertyGroup");
			
			IList<OptionSet> options = new List<OptionSet>();
			foreach (XmlElement propgroup in propnodes)
			{
				OptionSet os = OptionSet.CreateFrom(doc, propgroup, proj.FileName);
				if (!string.IsNullOrEmpty(os.Condition))
				{
					options.Add(os);
				}
			}
			record.Options = options;
			//if debug and release does not match clear all and
			if (OptionSet.IsCorrupt(options))
			{
				OptionSet.Clear(options);
				return new Manner20UnsignedHandler(record);
			}
			return new Manner20SignedHandler(proj.FileName);
		}
 public void  NewProjectResource(IOTAProject project) {
 }
示例#4
0
        /// <summary>
        /// Verifies a project has unsaved files and warns.
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="warningMessageTitle">Message title</param>
        /// <returns>true if it has, false if not.</returns>
        public static bool WarnForUnsavedFiles(IOTAProject project, string warningMessageTitle)
        {
            if (project == null)
            {
                return false;
            }

            IOTAModuleServices _ModuleServices = GetModuleServices();
            if (_ModuleServices == null)
            {
                return false;
            }

            for (int k = 0; k < project.ModuleCount; k++)
            {
                IOTAModuleInfo _ModuleInfo = project.GetModuleInfo(k);

                IOTAModule _Module = _ModuleServices.FindModule(_ModuleInfo.FileName);

                if (_Module != null)
                {

                    IOTAEditor _Editor = GetEditorWithSourceEditor(_Module);

                    if (_Editor != null && _Editor.IsModified)
                    {
                        if (Lextm.Windows.Forms.MessageBoxFactory.Confirm(null, "The project contains unsaved files", "Do you still want to compile the project?") == DialogResult.No)
                        {
                            return true;
                        }
                    }
                }
            }
            return false;
        }
 public void NewDefaultProjectModule(IOTAProject project) {}
示例#6
0
 //		/// <summary>
 //		/// Removes a file from project.
 //		/// </summary>
 //		/// <remarks>No implemented.</remarks>
 //		/// <param name="project">Project</param>
 //		/// <param name="fileName">File name</param>
 //		public static void RemoveFromProject(IOTAProject project, string fileName) {
 //			Lextm.Windows.Forms.MessageBoxFactory.Warn("Not yet implmented in the Borlant OTA");
 //		}
 /// <summary>
 /// Gets project target name.
 /// </summary>
 /// <param name="project">Project</param>
 /// <returns>Target name or null.</returns>
 public static string GetProjectTarget(IOTAProject project)
 {
     if (project == null)
     {
         return null;
     }
     String targetName = project.ProjectOptions.TargetName;
     if (IsDelphiProject(project))
     {
         string folder = Path.GetDirectoryName(targetName);
         string file = Path.GetFileName(OtaUtils.GetDelphiProjectFileName(project.FileName));
         return Path.ChangeExtension(Path.Combine(folder, file), Path.GetExtension(targetName));
     }
     return targetName;
 }
示例#7
0
        /// <summary>
        /// Gets project source file list.
        /// </summary>
        /// <param name="project">Project</param>
        /// <returns></returns>
        public static IList<string> GetProjectSourceFiles(IOTAProject project)
        {
            IList<string> result = new List<string>();
            if (project == null)
            {
                return result;
            }

            for (int i = 0; i < project.ModuleCount; i++)
            {
                IOTAModuleInfo _ModuleInfo = project.GetModuleInfo(i);

                if (IsSourceFile(_ModuleInfo.FileName))
                {
                    result.Add(_ModuleInfo.FileName);
                }
            }
            return result;
        }
示例#8
0
        /// <summary>
        /// Gets module info from project.
        /// </summary>
        /// <param name="project">Project</param>
        /// <param name="fileName">File name</param>
        /// <returns>The module info, or null.</returns>
        public static IOTAModuleInfo GetModuleInfoFromProject(IOTAProject project, string fileName)
        {
            for (int i = 0; i < project.ModuleCount; i++)
            {
                if (project.GetModuleInfo(i).FileName == fileName)
                {
                    return project.GetModuleInfo(i);
                }
            }

            return null;
        }
示例#9
0
 /// <summary>Validates current is a Delphi for .NET project.</summary>
 /// <remarks>only CodeGear RAD Studio 2007 is supported.</remarks>
 public static bool IsDelphiDotNetProject(IOTAProject project)
 {
     return project.Personality == OTAIDEPersonalities.sDelphiDotNetPersonality;
 }
示例#10
0
 /// <summary>
 /// Validates if current project is VB personality.
 /// </summary>
 /// <remarks>Only CodeGear RAD Studio 2007 is supported.</remarks>
 public static bool IsVisualBasicProject(IOTAProject project)
 {
     return project.Personality == OTAIDEPersonalities.sVBPersonality;
 }
示例#11
0
 /// <summary>Validates current is a C# project.</summary>
 /// <remarks>Only CodeGear RAD Studio 2007 is supported.</remarks>
 public static bool IsCSharpProject(IOTAProject project)
 {
     return project.Personality == OTAIDEPersonalities.sCSharpPersonality;
 }
示例#12
0
 /// <summary>
 /// Gets all module info of a project.
 /// </summary>
 /// <param name="project">Project</param>
 /// <returns></returns>
 /// <remarks>The real project file (*.dpr or *.dpk) is added, too.</remarks>
 public static IList<IOTAModuleInfo> GetAllModuleInfoOf(IOTAProject project)
 {
     if (project == null || project.ModuleCount == 0)
     {
         return null;
     }
     IList<IOTAModuleInfo> result = new List<IOTAModuleInfo>();
     for (int i = 0; i < project.ModuleCount; i++)
     {
         IOTAModuleInfo info = project.GetModuleInfo(i);
         result.Add(info);
     }
     if (IsDelphiProject(project))
     {
         string projectFile = OtaUtils.GetDelphiProjectFileName(project.FileName);
         if (File.Exists(projectFile))
         {
             result.Add(new DelphiProjectModuleInfo(projectFile));
         }
     }
     return result;
 }