From bf86d1dbc24474fd9041f1fb3c002a7a71242fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Ladst=C3=A4tter?= Date: Mon, 2 Oct 2023 23:16:49 +0200 Subject: [PATCH] #147: calculate LogEntry color on demand --- .../app/logorrr/conf/LogoRRRGlobals.scala | 2 +- .../logorrr/conf/mut/MutLogFileSettings.scala | 18 +++-- .../scala/app/logorrr/model/LogEntry.scala | 4 -- .../logorrr/model/LogEntryFileReader.scala | 12 ++-- .../app/logorrr/model/LogFileSettings.scala | 2 +- .../scala/app/logorrr/views/LogFileTab.scala | 8 --- .../views/autoscroll/LogEntryListener.scala | 4 +- .../app/logorrr/views/block/BlockImage.scala | 12 +++- .../app/logorrr/views/block/BlockView.scala | 29 +++++---- .../logorrr/views/block/BlockViewPane.scala | 65 ++++++++++++------- .../logorrr/views/search/FiltersToolBar.scala | 7 +- .../app/logorrr/views/text/LogTextView.scala | 4 +- .../logorrr/views/visual/LogVisualView.scala | 9 +-- .../test/scala/app/logorrr/LogEntrySpec.scala | 3 +- .../views/block/BlockViewDemoApp.scala | 6 +- .../views/text/FilterCalculatorSpec.scala | 2 +- .../main/scala/app/logorrr/util/OsUtil.scala | 6 +- pom.xml | 2 +- 18 files changed, 105 insertions(+), 90 deletions(-) diff --git a/app/src/main/scala/app/logorrr/conf/LogoRRRGlobals.scala b/app/src/main/scala/app/logorrr/conf/LogoRRRGlobals.scala index 4cfb858b..8759a29e 100644 --- a/app/src/main/scala/app/logorrr/conf/LogoRRRGlobals.scala +++ b/app/src/main/scala/app/logorrr/conf/LogoRRRGlobals.scala @@ -90,7 +90,7 @@ object LogoRRRGlobals extends CanLog { } - def setSelectedIndex(pathAsString: String, index: Int): Unit = getLogFileSettings(pathAsString).setSelectedIndex(index) + def setSelectedIndex(pathAsString: String, index: Int): Unit = getLogFileSettings(pathAsString).selectedLineNumber(index) def setBlockSettings(pathAsString: String, bs: BlockSettings): Unit = mupdate({ lfs: MutLogFileSettings => lfs.setBlockSettings(bs) })(pathAsString) diff --git a/app/src/main/scala/app/logorrr/conf/mut/MutLogFileSettings.scala b/app/src/main/scala/app/logorrr/conf/mut/MutLogFileSettings.scala index f5634a9b..ab3f3eae 100644 --- a/app/src/main/scala/app/logorrr/conf/mut/MutLogFileSettings.scala +++ b/app/src/main/scala/app/logorrr/conf/mut/MutLogFileSettings.scala @@ -14,13 +14,13 @@ object MutLogFileSettings { def apply(logFileSettings: LogFileSettings): MutLogFileSettings = { val s = new MutLogFileSettings - s.setSelectedIndex(logFileSettings.selectedIndex) + s.selectedLineNumber(logFileSettings.selectedLineNumber) s.setFontSize(logFileSettings.fontSize) s.setBlockSettings(logFileSettings.blockSettings) s.setPathAsString(logFileSettings.pathAsString) s.firstOpenedProperty.set(logFileSettings.firstOpened) s.setDividerPosition(logFileSettings.dividerPosition) - s.filtersProperty.setAll(logFileSettings.filters.asJava) + s.setFilters(logFileSettings.filters) s.someLogEntrySettingsProperty.set(logFileSettings.someLogEntryInstantFormat) s.setAutoScroll(logFileSettings.autoScroll) s @@ -31,7 +31,7 @@ class MutLogFileSettings { private val pathAsStringProperty = new SimpleStringProperty() private val firstOpenedProperty = new SimpleLongProperty() - val selectedIndexProperty = new SimpleIntegerProperty() + val selectedLineNumber = new SimpleIntegerProperty() private val dividerPositionProperty = new SimpleDoubleProperty() private val fontSizeProperty = new SimpleIntegerProperty() @@ -40,6 +40,14 @@ class MutLogFileSettings { val someLogEntrySettingsProperty = new SimpleObjectProperty[Option[LogEntryInstantFormat]](None) val blockWidthSettingsProperty = new SimpleIntegerProperty() + def setFilters(filters: Seq[Filter]): Unit = { + filtersProperty.setAll(filters.asJava) + } + + def setFilter(index: Int, filter: Filter): Unit = { + filtersProperty.set(index, filter) + } + val hasLogEntrySettingBinding: BooleanBinding = new BooleanBinding { bind(someLogEntrySettingsProperty) @@ -72,7 +80,7 @@ class MutLogFileSettings { def getPathAsString(): String = pathAsStringProperty.get() - def setSelectedIndex(index: Int): Unit = selectedIndexProperty.set(index) + def selectedLineNumber(lineNumber: Int): Unit = selectedLineNumber.set(lineNumber) def setFontSize(fontSize: Int): Unit = fontSizeProperty.set(fontSize) @@ -85,7 +93,7 @@ class MutLogFileSettings { def petrify(): LogFileSettings = { val lfs = LogFileSettings(pathAsStringProperty.get() - , selectedIndexProperty.get() + , selectedLineNumber.get() , firstOpenedProperty.get() , dividerPositionProperty.get() , fontSizeProperty.get() diff --git a/app/src/main/scala/app/logorrr/model/LogEntry.scala b/app/src/main/scala/app/logorrr/model/LogEntry.scala index 51e91fa2..ab7d6468 100644 --- a/app/src/main/scala/app/logorrr/model/LogEntry.scala +++ b/app/src/main/scala/app/logorrr/model/LogEntry.scala @@ -1,7 +1,5 @@ package app.logorrr.model -import app.logorrr.views.block.BlockView -import javafx.scene.paint.Color import java.time.Instant @@ -13,7 +11,5 @@ import java.time.Instant * @param someInstant a timestamp if there is any * */ case class LogEntry(lineNumber: Int - , color: Color // remove, should be calculated because of given filters , value: String , someInstant: Option[Instant]) - extends BlockView.E diff --git a/app/src/main/scala/app/logorrr/model/LogEntryFileReader.scala b/app/src/main/scala/app/logorrr/model/LogEntryFileReader.scala index ac67e1eb..c05fdd92 100644 --- a/app/src/main/scala/app/logorrr/model/LogEntryFileReader.scala +++ b/app/src/main/scala/app/logorrr/model/LogEntryFileReader.scala @@ -1,9 +1,8 @@ package app.logorrr.model import app.logorrr.util.CanLog -import app.logorrr.views.search.{Filter, Fltr} +import app.logorrr.views.search.Fltr import javafx.collections.{FXCollections, ObservableList} -import javafx.scene.paint.Color import java.nio.file.Path import java.time.Instant @@ -12,23 +11,22 @@ import java.util /** Abstraction for a log file */ object LogEntryFileReader extends CanLog { - private def mkLogEntryList(parseColor: String => Color - , parseEntryForTimeInstant: String => Option[Instant]) + private def mkLogEntryList(parseEntryForTimeInstant: String => Option[Instant]) (logFilePath: Path): ObservableList[LogEntry] = timeR({ var lineNumber: Int = 0 val arraylist = new util.ArrayList[LogEntry]() LogFileReader.readFromFile(logFilePath).map(l => { lineNumber = lineNumber + 1 - arraylist.add(LogEntry(lineNumber, parseColor(l), l, parseEntryForTimeInstant(l))) + arraylist.add(LogEntry(lineNumber, l, parseEntryForTimeInstant(l))) }) FXCollections.observableList(arraylist) }, s"Imported ${logFilePath.toAbsolutePath.toString} ... ") def from(logFilePath: Path, filters: Seq[Fltr], logEntryTimeFormat: LogEntryInstantFormat): ObservableList[LogEntry] = { - mkLogEntryList(l => Filter.calcColor(l, filters), l => LogEntryInstantFormat.parseInstant(l, logEntryTimeFormat))(logFilePath) + mkLogEntryList(l => LogEntryInstantFormat.parseInstant(l, logEntryTimeFormat))(logFilePath) } - def from(logFile: Path, filters: Seq[Fltr]): ObservableList[LogEntry] = mkLogEntryList(l => Filter.calcColor(l, filters), _ => None)(logFile) + def from(logFile: Path, filters: Seq[Fltr]): ObservableList[LogEntry] = mkLogEntryList(_ => None)(logFile) } diff --git a/app/src/main/scala/app/logorrr/model/LogFileSettings.scala b/app/src/main/scala/app/logorrr/model/LogFileSettings.scala index 9ce3bb88..bd5676a0 100644 --- a/app/src/main/scala/app/logorrr/model/LogFileSettings.scala +++ b/app/src/main/scala/app/logorrr/model/LogFileSettings.scala @@ -55,7 +55,7 @@ object LogFileSettings { * */ case class LogFileSettings(pathAsString: String - , selectedIndex: Int + , selectedLineNumber: Int , firstOpened: Long , dividerPosition: Double , fontSize: Int diff --git a/app/src/main/scala/app/logorrr/views/LogFileTab.scala b/app/src/main/scala/app/logorrr/views/LogFileTab.scala index 3531f4ab..d378cfc1 100644 --- a/app/src/main/scala/app/logorrr/views/LogFileTab.scala +++ b/app/src/main/scala/app/logorrr/views/LogFileTab.scala @@ -171,19 +171,11 @@ class LogFileTab(val pathAsString: String filtersListProperty.addListener(JfxUtils.mkListChangeListener(handleFilterChange)) } - /** update all log entries with current filter settings */ - def updateLogEntryColors(): Unit = { - val filters = filtersListProperty.get().asScala.toSeq - val lE: mutable.Seq[LogEntry] = for (old <- logEntries.asScala) yield old.copy(color = Filter.calcColor(old.value, filters)) - logEntries.setAll(lE.asJava) - } - private def handleFilterChange(change: ListChangeListener.Change[_ <: Fltr]): Unit = { while (change.next()) { Future { LogoRRRGlobals.persist() } - updateLogEntryColors() } } diff --git a/app/src/main/scala/app/logorrr/views/autoscroll/LogEntryListener.scala b/app/src/main/scala/app/logorrr/views/autoscroll/LogEntryListener.scala index 56186304..519f8828 100644 --- a/app/src/main/scala/app/logorrr/views/autoscroll/LogEntryListener.scala +++ b/app/src/main/scala/app/logorrr/views/autoscroll/LogEntryListener.scala @@ -3,7 +3,6 @@ package app.logorrr.views.autoscroll import app.logorrr.conf.LogoRRRGlobals import app.logorrr.model.LogEntry import app.logorrr.util.{CanLog, JfxUtils} -import app.logorrr.views.search.Filter import javafx.collections.ObservableList import org.apache.commons.io.input.{Tailer, TailerListener} @@ -24,8 +23,7 @@ class LogEntryListener(pathAsString: String override def handle(l: String): Unit = { currentCnt = currentCnt + 1 - val filters = LogoRRRGlobals.getLogFileSettings(pathAsString).getFilters - val e = LogEntry(currentCnt, Filter.calcColor(l, filters), l, None) + val e = LogEntry(currentCnt, l, None) JfxUtils.execOnUiThread(ol.add(e)) } diff --git a/app/src/main/scala/app/logorrr/views/block/BlockImage.scala b/app/src/main/scala/app/logorrr/views/block/BlockImage.scala index fec62b44..a1176ec8 100644 --- a/app/src/main/scala/app/logorrr/views/block/BlockImage.scala +++ b/app/src/main/scala/app/logorrr/views/block/BlockImage.scala @@ -1,6 +1,9 @@ package app.logorrr.views.block +import app.logorrr.conf.LogoRRRGlobals +import app.logorrr.model.LogEntry import app.logorrr.util.{CanLog, ColorUtil, JfxUtils} +import app.logorrr.views.search.Filter import javafx.beans.property.{SimpleIntegerProperty, SimpleListProperty, SimpleObjectProperty} import javafx.beans.{InvalidationListener, Observable} import javafx.collections.FXCollections @@ -9,6 +12,7 @@ import javafx.scene.image.{PixelBuffer, PixelFormat, WritableImage} import javafx.scene.paint.Color import java.nio.IntBuffer +import scala.jdk.CollectionConverters.ListHasAsScala object BlockImage { @@ -20,7 +24,9 @@ object BlockImage { } -class BlockImage[Elem <: BlockView.E] extends CanLog { +class BlockImage extends CanLog { + + val filtersProperty = new SimpleListProperty[Filter]() var pixelBuffer: PixelBuffer[IntBuffer] = _ var intBuffer: IntBuffer = _ @@ -31,7 +37,7 @@ class BlockImage[Elem <: BlockView.E] extends CanLog { private val redrawListener: InvalidationListener = (_: Observable) => repaint() - val entries = new SimpleListProperty[Elem](FXCollections.observableArrayList()) + val entries = new SimpleListProperty[LogEntry](FXCollections.observableArrayList()) /* if blockwidth is changed redraw */ val blockWidthProperty = { @@ -112,7 +118,7 @@ class BlockImage[Elem <: BlockView.E] extends CanLog { cleanBackground() var i = 0 entries.forEach(e => { - drawRect(i, e.color) + drawRect(i, Filter.calcColor(e.value, filtersProperty.asScala.toSeq)) i = i + 1 }) roi diff --git a/app/src/main/scala/app/logorrr/views/block/BlockView.scala b/app/src/main/scala/app/logorrr/views/block/BlockView.scala index 6ac2a4a9..442f6bc7 100644 --- a/app/src/main/scala/app/logorrr/views/block/BlockView.scala +++ b/app/src/main/scala/app/logorrr/views/block/BlockView.scala @@ -1,13 +1,14 @@ package app.logorrr.views.block +import app.logorrr.model.LogEntry import app.logorrr.util.{CanLog, JfxUtils} +import app.logorrr.views.search.Filter import javafx.beans.property.{ReadOnlyDoubleProperty, SimpleIntegerProperty, SimpleListProperty, SimpleObjectProperty} import javafx.beans.value.ChangeListener import javafx.collections.FXCollections import javafx.event.EventHandler import javafx.scene.image.ImageView import javafx.scene.input.MouseEvent -import javafx.scene.paint.Color import scala.math.BigDecimal.RoundingMode import scala.util.Try @@ -18,10 +19,6 @@ object BlockView { val MinWidth = 200 - trait E { - def color: Color - } - def indexOf(x: Int, y: Int, blockWidth: Int, blockViewWidth: Int): Int = y / blockWidth * (blockViewWidth / blockWidth) + x / blockWidth @@ -57,16 +54,17 @@ object BlockView { /** * Displays a region with max 4096 x 4096 pixels and as many entries as can fit in this region. */ -class BlockView[Elem <: BlockView.E] extends ImageView with CanLog { +class BlockView extends ImageView with CanLog { private val blockSizeProperty = new SimpleIntegerProperty() private val widthProperty = new SimpleIntegerProperty() + private val filtersProperty = new SimpleListProperty[Filter]() - val entriesProperty = new SimpleListProperty[Elem](FXCollections.observableArrayList()) + val entriesProperty = new SimpleListProperty[LogEntry](FXCollections.observableArrayList()) - val selectedEntryProperty: SimpleObjectProperty[Elem] = new SimpleObjectProperty[Elem]() + val selectedEntryProperty: SimpleObjectProperty[LogEntry] = new SimpleObjectProperty[LogEntry]() - var selectedListener: ChangeListener[Elem] = _ + var selectedListener: ChangeListener[LogEntry] = _ private val mouseEventHandler: EventHandler[MouseEvent] = new EventHandler[MouseEvent]() { override def handle(me: MouseEvent): Unit = { @@ -85,11 +83,12 @@ class BlockView[Elem <: BlockView.E] extends ImageView with CanLog { private val blockImage = { - val bi = new BlockImage[Elem] + val bi = new BlockImage bi.widthProperty.bind(widthProperty) bi.blockWidthProperty.bind(blockSizeProperty) bi.blockHeightProperty.bind(blockSizeProperty) bi.entries.bind(entriesProperty) + bi.filtersProperty.bind(filtersProperty) bi } @@ -114,9 +113,11 @@ class BlockView[Elem <: BlockView.E] extends ImageView with CanLog { def setWidth(width: Int): Unit = widthProperty.set(width) - def bind(blockSizeProperty: SimpleIntegerProperty + def bind(filtersProperty: SimpleListProperty[Filter] + , blockSizeProperty: SimpleIntegerProperty , blockViewWidthProperty: ReadOnlyDoubleProperty - , setEntry: Elem => Unit): Unit = { + , setEntry: LogEntry => Unit): Unit = { + this.filtersProperty.bind(filtersProperty) this.blockSizeProperty.bind(blockSizeProperty) this.blockViewWidthPropertyHolder = blockViewWidthProperty this.blockViewWidthPropertyHolder.addListener(widthListener) @@ -129,9 +130,9 @@ class BlockView[Elem <: BlockView.E] extends ImageView with CanLog { this.selectedListener = null } - def setEntries(entries: java.util.List[Elem]): Unit = entriesProperty.setAll(entries) + def setEntries(entries: java.util.List[LogEntry]): Unit = entriesProperty.setAll(entries) - def getEntryAt(index: Int): Option[Elem] = Try(entriesProperty.get(index)).toOption + def getEntryAt(index: Int): Option[LogEntry] = Try(entriesProperty.get(index)).toOption def repaint(): Unit = blockImage.repaint() diff --git a/app/src/main/scala/app/logorrr/views/block/BlockViewPane.scala b/app/src/main/scala/app/logorrr/views/block/BlockViewPane.scala index 109e0811..9a2b4621 100644 --- a/app/src/main/scala/app/logorrr/views/block/BlockViewPane.scala +++ b/app/src/main/scala/app/logorrr/views/block/BlockViewPane.scala @@ -1,7 +1,11 @@ package app.logorrr.views.block +import app.logorrr.conf.LogoRRRGlobals +import app.logorrr.model.LogEntry import app.logorrr.util.{CanLog, JfxUtils} +import app.logorrr.views.search.Filter import javafx.beans.property.{SimpleIntegerProperty, SimpleListProperty, SimpleObjectProperty} +import javafx.beans.value.{ChangeListener, ObservableValue} import javafx.collections.{FXCollections, ListChangeListener, ObservableList} import javafx.scene.control._ import javafx.scene.layout.VBox @@ -9,11 +13,27 @@ import javafx.scene.layout.VBox import scala.collection.mutable.ListBuffer -class BlockViewPane[Elem <: BlockView.E] +class BlockViewPane(pathAsString: String) extends ScrollPane with HasBlockSizeProperty with CanLog { + /** vertical box which holds single SQViews and serves as a canvas for painting */ + private val vbox = new VBox() + private val repaintListener: ListChangeListener[LogEntry] = (_: ListChangeListener.Change[_ <: LogEntry]) => repaint() + + val selectedElemProperty = { + val sp = new SimpleObjectProperty[LogEntry]() + sp + } + + private val entriesProperty = { + val es = new SimpleListProperty[LogEntry](FXCollections.observableArrayList()) + es.addListener(repaintListener) + es + } + + val filtersProperty = new SimpleListProperty[Filter]() override val blockSizeProperty: SimpleIntegerProperty = { val p = new SimpleIntegerProperty() @@ -21,39 +41,37 @@ class BlockViewPane[Elem <: BlockView.E] p } - def setCanvasWidth(value: Double): Unit = { - super.setWidth(value) - } + init() - /** vertical box which holds single SQViews and serves as a canvas for painting */ - private val vbox = new VBox() - private val repaintListener: ListChangeListener[Elem] = (_: ListChangeListener.Change[_ <: Elem]) => repaint() + private def init(): Unit = { + selectedElemProperty.addListener(new ChangeListener[LogEntry] { + override def changed(observable: ObservableValue[_ <: LogEntry], oldValue: LogEntry, newLogEntry: LogEntry): Unit = { + LogoRRRGlobals.getLogFileSettings(pathAsString).selectedLineNumber(newLogEntry.lineNumber) + } + }) - val selectedElemProperty = { - val sp = new SimpleObjectProperty[Elem]() - sp + widthProperty().addListener(JfxUtils.onNew[Number](_ => repaint())) + + setContent(vbox) } - private val entriesProperty = { - val es = new SimpleListProperty[Elem](FXCollections.observableArrayList()) - es.addListener(repaintListener) - es + def setCanvasWidth(value: Double): Unit = { + super.setWidth(value) } def getEntriesSize(): Int = entriesProperty.size() - def setEntries(es: ObservableList[Elem]): Unit = { + def setEntries(es: ObservableList[LogEntry]): Unit = { entriesProperty.setValue(es) } - widthProperty().addListener(JfxUtils.onNew[Number](_ => repaint())) - def setSelectedElem(elem: Elem): Unit = selectedElemProperty.set(elem) + def setSelectedElem(elem: LogEntry): Unit = selectedElemProperty.set(elem) - private def mkBlockView(): BlockView[Elem] = { - val blockView = new BlockView[Elem] - blockView.bind(blockSizeProperty, widthProperty, setSelectedElem) + private def mkBlockView(): BlockView = { + val blockView = new BlockView + blockView.bind(filtersProperty,blockSizeProperty, widthProperty, setSelectedElem) blockView } @@ -61,7 +79,7 @@ class BlockViewPane[Elem <: BlockView.E] if (isVisible) { // unbind old listeners or we have a memory problem vbox.getChildren.forEach { - case c: BlockView[_] => c.unbind() + case c: BlockView => c.unbind() case _ => } @@ -76,7 +94,7 @@ class BlockViewPane[Elem <: BlockView.E] assert(getWidth.toInt > 0, getWidth) */ if (getBlockSize() > 0 && getWidth.toInt > 0) { - val blockViews: Seq[BlockView[Elem]] = { + val blockViews: Seq[BlockView] = { // if virtual canvas height is lower than maxheight, just create one sqView and be done with it if (virtualHeight <= BlockImage.MaxHeight) { val blockView = mkBlockView() @@ -90,7 +108,7 @@ class BlockViewPane[Elem <: BlockView.E] val nrOfRowsPerSquareView = (BlockImage.MaxHeight / blockSizeProperty.get()).toInt val nrElemsInSqView = nrOfRowsPerSquareView * nrOfElemsInRow var curIndex = 0 - val lb = new ListBuffer[BlockView[Elem]] + val lb = new ListBuffer[BlockView] while (curIndex < getEntriesSize()) { val v = mkBlockView() @@ -122,7 +140,6 @@ class BlockViewPane[Elem <: BlockView.E] () } - setContent(vbox) def scrollToEnd(): Unit = setVvalue(getVmax) diff --git a/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala b/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala index f7aab7ed..aebf75b9 100644 --- a/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala +++ b/app/src/main/scala/app/logorrr/views/search/FiltersToolBar.scala @@ -34,7 +34,12 @@ class FiltersToolBar(filteredList: FilteredList[LogEntry] val filtersProperty = new SimpleListProperty[Filter]() - filtersProperty.addListener(JfxUtils.mkListChangeListener[Filter](processFiltersChange)) + init() + + private def init(): Unit = { + filtersProperty.addListener(JfxUtils.mkListChangeListener[Filter](processFiltersChange)) + updateUnclassified() + } /** if list is changed in any way, react to this event and either add or remove filter from UI */ diff --git a/app/src/main/scala/app/logorrr/views/text/LogTextView.scala b/app/src/main/scala/app/logorrr/views/text/LogTextView.scala index 42d2b469..5a9e6259 100644 --- a/app/src/main/scala/app/logorrr/views/text/LogTextView.scala +++ b/app/src/main/scala/app/logorrr/views/text/LogTextView.scala @@ -34,13 +34,13 @@ class LogTextView(pathAsString: String val lv = new ListView[LogEntry]() lv.getStyleClass.add("dense") lv.setItems(filteredList) - val i = mutLogFileSettings.selectedIndexProperty.get() + val i = mutLogFileSettings.selectedLineNumber.get() lv.getSelectionModel.select(i) lv } listView.setCellFactory((_: ListView[LogEntry]) => new LogEntryListCell()) - mutLogFileSettings.selectedIndexProperty.addListener(JfxUtils.onNew((n: Number) => { + mutLogFileSettings.selectedLineNumber.addListener(JfxUtils.onNew((n: Number) => { Option(listView.getItems.filtered((t: LogEntry) => t.lineNumber == n.intValue()).get(0)) match { case Some(value) => val relativeIndex = listView.getItems.indexOf(value) diff --git a/app/src/main/scala/app/logorrr/views/visual/LogVisualView.scala b/app/src/main/scala/app/logorrr/views/visual/LogVisualView.scala index 6911f0dd..7ba5a1d2 100644 --- a/app/src/main/scala/app/logorrr/views/visual/LogVisualView.scala +++ b/app/src/main/scala/app/logorrr/views/visual/LogVisualView.scala @@ -5,7 +5,6 @@ import app.logorrr.model.LogEntry import app.logorrr.util.CanLog import app.logorrr.views.block.BlockViewPane import javafx.beans.property.SimpleObjectProperty -import javafx.beans.value.{ChangeListener, ObservableValue} import javafx.collections.ObservableList import javafx.scene.layout.BorderPane @@ -16,12 +15,8 @@ class LogVisualView(pathAsString: String, entries: ObservableList[LogEntry], can val selectedEntryProperty = new SimpleObjectProperty[LogEntry]() - val blockViewPane = new BlockViewPane[LogEntry] - blockViewPane.selectedElemProperty.addListener(new ChangeListener[LogEntry] { - override def changed(observable: ObservableValue[_ <: LogEntry], oldValue: LogEntry, newValue: LogEntry): Unit = { - LogoRRRGlobals.getLogFileSettings(pathAsString).setSelectedIndex(newValue.lineNumber) - } - }) + val blockViewPane = new BlockViewPane(pathAsString) + blockViewPane.filtersProperty.bind(LogoRRRGlobals.getLogFileSettings(pathAsString).filtersProperty) selectedEntryProperty.bind(blockViewPane.selectedElemProperty) blockViewPane.setCanvasWidth(canvasWidth) blockViewPane.setBlockSize(8) diff --git a/app/src/test/scala/app/logorrr/LogEntrySpec.scala b/app/src/test/scala/app/logorrr/LogEntrySpec.scala index cf165b56..4d173483 100644 --- a/app/src/test/scala/app/logorrr/LogEntrySpec.scala +++ b/app/src/test/scala/app/logorrr/LogEntrySpec.scala @@ -13,10 +13,9 @@ object LogEntrySpec { val gen: Gen[LogEntry] = for { l <- Gen.posNum[Int] - c <- Gen.const(Color.BLUE) value <- Gen.alphaStr someInstant <- Gen.const(None) - } yield LogEntry(l, c, value, someInstant) + } yield LogEntry(l, value, someInstant) } class LogEntrySpec extends AnyWordSpecLike { diff --git a/app/src/test/scala/app/logorrr/views/block/BlockViewDemoApp.scala b/app/src/test/scala/app/logorrr/views/block/BlockViewDemoApp.scala index 5a4974d3..5034bee0 100644 --- a/app/src/test/scala/app/logorrr/views/block/BlockViewDemoApp.scala +++ b/app/src/test/scala/app/logorrr/views/block/BlockViewDemoApp.scala @@ -16,7 +16,7 @@ import scala.util.Random */ object BlockViewDemoApp { - case class Block(index: Int, color: Color) extends BlockView.E + case class Block(index: Int, color: Color) val cols = Seq(Color.RED , Color.GREEN @@ -38,12 +38,12 @@ class BlockViewDemoApp extends javafx.application.Application { val nrElemsChoiceBox = new ChoiceBox[Int]() val elems = FXCollections.observableArrayList(1, 10, 100, 1000, 10000, 100000, 1000000, 10000000) - val blockViewPane = new BlockViewPane[BlockViewDemoApp.Block] + val blockViewPane = new BlockViewPane("string") nrElemsChoiceBox.setItems(elems) nrElemsChoiceBox.getSelectionModel().selectedIndexProperty().addListener(JfxUtils.onNew[Number](n => { val nrElems = elems.get(n.intValue()) val es = for (i <- 1 to nrElems) yield BlockViewDemoApp.Block(i, BlockViewDemoApp.cols(Random.nextInt(BlockViewDemoApp.cols.length))) - blockViewPane.setEntries(FXCollections.observableList(es.asJava)) + // blockViewPane.setEntries(FXCollections.observableList(es.asJava)) })) val slider = new Slider(5, 50, 5) diff --git a/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala b/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala index fed1f099..5e4bc192 100644 --- a/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala +++ b/app/src/test/scala/app/logorrr/views/text/FilterCalculatorSpec.scala @@ -84,7 +84,7 @@ class FilterCalculatorSpec extends LogoRRRSpec { , new Filter("b", Color.BLUE) , new Filter("t", Color.YELLOW) ) - val entry = LogEntry(0, Color.WHITE, "test a b c", None) + val entry = LogEntry(0, "test a b c", None) val calculator = FilterCalculator(entry, filters) "produce correct amount of matches" in { diff --git a/core/src/main/scala/app/logorrr/util/OsUtil.scala b/core/src/main/scala/app/logorrr/util/OsUtil.scala index f101ec94..20809a1e 100644 --- a/core/src/main/scala/app/logorrr/util/OsUtil.scala +++ b/core/src/main/scala/app/logorrr/util/OsUtil.scala @@ -27,9 +27,9 @@ object OsUtil { val isWin = currentOs == Windows // val isLinux = currentOs == Linux - val enableSecurityBookmarks = if (isMac) { - false - } else false + // for releases / mac installers this value should always be true + // set this flag only during development + val enableSecurityBookmarks = false //isMac def osFun[T](onWin: => T, onMac: => T, onLinux: => T): T = if (isWin) { diff --git a/pom.xml b/pom.xml index 3c752616..e98892a7 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ 23.3.0 2.13 - ${scala.major.version}.11 + ${scala.major.version}.12 21-ea+24 0.0.8