diff options
Diffstat (limited to 'support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala')
-rw-r--r-- | support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala | 126 |
1 files changed, 92 insertions, 34 deletions
diff --git a/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala b/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala index 4574ac4966..1864c8ab21 100644 --- a/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala +++ b/support/tlcockpit/src/main/scala/TLCockpit/ApplicationMain.scala @@ -47,6 +47,10 @@ import scalafx.event.ActionEvent import scalafx.collections.ObservableBuffer import scalafx.collections.ObservableMap +// configuration file handling support +import java.util.Properties +import java.io.{ File, FileOutputStream, FileInputStream } + // JSON support - important load TLPackageJsonProtocol later! import spray.json._ import TeXLive.JsonProtocol._ @@ -88,47 +92,50 @@ object ApplicationMain extends JFXApp with LazyLogging { logger.trace("starting program tlcockpit") - val javaVersion = System.getProperty("java.version") + val javaVersion = System.getProperty("java.specification.version") val javaVersionSplit: Array[String] = javaVersion.split('.') logger.debug(s"Got javaVersion ${javaVersion}") - if (javaVersionSplit.length == 1) { - logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") - } else { - val major = toInt(javaVersionSplit(0)) - val minor = toInt(javaVersionSplit(1)) - major match { - case Some(i) => - if (major.get == 1) { - minor match { - case Some(j) => - if (minor.get < 8) { - logger.error(s"Java version ${javaVersion} too old, need >= 1.8, terminating!") - Platform.exit() - sys.exit(1) - } else if (minor.get == 8) { - if (BuildInfo.javaVersion != 8) { - logger.warn(s"Build and run versions disagree: build: ${BuildInfo.javaVersion}, run: ${major.get}.${minor.get}, trying anyway!") - } + val major = toInt(javaVersionSplit(0)) + major match { + case Some(i) => + if (major.get == 1) { + val minor = toInt(javaVersionSplit(1)) + minor match { + case Some(j) => + if (minor.get < 8) { + logger.error(s"Java version ${javaVersion} too old, need >= 1.8, terminating!") + Platform.exit() + sys.exit(1) + } else if (minor.get == 8) { + if (BuildInfo.javaVersion != 8) { + logger.warn(s"Build and run versions disagree: build: ${BuildInfo.javaVersion}, run: ${major.get}.${minor.get}, trying anyway!") } - case None => - logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") - } - } else { - if (major.get > 9) { - if (major.get != BuildInfo.javaVersion) { - logger.warn(s"Build and run versions disagree: build: ${BuildInfo.javaVersion}, run: ${major.get}, trying anyway!") } - } else { - logger.warn(s"Strange version number, please report: ${javaVersion}, continuing anyway!") + case None => + logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") + } + } else { + if (major.get > 9) { + if (major.get != BuildInfo.javaVersion) { + logger.warn(s"Build and run versions disagree: build: ${BuildInfo.javaVersion}, run: ${major.get}, trying anyway!") } + } else { + logger.warn(s"Strange version number, please report: ${javaVersion}, continuing anyway!") } - case None => - logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") - } - // in all other cases just hope it is fine - logger.info(s"Running on Java Version ${javaVersion}") + } + case None => + logger.warn(s"Cannot find Java version from ${javaVersion}, continuing anyway!") } + logger.info(s"Running on Java Version ${javaVersion}") + + val userHomeDirectory = System.getProperty("user.home") + val confPath = userHomeDirectory + "/.tlcockpit.conf" + val props = new Properties() + val propsFile = new File(confPath) + if (propsFile.exists()) { + props.load(new FileInputStream(propsFile)) + } var tlmgrBusy = BooleanProperty(false) @@ -362,7 +369,7 @@ object ApplicationMain extends JFXApp with LazyLogging { title = "About TLCockpit" graphic = new ImageView(logoImage) headerText = "TLCockpit version " + version + "\n\nManage your TeX Live with speed!" - contentText = "Copyright 2017-2018 Norbert Preining\nLicense: GPL3+\nSources: https://github.com/TeX-Live/tlcockpit" + contentText = "Copyright 2017-2020 Norbert Preining\nLicense: GPL3+\nSources: https://github.com/TeX-Live/tlcockpit" }.showAndWait() } @@ -1068,10 +1075,39 @@ tlmgr> }) } + def save_properties(): Unit = { + props.store(new FileOutputStream(confPath), null) + } + val StartTabPkgs = new RadioMenuItem("Packages") { + onAction = (ae) => { + props.setProperty("StartupTab", "packages") + save_properties() + } + } + val StartTabUpds = new RadioMenuItem("Updates") { + onAction = (ae) => { + props.setProperty("StartupTab","updates") + save_properties() + } + } + val StartTabBcks = new RadioMenuItem("Backups") { + onAction = (ae) => { + props.setProperty("StartupTab","backups") + save_properties() + } + } + + val startupTabMenu: Menu = new Menu("Startup Tab") { + val foo = new ToggleGroup + foo.toggles = Seq(StartTabPkgs, StartTabUpds, StartTabBcks) + items = List(StartTabPkgs, StartTabUpds, StartTabBcks) + } + val optionsMenu: Menu = new Menu("Options") { items = List( new MenuItem("General ...") { onAction = (ae) => callback_general_options() }, new MenuItem("Paper ...") { onAction = (ae) => callback_paper() }, + startupTabMenu /* new MenuItem("Platforms ...") { disable = true; onAction = (ae) => not_implemented_info() }, new SeparatorMenuItem, new CheckMenuItem("Expert options") { disable = true }, @@ -1415,6 +1451,27 @@ tlmgr> stage.width = 800 + val selectedTab = props.getOrDefault("StartupTab", "packages") + StartTabPkgs.selected = true + StartTabUpds.selected = false + StartTabBcks.selected = false + var StartupTab = 0 + selectedTab match { + case "packages" => {} + case "updates" => { + StartTabPkgs.selected = false + StartTabUpds.selected = true + StartupTab = 1 + } + case "backups" => { + StartTabPkgs.selected = false + StartTabBcks.selected = true + StartupTab = 2 + } + case _ => { + logger.warn(s"Unrecognized setting for StartupTab in config file: $selectedTab") + } + } var currentPromise = Promise[(String,Array[String])]() val pendingJobs = scala.collection.mutable.Queue[(String,(String, Array[String]) => Unit)]() @@ -1567,6 +1624,7 @@ tlmgr> logger.debug("Before loading tlpdb") load_tlpdb_update_pkgs_view_no_json() logger.debug("after loading tlpdb") + pkgstabs.selectionModel().select(StartupTab) }) } |