Commits

Thibaut Colar  committed 691856d

Support for multiple configs(Fantom envs) and quick switching between them without restarting
Version bump to 1.0.4

  • Participants
  • Parent commits ef968b1

Comments (0)

Files changed (10)

 * Better separation of runtime fantom env VS deploy/index env
 * Alt+Space for quicly switching between last 2 files
 * New File command
+* Recognzing projects structured as prj/src/.... (rebasing root)
+* Recognizing pod groups and pods and showing as such in navigators
+* Support for building pod groups
+* Sorted slot lists
+* Support for switching betwen multiple configs(Fantom envs) : configs_myenv1.props etc ...
+* Many bug fixes
 
 # Screenshot
 

File src/brie/build.fan

                `fan/command/`,
                `fan/widget/`]
     resDirs = [`res/`]
-    version = Version("1.0.3")
+    version = Version("1.0.4")
     meta    =  ["license.name"   : "Academic License",
                 "vcs.uri"   : "https://bitbucket.org/tcolar/camembert"]
     docSrc  = true

File src/brie/fan/Main.fan

 {
   static Void main()
   {
-    sys := Sys {}
+    sys := Sys{options = Options.load}
     sys.install
     Frame(sys).open
   }

File src/brie/fan/MenuBar.fan

         MenuItem{ it.command = sys.commands.recentToggle.asCommand},
       }
 
+
+      configs := Menu{
+        it.text = "Switch config"
+          MenuItem{ it.command = SwitchConfigCmd("default", Options.standard).asCommand
+                    it.mode = MenuItemMode.radio
+                    it.selected = true
+                  },
+      }
+      sys.configs.each |file, name|
+      {
+        configs.add(MenuItem{
+          it.command = SwitchConfigCmd(name, file).asCommand; it.mode = MenuItemMode.radio
+        })
+      }
+
       options = Menu {
         it.text = "Options"
         MenuItem{ it.command = sys.commands.editConfig.asCommand},
         MenuItem{ it.command = sys.commands.reloadConfig.asCommand},
+        configs,
       }
 
       add(file)

File src/brie/fan/Options.fan

 @Serializable
 const class Options
 {
-  static const File file := Env.cur.workDir + `etc/camenbert/options.props`
+  static const File standard := Env.cur.workDir + `etc/camenbert/options.props`
 
   ** Reload options
-  static Options load()
+  static Options load(File file := standard)
   {
     return (Options) SettingUtils.load(file, Options#)
   }
       fanHome = fanHomeUri.toFile.normalize
   }
 
-  @Setting{ help = ["Home directory to use for fan/build commands"] }
+  @Setting{ help = [
+  "Note that you can create alternate configs: options_foo.props, options_bar.props ...",
+  "",
+  "Home directory to use for fan/build commands"] }
   const Uri fanHomeUri := Env.cur.homeDir.uri
 
   @Setting{ help = ["Sources Directories to crawl"] }
-  const Uri[] srcDirs := [file.parent.uri]
+  const Uri[] srcDirs := [standard.parent.uri]
 
   @Setting{ help = ["Pod directories to crawl. Typically [fanHomeUri]/lib/fan/"] }
   const Uri[] podDirs := [Env.cur.homeDir.uri]

File src/brie/fan/Sys.fan

   const Shortcuts shortcuts := Shortcuts.load
 
   ** Configuration options
-  const Options options := Options.load
+  const Options options
 
   ** Theme
-  const Theme theme := Theme.load(options.theme)
+  const Theme theme
 
   ** Indexing service
-  const Index index := Index(this)
+  const Index index
 
   ** Application level commands
-  const Commands commands := Commands(this)
+  const Commands commands
 
   ** Top-level frame (only in UI thread)
   Frame frame() { Actor.locals["frame"] ?: throw Err("Not on UI thread") }
 
   const Plugin[] plugins := [,]
 
-  new make(|This|? f) {if(f!=null) f(this)}
+  new make(|This|? f)
+  {
+    if(f!=null) f(this)
+    theme = Theme.load(options.theme)
+    index = Index(this)
+    commands = Commands(this)
+  }
 
   override Void onStop()
   {
     index.crawler.pool.kill
   }
 
-  static Void reload()
+  static Void loadConfig(File config := Options.standard)
   {
     sys := Service.find(Sys#) as Sys
     sys.uninstall
 
-    sys = Sys {}
+    sys = Sys
+    {
+      options = Options.load(config)
+    }
     sys.install
     sys.frame.updateSys()
   }
+
+  ** Look for alternate config files (options_xyz.props)
+  Str:File configs()
+  {
+    Str:File results := [:]
+    Options.standard.parent.listFiles.each |f|
+    {
+      if(f.name.startsWith("options_") && f.ext =="props")
+        results.add(f.basename[8 .. -1], f)
+    }
+    return results
+  }
 }
 
 mixin SysListener

File src/brie/fan/command/Commands.fan

   override const Str name := "Edit config"
   override Void invoke(Event event)
   {
-    frame.goto(Item(Options.file))
+    frame.goto(Item(Options.standard))
   }
   new make(|This| f) {f(this)}
 }
 
+internal const class SwitchConfigCmd : Cmd
+{
+  override const Str name
+  const File conf
+
+  override Void invoke(Event event)
+  {
+    Sys.loadConfig(conf)
+  }
+  new make(Str name, File conf)
+  {
+    this.name = name
+    this.conf = conf
+  }
+}
+
 internal const class ReloadConfigCmd : Cmd
 {
   override const Str name := "Reload Config"
   override Void invoke(Event event)
   {
-    Sys.reload
+    Sys.loadConfig
   }
   new make(|This| f) {f(this)}
 }
-
 internal const class HelpCmd : Cmd
 {
   override const Str name := "Search Docs"

File src/brie/fan/command/FileCommands.fan

   override const Str name := "New File"
   override Void invoke(Event event)
   {
-    clazz := File(`${Options.file.parent}/class.tpl`)
+    clazz := File(`${Options.standard.parent}/class.tpl`)
     if(!clazz.exists)
     {
       clazz.create.out.print("// History:\n//   {date} Creation\n\n**\n** {name}\n**\nclass {name}\n{\n}\n").close
     }
 
     Str:Str tpls := [:] {ordered = true}
-    Options.file.parent.listFiles.findAll |file->Bool|
+    Options.standard.parent.listFiles.findAll |file->Bool|
       {return file.ext == "tpl"}
       .each{tpls[it.basename] = it.readAllStr
     }

File src/brie/fan/widget/Console.fan

         e.trace
       }
     }
+    console.list.scrollToLine(console.list.lineCount)
   }
 
   private Item parseLine(Str str)
-Nav -> right click: find in space (so don't need to open file to do it)
-delete file
-rename file
+delete file/folder
+rename file/folder (& move)
 duplicate file
 
 find/replace .. local / global
 
 Bocce: Ctrl+A -> select all
 
-Have the console scroll
-allow copy from console output
-stack trace links in console ?
+Bug: When going in the text area, the first keystroke is lost (gains focus but do not act on the keystroke)
 
-quick fantom env switcher ? env manager / (update config & reload)
-options -> switch config -> conf1, conf2, conf3 (fanHomeUri, srcDirs, podDirs)
-or juts options2.conf ?
-checkmark next to cur config
 
 
-