ide: add import folder projects feature.
authorRejean Loyer <redj@ecere.com>
Sat, 3 Jan 2015 01:05:04 +0000 (20:05 -0500)
committerRejean Loyer <redj@ecere.com>
Mon, 16 Mar 2015 05:31:54 +0000 (01:31 -0400)
ide/src/ide.ec

index 673a1c5..d5ad5ab 100755 (executable)
@@ -44,6 +44,19 @@ import "about"
 
 import "FileSystemIterator"
 
+class ImportFolderProjectsFSI : NormalFileSystemIterator
+{
+   bool noParsing;
+   char selfProjectPath[MAX_LOCATION];
+   extensions = ProjectExtension;
+   bool OnFile(const char * filePath)
+   {
+      if(fstrcmp(filePath, selfProjectPath))
+         ide.OpenFile(filePath, false, true, ProjectExtension, no, add, noParsing);
+      return true;
+   }
+}
+
 AVLTree<const String> binaryDocExt
 { [
    "wav", "mp3", "flac", "ogg",
@@ -135,6 +148,7 @@ static Array<FileFilter> findInFilesFileFilters
    { $"All files", null }
 ] };
 
+FileDialog importFolderProjectsDialog { autoCreate = false, type = selectDir, text = $"Import Folder Projects" };
 FileDialog ideFileDialog
 {
    type = multiOpen, text = $"Open";
@@ -893,6 +907,32 @@ class IDEWorkSpace : Window
             return true;
          }
       };
+      MenuItem projectImportAddItem
+      {
+         projectMenu, $"Import projects into workspace...", a, Key { a, true, true };
+         disabled = true;
+         bool NotifySelect(MenuItem selection, Modifiers mods)
+         {
+            char path[MAX_LOCATION];
+            FileDialog fileDialog = importFolderProjectsDialog;
+            fileDialog.master = parent;
+            path[0] = '\0';
+            StripLastDirectory(path, ide.workspace.workspaceDir);
+            MakeSystemPath(path);
+            fileDialog.currentDirectory = path;
+            fileDialog.filePath = path;
+            if(fileDialog.Modal() == ok)
+            {
+               ImportFolderProjectsFSI fsi { noParsing = mods.ctrl && mods.shift };
+               ide.project.topNode.GetFullFilePath(fsi.selfProjectPath);
+               MakeSystemPath(fsi.selfProjectPath);
+               PrintLn("self: ", fsi.selfProjectPath);
+               fsi.Iterate(fileDialog.filePath);
+               delete fsi;
+            }
+            return true;
+         }
+      };
       MenuItem projectCloseItem
       {
          projectMenu, $"Close", c, disabled = true;
@@ -1983,6 +2023,7 @@ class IDEWorkSpace : Window
       bool unavailable = !project;
 
       projectAddItem.disabled             = unavailable;
+      projectImportAddItem.disabled       = unavailable;
       toolBar.buttonAddProject.disabled   = unavailable;
 
       projectSettingsItem.disabled        = unavailable;