Skip to content

Commit

Permalink
#104: implements a button to reset log entries in auto scroll mode
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Nov 1, 2022
1 parent 1868689 commit 26c0144
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
2 changes: 1 addition & 1 deletion app/src/main/scala/app/logorrr/views/LogFileTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class LogFileTab(val pathAsString: String
val filteredList = new FilteredList[LogEntry](logEntries)

private val opsToolBar = {
val op = new OpsToolBar(pathAsString, addFilter)
val op = new OpsToolBar(pathAsString, addFilter, logEntries)
op.blockSizeProperty.set(LogoRRRGlobals.getLogFileSettings(pathAsString).blockWidthSettingsProperty.get())
op
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
package app.logorrr.views.autoscroll

import app.logorrr.conf.LogoRRRGlobals
import app.logorrr.model.LogIdAware
import javafx.scene.control.{CheckBox, Tooltip}
import app.logorrr.model.{LogEntry, LogIdAware}
import app.logorrr.util.JfxUtils
import javafx.collections.ObservableList
import javafx.scene.control.{CheckBox, ContextMenu, MenuItem, Tooltip}
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid
import org.kordamp.ikonli.javafx.FontIcon

class ClearLogMenuItem(logEntries: ObservableList[LogEntry]) extends MenuItem("clear log") {
setOnAction(_ => {
logEntries.clear()
})
setGraphic(new FontIcon(FontAwesomeSolid.TRASH))
}

class AutoScrollCheckBox(val pathAsString: String) extends CheckBox with LogIdAware {
class AutoScrollCheckBox(val pathAsString: String
, logEntries: ObservableList[LogEntry]) extends CheckBox with LogIdAware {
setTooltip(new Tooltip("autoscroll"))

val cm = new ContextMenu(new ClearLogMenuItem(logEntries))
selectedProperty().bindBidirectional(LogoRRRGlobals.getLogFileSettings(pathAsString).autoScrollProperty)

selectedProperty().addListener(JfxUtils.onNew[java.lang.Boolean]({
selected =>
if (selected) {
if (Option(getContextMenu).isEmpty) {
setContextMenu(cm)
}
} else {
setContextMenu(null)
}
}))
}
8 changes: 6 additions & 2 deletions app/src/main/scala/app/logorrr/views/search/OpsToolBar.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package app.logorrr.views.search

import app.logorrr.model.LogEntry
import app.logorrr.util.OsUtil
import app.logorrr.views.autoscroll.AutoScrollCheckBox
import app.logorrr.views.block.HasBlockSizeProperty
import app.logorrr.views.ops.{DecreaseBlockSizeButton, IncreaseBlockSizeButton}
import app.logorrr.views.text.{DecreaseTextSizeButton, IncreaseTextSizeButton}
import javafx.beans.property.SimpleIntegerProperty
import javafx.collections.ObservableList
import javafx.scene.control._
import javafx.scene.input.{KeyCode, KeyEvent}

Expand Down Expand Up @@ -33,7 +35,9 @@ object OpsToolBar {
*
* @param addFilterFn filter function which results from user interaction with SearchToolbar
*/
class OpsToolBar(pathAsString: String, addFilterFn: Filter => Unit)
class OpsToolBar(pathAsString: String
, addFilterFn: Filter => Unit
, logEntries: ObservableList[LogEntry])
extends ToolBar
with HasBlockSizeProperty {

Expand All @@ -57,7 +61,7 @@ class OpsToolBar(pathAsString: String, addFilterFn: Filter => Unit)

private val searchButton = new SearchButton(searchTextField, regexToggleButton, colorPicker, addFilterFn)

val autoScrollCheckBox = new AutoScrollCheckBox(pathAsString)
val autoScrollCheckBox = new AutoScrollCheckBox(pathAsString, logEntries)

def execSearchOnHitEnter(event: KeyEvent): Unit = {
if (event.getCode == KeyCode.ENTER) {
Expand Down

0 comments on commit 26c0144

Please sign in to comment.