ide; support for multiple selection when compiling and cleaning single file and folders.
authorRejean Loyer <rejean.loyer@gmail.com>
Wed, 21 Nov 2012 06:03:47 +0000 (01:03 -0500)
committerRejean Loyer <rejean.loyer@gmail.com>
Thu, 22 Nov 2012 16:34:00 +0000 (11:34 -0500)
ide/src/ide.ec
ide/src/project/Project.ec
ide/src/project/ProjectNode.ec
ide/src/project/ProjectView.ec

index c039753..fc00bff 100644 (file)
@@ -2435,8 +2435,14 @@ class IDEWorkSpace : Window
                            for(p : ide.workspace.projects)
                            {
                               node = projectView.GetNodeFromWindow(activeClient, p);
-                              if(node && projectView.Compile(node, mods.ctrl && mods.shift))
+                              //if(node && projectView.Compile(node.project, node, mods.ctrl && mods.shift))
+                              if(node)
                               {
+                                 List<ProjectNode> nodes { };
+                                 nodes.Add(node);
+                                 projectView.Compile(node.project, nodes, mods.ctrl && mods.shift);
+                                 delete nodes;
+
                                  result = true;
                                  break;
                               }
index fd4d5fb..e224877 100755 (executable)
@@ -1349,7 +1349,7 @@ private:
       }
    }
 
-   bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, ProjectNode onlyNode,
+   bool ProcessBuildPipeOutput(DualPipe f, DirExpression objDirExp, bool isARun, List<ProjectNode> onlyNodes,
       CompilerConfig compiler, ProjectConfig config)
    {
       char line[65536];
@@ -1631,7 +1631,7 @@ private:
          }
          else
          {
-            if(!onlyNode)
+            if(!onlyNodes)
                ide.outputView.buildBox.Logf("\n%s (%s) - ", GetTargetFileName(config), configName);
             if(numErrors)
                ide.outputView.buildBox.Logf("%d %s, ", numErrors, (numErrors > 1) ? $"errors" : $"error");
@@ -1695,7 +1695,7 @@ private:
       }
    }
 
-   bool Build(bool isARun, ProjectNode onlyNode, CompilerConfig compiler, ProjectConfig config, bool justPrint)
+   bool Build(bool isARun, List<ProjectNode> onlyNodes, CompilerConfig compiler, ProjectConfig config, bool justPrint)
    {
       bool result = false;
       DualPipe f;
@@ -1710,7 +1710,7 @@ private:
       char * targetPlatform = crossCompiling ? (char *)compiler.targetPlatform : "";
 
       int numJobs = compiler.numJobs;
-      char command[MAX_LOCATION];
+      char command[MAX_F_STRING];
       char * compilerName;
 
       compilerName = CopyString(compiler.name);
@@ -1726,7 +1726,7 @@ private:
       PathCatSlash(makeFilePath, makeFile);
 
       // TODO: TEST ON UNIX IF \" around makeTarget is ok
-      if(onlyNode)
+      if(onlyNodes)
       {
          if(compiler.type.isVC)
          {
@@ -1754,7 +1754,16 @@ private:
 
             ChangeWorkingDir(pushD);
 
-            onlyNode.GetTargets(config, objDirExp.dir, makeTargets);
+            for(node : onlyNodes)
+            {
+               if(node.GetIsExcluded(config))
+                  ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
+               else
+               {
+                  node.DeleteIntermediateFiles(compiler, config);
+                  node.GetTargets(config, objDirExp.dir, makeTargets);
+               }
+            }
          }
       }
 
@@ -1798,7 +1807,7 @@ private:
                result = true;
             }
             else
-               result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNode, compiler, config);
+               result = ProcessBuildPipeOutput(f, objDirExp, isARun, onlyNodes, compiler, config);
             delete f;
          }
          else
@@ -1929,9 +1938,9 @@ private:
       delete target;
    }
 
-   void Compile(ProjectNode node, CompilerConfig compiler, ProjectConfig config, bool justPrint)
+   void Compile(List<ProjectNode> nodes, CompilerConfig compiler, ProjectConfig config, bool justPrint)
    {
-      Build(false, node, compiler, config, justPrint);
+      Build(false, nodes, compiler, config, justPrint);
    }
 #endif
 
index bf19897..19ab265 100755 (executable)
@@ -2258,6 +2258,7 @@ private:
    {
       if(type == file)
       {
+         //output.concat(" $(OBJ)");
          output.concat(" \"");
          output.concat(objDir);
          output.concat("/");
index 132bec1..b2b57f1 100644 (file)
@@ -990,13 +990,12 @@ class ProjectView : Window
       return true;
    }
 
-   bool Compile(ProjectNode node, bool justPrint)
+   bool Compile(Project project, List<ProjectNode> nodes, bool justPrint)
    {
       bool result = true;
       char fileName[MAX_LOCATION];
       Window document;
-      Project prj = node.project;
-      ProjectConfig config = prj.config;
+      ProjectConfig config = project.config;
 
       stopBuild = false;
 
@@ -1004,11 +1003,15 @@ class ProjectView : Window
       {
          if(document.modifiedDocument)
          {
-            ProjectNode n = GetNodeFromWindow(document, prj);
-            if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
+            ProjectNode n = GetNodeFromWindow(document, project);
+            for(node : nodes)
             {
-               result = false;
-               break;
+               if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
+               {
+                  ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
+                  result = false;
+                  break;
+               }
             }
          }
       }
@@ -1017,44 +1020,34 @@ class ProjectView : Window
       {
          CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
          result = false;
-         if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
+         if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
          {
-            if(!node.GetIsExcluded(config))
-            {
-               node.DeleteIntermediateFiles(compiler, config);
-
-               buildInProgress = compilingFile;
-               ide.AdjustBuildMenus();
-
-               //ide.outputView.ShowClearSelectTab(build);
-               // this stuff doesn't even appear
-               //ide.outputView.buildBox.Logf($"%s Compiler\n", compiler.name);
-               if(config)
-                  ide.outputView.buildBox.Logf($"Compiling %s %s in project %s using the %s configuration...\n",
-                        node.type == file ? $"single file" : $"folder", node.name, prj.name, config.name);
-               else
-                  ide.outputView.buildBox.Logf($"Compiling %s %s in project %s...\n",
-                        node.type == file ? $"single file" : $"folder", node.name, prj.name);
+            if(config)
+               ide.outputView.buildBox.Logf($"Compiling specific file(s) in project %s using the %s configuration...\n",
+                     project.name, config.name);
+            else
+               ide.outputView.buildBox.Logf($"Compiling specific file(s) in project %s...\n",
+                     project.name);
 
-               prj.Compile(node, compiler, config, justPrint);
-               buildInProgress = none;
-               ide.AdjustBuildMenus();
+            buildInProgress = compilingFile;
+            ide.AdjustBuildMenus();
+            project.Compile(nodes, compiler, config, justPrint);
+            buildInProgress = none;
+            ide.AdjustBuildMenus();
 
-               result = true;
-            }
+            result = true;
          }
          delete compiler;
       }
       return result;
    }
 
-   bool Clean(ProjectNode node, bool justPrint)
+   bool Clean(Project project, List<ProjectNode> nodes, bool justPrint)
    {
       bool result = true;
       char fileName[MAX_LOCATION];
       Window document;
-      Project prj = node.project;
-      ProjectConfig config = prj.config;
+      ProjectConfig config = project.config;
 
       stopBuild = false;
 
@@ -1062,11 +1055,15 @@ class ProjectView : Window
       {
          if(document.modifiedDocument)
          {
-            ProjectNode n = GetNodeFromWindow(document, prj);
-            if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
+            ProjectNode n = GetNodeFromWindow(document, project);
+            for(node : nodes)
             {
-               result = false;
-               break;
+               if(n && n.IsInNode(node) && !document.MenuFileSave(null, 0))
+               {
+                  ide.outputView.buildBox.Logf($"Unable to save %s file.\n", node.name);
+                  result = false;
+                  break;
+               }
             }
          }
       }
@@ -1075,20 +1072,24 @@ class ProjectView : Window
       {
          CompilerConfig compiler = ideSettings.GetCompilerConfig(ide.workspace.compiler);
          result = false;
-         if(ProjectPrepareForToolchain(prj, normal, true, true, compiler, config))
+         if(ProjectPrepareForToolchain(project, normal, true, true, compiler, config))
          {
-            if(!node.GetIsExcluded(config))
+            for(node : nodes)
             {
-               node.DeleteIntermediateFiles(compiler, config);
-
-               if(config)
-                  ide.outputView.buildBox.Logf($"Delete Intermediate Objects for %s %s in project %s using the %s configuration...\n",
-                        node.type == file ? $"single file" : $"folder", node.name, prj.name, config.name);
+               if(node.GetIsExcluded(config))
+                  ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
                else
-                  ide.outputView.buildBox.Logf($"Delete Intermediate Objects for %s %s in project %s...\n",
-                        node.type == file ? $"single file" : $"folder", node.name, prj.name);
+               {
+                  if(config)
+                     ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s using the %s configuration...\n",
+                           node.type == file ? $"single file" : $"folder", node.name, project.name, config.name);
+                  else
+                     ide.outputView.buildBox.Logf($"Deleteing intermediate objects for %s %s in project %s...\n",
+                           node.type == file ? $"single file" : $"folder", node.name, project.name);
 
-               result = true;
+                  node.DeleteIntermediateFiles(compiler, config);
+                  result = true;
+               }
             }
          }
          delete compiler;
@@ -1267,25 +1268,61 @@ class ProjectView : Window
 
    bool FileCompile(MenuItem selection, Modifiers mods)
    {
-      DataRow row = fileList.currentRow;
-      if(row)
+      OldLink item;
+      OldList selectedRows;
+      Project project = null;
+      List<ProjectNode> nodes { };
+      fileList.GetMultiSelection(selectedRows);
+      for(item = selectedRows.first; item; item = item.next)
       {
+         OldLink i;
+         DataRow row = item.data;
          ProjectNode node = (ProjectNode)row.tag;
-         if(!Compile(node, mods.ctrl && mods.shift))
-            ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
+         if(!project)
+            project = node.project;
+         else if(node.project != project)
+         {
+            project = null;
+            break;
+         }
+         nodes.Add(node);
       }
+      selectedRows.Free(null);
+      if(project)
+         Compile(project, nodes, mods.ctrl && mods.shift);
+      else
+         ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
+      delete nodes;
       return true;
    }
 
    bool FileClean(MenuItem selection, Modifiers mods)
    {
-      DataRow row = fileList.currentRow;
-      if(row)
+      OldLink item;
+      OldList selectedRows;
+      Project project = null;
+      List<ProjectNode> nodes { };
+      fileList.GetMultiSelection(selectedRows);
+      for(item = selectedRows.first; item; item = item.next)
       {
+         OldLink i;
+         DataRow row = item.data;
          ProjectNode node = (ProjectNode)row.tag;
-         if(!Clean(node, mods.ctrl && mods.shift))
-            ide.outputView.buildBox.Logf($"File %s is excluded from current build configuration.\n", node.name);
+         if(!project)
+            project = node.project;
+         else if(node.project != project)
+         {
+            project = null;
+            break;
+         }
+         nodes.Add(node);
       }
+      selectedRows.Free(null);
+      if(project)
+         Clean(project, nodes, mods.ctrl && mods.shift);
+      else
+         ide.outputView.buildBox.Logf($"Please select files from a single project.\n");
+      delete nodes;
       return true;
    }