/// <summary>
 /// Processes the specified document
 /// </summary>
 private void DoProcess(ITabbedDocument document)
 {
     switch (this.operationComboBox.SelectedIndex)
     {
         case 0: // Format Code
         {
             DataEvent de = new DataEvent(EventType.Command, "CodeFormatter.FormatDocument", document);
             EventManager.DispatchEvent(this, de);
             break;
         }
         case 1: // Organize Imports
         {
             OrganizeImports command = new OrganizeImports();
             command.SciControl = document.SciControl;
             command.Execute();
             break;
         }
         case 2: // Truncate Imports
         {
             OrganizeImports command = new OrganizeImports();
             command.SciControl = document.SciControl;
             command.TruncateImports = true;
             command.Execute();
             break;
         }
         case 3: // Consistent EOLs
         {
             document.SciControl.ConvertEOLs(document.SciControl.EOLMode);
             break;
         }
     }
 }
示例#2
0
 public static void RestoreSession(String file, Session session)
 {
     try
     {
         Globals.MainForm.RestoringContents = true;
         Globals.MainForm.CloseAllDocuments(false);
         if (!Globals.MainForm.CloseAllCanceled)
         {
             DataEvent te = new DataEvent(EventType.RestoreSession, file, session);
             EventManager.DispatchEvent(Globals.MainForm, te);
             if (!te.Handled)
             {
                 for (Int32 i = 0; i < session.Files.Count; i++)
                 {
                     String fileToOpen = session.Files[i];
                     if (File.Exists(fileToOpen)) Globals.MainForm.OpenEditableDocument(fileToOpen);
                 }
                 if (Globals.MainForm.Documents.Length == 0)
                 {
                     NotifyEvent ne = new NotifyEvent(EventType.FileEmpty);
                     EventManager.DispatchEvent(Globals.MainForm, ne);
                     if (!ne.Handled) Globals.MainForm.New(null, null);
                 }
                 DocumentManager.ActivateDocument(session.Index);
             }
         }
         Globals.MainForm.RestoringContents = false;
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
示例#3
0
 static void debugger_OnStarted(string line)
 {
     if (startMessage == null) 
         return;
     PluginBase.RunAsync(delegate
     {
         // send message again
         ignoreMessage = true;
         EventManager.DispatchEvent(null, startMessage);
         startMessage = null;
         ignoreMessage = false;
     });
 }
示例#4
0
 static void debugger_OnStarted(string line)
 {
     if (startMessage == null) 
         return;
     if ((PluginBase.MainForm as Form).InvokeRequired)
     {
         (PluginBase.MainForm as Form).BeginInvoke(new LineEvent(debugger_OnStarted), new object[] { line });
         return;
     }
     // send message again
     ignoreMessage = true;
     EventManager.DispatchEvent(null, startMessage);
     startMessage = null;
     ignoreMessage = false;
 }
示例#5
0
		/// <summary>
		/// Creates a new project based on the specified template directory.
		/// </summary>
		public Project CreateProject(string templateDirectory, string projectLocation, string projectName, string packageName)
		{
            isRunning = true;
            if (!projectTypesSet) SetInitialProjectHash();
			this.projectName = projectName;
            this.packageName = packageName;
            projectId = Regex.Replace(Project.RemoveDiacritics(projectName), "[^a-z0-9]", "", RegexOptions.IgnoreCase);
            packagePath = packageName.Replace('.', '\\');
            if (packageName.Length > 0)
            {
                packageDot = packageName + ".";
                packageSlash = packagePath + "\\";
            }
            string projectTemplate = FindProjectTemplate(templateDirectory);
            string projectPath = Path.Combine(projectLocation, projectName + Path.GetExtension(projectTemplate));
            projectPath = PathHelper.GetPhysicalPathName(projectPath);
            // notify & let a plugin handle project creation
            Hashtable para = new Hashtable();
            para["template"] = projectTemplate;
            para["location"] = projectLocation;
            para["project"] = projectPath;
            para["id"] = projectId;
            para["package"] = packageName;
            DataEvent de = new DataEvent(EventType.Command, ProjectManagerEvents.CreateProject, para);
            EventManager.DispatchEvent(this, de);
            if (!de.Handled)
            {
                int addArgs = 1;
                arguments = new Argument[PluginBase.MainForm.Settings.CustomArguments.Count + addArgs];
                arguments[0] = new Argument("FlexSDK", PluginBase.MainForm.ProcessArgString("$(FlexSDK)"));
                PluginBase.MainForm.Settings.CustomArguments.CopyTo(arguments, addArgs);
                Directory.CreateDirectory(projectLocation);
                // manually copy important files
                CopyFile(projectTemplate, projectPath);
                CopyProjectFiles(templateDirectory, projectLocation, true);
            }
            isRunning = false;
            if (File.Exists(projectPath))
            {
                projectPath = PathHelper.GetPhysicalPathName(projectPath);
                de = new DataEvent(EventType.Command, ProjectManagerEvents.ProjectCreated, para);
                EventManager.DispatchEvent(this, de);
                return ProjectLoader.Load(projectPath);
            }
            else return null;
		}
 /// <summary>
 /// Applies all shortcuts to the items
 /// </summary>
 public static void ApplyAllShortcuts()
 {
     ShortcutManager.UpdateAllShortcuts();
     foreach (ShortcutItem item in RegistedItems)
     {
         if (item.Item != null)
         {
             item.Item.ShortcutKeys = Keys.None;
             item.Item.ShortcutKeys = item.Custom;
         }
         else if (item.Default != item.Custom)
         {
             DataEvent de = new DataEvent(EventType.Shortcut, item.Id, item.Custom);
             EventManager.DispatchEvent(Globals.MainForm, de);
         }
     }
 }
示例#7
0
 /// <summary>
 /// Creates a new project based on the specified template directory.
 /// </summary>
 public Project CreateProject(string templateDirectory, string projectLocation, string projectName, string packageName)
 {
     isRunning = true;
     if (!projectTypesSet) SetInitialProjectHash();
     SetContext(projectName, packageName);
     string projectTemplate = FindProjectTemplate(templateDirectory);
     string projectPath = Path.Combine(projectLocation, projectName + Path.GetExtension(projectTemplate));
     projectPath = PathHelper.GetPhysicalPathName(projectPath);
     // notify & let a plugin handle project creation
     Hashtable para = new Hashtable();
     para["template"] = projectTemplate;
     para["location"] = projectLocation;
     para["project"] = projectPath;
     para["id"] = projectId;
     para["package"] = packageName;
     DataEvent de = new DataEvent(EventType.Command, ProjectManagerEvents.CreateProject, para);
     EventManager.DispatchEvent(this, de);
     if (!de.Handled)
     {
         Directory.CreateDirectory(projectLocation);
         // manually copy important files
         CopyFile(projectTemplate, projectPath);
         CopyProjectFiles(templateDirectory, projectLocation, true);
     }
     isRunning = false;
     if (File.Exists(projectPath))
     {
         projectPath = PathHelper.GetPhysicalPathName(projectPath);
         de = new DataEvent(EventType.Command, ProjectManagerEvents.ProjectCreated, para);
         EventManager.DispatchEvent(this, de);
         try
         {
             return ProjectLoader.Load(projectPath);
         }
         catch (Exception ex)
         {
             TraceManager.Add(ex.Message);
             return null;
         }
     }
     else return null;
 }
示例#8
0
 public static bool Start(string projectPath, string flex2Path, DataEvent message)
 {
     if (ignoreMessage) return false;
     try
     {
         if (debugger != null) debugger.Cleanup();
         startMessage = message;
         debugger = new FdbWrapper();
         debugger.OnStarted += new LineEvent(debugger_OnStarted);
         debugger.OnTrace += new LineEvent(debugger_OnTrace);
         debugger.OnError += new LineEvent(debugger_OnError);
         if (PluginMain.Settings.VerboseFDB)
             debugger.OnOutput += new LineEvent(debugger_OnOutput);
         debugger.Run(projectPath, flex2Path);
         TraceManager.AddAsync(TextHelper.GetString("Info.CapturingTracesWithFDB"));
         return true;
     }
     catch
     {
         TraceManager.AddAsync(TextHelper.GetString("Info.FailedToLaunchFBD"), 3);
     }
     return false;
 }
示例#9
0
 private void NotifyDisposed(String file)
 {
     DataEvent de = new DataEvent(EventType.Command, "FlashViewer.Closed", file);
     EventManager.DispatchEvent(this, de);
 }
示例#10
0
 /// <summary>
 /// Saves an editable document
 /// </summary>
 public void Save(String file)
 {
     if (!this.IsEditable) return;
     if (!this.IsUntitled && FileHelper.FileIsReadOnly(this.FileName))
     {
         String dlgTitle = TextHelper.GetString("Title.ConfirmDialog");
         String message = TextHelper.GetString("Info.MakeReadOnlyWritable");
         if (MessageBox.Show(Globals.MainForm, message, dlgTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             ScintillaManager.MakeFileWritable(this.SciControl);
         }
         else return;
     }
     String oldFile = this.SciControl.FileName;
     Boolean otherFile = (this.SciControl.FileName != file);
     if (otherFile)
     {
         String args = this.FileName + ";" + file;
         RecoveryManager.RemoveTemporaryFile(this.FileName);
         TextEvent renaming = new TextEvent(EventType.FileRenaming, args);
         EventManager.DispatchEvent(this, renaming);
         TextEvent close = new TextEvent(EventType.FileClose, this.FileName);
         EventManager.DispatchEvent(this, close);
     }
     TextEvent saving = new TextEvent(EventType.FileSaving, file);
     EventManager.DispatchEvent(this, saving);
     if (!saving.Handled)
     {
         this.UpdateDocumentIcon(file);
         this.SciControl.FileName = file;
         ScintillaManager.CleanUpCode(this.SciControl);
         DataEvent de = new DataEvent(EventType.FileEncode, file, this.SciControl.Text);
         EventManager.DispatchEvent(this, de); // Lets ask if a plugin wants to encode and save the data..
         if (!de.Handled) FileHelper.WriteFile(file, this.SciControl.Text, this.SciControl.Encoding, this.SciControl.SaveBOM);
         this.IsModified = false;
         this.SciControl.SetSavePoint();
         RecoveryManager.RemoveTemporaryFile(this.FileName);
         this.fileInfo = new FileInfo(this.FileName);
         if (otherFile)
         {
             ScintillaManager.UpdateControlSyntax(this.SciControl);
             Globals.MainForm.OnFileSave(this, oldFile);
         }
         else Globals.MainForm.OnFileSave(this, null);
     }
     this.RefreshTexts();
 }
示例#11
0
		/**
		* Inserts a color to the editor
		*/
		public void InsertColor(object sender, System.EventArgs e)
		{
			try
			{
	    		ScintillaControl sci = this.CurSciControl;
	    		if (this.colorDialog.ShowDialog(this) == DialogResult.OK)
	    		{
					DataEvent de = new DataEvent(EventType.CustomData, "FlashDevelop.InsertColor", this.colorDialog.Color);
					Global.Plugins.NotifyPlugins(this, de);
					//
					if (!de.Handled)
					{
						int position = this.CurSciControl.CurrentPos;
						string colorText = SharedUtils.ColorToHex(this.colorDialog.Color);
						if (sci.ConfigurationLanguage != "xml" && sci.ConfigurationLanguage != "html")
		    			{
		    				colorText = Regex.Replace(colorText, "#", "0x");
		    			}
		    			sci.ReplaceSel(colorText);
					}
	    		}
			}
			catch (Exception ex)
			{
				ErrorHandler.ShowError("Error while inserting color.", ex);
			}
		}
示例#12
0
 /// <summary>
 /// Handles the Command event and displays the movie
 /// </summary>
 public void HandleCommand(DataEvent evnt)
 {
     try
     {
         if (evnt.Action.StartsWith("PanelFlashViewer."))
         {
             String action = evnt.Action;
             String[] args = evnt.Data.ToString().Split(',');
             switch (action)
             {
                 case "PanelFlashViewer.Panel":
                     this.pluginPanel.Show();
                     this.pluginUI.OpenSWF(args[0]);
                     break;
             }
             evnt.Handled = true;
         }
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
示例#13
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            if (debugManager == null)
            {
                return;
            }
            switch (e.Type)
            {
            case EventType.FileOpen:
                TextEvent evnt = (TextEvent)e;
                ScintillaHelper.AddSciEvent(evnt.Value);
                breakPointManager.SetBreakPointsToEditor(evnt.Value);
                break;

            case EventType.UIStarted:
                menusHelper.AddToolStripItems();
                menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                break;

            case EventType.UIClosing:
                if (debugManager.FlashInterface.isDebuggerStarted)
                {
                    debugManager.FlashInterface.Detach();
                }
                break;

            case EventType.ApplySettings:
                menusHelper.UpdateMenuState(this);
                break;

            case EventType.ProcessEnd:
                TextEvent textevnt = (TextEvent)e;
                if (buildCmpFlg && textevnt.Value != "Done(0)")
                {
                    buildCmpFlg = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }
                break;

            case EventType.Command:
                PluginCore.DataEvent buildevnt = (PluginCore.DataEvent)e;
                if (buildevnt.Action == "AS3Context.StartDebugger")
                {
                    if (settingObject.StartDebuggerOnTestMovie)
                    {
                        if (debugManager.Start(false))
                        {
                            buildevnt.Handled = true;
                        }
                    }
                    return;
                }
                if (!buildevnt.Action.StartsWith("ProjectManager"))
                {
                    return;
                }
                if (buildevnt.Action == ProjectManager.ProjectManagerEvents.Project)
                {
                    IProject project = PluginBase.CurrentProject;
                    if (project != null && project is AS3Project)
                    {
                        disableDebugger = false;
                        PanelsHelper.breakPointUI.Clear();
                        if (breakPointManager.Project != null && breakPointManager.Project != project)
                        {
                            breakPointManager.Save();
                        }
                        breakPointManager.Project = project;
                        breakPointManager.Load();
                        breakPointManager.SetBreakPointsToEditor(PluginBase.MainForm.Documents);
                    }
                    else
                    {
                        disableDebugger = true;
                        if (breakPointManager.Project != null)
                        {
                            breakPointManager.Save();
                        }
                        PanelsHelper.breakPointUI.Clear();
                    }
                }
                else if (disableDebugger)
                {
                    return;
                }
                if (debugBuildStart && buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildFailed)
                {
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }
                else if (buildevnt.Action == ProjectManager.ProjectManagerEvents.TestProject)
                {
                    if (debugManager.FlashInterface.isDebuggerStarted)
                    {
                        if (debugManager.FlashInterface.isDebuggerSuspended)
                        {
                            debugManager.Continue_Click(null, null);
                        }
                        e.Handled = true;
                        return;
                    }
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }
                else if (debugBuildStart && buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildProject && buildevnt.Data.ToString() == "Debug")
                {
                    buildCmpFlg = true;
                }
                else if (buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildFailed)
                {
                    menusHelper.OnBuildFailed();
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                }
                else if (buildCmpFlg && buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildComplete)
                {
                    if (buildCmpFlg)
                    {
                        debugManager.Start(debugManager.currentProject.OutputPathAbsolute);
                    }
                    else
                    {
                        menusHelper.OnBuildComplete();
                    }
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Stopped);
                }
                break;
            }
        }
        public void AddFileFromTemplate(Project project, string inDirectory, string templatePath, bool noName)
        {
            try
            {
                // the template could be named something like "MXML.fdt", or maybe "Class.as.fdt"
                string extension = "";
                string fileName = Path.GetFileNameWithoutExtension(templatePath);
                string caption = TextHelper.GetString("Label.AddNew") + " ";

                if (fileName.IndexOf('.') > -1)
                {
                    // it's something like Class.as.fdt
                    extension = Path.GetExtension(fileName); // .as
                    if (noName)
                    {
                        caption += extension.Substring(1).ToUpper() + " " + TextHelper.GetString("Label.File");
                        fileName = TextHelper.GetString("Label.NewFile");
                    }
                    else
                    {
                        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 (!FileHelper.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);
            }
        }
示例#15
0
 /// <summary>
 /// Invokes the ASCompletion contextual generator
 /// </summary>
 private void CodeGeneratorMenuItemClicked(Object sender, EventArgs e)
 {
     DataEvent de = new DataEvent(EventType.Command, "ASCompletion.ContextualGenerator", null);
     EventManager.DispatchEvent(this, de);
 }
示例#16
0
 /// <summary>
 /// Opens the find and replace in files popup in the current path
 /// </summary>
 private void FindHere(Object sender, System.EventArgs e)
 {
     DataEvent de = new DataEvent(EventType.Command, "FileExplorer.FindHere", this.GetSelectedFiles());
     EventManager.DispatchEvent(this, de);
 }
示例#17
0
 /// <summary>
 /// Opens the specified file and creates a editable document
 /// </summary>
 public DockContent OpenEditableDocument(String org, Encoding encoding, Boolean restorePosition)
 {
     DockContent createdDoc;
     EncodingFileInfo info = new EncodingFileInfo();
     String file = PathHelper.GetPhysicalPathName(org);
     TextEvent te = new TextEvent(EventType.FileOpening, file);
     EventManager.DispatchEvent(this, te);
     if (te.Handled)
     {
         if (this.Documents.Length == 0)
         {
             this.New(null, null);
             return null;
         }
         else return null;
     }
     else if (file.EndsWith(".fdz"))
     {
         this.CallCommand("ExtractZip", file);
         return null;
     }
     try
     {
         Int32 count = this.Documents.Length;
         for (Int32 i = 0; i < count; i++)
         {
             if (this.Documents[i].IsEditable && this.Documents[i].FileName.ToUpper() == file.ToUpper())
             {
                 this.Documents[i].Activate();
                 return null;
             }
         }
     }
     catch {}
     if (encoding == null)
     {
         info = FileHelper.GetEncodingFileInfo(file);
         if (info.CodePage == -1) return null; // If the file is locked, stop.
     }
     else
     {
         info = FileHelper.GetEncodingFileInfo(file);
         info.Contents = FileHelper.ReadFile(file, encoding);
         info.CodePage = encoding.CodePage;
     }
     DataEvent de = new DataEvent(EventType.FileDecode, file, null);
     EventManager.DispatchEvent(this, de); // Lets ask if a plugin wants to decode the data..
     if (de.Handled)
     {
         info.Contents = de.Data as String;
         info.CodePage = Encoding.UTF8.CodePage; // assume plugin always return UTF8
     }
     try
     {
         if (this.CurrentDocument != null && this.CurrentDocument.IsUntitled && !this.CurrentDocument.IsModified && this.Documents.Length == 1)
         {
             this.closingForOpenFile = true;
             this.CurrentDocument.Close();
             this.closingForOpenFile = false;
             createdDoc = this.CreateEditableDocument(file, info.Contents, info.CodePage);
         }
         else createdDoc = this.CreateEditableDocument(file, info.Contents, info.CodePage);
         ButtonManager.AddNewReopenMenuItem(file);
     }
     catch
     {
         createdDoc = this.CreateEditableDocument(file, info.Contents, info.CodePage);
         ButtonManager.AddNewReopenMenuItem(file);
     }
     TabbedDocument document = (TabbedDocument)createdDoc;
     document.SciControl.SaveBOM = info.ContainsBOM;
     document.SciControl.BeginInvoke((MethodInvoker)delegate 
     {
         if (this.appSettings.RestoreFileStates)
         {
             FileStateManager.ApplyFileState(document, restorePosition);
         }
     });
     ButtonManager.UpdateFlaggedButtons();
     return createdDoc;
 }
示例#18
0
 public void SetGlobalClasspaths(String lang, List<String> classpaths)
 {
     Hashtable info = new Hashtable();
     info["language"] = lang;
     info["cp"] = classpaths;
     DataEvent de = new DataEvent(EventType.Command, "ASCompletion.SetUserClasspath", info);
     EventManager.DispatchEvent(this, de);
     FireChanged("GlobalClasspath");
 }
示例#19
0
 /// <summary>
 /// Calls a custom plugin command
 /// </summary>
 public void PluginCommand(Object sender, System.EventArgs e)
 {
     try
     {
         ToolStripItem button = (ToolStripItem)sender;
         String[] args = ((ItemData)button.Tag).Tag.Split(';');
         String action = args[0]; // Action of the command
         String data = (args.Length > 1) ? args[1] : null;
         DataEvent de = new DataEvent(EventType.Command, action, data);
         EventManager.DispatchEvent(this, de);
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
示例#20
0
        /// <summary>
        /// Processes the incoming arguments 
        /// </summary> 
        public void ProcessParameters(String[] args)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke((MethodInvoker)delegate 
                { 
                    this.ProcessParameters(args);
                });
                return;
            }
            this.Activate(); this.Focus();
            if (args != null && args.Length != 0)
            {
                for (Int32 i = 0; i < args.Length; i++)
                {
				    String file = PathHelper.GetLongPathName(args[i]);
                    if (File.Exists(file)) this.OpenEditableDocument(file);
                }
            }
            Win32.ActivateWindow(this.Handle);
            /**
            * Notify plugins about start arguments
            */
            DataEvent de = new DataEvent(EventType.Command, "FlashDevelop.StartArgs", StartArguments);
            EventManager.DispatchEvent(this, de);
        }
示例#21
0
        private void BuildProject() 
        {
            Project project = activeProject; // TODO build all projects

            bool noTrace = pluginUI.IsTraceDisabled;
            DataEvent de = new DataEvent(EventType.Command, ProjectManagerEvents.BuildProject, (noTrace) ? "Release" : "Debug");
            EventManager.DispatchEvent(this, de);
            if (de.Handled) return;

            if (!buildActions.Build(project, false, noTrace))
            {
                BroadcastBuildFailed(project);
            }
        }
示例#22
0
 private void RunProject()
 {
     var de = new DataEvent(EventType.Command, ProjectManagerCommands.PlayOutput, null);
     EventManager.DispatchEvent(this, de);
 }
示例#23
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            if (debugManager == null)
            {
                return;
            }
            switch (e.Type)
            {
            case EventType.FileOpen:
                TextEvent evnt = (TextEvent)e;
                ScintillaHelper.AddSciEvent(evnt.Value);
                breakPointManager.SetBreakPointsToEditor(evnt.Value);
                break;

            case EventType.UIStarted:
                menusHelper.AddToolStripItems();
                menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                debugManager.RestoreOldLayout();
                break;

            case EventType.UIClosing:
                if (debugManager.FlashInterface.isDebuggerStarted)
                {
                    debugManager.FlashInterface.Detach();
                }
                break;

            case EventType.ApplySettings:
                menusHelper.UpdateMenuState(this);
                break;

            case EventType.FileSwitch:
                menusHelper.UpdateMenuState(this);
                break;

            case EventType.Command:
                PluginCore.DataEvent buildevnt = (PluginCore.DataEvent)e;
                if (buildevnt.Action == "AS3Context.StartDebugger")
                {
                    if (settingObject.StartDebuggerOnTestMovie)
                    {
                        if (debugManager.Start(buildevnt.Data != null))
                        {
                            buildevnt.Handled = true;
                        }
                    }
                    return;
                }
                if (!buildevnt.Action.StartsWith("ProjectManager"))
                {
                    return;
                }
                if (buildevnt.Action == ProjectManager.ProjectManagerEvents.Project)
                {
                    IProject project = PluginBase.CurrentProject;
                    if (project != null && project.EnableInteractiveDebugger)
                    {
                        disableDebugger = false;
                        PanelsHelper.breakPointUI.Clear();
                        if (breakPointManager.Project != null && breakPointManager.Project != project)
                        {
                            breakPointManager.Save();
                        }
                        breakPointManager.Project = project;
                        breakPointManager.Load();
                        breakPointManager.SetBreakPointsToEditor(PluginBase.MainForm.Documents);
                    }
                    else
                    {
                        disableDebugger = true;
                        if (breakPointManager.Project != null)
                        {
                            breakPointManager.Save();
                        }
                        PanelsHelper.breakPointUI.Clear();
                    }
                }
                else if (disableDebugger)
                {
                    return;
                }
                if (buildevnt.Action == ProjectManager.ProjectManagerCommands.HotBuild || buildevnt.Action == ProjectManager.ProjectManagerCommands.BuildProject)
                {
                    if (debugManager.FlashInterface.isDebuggerStarted)
                    {
                        if (debugManager.FlashInterface.isDebuggerSuspended)
                        {
                            debugManager.Continue_Click(null, null);
                        }
                        debugManager.Stop_Click(null, null);
                    }
                }
                if (buildevnt.Action == ProjectManager.ProjectManagerEvents.TestProject)
                {
                    if (debugManager.FlashInterface.isDebuggerStarted)
                    {
                        if (debugManager.FlashInterface.isDebuggerSuspended)
                        {
                            debugManager.Continue_Click(null, null);
                            e.Handled = true;
                            return;
                        }
                    }
                }
                if (buildevnt.Action == ProjectManager.ProjectManagerEvents.TestProject)
                {
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }
                break;
            }
        }
示例#24
0
 public List<string> GetGlobalClasspaths(String lang)
 {
     List<String> cp = null;
     Hashtable info = new Hashtable();
     info["language"] = lang;
     DataEvent de = new DataEvent(EventType.Command, "ASCompletion.GetUserClasspath", info);
     EventManager.DispatchEvent(this, de);
     if (de.Handled && info.ContainsKey("cp")) cp = info["cp"] as List<string>;
     return cp ?? new List<string>();
 }
示例#25
0
        private static void ConvertToConst(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member, bool detach)
        {
            String suggestion = "NEW_CONST";
            String label = TextHelper.GetString("ASCompletion.Label.ConstName");
            String title = TextHelper.GetString("ASCompletion.Title.ConvertToConst");

            Hashtable info = new Hashtable();
            info["suggestion"] = suggestion;
            info["label"] = label;
            info["title"] = title;
            DataEvent de = new DataEvent(EventType.Command, "ProjectManager.LineEntryDialog", info);
            EventManager.DispatchEvent(null, de);
            if (!de.Handled)
                return;
            
            suggestion = (string)info["suggestion"];

            int position = Sci.CurrentPos;
            MemberModel latest = null;

            int wordPosEnd = Sci.WordEndPosition(position, true);
            int wordPosStart = Sci.WordStartPosition(position, true);
            char cr = (char)Sci.CharAt(wordPosEnd);
            if (cr == '.')
            {
                wordPosEnd = Sci.WordEndPosition(wordPosEnd + 1, true);
            }
            else
            {
                cr = (char)Sci.CharAt(wordPosStart - 1);
                if (cr == '.')
                {
                    wordPosStart = Sci.WordStartPosition(wordPosStart - 1, true);
                }
            }
            Sci.SetSel(wordPosStart, wordPosEnd);
            string word = Sci.SelText;
            Sci.ReplaceSel(suggestion);
            
            if (member == null)
            {
                detach = false;
                lookupPosition = -1;
                position = Sci.WordStartPosition(Sci.CurrentPos, true);
                Sci.SetSel(position, Sci.WordEndPosition(position, true));
            }
            else
            {
                latest = GetLatestMemberForVariable(GeneratorJobType.Constant, inClass, 
                    Visibility.Private, new MemberModel("", "", FlagType.Static, 0));
                if (latest != null)
                {
                    position = FindNewVarPosition(Sci, inClass, latest);
                }
                else
                {
                    position = GetBodyStart(inClass.LineFrom, inClass.LineTo, Sci);
                    detach = false;
                }
                if (position <= 0) return;
                Sci.SetSel(position, position);
            }

            MemberModel m = NewMember(suggestion, member, FlagType.Variable | FlagType.Constant | FlagType.Static);
            m.Type = ASContext.Context.Features.numberKey;
            m.Value = word;
            GenerateVariable(m, position, detach);
        }
示例#26
0
 /// <summary>
 /// Add directory to trust files
 /// </summary>
 private void TrustHere(Object sender, System.EventArgs e)
 {
     String path;
     String trustFile;
     String trustParams;
     // add selected file
     if ((this.fileView.SelectedItems.Count != 0) && (this.fileView.SelectedIndices[0] > 0))
     {
         String file = this.fileView.SelectedItems[0].Tag.ToString();
         if (File.Exists(file)) file = Path.GetDirectoryName(file);
         if (!Directory.Exists(file)) return;
         DirectoryInfo info = new DirectoryInfo(file);
         path = info.FullName;
         trustFile = path.Replace('\\', '_').Remove(1, 1);
         while ((trustFile.Length > 100) && (trustFile.IndexOf('_') > 0)) trustFile = trustFile.Substring(trustFile.IndexOf('_'));
         trustParams = "FlashDevelop_" + trustFile + ".cfg;" + path;
     }
     // add current folder
     else
     {
         FileInfo info = new FileInfo(this.selectedPath.Text);
         path = info.FullName;
         trustFile = path.Replace('\\', '_').Remove(1, 1);
         while ((trustFile.Length > 100) && (trustFile.IndexOf('_') > 0)) trustFile = trustFile.Substring(trustFile.IndexOf('_'));
         trustParams = "FlashDevelop_" + trustFile + ".cfg;" + path;
     }
     // add to trusted files
     DataEvent deTrust = new DataEvent(EventType.Command, "ASCompletion.CreateTrustFile", trustParams);
     EventManager.DispatchEvent(this, deTrust);
     if (deTrust.Handled)
     {
         String message = TextHelper.GetString("Info.PathTrusted");
         ErrorManager.ShowInfo("\"" + path + "\"\n" + message);
     }
 }
示例#27
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            if (debugManager == null)
            {
                return;
            }

            switch (e.Type)
            {
            case EventType.FileOpen:
                TextEvent evnt = (TextEvent)e;
                ScintillaHelper.AddSciEvent(evnt.Value);
                breakPointManager.SetBreakPointsToEditor(evnt.Value);
                break;

            case EventType.UIStarted:
                menusHelper.AddToolStrip();
                menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                CheckValidFile(!disableDebugger);
                break;

            case EventType.UIClosing:
                if (debugManager.FlashInterface.isDebuggerStarted)
                {
                    String title = " " + PluginCore.Localization.TextHelper.GetString("FlashDevelop.Title.ConfirmDialog");
                    switch (MessageBox.Show(TextHelper.GetString("Info.PlayerStillRunning"), title, MessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.Yes:
                    default:
                        debugManager.FlashInterface.Stop();
                        break;

                    case DialogResult.No:
                        debugManager.FlashInterface.Detach();
                        break;

                    case DialogResult.Cancel:
                        e.Handled = true;
                        break;
                    }
                }

                breakPointManager.Save();
                break;

            case EventType.FileSwitch:
                CheckValidFile(!disableDebugger);
                break;

            case EventType.ProcessEnd:
                TextEvent textevnt = (TextEvent)e;
                if (buildCmpFlg && (textevnt.Value != "Done (0)"))
                {
                    buildCmpFlg = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }
                break;

            case EventType.Command:
                PluginCore.DataEvent buildevnt = (PluginCore.DataEvent)e;

                if (buildevnt.Action == "AS3Context.StartDebugger")
                {
                    if (settingObject.StartDebuggerOnTestMovie)
                    {
                        // TODO Detect what sort of TestMovieBehavior is set (or some other way) to disable debugging of ActiveX player
                        buildevnt.Handled = true;
                        debugManager.Start();
                    }
                    return;
                }

                if (!buildevnt.Action.StartsWith("ProjectManager"))
                {
                    return;
                }

                if (buildevnt.Action == ProjectManager.ProjectManagerEvents.Project)
                {
                    IProject project = PluginBase.CurrentProject;
                    if (project != null && project is AS3Project)
                    {
                        disableDebugger = false;
                        CheckValidFile(true);

                        PanelsHelper.breakPointUI.Clear();
                        breakPointManager.Project = project;
                        breakPointManager.Load();
                        breakPointManager.SetBreakPointsToEditor(PluginBase.MainForm.Documents);
                    }
                    else
                    {
                        disableDebugger = true;
                        CheckValidFile(false);

                        if (breakPointManager.Project != null)
                        {
                            breakPointManager.Save();
                        }
                        PanelsHelper.breakPointUI.Clear();
                    }
                }
                else if (disableDebugger)
                {
                    return;
                }

                if (debugBuildStart && buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildFailed)
                {
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }

                else if (buildevnt.Action == ProjectManager.ProjectManagerEvents.TestProject)
                {
                    if (debugManager.FlashInterface.isDebuggerStarted)
                    {
                        if (debugManager.FlashInterface.isDebuggerSuspended)
                        {
                            debugManager.Continue_Click(null, null);
                        }
                        e.Handled = true;
                        return;
                    }
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Initializing);
                }

#if false
                else if (buildevnt.Action == "ProjectManager.TestingProject")
                {
                    // no new build while debugging
                    if (debugBuildStart || debugManager.FlashInterface.isDebuggerStarted)
                    {
                        buildevnt.Handled = true;
                        return;
                    }
                    Project newProject = PluginBase.CurrentProject as AS3Project;
                    if (newProject != null && !newProject.NoOutput &&
                        buildevnt.Data.ToString() == "Debug")
                    {
                        buildevnt.Handled           = true;
                        debugManager.currentProject = newProject;
                        debugManager.Start();
                        buildCmpFlg = true;
                    }
                    else
                    {
                        debugManager.currentProject = null;
                    }
                }
#endif
                else if (debugBuildStart && buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildProject &&
                         buildevnt.Data.ToString() == "Debug")
                {
                    buildCmpFlg = true;
                }
                else if (buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildFailed)
                {
                    menusHelper.OnBuildFailed();
                    debugBuildStart = false;
                    buildCmpFlg     = false;
                }
                else if (buildCmpFlg && buildevnt.Action == ProjectManager.ProjectManagerEvents.BuildComplete)
                {
                    if (buildCmpFlg)
                    {
                        debugManager.Start(debugManager.currentProject.OutputPathAbsolute);
                    }
                    else
                    {
                        menusHelper.OnBuildComplete();
                    }

                    debugBuildStart = false;
                    buildCmpFlg     = false;
                    menusHelper.UpdateMenuState(this, DebuggerState.Stopped);
                }
                break;
            }
        }
示例#28
0
 /// <summary>
 /// Opens the command prompt in the current path
 /// </summary>
 private void CommandPromptHere(Object sender, System.EventArgs e)
 {
     DataEvent de = new DataEvent(EventType.Command, "FileExplorer.PromptHere", this.selectedPath.Text);
     EventManager.DispatchEvent(this, de);
 }
 private void EnableWatchers()
 {
     DataEvent enableWatchers = new DataEvent(EventType.Command, ProjectFileActionsEvents.FileEnableWatchers, null);
     EventManager.DispatchEvent(this, enableWatchers);
 }
示例#30
0
		/**
		* Add the current folder or selected file to Flash Player trusted files
		*/ 		
		private void MenuItemTrustClick(object sender, System.EventArgs e)
		{
			string path;
			string trustFile;
			string trustParams;
			// add selected file
			if ((this.fileView.SelectedItems.Count != 0) && (this.fileView.SelectedIndices[0] > 0)) 
			{
				string file = this.fileView.SelectedItems[0].Tag.ToString();
				if (!System.IO.Directory.Exists(file)) return;
				System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(file);
				//
				path = info.FullName;
				trustFile = path.Replace('\\','_').Remove(1,1);
				while ((trustFile.Length > 100) && (trustFile.IndexOf('_') > 0)) trustFile = trustFile.Substring(trustFile.IndexOf('_'));
				//
				trustParams = "FlashDevelop_"+trustFile+".cfg;"+path;
			}
			// add current folder
			else 
			{
				System.IO.FileInfo info = new System.IO.FileInfo(this.selectedPath.Text);
				//
				path = info.FullName;
				trustFile = path.Replace('\\','_').Remove(1,1);
				while ((trustFile.Length > 100) && (trustFile.IndexOf('_') > 0)) trustFile = trustFile.Substring(trustFile.IndexOf('_'));
				//
				trustParams = "FlashDevelop_"+trustFile+".cfg;"+path;
			}
			// add to trusted files
			DataEvent deTrust = new DataEvent(EventType.CustomData, "CreateTrustFile", trustParams);
			this.plugin.MainForm.DispatchEvent(deTrust);
			//
			if (deTrust.Handled)
			{
				ErrorHandler.ShowInfo("'"+path+"'\nwas added to the Flash Player trusted files");
			}
		}
 /// <summary>
 /// Applies all shortcuts to the items
 /// </summary>
 public static void ApplyAllShortcuts()
 {
     UpdateAllShortcuts();
     foreach (ShortcutItem item in RegisteredItems)
     {
         if (item.Item != null)
         {
             item.Item.ShortcutKeys = Keys.None;
             item.Item.ShortcutKeys = item.Custom;
         }
         else if (item.Default != item.Custom)
         {
             ScintillaControl.UpdateShortcut(item.Id, item.Custom);
             DataEvent de = new DataEvent(EventType.Shortcut, item.Id, item.Custom);
             EventManager.DispatchEvent(Globals.MainForm, de);
         }
     }
     foreach (ToolStripItem button in SecondaryItems)
     {
         ApplySecondaryShortcut(button);
     }
 }
示例#32
0
        private static void GenerateClass(ScintillaNet.ScintillaControl Sci, String className, ClassModel inClass)
        {
            AddLookupPosition(); // remember last cursor position for Shift+F4

            List<FunctionParameter> parameters = ParseFunctionParameters(Sci, Sci.WordEndPosition(Sci.CurrentPos, true));
            List<MemberModel> constructorArgs = new List<MemberModel>();
            List<String> constructorArgTypes = new List<String>();
            MemberModel paramMember = new MemberModel();
            for (int i = 0; i < parameters.Count; i++)
            {
                FunctionParameter p = parameters[i];
                constructorArgs.Add(new MemberModel(p.paramName, p.paramType, FlagType.ParameterVar, 0));
                constructorArgTypes.Add(CleanType(getQualifiedType(p.paramQualType, inClass)));
            }
            
            paramMember.Parameters = constructorArgs;

            IProject project = PluginBase.CurrentProject;
            if (String.IsNullOrEmpty(className)) className = "Class";
            string projFilesDir = Path.Combine(PathHelper.TemplateDir, "ProjectFiles");
            string projTemplateDir = Path.Combine(projFilesDir, project.GetType().Name);
            string paramsString = TemplateUtils.ParametersString(paramMember, true);
            Hashtable info = new Hashtable();
            info["className"] = className;
            if (project.Language.StartsWith("as")) info["templatePath"] = Path.Combine(projTemplateDir, "Class.as.fdt");
            else if (project.Language.StartsWith("haxe")) info["templatePath"] = Path.Combine(projTemplateDir, "Class.hx.fdt");
            else if (project.Language.StartsWith("loom")) info["templatePath"] = Path.Combine(projTemplateDir, "Class.ls.fdt");
            info["inDirectory"] = Path.GetDirectoryName(inClass.InFile.FileName);
            info["constructorArgs"] = paramsString.Length > 0 ? paramsString : null;
            info["constructorArgTypes"] = constructorArgTypes;
            DataEvent de = new DataEvent(EventType.Command, "ProjectManager.CreateNewFile", info);
            EventManager.DispatchEvent(null, de);
            if (de.Handled) return;
        }
 /// <summary>
 /// Notify of file action and allow plugins to handle the operation
 /// </summary>
 private bool CancelAction(string name, object context)
 {
     DataEvent de = new DataEvent(EventType.Command, name, context);
     EventManager.DispatchEvent(this, de);
     return de.Handled;
 }