public static void Copy(string oldPath, string newPath, bool renaming, bool simulateMove) { if (string.IsNullOrEmpty(oldPath) || string.IsNullOrEmpty(newPath)) { return; } ProjectManager.Projects.Project project = (ProjectManager.Projects.Project)PluginBase.CurrentProject; string newDocumentClass = null; if (File.Exists(oldPath) && FileHelper.ConfirmOverwrite(newPath)) { File.Copy(oldPath, newPath, true); if (simulateMove) { PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, newPath); if (project.IsDocumentClass(oldPath)) { newDocumentClass = newPath; } } } else if (Directory.Exists(oldPath)) { newPath = renaming ? Path.Combine(Path.GetDirectoryName(oldPath), newPath) : Path.Combine(newPath, Path.GetFileName(oldPath)); if (!FileHelper.ConfirmOverwrite(newPath)) { return; } string searchPattern = project.DefaultSearchFilter; if (simulateMove) { // We need to use our own method for moving directories if folders in the new path already exist FileHelper.CopyDirectory(oldPath, newPath, true); 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; } PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, newPath); } if (newDocumentClass != null) { break; } } } } if (!string.IsNullOrEmpty(newDocumentClass)) { project.SetDocumentClass(newDocumentClass, true); project.Save(); } }
/// <summary> /// Enables or disables the menu item if the project is an AIR project /// </summary> public void UpdateMenuItems() { Boolean pluginActive = false; ToolStrip mainToolStrip = (ToolStrip)PluginBase.MainForm.ToolStrip; if (this.pluginMenuItem == null || this.pmMenuButton == null) { return; } if (PluginBase.CurrentProject != null) { ProjectManager.Projects.Project project = (ProjectManager.Projects.Project)PluginBase.CurrentProject; pluginActive = project.MovieOptions.Platform.StartsWith("AIR"); } this.pluginMenuItem.Enabled = this.pmMenuButton.Enabled = pluginActive; }
public bool SaveProject() { if (manager.CurrentWorkingFolder == null) { return(false); } ProjectManager.Projects.Project project = PluginBase.CurrentProject as ProjectManager.Projects.Project; Workstation ws = Workstation.Current; WorkspaceInfo wsi = ws.GetLocalWorkspaceInfo(project.ProjectPath); if (wsi == null) { return(false); } PendingChange[] changes = manager.CurrentWorkspace.GetPendingChanges(project.ProjectPath); if (changes.Length > 0) { return(false); } CheckOutForm checkOutForm = new CheckOutForm(); checkOutForm.FilesToCheckOut = new List <string>() { project.ProjectPath }; checkOutForm.LockLevel = (manager.PluginMain.Settings as Settings).DefaultLockLevel; if (checkOutForm.ShowDialog() != DialogResult.Cancel) { manager.CurrentWorkspace.PendEdit(checkOutForm.SelectedFilesToCheckOut.ToArray(), RecursionType.None, null, checkOutForm.LockLevel); return(false); } else { return(true); } }
public static void Move(string oldPath, string newPath, bool renaming) { if (string.IsNullOrEmpty(oldPath) || string.IsNullOrEmpty(newPath)) { return; } ProjectManager.Projects.Project project = (ProjectManager.Projects.Project)PluginBase.CurrentProject; string newDocumentClass = null; if (File.Exists(oldPath)) { File.Move(oldPath, newPath); PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, newPath); if (project.IsDocumentClass(oldPath)) { newDocumentClass = newPath; } } else if (Directory.Exists(oldPath)) { newPath = renaming ? Path.Combine(Path.GetDirectoryName(oldPath), newPath) : Path.Combine(newPath, Path.GetFileName(oldPath)); string searchPattern = GetSearchPatternFromLang(project.Language.ToLower()); foreach (string file in Directory.GetFiles(oldPath, searchPattern, SearchOption.AllDirectories)) { if (project.IsDocumentClass(file)) { newDocumentClass = file.Replace(oldPath, newPath); break; } } Directory.Move(oldPath, newPath); PluginCore.Managers.DocumentManager.MoveDocuments(oldPath, newPath); } if (!string.IsNullOrEmpty(newDocumentClass)) { project.SetDocumentClass(newDocumentClass, true); project.Save(); } }
public ProjectItem(ProjectManager.Projects.Project project, TreeNode node) { _project = project; _node = node; InitializeItem(); }
/// <summary> /// Handles the incoming events /// </summary> public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority) { TextEvent te = e as TextEvent; DataEvent de = e as DataEvent; ITabbedDocument document = PluginBase.MainForm.CurrentDocument; //BxmlDesigner designer = document != null && designers.ContainsKey(document) ? designers[document] : null; // TODO: we need to handle these too: //ProjectManagerEvents.BuildComplete; //ProjectManagerEvents.BuildFailed; //ProjectManagerEvents.BuildProject; //ProjectManagerEvents.CreateProject; //ProjectManagerEvents.FileMoved; //ProjectManagerEvents.FilePasted; //ProjectManagerEvents.OpenVirtualFile; //ProjectManagerEvents.ProjectCreated; if (e.Type == EventType.Command && de.Action == ProjectManagerEvents.FileMapping) { ProjectFileMapper.Map((FileMappingRequest)de.Data); return; } // our first priority is getting a non-null Project, otherwise // we can't do anything if (e.Type == EventType.Command && de.Action == ProjectManagerEvents.Project) { // the projectexplorer plugin is telling us what project we're working with this.asproject = de.Data as ProjectManager.Projects.Project; Console.WriteLine("We found a project " + this.asproject + " : " + de.Data + " : " + (de.Data is ProjectManager.Projects.Project)); //return; } // we need a project and context to handle these events if (e.Type == EventType.FileOpen) { if (this.IsNfxMxml(document)) { Console.WriteLine("MXML file opened"); PluginBase.MainForm.CallCommand("ChangeSyntax", "xml"); // var timer = new Timer { Interval = 1, Enabled = true }; // timer.Tick += (o, evt) => // { // timer.Enabled = false; // create the design surface //if (GetProjectAndContext()) //{ // if (project.AbsoluteClasspaths.GetClosestParent(document.FileName) != null) // { // designer = new BxmlDesigner(document, project, GetDesignerSwfPath()); // designers.Add(document, designer); // //Compile(document, designer); // } // else // SendErrorToResults(document.FileName, "Cannot design this file because the classpath could not be determined."); //} //else SendErrorToResults(document.FileName, "Could not start up the Bent Designer - no project loaded or AS3 completion plugin not loaded."); // }; } } else if (e.Type == EventType.FileClose) { Console.WriteLine("MXML file closed"); // TODO: Recompile code behind here //if (designers.ContainsKey(document)) // designers.Remove(document); } else if (e.Type == EventType.Command) { switch (de.Action) { case ProjectManagerEvents.BuildComplete: // TODO: Not sure we need this //if (!GetProjectAndContext()) return; //if (!File.Exists(project.OutputPathAbsolute)) return; //if (!CheckIsBentApplication()) return; //BuildDesignerSwf(); //foreach (BxmlDesigner d in designers.Values) // d.SwfOutdated = true; //if (designer != null) // designer.ReloadSwf(); break; case "XMLCompletion.Element": // TODO: Not yet... //if (!IsBxml(document) || !GetProjectAndContext()) return; //if (designer == null) return; ////DateTime started = DateTime.Now; //completion.HandleElement(designer, (XMLContextTag)de.Data); //TraceManager.Add("Took " + (DateTime.Now - started).TotalMilliseconds + "ms."); //e.Handled = true; break; case "XMLCompletion.CloseElement": // TODO: We would try to rely on FD own autocompletion better... //if (!IsBxml(document) || !GetProjectAndContext()) return; //if (designer == null) return; //string ending = completion.HandleCloseElement(designer, (XMLContextTag)de.Data); //if (ending != null) //{ // if (ending != ">") // { // ScintillaNet.ScintillaControl sci = document.SciControl; // int position = sci.CurrentPos; // sci.SetSel(position - 1, position); // sci.ReplaceSel(ending); // sci.SetSel(position + 1, position + 1); // } // e.Handled = true; //} break; case "XMLCompletion.Attribute": // TODO: We would try to rely on FD own autocompletion better... //if (!IsBxml(document) || !GetProjectAndContext()) return; //if (designer == null) return; //object[] o = de.Data as object[]; ////started = DateTime.Now; //completion.HandleAttribute(designer, (XMLContextTag)o[0], o[1] as string); ////TraceManager.Add("Took " + (DateTime.Now - started).TotalMilliseconds + "ms."); //e.Handled = true; break; } } else if (e.Type == EventType.FileSave && this.IsNfxMxml(document)) { Console.WriteLine("MXML file saved " + document.FileName); if (String.IsNullOrEmpty(this.preprocessorLocation)) { OpenFileDialog dialog = new OpenFileDialog(); dialog.CheckFileExists = true; dialog.Filter = "JAR files (*.jar)|*.jar"; DialogResult dr = dialog.ShowDialog(); if (dr == DialogResult.OK) { this.preprocessorLocation = this.settingObject.ParserPath = dialog.FileNames[0]; } else { return; } } this.context = ASCompletion.Context.ASContext.GetLanguageContext("as3"); string classpath = this.asproject.AbsoluteClasspaths.GetClosestParent(document.FileName); Console.WriteLine("Our classpath: " + classpath); ASCompletion.Model.PathModel pathModel = context.Classpath.Find(pm => pm.Path == classpath); Hashtable ht = new Hashtable(); ht.Add("-source", document.FileName); ht.Add("-source-dir", classpath); NotifyEvent ne = new NotifyEvent(EventType.ProcessStart); EventManager.DispatchEvent(this, ne); PluginCore.Managers.EventManager.DispatchEvent( this, new DataEvent(EventType.Command, "ResultsPanel.ClearResults", null)); // TEST: trying to remove sci from our generated AS file so we won't get an update message ITabbedDocument[] documents = FlashDevelop.Globals.MainForm.Documents; ITabbedDocument current = FlashDevelop.Globals.MainForm.CurrentDocument; Boolean designerOpen = false; Char[] splitter = new Char[] { '.' }; foreach (ITabbedDocument doc in documents) { Console.WriteLine("doc.FileName " + doc.FileName + " document " + document.FileName); if (doc.FileName.Split(splitter)[0] == document.FileName.Split(splitter)[0]) { // Our designer AS file is open now designerOpen = true; this.lastDesignerFileName = doc.FileName; this.tempRemovedSci = doc.SciControl; //((Form)doc).Controls.Remove(doc.SciControl); break; } } if (designerOpen) { if (this.restoreDesigner == null) { this.restoreDesigner = new Timer(); this.restoreDesigner.Interval = 50; this.restoreDesigner.Tick += new EventHandler(restoreDesigner_Tick); } this.restoreDesigner.Enabled = true; } NFXShell.Run(new FileInfo(document.FileName), this.preprocessorLocation, null, ht); // TODO: we should only handle our projects // TODO: not really sure this will be needed as those files should be picked up by ASCompletion anyway. //string classpath = this.project.AbsoluteClasspaths.GetClosestParent(document.FileName); this.TellASCompletionAbout(document.FileName, pathModel); } else if (e.Type == EventType.FileSwitch) { // TODO: think we don't need this //if (!GetProjectAndContext()) return; //// if this flash is marked as "dirty" we'll need to reload it //if (designer != null && designer.SwfOutdated) // designer.ReloadSwf(); } else if (e.Type == EventType.UIStarted) { // TODO: Not sure what this does... we'll see later this.projectManager = (ProjectManager.PluginMain)PluginBase.MainForm.FindPlugin( "30018864-fadd-1122-b2a5-779832cbbf23"); //ProjectManager.Controls.TreeView.FileNode.FileAssociations.Add(".nxml", NFXNode.Create); //Timer timer = new Timer(); //timer.Interval = 100; //timer.Tick += delegate { GetProjectAndContext(); timer.Stop(); }; //timer.Start(); } }
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; }