void updater_Tick(object sender, EventArgs e)
        {
            updater.Stop();
            string src = File.Exists(logFile) ? File.ReadAllText(logFile) : "";
            MatchCollection matches = reError.Matches(src);

            TextEvent te;
            if (matches.Count == 0)
            {
                te = new TextEvent(EventType.ProcessEnd, "Done(0)");
                EventManager.DispatchEvent(this, te);
                if (!te.Handled) PlaySWF();
                return;
            }

            NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);
            EventManager.DispatchEvent(this, ne);
            foreach (Match m in matches)
            {
                string file = m.Groups["file"].Value;
                string line = m.Groups["line"].Value;
                string desc = m.Groups["desc"].Value.Trim();
                TraceManager.Add(String.Format("{0}:{1}: {2}", file, line, desc), -3);
            }
            te = new TextEvent(EventType.ProcessEnd, "Done(" + matches.Count + ")");
            EventManager.DispatchEvent(this, te);

            (PluginBase.MainForm as Form).Activate();
            (PluginBase.MainForm as Form).Focus();
        }
 public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
 {
     if (e.Type == EventType.ApplyTheme)
     {
         RefreshColors();
     }
 }
 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);
     }
 }
Beispiel #4
0
		/**
		* Adds a new entry to the log
		*/
		public static void AddMessage(string message, int state)
		{
			log.Add(new TraceEntry(message, state));
			//
			NotifyEvent ne = new NotifyEvent(EventType.LogEntry);
			Global.Plugins.NotifyPlugins(null, ne);
		}
        void updater_Tick(object sender, EventArgs e)
        {
            updater.Stop();
            string src = File.Exists(logFile) ? File.ReadAllText(logFile) : "";
            MatchCollection errorMatches = reError.Matches(src);
            MatchCollection warningMatches = warnError.Matches(src);

            TextEvent te;
            if (errorMatches.Count == 0 && warningMatches.Count == 0)
            {
                te = new TextEvent(EventType.ProcessEnd, "Done(0)");
                EventManager.DispatchEvent(this, te);
                if (!te.Handled) PlaySWF();
                return;
            }

            NotifyEvent ne = new NotifyEvent(EventType.ProcessStart);
            EventManager.DispatchEvent(this, ne);
            foreach (Match m in errorMatches)
            {
                string file = m.Groups["file"].Value;
                string line = m.Groups["line"].Value;
                string desc = m.Groups["desc"].Value.Trim();
                Match mCol = Regex.Match(desc, @"\s*[a-z]+\s([0-9]+)\s");
                if (mCol.Success)
                {
                    line += "," + mCol.Groups[1].Value;
                    desc = desc.Substring(mCol.Length);
                }
                TraceManager.Add(String.Format("{0}({1}): {2}", file, line, desc), -3);
            }
            foreach (Match m in warningMatches)
            {
                string file = m.Groups["file"].Value;
                string line = m.Groups["line"].Value;
                string desc = m.Groups["desc"].Value.Trim();
                Match mCol = Regex.Match(desc, @"\s*[a-z]+\s([0-9]+)\s");
                if (mCol.Success)
                {
                    line += "," + mCol.Groups[1].Value;
                    desc = desc.Substring(mCol.Length);
                }
                TraceManager.Add(String.Format("{0}({1}): {2}", file, line, desc), -3);
            }
            te = new TextEvent(EventType.ProcessEnd, "Done(" + errorMatches.Count + ")");
            EventManager.DispatchEvent(this, te);

            if (errorMatches.Count == 0)
            {
                if (!te.Handled)
                {
                    PlaySWF();
                    return;
                }
            }
            
            (PluginBase.MainForm as Form).Activate();
            (PluginBase.MainForm as Form).Focus();
        }
 public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
 {
     switch (e.Type)
     {
         case EventType.Trace:
             ProcessTraces();
             ui.EndUpdate();
             break;
     }
 }
Beispiel #7
0
 public void HandleEvent(object sender, PluginCore.NotifyEvent e, PluginCore.HandlingPriority priority)
 {
     switch (e.Type)
     {
     case EventType.Trace:
         ProcessTraces();
         ui.EndUpdate();
         break;
     }
 }
Beispiel #8
0
        public void HandleEvent(object sender, NotifyEvent e,
			HandlingPriority priority)
        {
            var de = e as DataEvent;

            // If it's a DE event with subs for the DE's action
            if (de != null && subs.ContainsKey (de.Action)) {
                subs[de.Action].ForEach (i => i (de));
            }
        }
Beispiel #9
0
		/**
		* Adds a group of new entries to the log
		*/
		public static void AddMessage(ArrayList messages, int state)
		{
			int count = messages.Count;
			for (int i = 0; i<count; i++)
			{
				log.Add(new TraceEntry(messages[i].ToString(), state));
			}
			NotifyEvent ne = new NotifyEvent(EventType.LogEntry);
			Global.Plugins.NotifyPlugins(null, ne);
		}
 public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
 {
     switch (e.Type)
     {
         case EventType.ProcessStart:
             ui.BeginUpdate();
             break;
         case EventType.ProcessEnd:
             ui.EndUpdate();
             break;
     }
 }
Beispiel #11
0
        public void HandleEvent(object sender, PluginCore.NotifyEvent e, PluginCore.HandlingPriority priority)
        {
            switch (e.Type)
            {
            case EventType.ProcessStart:
                ui.BeginUpdate();
                break;

            case EventType.ProcessEnd:
                ui.EndUpdate();
                break;
            }
        }
 /// <summary>
 /// Handle the incoming theme events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     if (e.Type == EventType.ApplyTheme)
     {
         Boolean enabled = PluginBase.MainForm.GetThemeColor("ScrollBar.ForeColor") != Color.Empty;
         if (enabled && !this.Controls.Contains(this.vScrollBar))
         {
             this.AddScrollBars(this);
         }
         else if (!enabled && this.Controls.Contains(this.vScrollBar))
         {
             this.RemoveScrollBars(this);
         }
     }
 }
Beispiel #13
0
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            Project project;
            switch (e.Type)
            {
                case EventType.Command:
                    DataEvent evt = (DataEvent)e;
                    if (evt.Action == "ProjectManager.CreateNewFile")
                    {
                        Hashtable table = evt.Data as Hashtable;
                        project = PluginBase.CurrentProject as Project;
                        if ((project.Language.StartsWith("as")) && IsModuleTemplate(table["templatePath"] as String))
                        {
                            evt.Handled = true;
                            showWizard(table["inDirectory"] as string, table["templatePath"] as String);

                            //String className = table.ContainsKey("className") ? table["className"] as String : TextHelper.GetString("Wizard.Label.NewClass");
                            //DisplayClassWizard(table["inDirectory"] as String, table["templatePath"] as String, className, table["constructorArgs"] as String, table["constructorArgTypes"] as List<String>);
                        }
                    }
                    break;

                //case EventType.FileSwitch:
                //    if (PluginBase.MainForm.CurrentDocument.FileName == processOnSwitch)
                //    {
                //        processOnSwitch = null;
                //        if (lastFileOptions == null || lastFileOptions.interfaces == null) return;
                //        foreach (String cname in lastFileOptions.interfaces)
                //        {
                //            ASContext.Context.CurrentModel.Check();
                //            ClassModel inClass = ASContext.Context.CurrentModel.GetPublicClass();
                //            ASGenerator.SetJobContext(null, cname, null, null);
                //            ASGenerator.GenerateJob(GeneratorJobType.ImplementInterface, null, inClass, null, null);
                //        }
                //        lastFileOptions = null;
                //    }
                //    break;

                case EventType.ProcessArgs:
                    TextEvent te = e as TextEvent;
                    project = PluginBase.CurrentProject as Project;
                    if (lastFileFromTemplate != null && project != null && (project.Language.StartsWith("as")))
                    {
                        te.Value = ProcessArgs(project, te.Value);
                    }
                    break;
            }
        }
Beispiel #14
0
		/**
		* Handles the incoming file save events
		*/
		public void HandleEvent(object sender, NotifyEvent e)
		{
			if (e.Type == EventType.FileSaving)
			{
				TextEvent te = (TextEvent)e;
				if (te.Text.ToLower() == this.FilePath.ToLower())
				{
					this.fileInfo = null;
				}
			} 
			else if (e.Type == EventType.FileSave)
			{
				TextEvent te = (TextEvent)e;
				if (te.Text.ToLower() == this.FilePath.ToLower())
				{
					this.fileInfo = new FileInfo(this.FilePath);
				}
			}
		}
Beispiel #15
0
		// Receives only eventMask events
		public void HandleEvent(object sender, NotifyEvent e)
		{
			if (e.Type == EventType.FileOpen)
			{
				string path = MainForm.CurFile;
				string extension = Path.GetExtension(path);

				if (extension.ToLower() == ".swf")
					DisplaySwf(MainForm.CurFile);
			}
			else if (e.Type == EventType.Command)
			{
				TextEvent te = e as TextEvent;
				if (te.Text.StartsWith(COMMAND_POPUPSWF))
				{
					string[] split = te.Text.Split(';');
					string path = split[2];
					int width = int.Parse(split[3]);
					int height = int.Parse(split[4]);
					PopupSwf(path,width,height);
				}
			}
		}
Beispiel #16
0
 /// <summary>
 /// Dispatches an event to the registered event handlers
 /// </summary>
 public static void DispatchEvent(Object sender, NotifyEvent e)
 {
     try
     {
         List<EventObject>[] objectList = GetObjectListCollection();
         for (Int32 i = 0; i < objectList.Length; i++)
         {
             List<EventObject> subObjects = objectList[i];
             for (Int32 j = 0; j < subObjects.Count; j++)
             {
                 EventObject obj = subObjects[j];
                 if ((obj.Mask & e.Type) > 0)
                 {
                     obj.Handler.HandleEvent(sender, e, obj.Priority);
                     if (e.Handled) return;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ErrorManager.ShowError(ex);
     }
 }
Beispiel #17
0
		/// <summary>
		/// Handles the incoming events
		/// </summary>
		public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
		{
            switch (e.Type)
            {
                case EventType.ProcessStart:
                    this.pluginUI.ClearOutput(null, null);
                    break;

                case EventType.ProcessEnd:
                    if (this.settingObject.ShowOnProcessEnd && !this.settingObject.ShowOnOutput)
                    {
                        this.pluginUI.DisplayOutput();
                    }
                    break;

                case EventType.Trace:
                    this.pluginUI.AddTraces();
                    if (this.settingObject.ShowOnOutput)
                    {
                        this.pluginUI.DisplayOutput();
                    }
                    break;

                case EventType.Keys:
                    Keys keys = (e as KeyEvent).Value;
                    e.Handled = this.pluginUI.OnShortcut(keys);
                    break;

                case EventType.ApplySettings:
                    this.pluginUI.ApplyWrapText();
                    break;
            }
		}
Beispiel #18
0
        /**
        * Handles the incoming events
        */
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            try
            {
                // ignore all events when leaving
                if (PluginBase.MainForm.ClosingEntirely) return;
                // current active document
                ITabbedDocument doc = PluginBase.MainForm.CurrentDocument;

                // application start
                if (!started && e.Type == EventType.UIStarted)
                {
                    started = true;
                    PathExplorer.OnUIStarted();
                    // associate context to initial document
                    e = new NotifyEvent(EventType.SyntaxChange);
                    this.pluginUI.UpdateAfterTheme();
                }

                // editor ready?
                if (doc == null) return;
                ScintillaControl sci = doc.IsEditable ? doc.SciControl : null;

                //
                //  Events always handled
                //
                bool isValid;
                DataEvent de;
                switch (e.Type)
                {
                    // caret position in editor
                    case EventType.UIRefresh:
                        if (!doc.IsEditable) return;
                        timerPosition.Enabled = false;
                        timerPosition.Enabled = true;
                        return;

                    // key combinations
                    case EventType.Keys:
                        Keys key = (e as KeyEvent).Value;
                        if (ModelsExplorer.HasFocus)
                        {
                            e.Handled = ModelsExplorer.Instance.OnShortcut(key);
                            return;
                        }
                        if (!doc.IsEditable) return;
                        e.Handled = ASComplete.OnShortcut(key, sci);
                        return;

                    // user-customized shortcuts
                    case EventType.Shortcut:
                        de = e as DataEvent;
                        if (de.Action == "Completion.ShowHelp")
                        {
                            ASComplete.HelpKeys = (Keys)de.Data;
                            de.Handled = true;
                        }
                        return;

                    //
                    // File management
                    //
                    case EventType.FileSave:
                        if (!doc.IsEditable) return;
                        ASContext.Context.CheckModel(false);
                        // toolbar
                        isValid = ASContext.Context.IsFileValid;
                        if (isValid && !PluginBase.MainForm.SavingMultiple)
                        {
                            if (ASContext.Context.Settings.CheckSyntaxOnSave) CheckSyntax(null, null);
                            ASContext.Context.RemoveClassCompilerCache();
                        }
                        return;

                    case EventType.SyntaxDetect:
                        // detect Actionscript language version
                        if (!doc.IsEditable) return;
                        if (doc.FileName.ToLower().EndsWithOrdinal(".as"))
                        {
                            settingObject.LastASVersion = DetectActionscriptVersion(doc);
                            (e as TextEvent).Value = settingObject.LastASVersion;
                            e.Handled = true;
                        }
                        break;

                    case EventType.ApplySettings:
                    case EventType.SyntaxChange:
                    case EventType.FileSwitch:
                        if (!doc.IsEditable)
                        {
                            ASContext.SetCurrentFile(null, true);
                            ContextChanged();
                            return;
                        }
                        currentDoc = doc.FileName;
                        currentPos = sci.CurrentPos;
                        // check file
                        bool ignoreFile = !doc.IsEditable;
                        ASContext.SetCurrentFile(doc, ignoreFile);
                        // UI
                        ContextChanged();
                        return;

                    case EventType.Completion:
                        if (ASContext.Context.IsFileValid) e.Handled = true;
                        return;

                    // some commands work all the time
                    case EventType.Command:
                        de = e as DataEvent;
                        string command = de.Action ?? "";

                        if (command.StartsWithOrdinal("ASCompletion."))
                        {
                            string cmdData = de.Data as string;

                            // add a custom classpath
                            if (command == "ASCompletion.ClassPath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null)
                                {
                                    ContextSetupInfos setup = new ContextSetupInfos();
                                    setup.Platform = (string)info["platform"];
                                    setup.Lang = (string)info["lang"];
                                    setup.Version = (string)info["version"];
                                    setup.TargetBuild = (string)info["targetBuild"];
                                    setup.Classpath = (string[])info["classpath"];
                                    setup.HiddenPaths = (string[])info["hidden"];
                                    ASContext.SetLanguageClassPath(setup);
                                    if (setup.AdditionalPaths != null) // report custom classpath
                                        info["additional"] = setup.AdditionalPaths.ToArray();
                                }
                                e.Handled = true;
                            }

                            // send a UserClasspath
                            else if (command == "ASCompletion.GetUserClasspath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    if (context != null && context.Settings != null 
                                        && context.Settings.UserClasspath != null)
                                        info["cp"] = new List<string>(context.Settings.UserClasspath);
                                }
                                e.Handled = true;
                            }
                            // update a UserClasspath
                            else if (command == "ASCompletion.SetUserClasspath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language") && info.ContainsKey("cp"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    List<string> cp = info["cp"] as List<string>;
                                    if (cp != null && context != null && context.Settings != null)
                                    {
                                        string[] pathes = new string[cp.Count];
                                        cp.CopyTo(pathes);
                                        context.Settings.UserClasspath = pathes;
                                    }
                                }
                                e.Handled = true;
                            }
                            // send the language's default compiler path
                            else if (command == "ASCompletion.GetCompilerPath")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    if (context != null)
                                        info["compiler"] = context.GetCompilerPath();
                                }
                                e.Handled = true;
                            }

                            // show a language's compiler settings
                            else if (command == "ASCompletion.ShowSettings")
                            {
                                e.Handled = true;
                                IASContext context = ASContext.GetLanguageContext(cmdData);
                                if (context == null) return;
                                string filter = "SDK";
                                string name = "";
                                switch (cmdData.ToUpper())
                                {
                                    case "AS2": name = "AS2Context"; break;
                                    case "AS3": name = "AS3Context"; break;
                                    default: 
                                        name = cmdData.Substring(0, 1).ToUpper() + cmdData.Substring(1) + "Context";
                                        break;
                                }
                                PluginBase.MainForm.ShowSettingsDialog(name, filter);
                            }

                            // Open types explorer dialog
                            else if (command == "ASCompletion.TypesExplorer")
                            {
                                TypesExplorer(null, null);
                            }

                            // call the Flash IDE
                            else if (command == "ASCompletion.CallFlashIDE")
                            {
                                if (flashErrorsWatcher == null) flashErrorsWatcher = new FlashErrorsWatcher();
                                e.Handled = CallFlashIDE.Run(settingObject.PathToFlashIDE, cmdData);
                            }

                            // create Flash 8+ trust file
                            else if (command == "ASCompletion.CreateTrustFile")
                            {
                                if (cmdData != null)
                                {
                                    string[] args = cmdData.Split(';');
                                    if (args.Length == 2)
                                        e.Handled = CreateTrustFile.Run(args[0], args[1]);
                                }
                            }
                            else if (command == "ASCompletion.GetClassPath")
                            {
                                if (cmdData != null)
                                {
                                    string[] args = cmdData.Split(';');
                                    if (args.Length == 1)
                                    {
                                        FileModel model = ASContext.Context.GetFileModel(args[0]);
                                        ClassModel aClass = model.GetPublicClass();
                                        if (!aClass.IsVoid())
                                        {
                                            Clipboard.SetText(aClass.QualifiedName);
                                            e.Handled = true;
                                        }
                                    }
                                }
                            }
                            else if (command == "ProjectManager.FileActions.DisableWatchers")
                            {
                                foreach (PathModel cp in ASContext.Context.Classpath)
                                    cp.DisableWatcher();
                            }
                            else if (command == "ProjectManager.FileActions.EnableWatchers")
                            {
                                // classpaths could be invalid now - remove those, BuildClassPath() is too expensive
                                ASContext.Context.Classpath.RemoveAll(cp => !Directory.Exists(cp.Path));

                                foreach (PathModel cp in ASContext.Context.Classpath)
                                    cp.EnableWatcher();
                            }

                            // Return requested language SDK list
                            else if (command == "ASCompletion.InstalledSDKs")
                            {
                                Hashtable info = de.Data as Hashtable;
                                if (info != null && info.ContainsKey("language"))
                                {
                                    IASContext context = ASContext.GetLanguageContext(info["language"] as string);
                                    if (context != null)
                                        info["sdks"] = context.Settings.InstalledSDKs;
                                }
                                e.Handled = true;
                            }
                        }

                        // Create a fake document from a FileModel
                        else if (command == "ProjectManager.OpenVirtualFile")
                        {
                            string cmdData = de.Data as string;
                            if (reVirtualFile.IsMatch(cmdData))
                            {
                                string[] path = Regex.Split(cmdData, "::");
                                string fileName = path[0] + Path.DirectorySeparatorChar
                                    + path[1].Replace('.', Path.DirectorySeparatorChar).Replace("::", Path.DirectorySeparatorChar.ToString());
                                FileModel found = ModelsExplorer.Instance.OpenFile(fileName);
                                if (found != null) e.Handled = true;
                            }
                        }
                        else if (command == "ProjectManager.UserRefreshTree")
                        {
                            ASContext.UserRefreshRequestAll();
                        }
                        break;
                }

                //
                // Actionscript context specific
                //
                if (ASContext.Context.IsFileValid)
                {
                    switch (e.Type)
                    {
                        case EventType.ProcessArgs:
                            TextEvent te = (TextEvent) e;
                            if (reArgs.IsMatch(te.Value))
                            {
                                // resolve current element
                                Hashtable details = ASComplete.ResolveElement(sci, null);
                                te.Value = ArgumentsProcessor.Process(te.Value, details);

                                if (te.Value.IndexOf('$') >= 0 && reCostlyArgs.IsMatch(te.Value))
                                {
                                    ASResult result = ASComplete.CurrentResolvedContext.Result ?? new ASResult();
                                    details = new Hashtable();
                                    // Get closest list (Array or Vector)
                                    string closestListName = "", closestListItemType = "";
                                    ASComplete.FindClosestList(ASContext.Context, result.Context, sci.CurrentLine, ref closestListName, ref closestListItemType);
                                    details.Add("TypClosestListName", closestListName);
                                    details.Add("TypClosestListItemType", closestListItemType);
                                    // get free iterator index
                                    string iterator = ASComplete.FindFreeIterator(ASContext.Context, ASContext.Context.CurrentClass, result.Context);
                                    details.Add("ItmUniqueVar", iterator);
                                    te.Value = ArgumentsProcessor.Process(te.Value, details);
                                }
                            }
                            break;

                        // menu commands
                        case EventType.Command:
                            de = e as DataEvent;
                            string command = de.Action ?? "";
                            if (command.StartsWith("ASCompletion.", StringComparison.Ordinal))
                            {
                                string cmdData = de.Data as string;
                                switch (command)
                                {
                                    // run MTASC
                                    case "ASCompletion.CustomBuild":
                                        if (cmdData != null) ASContext.Context.RunCMD(cmdData);
                                        else ASContext.Context.RunCMD("");
                                        e.Handled = true;
                                        break;

                                    // build the SWF using MTASC
                                    case "ASCompletion.QuickBuild":
                                        ASContext.Context.BuildCMD(false);
                                        e.Handled = true;
                                        break;

                                    // resolve element under cursor and open declaration
                                    case "ASCompletion.GotoDeclaration":
                                        ASComplete.DeclarationLookup(sci);
                                        e.Handled = true;
                                        break;

                                    // resolve element under cursor and send a CustomData event
                                    case "ASCompletion.ResolveElement":
                                        ASComplete.ResolveElement(sci, cmdData);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.MakeIntrinsic":
                                        ASContext.Context.MakeIntrinsic(cmdData);
                                        e.Handled = true;
                                        break;

                                    // alternative to default shortcuts
                                    case "ASCompletion.CtrlSpace":
                                        ASComplete.OnShortcut(Keys.Control | Keys.Space, ASContext.CurSciControl);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.CtrlShiftSpace":
                                        ASComplete.OnShortcut(Keys.Control | Keys.Shift | Keys.Space, ASContext.CurSciControl);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.CtrlAltSpace":
                                        ASComplete.OnShortcut(Keys.Control | Keys.Alt | Keys.Space, ASContext.CurSciControl);
                                        e.Handled = true;
                                        break;

                                    case "ASCompletion.ContextualGenerator":
                                        if (ASContext.HasContext && ASContext.Context.IsFileValid)
                                        {
                                            var options = new List<ICompletionListItem>();
                                            ASGenerator.ContextualGenerator(ASContext.CurSciControl, options);
                                            EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "ASCompletion.ContextualGenerator.AddOptions", options));
                                            if (options.Count == 0)
                                            {
                                                PluginBase.MainForm.StatusLabel.Text = TextHelper.GetString("Info.NoContextGeneratorCode");
                                            }
                                            CompletionList.Show(options, false);
                                        }
                                        break;
                                }
                            }
                            return;

                        case EventType.ProcessEnd:
                            string procResult = (e as TextEvent).Value;
                            ASContext.Context.OnProcessEnd(procResult);
                            break;
                    }
                }
            }
            catch(Exception ex)
            {
                ErrorManager.ShowError(ex);
            }
        }
Beispiel #19
0
 public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
 {
     switch (e.Type)
     {
         default:
             break;
     };
 }
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
                case EventType.UIStarted:
                    ProjectWatcher.Init();
                    this.ready = true;
                    break;

                // Catches Project change event and display the active project path
                case EventType.Command:
                    if (!this.ready) return;
                    DataEvent de = e as DataEvent;
                    String cmd = de.Action;
                    if (!cmd.StartsWith("ProjectManager.")) return;
                    switch (cmd)
                    {
                        case ProjectManagerEvents.Project:
                            ProjectWatcher.SetProject(de.Data as Project);
                            break;

                        case ProjectManagerEvents.TreeSelectionChanged:
                            ProjectWatcher.SelectionChanged();
                            break;

                        case ProjectManagerEvents.UserRefreshTree:
                            ProjectWatcher.ForceRefresh();
                            break;

                        case ProjectFileActionsEvents.FileBeforeRename:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleFileBeforeRename(de.Data as String);
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectFileActionsEvents.FileRename:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleFileRename(de.Data as String[]);
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectFileActionsEvents.FileDeleteSilent:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], false);
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectFileActionsEvents.FileDelete:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleFileDelete(de.Data as String[], true);
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectFileActionsEvents.FileMove:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleFileMove(de.Data as String[]);
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectManagerEvents.BuildProject:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleBuildProject();
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectManagerEvents.TestProject:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleTestProject();
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;

                        case ProjectManagerEvents.BeforeSave:
                            try
                            {
                                de.Handled = ProjectWatcher.HandleSaveProject((string)de.Data);
                            }
                            catch (Exception ex)
                            {
                                ErrorManager.ShowError(ex);
                                de.Handled = true;
                            }
                            break;
                    }
                    break;
                case EventType.FileOpen:
                    try
                    {
                        e.Handled = ProjectWatcher.HandleFileOpen((e as TextEvent).Value);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        e.Handled = true;
                    }
                    break;
                case EventType.FileReload:
                    try
                    {
                        e.Handled = ProjectWatcher.HandleFileReload((e as TextEvent).Value);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        e.Handled = true;
                    }
                    break;
                case EventType.FileModifyRO:
                    try
                    {
                        e.Handled = ProjectWatcher.HandleFileModifyRO((e as TextEvent).Value);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        e.Handled = true;
                    }
                    break;
                case EventType.FileNew:
                case EventType.FileTemplate:
                    try
                    {
                        e.Handled = ProjectWatcher.HandleFileNew((e as TextEvent).Value);
                    }
                    catch (Exception ex)
                    {
                        ErrorManager.ShowError(ex);
                        e.Handled = true;
                    }
                    break;
            }
        }
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority) {
            string fileName = PluginBase.MainForm.CurrentDocument.FileName;

            switch (e.Type) {
                case EventType.FileSwitch:
                    handleActivity(fileName, false);
                    break;

                case EventType.FileSave:
                    handleActivity(fileName, true);
                    break;

            }
        }
Beispiel #22
0
		/// <summary>
		/// Handles the incoming events
		/// </summary>
		public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
		{
            switch (e.Type)
            {
                case EventType.FileSwitch:
                    this.GenerateSurroundMenuItems();
                    UpdateMenuItems();
                    break;

                case EventType.UIStarted:
                    // Expose plugin's refactor main menu & context menu...
                    EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "CodeRefactor.Menu", this.refactorMainMenu));
                    EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "CodeRefactor.ContextMenu", this.refactorContextMenu));
                    // Watch resolved context for menu item updating...
                    ASComplete.OnResolvedContextChanged += OnResolvedContextChanged;
                    this.UpdateMenuItems();
                    break;

                case EventType.Command:
                    DataEvent de = (DataEvent)e;
                    string[] args;
                    string oldPath;
                    string newPath;
                    switch (de.Action)
                    {
                        case ProjectFileActionsEvents.FileRename:
                            args = de.Data as string[];
                            oldPath = args[0];
                            newPath = args[1];
                            if (Directory.Exists(oldPath) && IsValidForMove(oldPath, newPath))
                            {
                                MovingHelper.AddToQueue(new Dictionary<string, string> { { oldPath, newPath } }, true, true);
                                e.Handled = true;
                            }
                            else if (IsValidForRename(oldPath, newPath))
                            {
                                RenameFile(oldPath, newPath);
                                e.Handled = true;
                            }
                            break;

                        case ProjectFileActionsEvents.FileMove:
                            args = de.Data as string[];
                            oldPath = args[0];
                            newPath = args[1];
                            if (IsValidForMove(oldPath, newPath))
                            {
                                MovingHelper.AddToQueue(new Dictionary<string, string> { { oldPath, newPath } });
                                e.Handled = true;
                            }
                            break;
                    }
                    break;
            }
		}
Beispiel #23
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
 }
Beispiel #24
0
        /// <summary>
        /// Handles the incoming events
        /// </summary>
        public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
        {
            switch (e.Type)
            {
                case EventType.FileSwitch:
                    this.GenerateSurroundMenuItems();
                    break;

                case EventType.UIStarted:
                    // Expose plugin's refactor main menu & context menu...
                    EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "CodeRefactor.Menu", this.refactorMainMenu));
                    EventManager.DispatchEvent(this, new DataEvent(EventType.Command, "CodeRefactor.ContextMenu", this.refactorContextMenu));
                    // Watch resolved context for menu item updating...
                    ASComplete.OnResolvedContextChanged += new ResolvedContextChangeHandler(this.OnResolvedContextChanged);
                    this.UpdateMenuItems();
                    break;

                case EventType.Command:
                    DataEvent de = (DataEvent)e;
                    switch (de.Action)
                    {
                        case ProjectFileActionsEvents.FileRename:
                            string[] args = de.Data as String[];
                            string oldPath = args[0];
                            string newPath = args[1];
                            if (IsValidForRename(args[0], args[1]))
                            {
                                RenameFile(args[0], args[1]);
                                e.Handled = true;
                            }
                            break;
                    }
                    break;
            }
        }
Beispiel #25
0
        public void HandleEvent(object sender, NotifyEvent e, HandlingPriority priority)
        {
            switch (e.Type)
            {
                case EventType.FileSwitch:
                    if (PluginBase.MainForm.CurrentDocument.IsEditable)
                    {
                        PluginBase.MainForm.CurrentDocument.SciControl.DoubleClick -= new ScintillaNet.DoubleClickHandler(SciControl_DoubleClick);
                        PluginBase.MainForm.CurrentDocument.SciControl.Modified -= new ScintillaNet.ModifiedHandler(SciControl_Modified);
                        PluginBase.MainForm.CurrentDocument.SciControl.UpdateUI -= new ScintillaNet.UpdateUIHandler(SciControl_UpdateUI);
                        PluginBase.MainForm.CurrentDocument.SciControl.DoubleClick += new ScintillaNet.DoubleClickHandler(SciControl_DoubleClick);
                        PluginBase.MainForm.CurrentDocument.SciControl.Modified += new ScintillaNet.ModifiedHandler(SciControl_Modified);
                        PluginBase.MainForm.CurrentDocument.SciControl.UpdateUI += new ScintillaNet.UpdateUIHandler(SciControl_UpdateUI);

                    }
                    break;
                case EventType.FileModify:
                    cb.Visible = false;
                    isActive = false;
                    break;
                default:
                    break;
            };
        }
Beispiel #26
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority priority)
 {
     ITabbedDocument document = PluginBase.MainForm.CurrentDocument;
     if (document == null || !document.IsEditable) return;
     switch (e.Type)
     {
         case EventType.Keys:
         {
             Keys keys = (e as KeyEvent).Value;
             if (this.IsSupported(document) && keys == (Keys.Control | Keys.Space))
             {
                 if (completion != null)
                 {
                     completion.OnComplete(document.SciControl, document.SciControl.CurrentPos);
                     e.Handled = true;
                 }
             }
             break;
         }
         case EventType.FileSwitch:
         case EventType.SyntaxChange:
         case EventType.ApplySettings:
         {
             if (document.IsEditable && this.IsSupported(document))
             {
                 string ext = Path.GetExtension(document.FileName).ToLower();
                 features = enabledLanguages.ContainsKey(ext) ? enabledLanguages[ext] : null;
                 if (completion == null) completion = new Completion(config, settingObject);
                 completion.OnFileChanged(features);
                 if (features != null && features.Syntax != null)
                 {
                     ScintillaControl sci = document.SciControl;
                     sci.SetProperty(features.Syntax, features != null ? "1" : "0");
                     sci.Colourise(0, -1);
                 }
             }
             break;
         }
         case EventType.Completion:
         {
             if (features != null) e.Handled = true;
             return;
         }
         case EventType.FileSave:
         {
             if (document != null && document.IsEditable && this.IsSupported(document))
             {
                 updateFile = document.FileName;
                 updateFeatures = features;
                 updater.Start();
             }
             break;
         }
     }
 }
Beispiel #27
0
 public void HandleEvent(object sender, PluginCore.NotifyEvent e, PluginCore.HandlingPriority priority)
 {
 }
Beispiel #28
0
		// Receives only events in EventMask
		public void HandleEvent(object sender, NotifyEvent e)
		{
			TextEvent te = e as TextEvent;

			switch (e.Type)
			{
				// replace @MACRO type stuff with things we know about
				case EventType.ProcessArgs:
					if (Project != null)
					{
						// steal macro names and values from the very useful
						// BuildEvent macros, except instead of $(Var) we expect @VAR
						string[] globalCP = Settings.GlobalClasspaths.Split(';');
						BuildEventVars vars = new BuildEventVars(Project,globalCP);

						foreach (BuildEventInfo info in vars.GetVars())
							te.Text = te.Text.Replace("@"+info.Name.ToUpper(),info.Value);
					}
					break;
				case EventType.FileOpening:
					// if this is an .fdp file, we can handle it ourselves
					if (Path.GetExtension(te.Text).ToLower() == ".fdp")
					{
						te.Handled = true;
						OpenProjectSilent(te.Text);
						menus.RecentComboBox.Add(Project);
					}
					break;
				case EventType.FileOpen:
					
					if (fileActions.DocumentSeekRequest > 0)
					{
						// we just created a new class, put the cursor between the brackets.
						MainForm.CurSciControl.GotoPos(fileActions.DocumentSeekRequest);
						fileActions.DocumentSeekRequest = 0;
					}
					// add some support for additional known xml files (like asml)
					if (MainForm.CurSciControl.ConfigurationLanguage == "text" &&
					    FileHelper.IsXml(MainForm.CurFile))
						MainForm.CallCommand("ChangeSyntax","xml");

					OpenNextFile(); // it's safe to open any other files on the queue
					break;
				case EventType.ProcessStart:
					buildActions.NotifyBuildStarted();
					break;
				case EventType.ProcessEnd:
					string result = (e as TextEvent).Text;
					buildActions.NotifyBuildEnded(result);
					break;
				case EventType.Command:
					if (te.Text == COMMAND_SENDPROJECTINFO)
					{
						BroadcastProjectInfo();
						e.Handled = true;
					}
					else if (te.Text == COMMAND_BUILDPROJECT)
					{
						if (Project != null)
						{
							buildActions.Build(Project,false,pluginUI.IsTraceDisabled);
							e.Handled = true;
						}
					}
					else if (te.Text == COMMAND_HOTBUILD)
					{
						if (Project != null && Project.OutputPath.Length > 0)
						{
							buildActions.Build(Project,true,pluginUI.IsTraceDisabled);
							e.Handled = true;
						}
					}
					break;
				case EventType.SettingUpdate:
					if (Project == null)
						return;

					if (showProjectClasspaths != Settings.ShowProjectClasspaths ||
						showGlobalClasspaths != Settings.ShowGlobalClasspaths)
					{
						showProjectClasspaths = Settings.ShowProjectClasspaths;
						showGlobalClasspaths = Settings.ShowGlobalClasspaths;
						pluginUI.Tree.RebuildTree(true);
					}
					break;
					
				// PHILIPPE: handle copy/paste shortcuts
				case EventType.Shortcut:
					KeyEvent ke = e as KeyEvent;
					if (pluginUI.Tree.Focused && !pluginUI.IsEditingLabel && ke != null)
					{
						switch (ke.Value)
						{
							case Keys.Control|Keys.C:
								if (pluginUI.Menu.Copy.IsEnabled) TreeCopyItems(null, null);
								ke.Handled = true;
								break;
							case Keys.Control|Keys.X:
								if (pluginUI.Menu.Cut.IsEnabled) TreeCutItems(null, null);
								ke.Handled = true;
								break;
							case Keys.Control|Keys.V:
								if (pluginUI.Menu.Paste.IsEnabled) TreePasteItems(null, null);
								ke.Handled = true;
								break;
							case Keys.Delete:
								if (pluginUI.Menu.Delete.IsEnabled) TreeDeleteItems(null,null);
								ke.Handled = true;
								break;
							case Keys.Enter:
								
								break;
						}
					}
					break;
			}
		}
Beispiel #29
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     switch (e.Type)
     {
         case EventType.Command :
             this.HandleCommand(((DataEvent)e));
             break;
     }
 }
Beispiel #30
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     switch (e.Type)
     {
         case EventType.UIStarted :
             contextInstance = new Context(settingObject);
             // Associate this context with a file type
             ASCompletion.Context.ASContext.RegisterLanguage(contextInstance, associatedSyntax);
             break;
     }
 }
Beispiel #31
0
		/// <summary>
		/// Handles the incoming events
		/// </summary>
		public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
		{
            if (e.Type == EventType.UIStarted)
            {
                try
                {
                    foreach (Macro macro in this.settingObject.UserMacros)
                    {
                        if (macro.AutoRun)
                        {
                            foreach (String entry in macro.Entries)
                            {
                                String[] parts = entry.Split(new Char[1] { '|' });
                                PluginBase.MainForm.CallCommand(parts[0], parts[1]);
                            }
                        }
                    }
                }
                catch (Exception ex) 
                {
                    ErrorManager.AddToLog("Macro AutoRun Failed.", ex);
                }
            }
            if (e.Type == EventType.ApplySettings)
            {
                this.UpdateMenuShortcut();
            }
		}
Beispiel #32
0
		/// <summary>
		/// Handles the incoming events
		/// </summary>
		public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
		{
            switch (e.Type)
            {
                case EventType.Keys:
                    Keys key = (e as KeyEvent).Value;
                    if (key == this.settingObject.IncreaseShortcut) DuplicateIncrease();
                    else if (key == this.settingObject.SwitchShortcut) DuplicateSwitch();
                    else if (key == this.settingObject.WordShortcut) WordSwitch();
                    break;
            }
		}
Beispiel #33
0
 /// <summary>
 /// Handles the incoming events
 /// </summary>
 public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
 {
     if (e.Type == EventType.UIStarted)
     {
         String initScript = Path.Combine(PathHelper.BaseDir, "InitScript.cs");
         if (File.Exists(initScript))
         {
             String command = "Internal;" + initScript;
             PluginBase.MainForm.CallCommand("ExecuteScript", command);
         }
         this.RunAutoRunMacros();
     }
 }