public MDASolutionManager(DTE applicationObject, AddInSettings addInSettings)
 {
     m_applicationObject     = applicationObject;
     m_addInSettings         = addInSettings;
     m_mavenProxy            = new Maven2Proxy(m_applicationObject, m_addInSettings);
     m_mavenProxy.Completed += new EventHandler(m_mavenProxy_Completed);
 }
        public void InitializeSolution()
        {
            m_solutionIsUsingMDA = MDAConfigFilesExist(m_applicationObject.Solution);
            m_enabled            = false;
            if (m_solutionIsUsingMDA)
            {
                try
                {
                    // Notify the user that the solution is using MDA
                    m_applicationObject.StatusBar.Text = "Android/VS: Solution is AndroMDA-enabled.  Loading configuration...";
                    m_applicationObject.StatusBar.Highlight(true);

                    // Get the solution path
                    string solutionPath = VSSolutionUtils.GetSolutionPath(m_applicationObject.Solution);

                    /// Load the properties file and set the the root directory
                    if (Maven1PropertiesExist(m_applicationObject.Solution))
                    {
                        // Load the properties directly from the project.properties file
                        m_projectProperties.LoadFromFile(GetMaven1ProjectPropertiesPath(m_applicationObject.Solution));
                        m_projectProperties["maven.version"] = "1";
                    }
                    else if (Maven2PropertiesExist(m_applicationObject.Solution))
                    {
                        // Load the properties from the pom.xml
                        m_projectProperties.LoadFromXML(GetMaven2ProjectPropertiesPath(m_applicationObject.Solution), "maven.andromda.");
                        m_projectProperties["maven.version"] = "2";
                    }
                    else
                    {
                        throw new Exception("Unable to locate the project's properties file.");
                    }
                    m_projectProperties["maven.src.dir"] = solutionPath + "\\mda\\src";
                    m_projectProperties["project.build.sourceDirectory"] = solutionPath + "\\mda\\src\\uml";
                    m_projectProperties["pom.basedir"] = solutionPath + "\\mda";

                    if (m_projectProperties["maven.version"] == "2" && m_mavenProxy is Maven1Proxy)
                    {
                        m_mavenProxy = new Maven2Proxy(m_applicationObject, m_addInSettings);
                    }
                    else if (m_projectProperties["maven.version"] == "1" && m_mavenProxy is Maven2Proxy)
                    {
                        m_mavenProxy = new Maven1Proxy(m_applicationObject, m_addInSettings);
                    }

                    m_mavenProxy.Completed += new EventHandler(m_mavenProxy_Completed);

                    ////
                    ////  Resolve the core and common projects
                    ////

                    //m_coreProject = null;
                    //m_commonProject = null;
                    m_schemaExportProject = null;

                    // Iterate through the projects and search for the core and common directories
                    foreach (Project p in m_applicationObject.Solution.Projects)
                    {
                        try
                        {
                            // Get the project's directory
                            string projectPath = FileUtils.GetPathFromFilename(p.FileName);

                            /*
                             * // Check if the current (core) directory is the same as the project directory
                             * if (FileUtils.CompareDirectories(projectPath, m_projectProperties.GetPath("maven.andromda.core.dir")))
                             * {
                             *  // if so this is the core project
                             *  string generatedPath = m_projectProperties.GetPath("maven.andromda.core.generated.dir");
                             *  string manualPath = m_projectProperties.GetPath("maven.andromda.core.manual.dir");
                             *  m_coreProject = new MDAProject(p, FileUtils.GetFilename(projectPath), projectPath, generatedPath, manualPath);
                             *
                             * }
                             *
                             * // Check if the current (common) directory is the same as the project directory
                             * if (FileUtils.CompareDirectories(projectPath, m_projectProperties.GetPath("maven.andromda.common.dir")))
                             * {
                             *  // if so this is the common project
                             *  string generatedPath = m_projectProperties.GetPath("maven.andromda.common.generated.dir");
                             *  m_commonProject = new MDAProject(p, FileUtils.GetFilename(projectPath), projectPath, generatedPath, string.Empty);
                             * }
                             */

                            // Check if the current (schemaexport) directory is the same as the project directory
                            if (IsSchemaExportProjectAvailable && FileUtils.CompareDirectories(projectPath, m_projectProperties.GetPath("maven.andromda.schemaexport.dir")))
                            {
                                // if so this is the common project
                                m_schemaExportProject = new MDAProject(p, FileUtils.GetFilename(projectPath), projectPath, string.Empty, string.Empty);
                            }
                        }
                        catch (NotImplementedException)
                        {
                            // Swallow this exception (it means the project was not loaded for some reason)
                        }
                    }

                    /*
                     * // Show an error message if either the core or common projects could not be found
                     * if (m_coreProject == null || m_commonProject == null)
                     * {
                     *  string errorMessage = "The AndroMDA configuration was loaded, but the ";
                     *  if (m_coreProject == null)
                     *  {
                     *      errorMessage += "core (" + m_projectProperties["maven.andromda.core.assembly.name"] + ") ";
                     *      if (m_commonProject == null) { errorMessage += "and "; }
                     *  }
                     *  if (m_commonProject == null) { errorMessage += "common (" + m_projectProperties["maven.andromda.common.assembly.name"] + ") "; }
                     *  errorMessage += "project";
                     *  if (m_commonProject == null && m_coreProject == null) errorMessage += "s";
                     *  errorMessage += " could not be found in the solution.";
                     *  throw new Exception(errorMessage);
                     * }
                     */
                    m_solutionSettings = new ConfigFile(solutionPath + "\\mda\\android.user.properties");
                    m_applicationObject.StatusBar.Highlight(false);
                    m_applicationObject.StatusBar.Text = "Android/VS: AndroMDA configuration loaded.";
                    m_enabled = true;
                }
                catch (Exception e)
                {
                    m_enabled = false;
                    AddInUtils.ShowWarning("An error occured while trying to load the AndroMDA configuration.  When you fix the problem click the 'Reload MDA Config' button.\n\n" + e.Message);
                }
            }
        }