Exemple #1
0
        void SetProject(Project project, Boolean stealFocus, Boolean internalOpening)
        {
            if (Tree.Projects.Contains(project)) return;
            if (activeProject != null) CloseProject(true);

            // configure
            var prefs = PluginMain.Settings.GetPrefs(project);
            project.TraceEnabled = prefs.DebugMode;
            project.TargetBuild = prefs.TargetBuild;
            project.UpdateVars(true);

            SetActiveProject(project);

            // events
            project.ClasspathChanged += new ChangedHandler(ProjectClasspathsChanged);
            project.BeforeSave += new BeforeSaveHandler(ProjectBeforeSave);
            listenToPathChange = true;

            // activate
            if (!internalOpening) RestoreProjectSession(project);

            if (stealFocus)
            {
                OpenPanel();
                pluginUI.Focus();
            }
            TabColors.UpdateTabColors(Settings);
        }
        public void UpdateASCompletion(IMainForm mainForm, Project project)
        {
            List<string> classPaths = new List<string>();
            List<string> hiddenPaths = new List<string>();
            int majorVersion = 0;
            int minorVersion = 0;
            string platform = "";

            if (project != null)
            {
                BuildActions.GetCompilerPath(project); // refresh project's SDK
                project.UpdateVars(true);

                // platform/version
                platform = project.MovieOptions.Platform;
                majorVersion = project.MovieOptions.MajorVersion;
                minorVersion = project.MovieOptions.MinorVersion;
                if (project.MovieOptions.Platform == AS3MovieOptions.AIR_PLATFORM
                    || project.MovieOptions.Platform == AS3MovieOptions.AIR_MOBILE_PLATFORM)
                    AS3Project.GuessFlashPlayerForAIR(ref majorVersion, ref minorVersion);

                // add project classpaths
                foreach (string cp in project.AbsoluteClasspaths)
                    if (Directory.Exists(cp)) classPaths.Add(cp);

                // add AS3 libraries
                string absPath;
                if (project is AS3Project)
                {
                    MxmlcOptions options = (project as AS3Project).CompilerOptions;
                    foreach (string relPath in options.IntrinsicPaths)
                    {
                        absPath = PathHelper.ResolvePath(relPath);
                        if (absPath == null) absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (Directory.Exists(absPath)) classPaths.Add(absPath);
                    }
                    foreach (string relPath in options.LibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (File.Exists(absPath)) classPaths.Add(absPath);
                        else if (Directory.Exists(absPath))
                        {
                            string[] libs = Directory.GetFiles(absPath, "*.swc");
                            foreach (string lib in libs) classPaths.Add(lib);
                        }
                    }
                    foreach (string relPath in options.IncludeLibraries)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (Directory.Exists(absPath) || File.Exists(absPath)) classPaths.Add(absPath);
                    }
                    foreach (string relPath in options.ExternalLibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (Directory.Exists(absPath) || File.Exists(absPath)) classPaths.Add(absPath);
                    }
                    foreach (string relPath in options.RSLPaths)
                    {
                        string[] parts = relPath.Split(',');
                        if (parts.Length < 2) continue;
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (File.Exists(absPath)) classPaths.Add(absPath);
                    }
                }

                string dir = project.Directory;
                foreach (string hidPath in project.HiddenPaths)
                {
                    absPath = Path.Combine(dir, hidPath);
                    foreach (string cp in classPaths)
                        if (absPath.StartsWith(cp))
                        {
                            hiddenPaths.Add(absPath);
                            break;
                        }
                }
            }

            DataEvent de;
            Hashtable info = new Hashtable();
            // release old classpath
            if (currentLang != null && project == null)
            {
                info["lang"] = currentLang;
                info["platform"] = "";
                info["targetBuild"] = "";
                info["version"] = "0.0";
                info["classpath"] = null;
                info["hidden"] = null;

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);
            }

            // set new classpath
            if (project != null)
            {
                currentLang = project.Language;

                info["platform"] = platform;
                info["version"] = majorVersion + "." + minorVersion;
                info["targetBuild"] = project.TargetBuild;
                info["lang"] = currentLang;
                info["classpath"] = classPaths.ToArray();
                info["hidden"] = hiddenPaths.ToArray();

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);

                project.AdditionalPaths = info.ContainsKey("additional") ? info["additional"] as string[] : null;
            }
            else currentLang = null;
        }
        public void UpdateASCompletion(IMainForm mainForm, Project project)
        {
            List<string> classPaths = new List<string>();
            List<string> hiddenPaths = new List<string>();
            string version;
            string platform = "";

            if (project != null)
            {
                BuildActions.GetCompilerPath(project); // refresh project's SDK
                project.UpdateVars(true);

                // platform/version
                platform = project.MovieOptions.Platform;
                version = project.MovieOptions.Version;
                if (platform != PlatformData.FLASHPLAYER_PLATFORM
                    && project.MovieOptions.HasPlatformSupport && project.MovieOptions.PlatformSupport.IsFlashPlatform)
                    version = PlatformData.ResolveFlashPlayerVersion(project.Language, platform, version);

                // add project classpaths
                foreach (string cp in project.AbsoluteClasspaths)
                    if (Directory.Exists(cp)) classPaths.Add(cp);

                // add AS3 libraries
                string absPath;
                if (project is AS3Project)
                {
                    MxmlcOptions options = (project as AS3Project).CompilerOptions;
                    foreach (string relPath in options.IntrinsicPaths)
                    {
                        absPath = PathHelper.ResolvePath(relPath);
                        if (absPath == null) absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (Directory.Exists(absPath)) classPaths.Add(absPath);
                    }
                    foreach (string relPath in options.LibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (File.Exists(absPath)) classPaths.Add(absPath);
                        else if (Directory.Exists(absPath))
                        {
                            string[] libs = Directory.GetFiles(absPath, "*.swc");
                            foreach (string lib in libs) classPaths.Add(lib);
                        }
                    }
                    foreach (string relPath in options.IncludeLibraries)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (Directory.Exists(absPath) || File.Exists(absPath)) classPaths.Add(absPath);
                    }
                    foreach (string relPath in options.ExternalLibraryPaths)
                    {
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (Directory.Exists(absPath) || File.Exists(absPath)) classPaths.Add(absPath);
                    }
                    foreach (string relPath in options.RSLPaths)
                    {
                        string[] parts = relPath.Split(',');
                        if (parts.Length < 2) continue;
                        absPath = project.GetAbsolutePath(relPath);
                        if (absPath == null) continue;
                        if (File.Exists(absPath)) classPaths.Add(absPath);
                    }
                }

                string dir = project.Directory;
                foreach (string hidPath in project.HiddenPaths)
                {
                    absPath = Path.Combine(dir, hidPath);
                    foreach (string cp in classPaths)
                        if (absPath.StartsWithOrdinal(cp))
                        {
                            hiddenPaths.Add(absPath);
                            break;
                        }
                }
            }
            else if (PlatformData.SupportedLanguages.ContainsKey("as3"))
            {
                var targets = PlatformData.SupportedLanguages["as3"].Platforms;
                var flashPlatform = targets[PlatformData.FLASHPLAYER_PLATFORM];
                version = flashPlatform.LastVersion.Value;
            }
            else version = "11.0";

            DataEvent de;
            Hashtable info = new Hashtable();
            // release old classpath
            if (currentLang != null && project == null)
            {
                info["lang"] = currentLang;
                info["platform"] = "";
                info["targetBuild"] = "";
                info["version"] = "0.0";
                info["classpath"] = null;
                info["hidden"] = null;

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);
            }

            // set new classpath
            if (project != null)
            {
                currentLang = project.Language;

                info["platform"] = platform;
                info["version"] = version;
                info["targetBuild"] = project.TargetBuild;
                info["lang"] = currentLang;
                info["classpath"] = classPaths.ToArray();
                info["hidden"] = hiddenPaths.ToArray();

                de = new DataEvent(EventType.Command, "ASCompletion.ClassPath", info);
                EventManager.DispatchEvent(this, de);

                project.AdditionalPaths = info.ContainsKey("additional") ? info["additional"] as string[] : null;
            }
            else currentLang = null;
        }
Exemple #4
0
        void SetProject(Project project, Boolean stealFocus, Boolean internalOpening)
        {
            if (project == null || Tree.Projects.Contains(project)) return;
            if (activeProject != null) CloseProject(true);

            // configure
            var prefs = Settings.GetPrefs(project);
            project.TraceEnabled = prefs.DebugMode;
            project.TargetBuild = prefs.TargetBuild;
            project.UpdateVars(true);

            SetActiveProject(project);

            // events
            project.ClasspathChanged += new ChangedHandler(ProjectClasspathsChanged);
            project.BeforeSave += new BeforeSaveHandler(ProjectBeforeSave);
            listenToPathChange = true;

            // activate
            if (!internalOpening || (internalOpening && !PluginBase.Settings.RestoreFileSession))
            {
                RestoreProjectSession(project);
            }

            // track active file
            if (Settings.TrackActiveDocument) TreeSyncToCurrentFile();

            if (stealFocus)
            {
                OpenPanel();
                pluginUI.Focus();
            }
            TabColors.UpdateTabColors(Settings);
            UpdateUIStatus(ProjectManagerUIStatus.NotBuilding);
        }