diff --git a/app/src/main/scala/app/logorrr/util/CpResource.scala b/app/src/main/scala/app/logorrr/util/CpResource.scala deleted file mode 100644 index 59a19537..00000000 --- a/app/src/main/scala/app/logorrr/util/CpResource.scala +++ /dev/null @@ -1,3 +0,0 @@ -package app.logorrr.util - -abstract class CpResource(value: String) diff --git a/app/src/main/scala/app/logorrr/util/Encoding.scala b/app/src/main/scala/app/logorrr/util/Encoding.scala deleted file mode 100644 index 1604e026..00000000 --- a/app/src/main/scala/app/logorrr/util/Encoding.scala +++ /dev/null @@ -1,9 +0,0 @@ -package app.logorrr.util - -import java.nio.charset.Charset - -object Encoding { - - val Utf8: Charset = Charset.forName("UTF-8") - -} diff --git a/app/src/main/scala/app/logorrr/util/ImageCp.scala b/app/src/main/scala/app/logorrr/util/ImageCp.scala index 1ad62d14..c00bf8bd 100644 --- a/app/src/main/scala/app/logorrr/util/ImageCp.scala +++ b/app/src/main/scala/app/logorrr/util/ImageCp.scala @@ -5,6 +5,8 @@ import javafx.scene.image.{Image, ImageView} import java.util.Properties +abstract class CpResource(value: String) + case class PropsCp(classPathResource : String) extends CpResource(classPathResource) { def asProperties(clazz: Class[_]): Properties = { diff --git a/app/src/main/scala/app/logorrr/util/JfxEventHandler.scala b/app/src/main/scala/app/logorrr/util/JfxEventHandler.scala deleted file mode 100644 index a0173d11..00000000 --- a/app/src/main/scala/app/logorrr/util/JfxEventHandler.scala +++ /dev/null @@ -1,9 +0,0 @@ -package app.logorrr.util - -import javafx.event.{Event, EventHandler} - -object JfxEventHandler { - - def apply[E <: Event](f: E => Unit): EventHandler[E] = (e: E) => f(e) - -} diff --git a/app/src/main/scala/app/logorrr/util/JfxUtils.scala b/app/src/main/scala/app/logorrr/util/JfxUtils.scala index 1de5059a..99dee067 100644 --- a/app/src/main/scala/app/logorrr/util/JfxUtils.scala +++ b/app/src/main/scala/app/logorrr/util/JfxUtils.scala @@ -7,7 +7,6 @@ import javafx.stage.{Stage, WindowEvent} object JfxUtils extends CanLog { - def execOnUiThread(f: => Unit): Unit = { if (!Platform.isFxApplicationThread) { Platform.runLater(() => f) diff --git a/app/src/main/scala/app/logorrr/util/LogFileUtil.scala b/app/src/main/scala/app/logorrr/util/LogFileUtil.scala deleted file mode 100644 index 63401e86..00000000 --- a/app/src/main/scala/app/logorrr/util/LogFileUtil.scala +++ /dev/null @@ -1,11 +0,0 @@ -package app.logorrr.util - -import java.nio.file.Paths - -object LogFileUtil { - - /** compute file name from a LogFilePath */ - def logFileName(pathAsString: String): String = - Paths.get(pathAsString).getFileName.toString - -} diff --git a/app/src/main/scala/app/logorrr/util/LogUtil.scala b/app/src/main/scala/app/logorrr/util/LogUtil.scala deleted file mode 100644 index b02647a4..00000000 --- a/app/src/main/scala/app/logorrr/util/LogUtil.scala +++ /dev/null @@ -1,25 +0,0 @@ -package app.logorrr.util - -import org.apache.commons.io.output.ByteArrayOutputStream - -import java.io.PrintStream - -/** - * to debug System.err and System.in streams - */ -object LogUtil { - - private def mkStream(baos: ByteArrayOutputStream): PrintStream = { - val ps = new PrintStream(baos, true, StringUtil.utf8) - ps - } - - val errBackingStream = new ByteArrayOutputStream() - val outBackingStream = new ByteArrayOutputStream() - - def init(): Unit = { - System.setOut(mkStream(outBackingStream)) - System.setErr(mkStream(errBackingStream)) - } - -} diff --git a/app/src/main/scala/app/logorrr/util/LogoRRRFileChooser.scala b/app/src/main/scala/app/logorrr/util/LogoRRRFileChooser.scala index 229ee208..1e4c8790 100644 --- a/app/src/main/scala/app/logorrr/util/LogoRRRFileChooser.scala +++ b/app/src/main/scala/app/logorrr/util/LogoRRRFileChooser.scala @@ -5,16 +5,4 @@ import javafx.stage.{FileChooser, Window} import java.nio.file.Path -class LogoRRRFileChooser(title: String) { - def showAndWait(window: Window): Option[Path] = { - val fc = new FileChooser - fc.setTitle(title) - LogoRRRGlobals.getSomeLastUsedDirectory.foreach(d => fc.setInitialDirectory(d.toFile)) - val somePath = Option(fc.showOpenDialog(window)).map(_.toPath) - LogoRRRGlobals.setSomeLastUsedDirectory(somePath.map(_.getParent)) - LogoRRRGlobals.persist() - somePath - } - -} diff --git a/app/src/main/scala/app/logorrr/util/StringUtil.scala b/app/src/main/scala/app/logorrr/util/StringUtil.scala deleted file mode 100644 index dd84543f..00000000 --- a/app/src/main/scala/app/logorrr/util/StringUtil.scala +++ /dev/null @@ -1,15 +0,0 @@ -package app.logorrr.util - -import java.nio.charset.StandardCharsets - -object StringUtil { - - val utf8: String = StandardCharsets.UTF_8.name() - - /** handy for conversions where T has a string representation. if f returns null, a 'n/a' string will be displayed */ - def tOrNa[T](f: => T): String = Option(f) match { - case Some(value) => value.toString - case None => "n/a" - } - -} diff --git a/app/src/main/scala/app/logorrr/util/Throttler.scala b/app/src/main/scala/app/logorrr/util/Throttler.scala deleted file mode 100644 index 58aac7d7..00000000 --- a/app/src/main/scala/app/logorrr/util/Throttler.scala +++ /dev/null @@ -1,43 +0,0 @@ -package app.logorrr.util - -import scala.concurrent.{CancellationException, ExecutionContext, Future, Promise} -import scala.util.{Failure, Success} - -/** - * Simple implementation to throttle signals for an api - * - * @param api the (blocking) api to call - * @param ec Execution Context to run on - * @tparam A input type - * @tparam B output type - */ -class Throttler[A, B](api: A => B)(implicit ec: ExecutionContext) { - @volatile private var ongoingComputation: Option[(Promise[B], Future[B])] = None - - def process(input: A): Future[B] = { - // Cancel any ongoing computation - ongoingComputation.foreach { case (promise, _) => - if (!promise.isCompleted) { - promise.failure(new CancellationException("Cancelled due to new input")) - } - } - - val newPromise = Promise[B]() - val newComputation = Future { - api(input) - } - - newComputation.onComplete { - case Success(result) => - if (!newPromise.isCompleted) newPromise.success(result) - case Failure(e) => - if (!newPromise.isCompleted) newPromise.failure(e) - } - - ongoingComputation = Some((newPromise, newComputation)) - - newPromise.future - } -} - - diff --git a/app/src/main/scala/app/logorrr/views/block/BorderPaneChunkListView.scala b/app/src/main/scala/app/logorrr/views/block/ChunkListView.scala similarity index 99% rename from app/src/main/scala/app/logorrr/views/block/BorderPaneChunkListView.scala rename to app/src/main/scala/app/logorrr/views/block/ChunkListView.scala index 3add160c..443be15b 100644 --- a/app/src/main/scala/app/logorrr/views/block/BorderPaneChunkListView.scala +++ b/app/src/main/scala/app/logorrr/views/block/ChunkListView.scala @@ -8,7 +8,6 @@ import javafx.beans.property.{SimpleDoubleProperty, SimpleIntegerProperty} import javafx.beans.{InvalidationListener, Observable} import javafx.collections.{FXCollections, ObservableList} import javafx.scene.control.ListView -import javafx.scene.layout.BorderPane import scala.util.{Failure, Success, Try} diff --git a/app/src/main/scala/app/logorrr/views/logfiletab/LogFileTab.scala b/app/src/main/scala/app/logorrr/views/logfiletab/LogFileTab.scala index 44fc63f1..6655de73 100644 --- a/app/src/main/scala/app/logorrr/views/logfiletab/LogFileTab.scala +++ b/app/src/main/scala/app/logorrr/views/logfiletab/LogFileTab.scala @@ -148,17 +148,8 @@ class LogFileTab(val pathAsString: String val repaintChunkListViewListener = JfxUtils.onNew[Number](n => { if (n.doubleValue() > 0.1) { - logTrace("divider") repaint() } - /* - throttler.process(n).onComplete { - case Success(_) => LogoRRRGlobals.setDividerPosition(pathAsString, n.doubleValue()) - case Failure(_: CancellationException) => logTrace(s"Computation for $n was cancelled.") - case Failure(e) => logException(s"Error processing $n: $e", e) - } - - */ }) def init(): Unit = { diff --git a/app/src/main/scala/app/logorrr/views/menubar/FileMenu.scala b/app/src/main/scala/app/logorrr/views/menubar/FileMenu.scala index e99fe376..310c1aee 100644 --- a/app/src/main/scala/app/logorrr/views/menubar/FileMenu.scala +++ b/app/src/main/scala/app/logorrr/views/menubar/FileMenu.scala @@ -1,11 +1,25 @@ package app.logorrr.views.menubar -import app.logorrr.util.{CanLog, LogoRRRFileChooser, OsUtil} + import app.logorrr.conf.LogoRRRGlobals +import app.logorrr.util.{CanLog, OsUtil} import javafx.scene.control.{Menu, MenuItem} -import javafx.stage.Window +import javafx.stage.{FileChooser, Window} import java.nio.file.Path +class LogoRRRFileChooser(title: String) { + + def showAndWait(window: Window): Option[Path] = { + val fc = new FileChooser + fc.setTitle(title) + LogoRRRGlobals.getSomeLastUsedDirectory.foreach(d => fc.setInitialDirectory(d.toFile)) + val somePath = Option(fc.showOpenDialog(window)).map(_.toPath) + LogoRRRGlobals.setSomeLastUsedDirectory(somePath.map(_.getParent)) + LogoRRRGlobals.persist() + somePath + } + +} object FileMenu { class OpenMenuItem(getWindow: () => Window diff --git a/core/src/main/scala/app/logorrr/io/Fs.scala b/core/src/main/scala/app/logorrr/io/Fs.scala index 469bc355..2d6d3102 100644 --- a/core/src/main/scala/app/logorrr/io/Fs.scala +++ b/core/src/main/scala/app/logorrr/io/Fs.scala @@ -3,13 +3,16 @@ package app.logorrr.io import app.logorrr.util.CanLog import java.nio.charset.Charset -import java.nio.file.{Files, Path} +import java.nio.file.{Files, Path, Paths} /** * File related operations */ object Fs extends CanLog { + /** compute file name from a LogFilePath */ + def logFileName(pathAsString: String): String = Paths.get(pathAsString).getFileName.toString + def createDirectories(path: Path): Unit = { if (Files.exists(path)) { logTrace(s"Using directory ${path.toAbsolutePath.toString}")