Skip to content

Commit

Permalink
#108: show filename in tab tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Nov 1, 2022
1 parent d42404b commit 86c6643
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
33 changes: 20 additions & 13 deletions app/src/main/scala/app/logorrr/views/LogFileTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,8 @@ object LogFileTab {
* */
class LogFileTab(val pathAsString: String
, val logEntries: ObservableList[LogEntry])
extends Tab
with CanLog {
extends Tab with CanLog {

selectedProperty().addListener(JfxUtils.onNew[java.lang.Boolean](b => {
if (b) {
setStyle(LogFileTab.BackgroundSelectedStyle)
} else {
setStyle(LogFileTab.BackgroundStyle)
}
}))

// lazy since only if autoscroll is set start tailer
lazy val logTailer = LogTailer(pathAsString, logEntries)
Expand Down Expand Up @@ -136,7 +128,6 @@ class LogFileTab(val pathAsString: String

private val logTextView = new LogTextView(pathAsString, filteredList, timings)

// val selectedEntryProperty = new SimpleObjectProperty[LogEntry]()

lazy val scrollToEndEventListener: InvalidationListener = (_: Observable) => {
logVisualView.scrollToEnd()
Expand Down Expand Up @@ -214,13 +205,19 @@ class LogFileTab(val pathAsString: String
} else {
}
}))
selectedProperty().addListener(JfxUtils.onNew[java.lang.Boolean](b => {
if (b) {
setStyle(LogFileTab.BackgroundSelectedStyle)
} else {
setStyle(LogFileTab.BackgroundStyle)
}
}))


/** don't monitor file anymore if tab is closed, free invalidation listeners */
setOnClosed(_ => closeTab())
textProperty.bind(computeTabTitle)
val tooltip = new Tooltip()
tooltip.textProperty().bind(Bindings.concat(Bindings.size(logEntries).asString, " lines"))
setTooltip(tooltip)
setTooltip(mkTabToolTip)

// selectedEntryProperty.bind(logVisualView.selectedEntryProperty)

Expand All @@ -244,6 +241,16 @@ class LogFileTab(val pathAsString: String
initFiltersPropertyListChangeListener()
}

/** compute tab tooltip */
private def mkTabToolTip: Tooltip = {
val tooltip = new Tooltip()
tooltip.textProperty().bind(Bindings.concat(
pathAsString, "\n",
Bindings.size(logEntries).asString, " lines")
)
tooltip
}

/** compute title of tab */
private def computeTabTitle: StringExpression = Bindings.concat(Paths.get(pathAsString).getFileName.toString)

Expand Down
4 changes: 2 additions & 2 deletions app/src/test/scala/app/logorrr/LogProducer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ case class SimpleWriter(path: Path) extends Runnable {

override def run(): Unit = {
var linenumber = 1
Files.write(path, util.Arrays.asList("started, waiting 30 secs ..."), StandardOpenOption.CREATE, StandardOpenOption.APPEND)
Thread.sleep(30000)
Files.write(path, util.Arrays.asList("started, waiting 20 secs ..."), StandardOpenOption.CREATE, StandardOpenOption.APPEND)
Thread.sleep(20000)
while (running) {
Thread.sleep(50)
val now = LocalDateTime.now();
Expand Down

0 comments on commit 86c6643

Please sign in to comment.