diff --git a/ColtPlugin/PluginMain.cs b/ColtPlugin/PluginMain.cs
index 3b95b8a..5b0932e 100644
--- a/ColtPlugin/PluginMain.cs
+++ b/ColtPlugin/PluginMain.cs
@@ -31,7 +31,6 @@ public class PluginMain : IPlugin
private Settings settingObject;
private ToolStripMenuItem menuItem;
private ToolStripButton toolbarButton;
- private Boolean active = false;
private FileSystemWatcher watcher;
private String pathToLog;
private System.Timers.Timer timer;
@@ -134,21 +133,8 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
Boolean as3projectIsOpen = (project != null) && (project.Language == "as3");
if (menuItem != null) menuItem.Enabled = as3projectIsOpen;
if (toolbarButton != null) toolbarButton.Enabled = as3projectIsOpen;
- // deactivate
- active = false;
- if (watcher != null) watcher.EnableRaisingEvents = false;
- if (timer != null) { timer.Stop(); timer = null; }
- }
- else if (cmd == "ASCompletion.ClassPath")
- {
- // apparently project setting changes; reopen already opened COLT project
- if (active && (settingObject.AlwaysOverwriteProjects || (MessageBox.Show(
- LocaleHelper.GetString("SettingsChanged.DialogText"),
- LocaleHelper.GetString("SettingsChanged.DialogTitle"),
- MessageBoxButtons.YesNo) == DialogResult.Yes)))
- {
- OpenInCOLT();
- }
+ // modified or new project - reconnect in any case
+ ConnectToCOLT();
}
else if (cmd == "ProjectManager.Menu")
{
@@ -163,7 +149,7 @@ public void HandleEvent(Object sender, NotifyEvent e, HandlingPriority prority)
break;
case EventType.FileSave:
- if (active) ClearErrors();
+ if (watcher.EnableRaisingEvents) ClearErrors();
break;
case EventType.Keys: // shortcut pressed
@@ -244,6 +230,7 @@ public void AddEventHandlers()
private void CreateMenuItem(ToolStripMenuItem projectMenu)
{
menuItem = new ToolStripMenuItem(buttonText, GetImage("colt.png"), new EventHandler(OnClick), null);
+ menuItem.Enabled = false;
projectMenu.DropDownItems.Add(menuItem);
}
@@ -269,7 +256,6 @@ private static Image GetImage(String imageName)
private void OnClick(Object sender, System.EventArgs e)
{
- active = true;
OpenInCOLT();
}
@@ -332,35 +318,43 @@ private void OnTimerElapsed(object sender, EventArgs e)
String incremental = "colt\\incremental";
String[] sources = PluginBase.CurrentProject.SourcePaths;
- // [09.05.2013 17:26:54] Philippe Elsass: make sure you send the log line by line to the Output
+ // send the log line by line
String[] messageLines = message.Split(new Char[] {'\r', '\n'});
bool hasErrors = false;
foreach (String line in messageLines) if (line.Length > 0)
{
- // [08.05.2013 18:04:15] Philippe Elsass: you can also specify '-3' as 2nd parameter to the traces (error level)
- // [08.05.2013 18:05:02] Philippe Elsass: so it will appear in red in the output and have an error icon in the results panel
+ int errorLevel = -3;
if (line.Contains(incremental))
{
- // carefully take the file name out
- String file = line.Substring(0, line.IndexOf("): col"));
- file = file.Substring(0, file.LastIndexOf("("));
- file = file.Substring(file.IndexOf(incremental) + incremental.Length + 1);
-
- // look for it in all source folders
- for (int i = 0; i < sources.Length; i++)
+ try
{
- if (File.Exists(PluginBase.CurrentProject.GetAbsolutePath(Path.Combine(sources[i], file))))
+ // carefully take the file name out
+ String file = line.Substring(0, line.IndexOf("): col"));
+ file = file.Substring(0, file.LastIndexOf("("));
+ file = file.Substring(file.IndexOf(incremental) + incremental.Length + 1);
+
+ // look for it in all source folders
+ for (int i = 0; i < sources.Length; i++)
{
- TraceManager.Add(line.Replace(incremental, sources[i]), -3);
- hasErrors = true;
- break;
+ if (File.Exists(PluginBase.CurrentProject.GetAbsolutePath(Path.Combine(sources[i], file))))
+ {
+ TraceManager.Add(line.Replace(incremental, sources[i]), errorLevel);
+ hasErrors = true;
+ break;
+ }
}
}
+
+ catch (Exception)
+ {
+ // unexpected format, send as is
+ TraceManager.Add(line, errorLevel);
+ }
}
else
{
// send as is
- TraceManager.Add(line, -3);
+ TraceManager.Add(line, errorLevel);
}
}
@@ -434,6 +428,33 @@ private string LineIndentPosition(ScintillaNet.ScintillaControl sci, int line)
return "";
}
+ ///
+ /// Connects to COLT
+ ///
+ private void ConnectToCOLT(Boolean create = false)
+ {
+ // todo: clean up after previous connection
+
+ // for now, shut down errors log watcher and its timer
+ watcher.EnableRaisingEvents = false;
+ if (timer != null) { timer.Stop(); timer = null; }
+
+ // todo: if current project is opened in COLT - connect to it
+
+ // for now, create the folder and subscribe to errors log updates
+ IProject project = PluginBase.CurrentProject;
+
+ String coltFolderPath = project.GetAbsolutePath(settingObject.WorkingFolder);
+ if (create && !Directory.Exists(coltFolderPath)) Directory.CreateDirectory(coltFolderPath);
+
+ if (Directory.Exists(coltFolderPath))
+ {
+ pathToLog = Path.Combine(coltFolderPath, "compile_errors.log");
+ watcher.Path = coltFolderPath;
+ watcher.EnableRaisingEvents = true;
+ }
+ }
+
///
/// Opens the project in COLT
///
@@ -468,15 +489,11 @@ private void OpenInCOLT()
// Create COLT subfolder if does not exist yet
- String coltFolderPath = project.GetAbsolutePath(settingObject.WorkingFolder);
- if (!Directory.Exists(coltFolderPath)) Directory.CreateDirectory(coltFolderPath);
-
// While at that, start listening for colt/compile_errors.log changes
- pathToLog = Path.Combine(coltFolderPath, "compile_errors.log");
- watcher.Path = coltFolderPath;
- watcher.EnableRaisingEvents = true;
+ ConnectToCOLT(true);
+
- // Create COLT project with random name (if we'd update same file - are there file locks? how to reopen in colt?)
+ // Create COLT project with random name (todo: separate buttons for project export and project open)
String coltFileName = project.GetAbsolutePath(Path.Combine(settingObject.WorkingFolder, System.Guid.NewGuid() + ".colt"));
StreamWriter stream = File.CreateText(coltFileName);
@@ -551,7 +568,7 @@ private void OpenInCOLT()
}
// Remove older *.colt files
- foreach (String oldFile in Directory.GetFiles(coltFolderPath, "*.colt"))
+ foreach (String oldFile in Directory.GetFiles(project.GetAbsolutePath(settingObject.WorkingFolder), "*.colt"))
{
if (!coltFileName.Contains(Path.GetFileName(oldFile)))
{
diff --git a/ColtPlugin/Resources/en_US.resX b/ColtPlugin/Resources/en_US.resX
index 9429a28..92f45f0 100644
--- a/ColtPlugin/Resources/en_US.resX
+++ b/ColtPlugin/Resources/en_US.resX
@@ -123,10 +123,4 @@
COLT Plugin for FlashDevelop.
-
- Do you want to overwrite COLT project to reflect new settings?
-
-
- Project settings have changed
-
\ No newline at end of file
diff --git a/ColtPlugin/Settings.cs b/ColtPlugin/Settings.cs
index bce77e0..47090cd 100644
--- a/ColtPlugin/Settings.cs
+++ b/ColtPlugin/Settings.cs
@@ -11,7 +11,6 @@ public class Settings
{
private String workingFolder = "colt";
private Boolean fullConfig = false;
- private Boolean alwaysOverwriteProjects = false;
///
/// Get and sets colt folder
@@ -35,17 +34,6 @@ public Boolean FullConfig
set { this.fullConfig = value; }
}
- ///
- /// Get and sets full config flag
- ///
- [DisplayName("Always overwrite COLT projects")]
- [Description("Select this option to always overwrite COLT projects when FD project settings change."), DefaultValue(false)]
- public Boolean AlwaysOverwriteProjects
- {
- get { return this.alwaysOverwriteProjects; }
- set { this.alwaysOverwriteProjects = value; }
- }
-
}
}
diff --git a/ColtPlugin/obj/Debug/ColtPlugin.dll b/ColtPlugin/obj/Debug/ColtPlugin.dll
index 9cfa7fa..401a6b2 100644
Binary files a/ColtPlugin/obj/Debug/ColtPlugin.dll and b/ColtPlugin/obj/Debug/ColtPlugin.dll differ