diff options
author | Norbert Preining <norbert@preining.info> | 2020-04-23 03:02:25 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-04-23 03:02:25 +0000 |
commit | b86f6f3256611ce04f593d897b9cf412d18fa062 (patch) | |
tree | c5fecf75a10834f6ca5b39548a48f67d6294918c /support/tlcockpit/src/main | |
parent | e0e2537ccbac6924b371be81092c1177e817162c (diff) |
CTAN sync 202004230302
Diffstat (limited to 'support/tlcockpit/src/main')
5 files changed, 97 insertions, 38 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) }) } diff --git a/support/tlcockpit/src/main/scala/TLCockpit/LocationDialog.scala b/support/tlcockpit/src/main/scala/TLCockpit/LocationDialog.scala index 647e0cc038..2a45fb3db5 100644 --- a/support/tlcockpit/src/main/scala/TLCockpit/LocationDialog.scala +++ b/support/tlcockpit/src/main/scala/TLCockpit/LocationDialog.scala @@ -109,7 +109,7 @@ class LocationDialog(locs: Map[String,String]) extends LazyLogging { grid.columnConstraints = Seq(new ColumnConstraints(100, 100, 200), new ColumnConstraints(250, 250, 5000, Priority.Always, HPos.LEFT, true)) dialog.dialogPane().content = grid dialog.width = 500 - dialog.height = 1500 + // dialog.height = 1500 dialog.resultConverter = dialogButton => if (dialogButton == ButtonType.OK) { diff --git a/support/tlcockpit/src/main/scala/TLCockpit/OptionsDialog.scala b/support/tlcockpit/src/main/scala/TLCockpit/OptionsDialog.scala index 52a9d5d0ce..3e23270d95 100644 --- a/support/tlcockpit/src/main/scala/TLCockpit/OptionsDialog.scala +++ b/support/tlcockpit/src/main/scala/TLCockpit/OptionsDialog.scala @@ -109,7 +109,8 @@ class OptionsDialog(opts: List[TLOption]) extends LazyLogging { grid.columnConstraints = Seq(new ColumnConstraints(300, 300, 500), new ColumnConstraints(200, 200, 5000, Priority.Always, HPos.LEFT, true)) dialog.dialogPane().content = grid dialog.width = 500 - dialog.height = 1500 + // This seems to be necessary for some old versions of ScalaFX or JavaFX or Java?? + // dialog.height = 1500 dialog.resultConverter = dialogButton => if (dialogButton == ButtonType.OK) { diff --git a/support/tlcockpit/src/main/scala/TLCockpit/PaperDialog.scala b/support/tlcockpit/src/main/scala/TLCockpit/PaperDialog.scala index 3d7a2e8403..cb3e28907c 100644 --- a/support/tlcockpit/src/main/scala/TLCockpit/PaperDialog.scala +++ b/support/tlcockpit/src/main/scala/TLCockpit/PaperDialog.scala @@ -64,7 +64,7 @@ class PaperDialog(paperconf: Map[String, TLPaperConf]) extends LazyLogging { grid.columnConstraints = Seq(new ColumnConstraints(100, 100, 150), new ColumnConstraints(150, 150, 5000, Priority.Always, HPos.LEFT, true)) dialog.dialogPane().content = grid dialog.width = 300 - dialog.height = 1500 + // dialog.height = 1500 dialog.resultConverter = dialogButton => if (dialogButton == ButtonType.OK) diff --git a/support/tlcockpit/src/main/scala/TLCockpit/PkgInfoDialog.scala b/support/tlcockpit/src/main/scala/TLCockpit/PkgInfoDialog.scala index 89ba164de2..fbea1ecd62 100644 --- a/support/tlcockpit/src/main/scala/TLCockpit/PkgInfoDialog.scala +++ b/support/tlcockpit/src/main/scala/TLCockpit/PkgInfoDialog.scala @@ -116,7 +116,7 @@ class PkgInfoDialog(tlp: TLPackage) extends Dialog { grid.columnConstraints = Seq(new ColumnConstraints(100, 200, 200), new ColumnConstraints(100, 400, 5000, Priority.Always, HPos.LEFT, true)) dialog.dialogPane().content = grid dialog.width = 600 - dialog.height = 1500 + // dialog.height = 1500 // dialog def showAndWait(): Unit = this.dialog.showAndWait() |