ide: Correctly handling (once again) non existing files passed on command line, with...
authorRejean Loyer <rejean.loyer@gmail.com>
Wed, 7 Mar 2012 15:07:47 +0000 (10:07 -0500)
committerJerome St-Louis <jerome@ecere.com>
Wed, 7 Mar 2012 15:07:47 +0000 (10:07 -0500)
ide/src/dialogs/NewProjectDialog.ec
ide/src/ide.ec

index caa955e..dd5b531 100644 (file)
@@ -21,35 +21,7 @@ class NewProjectDialog : Window
       hotKey = altL, text = $"Location";
       typeExpected = directory, browseDialog = fileDialog;
 
-      //NotifyUpdate = EditBoxUpdate;
-
-      bool NotifyModified(PathBox pathBox)
-      {
-         char location[MAX_LOCATION];
-         char lastPart[MAX_FILENAME];
-         char * text = pathBox.slashPath;
-         
-         //replacing this: NotifyUpdate = EditBoxUpdate;
-         okBtn.disabled = !(text[0] && projectName.contents[0]);
-
-         GetWorkingDir(location, sizeof(location) - 1);
-         PathCatSlash(location, text);
-         
-         GetLastDirectory(path, lastPart);
-         /*if(text[0] && (!name[0] || !strcmp(lastPart, name)))
-         {
-            char newName[MAX_FILENAME];
-            GetLastDirectory(location, newName);
-            if(strcmp(newName, location))
-            {
-               strcpy(name, newName);
-               projectName.contents = name;
-            }
-         }*/
-         strcpy(path, location);
-         pathBox.path = path;
-         return true;
-      }
+      NotifyModified = NotifyModifiedLocation;
    };
    Label { this, position = { 10, 60 }, labeledWindow = locationEditBox };
 
@@ -286,6 +258,34 @@ class NewProjectDialog : Window
       okBtn.disabled = !(locationEditBox.path[0] && projectName.contents[0]);
    }
 
+   bool NotifyModifiedLocation(PathBox pathBox)
+   {
+      char location[MAX_LOCATION];
+      char lastPart[MAX_FILENAME];
+      char * text = pathBox.slashPath;
+
+      //replacing this: NotifyUpdate = EditBoxUpdate;
+      okBtn.disabled = !(text[0] && projectName.contents[0]);
+
+      GetWorkingDir(location, sizeof(location) - 1);
+      PathCatSlash(location, text);
+
+      GetLastDirectory(path, lastPart);
+      /*if(text[0] && (!name[0] || !strcmp(lastPart, name)))
+      {
+         char newName[MAX_FILENAME];
+         GetLastDirectory(location, newName);
+         if(strcmp(newName, location))
+         {
+            strcpy(name, newName);
+            projectName.contents = name;
+         }
+      }*/
+      strcpy(path, location);
+      pathBox.path = path;
+      return true;
+   }
+
    NewProjectDialog()
    {
       char location[MAX_LOCATION];
index e7f034a..f5b2487 100644 (file)
@@ -2367,10 +2367,65 @@ class IDEWorkSpace : Window
       for(c = 1; c<app.argc; c++)
       {
          char fullPath[MAX_LOCATION];
+         char parentPath[MAX_LOCATION];
+         char ext[MAX_EXTENSION];
+         bool isProject;
+         FileAttribs dirAttribs;
          GetWorkingDir(fullPath, MAX_LOCATION);
          PathCat(fullPath, app.argv[c]);
-         if(FileExists(fullPath))
-            ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
+         StripLastDirectory(fullPath, parentPath);
+         GetExtension(app.argv[c], ext);
+         isProject = !strcmpi(ext, "epj");
+
+         if(isProject && c > 1) continue;
+
+         // Create directory for projects (only)
+         if(((dirAttribs = FileExists(parentPath)) && dirAttribs.isDirectory) || isProject)
+         {
+            if(isProject && !FileExists(fullPath))
+            {
+               // The NewProject will handle directory creation
+               /*if(!dirAttribs.isDirectory)
+               {
+                  MakeDir(parentPath);
+                  dirAttribs = FileExists(parentPath);
+               }
+               if(dirAttribs.isDirectory)*/
+               {
+                  char name[MAX_LOCATION];
+                  NewProjectDialog newProjectDialog;
+
+                  if(projectView)
+                  {
+                     projectView.visible = false;
+                     if(!projectView.Destroy(0))
+                        return true;
+                  }
+
+                  newProjectDialog = { master = this };
+
+                  strcpy(name, app.argv[c]);
+                  StripExtension(name);
+                  GetLastDirectory(name, name);
+                  newProjectDialog.projectName.contents = name;
+                  newProjectDialog.projectName.NotifyModified(newProjectDialog, newProjectDialog.projectName);
+                  newProjectDialog.locationEditBox.path = parentPath;
+                  newProjectDialog.NotifyModifiedLocation(newProjectDialog.locationEditBox);
+
+                  newProjectDialog.Modal();
+                  if(projectView)
+                  {
+                     ideSettings.AddRecentProject(projectView.fileName);
+                     ide.UpdateRecentMenus();
+                     settingsContainer.Save();
+                  }
+               }
+               // Open only one project
+               break;
+            }
+            else
+               ide.OpenFile(fullPath, (app.argc == 2) * maximized, true, null, yes, normal);
+         }
       }
       return true;
    }