public void BuildLibrarySwf(Project project, bool verbose)
        {
            // compile into frame 1 unless you're using shared libraries or preloaders
            Frame = 1;

            string swfPath = project.LibrarySWFPath;

            // delete existing output file if it exists
            if (File.Exists(swfPath))
                File.Delete(swfPath);

            // if we have any resources, build our library file and run swfmill on it
            if (!project.UsesInjection && project.LibraryAssets.Count > 0)
            {
                // ensure obj directory exists
                if (!Directory.Exists("obj"))
                    Directory.CreateDirectory("obj");

                string projectName = project.Name.Replace(" ", "");
                string backupLibraryPath = Path.Combine("obj", projectName + "Library.old");
                string relLibraryPath = Path.Combine("obj", projectName + "Library.xml");
                string backupSwfPath = Path.Combine("obj", projectName + "Resources.old");
                string arguments = string.Format("simple \"{0}\" \"{1}\"",
                    relLibraryPath, swfPath);

                SwfmillLibraryWriter swfmill = new SwfmillLibraryWriter(relLibraryPath);
                swfmill.WriteProject(project);

                if (swfmill.NeedsMoreFrames) Frame = 3;

                // compare the Library.xml with the one we generated last time.
                // if they're identical, and we have a Resources.swf, then we can
                // just assume that Resources.swf is up to date.
                if (File.Exists(backupSwfPath) && File.Exists(backupLibraryPath) &&
                    FileComparer.IsEqual(relLibraryPath, backupLibraryPath))
                {
                    // just copy the old one over!
                    File.Copy(backupSwfPath, swfPath, true);
                }
                else
                {
                    // delete old resource SWF as it's not longer valid
                    if (File.Exists(backupSwfPath))
                        File.Delete(backupSwfPath);

                    Console.WriteLine("Compiling resources");

                    if (verbose)
                        Console.WriteLine("swfmill " + arguments);

                    if (!ProcessRunner.Run(ExecutablePath, arguments, true))
                        throw new BuildException("Build halted with errors (swfmill).");

                    // ok, we just generated a swf with all our resources ... save it for
                    // reuse if no resources changed next time we compile
                    File.Copy(swfPath, backupSwfPath, true);
                    File.Copy(relLibraryPath, backupLibraryPath, true);
                }
            }
        }
示例#2
0
		public ClasspathNode(Project project, string classpath, string text) : base(classpath)
		{
			isDraggable = false;
			isRenamable = false;

            this.classpath = classpath;

            // shorten text
            string[] excludes = PluginMain.Settings.FilteredDirectoryNames;
            char sep = Path.DirectorySeparatorChar;
            string[] parts = text.Split(sep);
            List<string> label = new List<string>();
            Regex reVersion = new Regex("^[0-9]+[.,-][0-9]+");

            if (parts.Length > 0)
            {
                for (int i = parts.Length - 1; i > 0; --i)
                {
                    String part = parts[i] as String;
                    if (part != "" && part != "." && part != ".." && Array.IndexOf(excludes, part.ToLower()) == -1)
                    {
                        if (Char.IsDigit(part[0]) && reVersion.IsMatch(part)) label.Add(part);
                        else
                        {
                            label.Add(part);
                            break;
                        }
                    }
                    else label.Add(part);
                }
            }
            label.Reverse();
            Text = String.Join("/", label.ToArray());
            ToolTipText = classpath;
		}
        public void KeepUpdated(Project project)
        {
            foreach (LibraryAsset asset in project.LibraryAssets)
                if (asset.UpdatePath != null)
                {
                    string assetName = Path.GetFileName(asset.Path);
                    string assetPath = project.GetAbsolutePath(asset.Path);
                    string updatePath = project.GetAbsolutePath(asset.UpdatePath);
                    if (File.Exists(updatePath))
                    {
                        // check size/modified
                        FileInfo source = new FileInfo(updatePath);
                        FileInfo dest = new FileInfo(assetPath);

                        if (source.LastWriteTime != dest.LastWriteTime ||
                            source.Length != dest.Length)
                        {
                            Console.WriteLine("Updating asset '" + assetName + "'");
                            File.Copy(updatePath, assetPath, true);
                        }
                    }
                    else
                    {
                        Console.Error.WriteLine("Warning: asset '" + assetName + "' could "
                            + " not be updated, as the source file could does not exist.");
                    }
                }
        }
示例#4
0
		public ClasspathNode(Project project, string classpath, string text) : base(classpath)
		{
			isDraggable = false;
			isRenamable = false;

            this.classpath = classpath;

            // shorten text
            string[] excludes = PluginMain.Settings.FilteredDirectoryNames;
            char sep = Path.DirectorySeparatorChar;
            string[] parts = text.Split(sep);
            string label = "";

            if (parts.Length > 0)
            {
                for (int i = parts.Length - 1; i > 0; --i)
                {
                    String part = parts[i] as String;
                    if (part != "" && part != "." && part != ".." && Array.IndexOf(excludes, part.ToLower()) == -1)
                    {
                        label = part;
                        break;
                    }
                }
                if (label == "")
                {
                    label = parts[parts.Length - 1];
                }
            }

            Text = label;
            ToolTipText = classpath;
		}
        public void WriteProject(Project project)
        {
            this.project = project;

            try { InternalWriteProject(); }
            finally { Close(); }
        }
示例#6
0
        /// <summary>
        /// 
        /// </summary>
        private bool CheckCurrent()
        {
            try
            {
                IProject project = PluginBase.CurrentProject;
                if (project == null || !project.EnableInteractiveDebugger) return false;
                currentProject = project as Project;

                // ignore non-flash haxe targets
                if (project is HaxeProject)
                {
                    HaxeProject hproj = project as HaxeProject;
                    if (hproj.MovieOptions.Platform == HaxeMovieOptions.NME_PLATFORM
                        && (hproj.TargetBuild != null && !hproj.TargetBuild.StartsWith("flash")))
                        return false;
                }
                // Give a console warning for non external player...
                if (currentProject.TestMovieBehavior == TestMovieBehavior.NewTab || currentProject.TestMovieBehavior == TestMovieBehavior.NewWindow)
                {
                    TraceManager.Add(TextHelper.GetString("Info.CannotDebugActiveXPlayer"));
					return false;
                }
            }
            catch (Exception e) 
            { 
                ErrorManager.ShowError(e);
                return false;
            }
			return true;
        }
示例#7
0
        internal static void SetProject(Project project)
        {
            currentProject = project;

            fsWatchers.SetProject(project);
            ovManager.Reset();
        }
示例#8
0
        public bool Build(Project project, bool runOutput)
        {
            ipcName = Globals.MainForm.ProcessArgString("$(BuildIPC)");

            string compiler = null;
            if (project.NoOutput)
            {
                // get the compiler for as3 projects, or else the FDBuildCommand pre/post command in FDBuild will fail on "No Output" projects
                if (project.Language == "as3")
                    compiler = ProjectManager.Actions.BuildActions.GetCompilerPath(project);

                if (project.PreBuildEvent.Trim().Length == 0 && project.PostBuildEvent.Trim().Length == 0)
                {
                    // no output and no build commands
                    if (project is AS2Project || project is AS3Project)
                    {
                        //RunFlashIDE(runOutput);
                        //ErrorManager.ShowInfo(TextHelper.GetString("ProjectManager.Info.NoOutputAndNoBuild"));
                    }
                    else
                    {
                        //ErrorManager.ShowInfo("Info.InvalidProject");
                        ErrorManager.ShowInfo(TextHelper.GetString("ProjectManager.Info.NoOutputAndNoBuild"));
                    }
                    return false;
                }
            }
            else
            {
                // Ask the project to validate itself
                string error;
                project.ValidateBuild(out error);

                if (error != null)
                {
                    ErrorManager.ShowInfo(TextHelper.GetString(error));
                    return false;
                }

                // 出力先が空だったとき
                if (project.OutputPath.Length < 1)
                {
                    ErrorManager.ShowInfo(TextHelper.GetString("ProjectManager.Info.SpecifyValidOutputSWF"));
                    return false;
                }

                compiler = BuildActions.GetCompilerPath(project);
                if (compiler == null || (!Directory.Exists(compiler) && !File.Exists(compiler)))
                {
                    string info = TextHelper.GetString("ProjectManager.Info.InvalidCustomCompiler");
                    MessageBox.Show(info, TextHelper.GetString("ProjectManager.Title.ConfigurationRequired"), MessageBoxButtons.OK);
                    return false;
                }
            }

            return FDBuild(project, runOutput, compiler);
        }
        public static string ProcessArgs(Project project, string args)
        {
            lastFileFromTemplate = QuickGenerator.QuickSettings.GenerateClass.LastFileFromTemplate;
            lastFileOptions = QuickGenerator.QuickSettings.GenerateClass.LastFileOptions;

            if (lastFileFromTemplate != null)
            {
                string fileName = Path.GetFileNameWithoutExtension(lastFileFromTemplate);

                args = args.Replace("$(FileName)", fileName);

                if (args.Contains("$(FileNameWithPackage)") || args.Contains("$(Package)"))
                {
                    string package = "";
                    string path = lastFileFromTemplate;

                    // Find closest parent

                    string classpath="";
                    if(project!=null)
                    classpath = project.AbsoluteClasspaths.GetClosestParent(path);

                    // Can't find parent, look in global classpaths
                    if (classpath == null)
                    {
                        PathCollection globalPaths = new PathCollection();
                        foreach (string cp in ProjectManager.PluginMain.Settings.GlobalClasspaths)
                            globalPaths.Add(cp);
                        classpath = globalPaths.GetClosestParent(path);
                    }
                    if (classpath != null)
                    {
                        if (project != null)
                        {
                            // Parse package name from path
                            package = Path.GetDirectoryName(ProjectPaths.GetRelativePath(classpath, path));
                            package = package.Replace(Path.DirectorySeparatorChar, '.');
                        }
                    }

                    args = args.Replace("$(Package)", package);

                    if (package.Length!=0)
                        args = args.Replace("$(FileNameWithPackage)", package + "." + fileName);
                    else
                        args = args.Replace("$(FileNameWithPackage)", fileName);

                    if (lastFileOptions != null)
                    {
                        args = ProcessFileTemplate(args);
                        if (processOnSwitch == null) lastFileOptions = null;
                    }
                }
                lastFileFromTemplate = null;
            }
            return args;
        }
示例#10
0
        public void AddFileFromTemplate(Project project, string inDirectory, string templatePath)
        {
            try
            {
                // the template could be named something like "MXML.fdt", or maybe "Class.as.fdt"
                string fileName = Path.GetFileNameWithoutExtension(templatePath);
                string extension = "";
                string caption = TextHelper.GetString("Label.AddNew") + " ";

                if (fileName.IndexOf('.') > -1)
                {
                    // it's something like Class.as.fdt
                    extension = Path.GetExtension(fileName); // .as
                    caption += Path.GetFileNameWithoutExtension(fileName);
                    fileName = TextHelper.GetString("Label.New") + Path.GetFileNameWithoutExtension(fileName).Replace(" ", ""); // just Class
                }
                else
                {
                    // something like MXML.fdt
                    extension = "." + fileName.ToLower();
                    caption += fileName + " " + TextHelper.GetString("Label.File");
                    fileName = TextHelper.GetString("Label.NewFile");
                }

                // let plugins handle the file creation
                Hashtable info = new Hashtable();
                info["templatePath"] = templatePath;
                info["inDirectory"] = inDirectory;
                DataEvent de = new DataEvent(EventType.Command, "ProjectManager.CreateNewFile", info);
                EventManager.DispatchEvent(this, de);
                if (de.Handled) return;

                LineEntryDialog dialog = new LineEntryDialog(caption, TextHelper.GetString("Label.FileName"), fileName + extension);
                dialog.SelectRange(0, fileName.Length);

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    FlashDevelopActions.CheckAuthorName();

                    string newFilePath = Path.Combine(inDirectory, dialog.Line);
                    if (!Path.HasExtension(newFilePath) && extension != ".ext")
                        newFilePath = Path.ChangeExtension(newFilePath, extension);

                    if (!ConfirmOverwrite(newFilePath)) return;

                    // save this so when we are asked to process args, we know what file it's talking about
                    lastFileFromTemplate = newFilePath;

                    mainForm.FileFromTemplate(templatePath, newFilePath);
                }
            }
            catch (UserCancelException) { }
            catch (Exception exception)
            {
                ErrorManager.ShowError(exception);
            }
        }
示例#11
0
        internal static void SetProject(Project project)
        {
            currentProject = project;

            fsWatchers.SetProject(project);
            ovManager.Reset();

            foreach (ITabbedDocument document in PluginBase.MainForm.Documents)
                if (document.IsEditable) HandleFileReload(document.FileName);
        }
示例#12
0
 internal static void Dispose()
 {
     if (vcManager != null)
     {
         vcManager.Dispose();
         fsWatchers.Dispose();
         ovManager.Dispose();
         currentProject = null;
     }
 }
示例#13
0
        public BuildEventDialog(Project project)
        {
            InitializeComponent();
            InitializeLocalization();
            this.FormGuid = "ada69d37-2ec0-4484-b113-72bfeab2f239";
            this.Font = PluginCore.PluginBase.Settings.DefaultFont;

            this.project = project;
            this.vars = new BuildEventVars(project);
            foreach (BuildEventInfo info in vars.GetVars()) Add(info);
        }
示例#14
0
 public static ProjectBuilder Create(Project project, string ipcName, string compilerPath)
 {
     if (project is AS2Project)
         return new AS2ProjectBuilder(project as AS2Project, compilerPath);
     else if (project is AS3Project)
         return new AS3ProjectBuilder(project as AS3Project, compilerPath, ipcName);
     else if (project is HaxeProject)
         return new HaxeProjectBuilder(project as HaxeProject, compilerPath);
     else
         throw new Exception("FDBuild doesn't know how to build " + project.GetType().Name);
 }
示例#15
0
		public LibraryAsset(Project project, string path)
		{
			Project = project;
			Path = path;
			ManualID = null;
			UpdatePath = null;
			FontGlyphs = null;
			Sharepoint = null;
            BitmapLinkage = false;
			SwfMode = SwfAssetMode.Library;
		}
示例#16
0
        internal void SetProject(Project project)
        {
            Clear();
            if (project == null) return;

            CreateWatchers(project.Directory);

            if (project.Classpaths != null)
                foreach (string path in project.AbsoluteClasspaths)
                    CreateWatchers(path);

            if (ProjectManager.PluginMain.Settings.ShowGlobalClasspaths)
                foreach (string path in ProjectManager.PluginMain.Settings.GlobalClasspaths)
                    CreateWatchers(path);

            updateTimer.Interval = 1000;
            updateTimer.Start();
        }
示例#17
0
		/// <summary>
		/// Creates the correct type of FileNode based on the file name.
		/// </summary>
		public static FileNode Create(string filePath, Project project)
		{
            if (project != null) 
            {
                if (project.IsOutput(filePath))
                    return new ProjectOutputNode(filePath);
                if (project.IsInput(filePath))
                    return new InputSwfNode(filePath);
            }

            string ext = Path.GetExtension(filePath).ToLower();

            if (FileInspector.IsSwf(filePath, ext) || FileInspector.IsSwc(filePath, ext))
                return new SwfFileNode(filePath);
            else if (FileAssociations.ContainsKey(ext)) // custom nodes building
                return FileAssociations[ext](filePath);
            else
                return new FileNode(filePath);
		}
示例#18
0
        /// <summary>
        /// 
        /// </summary>
        private bool CheckCurrent()
        {
            try
            {
                IProject project = PluginBase.CurrentProject;
                if (project == null || !project.EnableInteractiveDebugger) return false;
                currentProject = project as Project;

                // Give a console warning for non external player...
                if (currentProject.TestMovieBehavior == TestMovieBehavior.NewTab || currentProject.TestMovieBehavior == TestMovieBehavior.NewWindow)
                {
                    TraceManager.Add(TextHelper.GetString("Info.CannotDebugActiveXPlayer"));
                    return false;
                }
            }
            catch (Exception e) 
            { 
                ErrorManager.ShowError(e);
                return false;
            }
            return true;
        }
示例#19
0
		public BuildEventRunner(Project project, string compilerPath)
		{
			this.project = project;
			this.vars = new BuildEventVars(project);
            vars.AddVar("CompilerPath", compilerPath);
		}
示例#20
0
 public ProjectNode(Project project)
     : base(project.Directory)
 {
     projectRef = project;
     isDraggable = false;
     isRenamable = false;
 }
示例#21
0
 public ProjectBuilder(Project project, string compilerPath)
 {
     this.project = project;
     this.compilerPath = compilerPath;
 }
示例#22
0
        private void MoveRefactoredFiles()
        {
            MessageBar.Locked = true;
            AssociatedDocumentHelper.CloseTemporarilyOpenedDocuments();
            foreach (var target in targets)
            {
                File.Delete(target.OldFilePath);

                if (target.OwnerPath == null)
                {
                    OldPathToNewPath.Remove(target.OldFilePath);
                }

                // Casing changes, we cannot move directly here, there may be conflicts, better leave it to the next step
                if (target.TmpFilePath != null)
                {
                    RefactoringHelper.Move(target.TmpFilePath, target.NewFilePath);
                }
            }
            // Move non-source files and whole folders
            foreach (KeyValuePair <string, string> item in OldPathToNewPath)
            {
                string oldPath = item.Key;
                string newPath = item.Value;
                if (File.Exists(oldPath))
                {
                    newPath = Path.Combine(newPath, Path.GetFileName(oldPath));
                    if (!Path.IsPathRooted(newPath))
                    {
                        newPath = Path.Combine(Path.GetDirectoryName(oldPath), newPath);
                    }
                    RefactoringHelper.Move(oldPath, newPath, true);
                }
                else if (Directory.Exists(oldPath))
                {
                    newPath = renaming ? Path.Combine(Path.GetDirectoryName(oldPath), newPath) : Path.Combine(newPath, Path.GetFileName(oldPath));

                    // Look for document class changes
                    // Do not use RefactoringHelper to avoid possible dialogs that we don't want
                    ProjectManager.Projects.Project project = (ProjectManager.Projects.Project)PluginBase.CurrentProject;
                    string newDocumentClass = null;
                    string searchPattern    = project.DefaultSearchFilter;
                    foreach (string pattern in searchPattern.Split(';'))
                    {
                        foreach (string file in Directory.GetFiles(oldPath, pattern, SearchOption.AllDirectories))
                        {
                            if (project.IsDocumentClass(file))
                            {
                                newDocumentClass = file.Replace(oldPath, newPath);
                                break;
                            }
                        }
                        if (newDocumentClass != null)
                        {
                            break;
                        }
                    }

                    // Check if this is a name casing change
                    if (oldPath.Equals(newPath, StringComparison.OrdinalIgnoreCase))
                    {
                        string tmpPath = oldPath + "$renaming$";
                        FileHelper.ForceMoveDirectory(oldPath, tmpPath);
                        PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, tmpPath);
                        oldPath = tmpPath;
                    }

                    // Move directory contents to final location
                    FileHelper.ForceMoveDirectory(oldPath, newPath);
                    PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, newPath);

                    if (!string.IsNullOrEmpty(newDocumentClass))
                    {
                        project.SetDocumentClass(newDocumentClass, true);
                        project.Save();
                    }
                }
            }

            MessageBar.Locked = false;
        }
 static void proj_ProjectUpdating(Project project)
 {
     string newConfig = Path.Combine(proj.Directory, "loom.config");
     if (configPath != newConfig)
     {
         configPath = newConfig;
         StopWatcher();
         if (File.Exists(configPath))
         {
             watcher = new WatcherEx(Path.GetDirectoryName(configPath), Path.GetFileName(configPath));
             watcher.Changed += watcher_Changed;
             watcher.EnableRaisingEvents = true;
             UpdateProject();
         }
     }
     else UpdateProject();
 }
示例#24
0
 public ReferencesNode(Project project, string text)
     : base(Path.Combine(project.Directory, "__References__"))
 {
     Text = text;
     ImageIndex = SelectedImageIndex = Icons.HiddenFolder.Index;
     ForeColorRequest = PluginBase.MainForm.GetThemeColor("ProjectTreeView.ForeColor", SystemColors.WindowText);
     isDraggable = false;
     isRenamable = false;
 }
示例#25
0
        private void RebuildProjectNode(Project project)
        {
            activeProject = project;

            // create the top-level project node
            ProjectNode projectNode = new ProjectNode(project);
            Nodes.Add(projectNode);
            projectNode.Refresh(true);
            projectNode.Expand();

            ReferencesNode refs = new ReferencesNode(project, "References");
            projectNode.References = refs;
        }
示例#26
0
		public ProjectWriter(Project project, string filename) : base(filename,Encoding.UTF8)
		{
			this.project = project;
			this.Formatting = Formatting.Indented;
		}
示例#27
0
 public ReferencesNode(Project project, string text)
     : base(Path.Combine(project.Directory, "__References__"))
 {
     this.project = project;
     Text = text;
     ImageIndex = SelectedImageIndex = Icons.HiddenFolder.Index;
     isDraggable = false;
     isRenamable = false;
 }
        public void AddLibraryAsset(Project project, string inDirectory)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title = TextHelper.GetString("Label.AddLibraryAsset");
            dialog.Filter = TextHelper.GetString("Info.FileFilter");
            dialog.Multiselect = false;

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                string filePath = CopyFile(dialog.FileName, inDirectory);

                // null means the user cancelled
                if (filePath == null) return;

                // add as an asset
                project.SetLibraryAsset(filePath, true);

                if (!FileInspector.IsSwc(filePath))
                {
                    // ask if you want to keep this file updated
                    string caption = TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                    string message = TextHelper.GetString("Info.ConfirmFileUpdate");

                    DialogResult result = MessageBox.Show(mainForm, message, caption,
                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        LibraryAsset asset = project.GetAsset(filePath);
                        asset.UpdatePath = project.GetRelativePath(dialog.FileName);
                    }
                }

                project.Save();
                OnProjectModified(new string[] { filePath });
            }
        }
示例#29
0
 public ProjectReader(string filename, Project project) : base(filename)
 {
     this.project = project;
     WhitespaceHandling = WhitespaceHandling.None;
 }
示例#30
0
 public ProjectClasspathNode(Project project, string classpath, string text)
     : base(project, classpath, text)
 {
     if (text != Text)
     {
         ToolTipText = text;
     }
     else
     {
         ToolTipText = "";
     }
 }
示例#31
0
		public AssetCollection(Project project)
		{
			this.project = project;
		}