Skip to content

Commit

Permalink
#152: add option to open given log file in explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Oct 22, 2023
1 parent 0c5f777 commit 533542b
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion app/src/main/scala/app/logorrr/views/logfiletab/LogFileTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import javafx.collections.{ListChangeListener, ObservableList}
import javafx.scene.control._
import javafx.scene.layout._

import java.awt.Desktop
import java.lang
import java.nio.file.Paths
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

Expand Down Expand Up @@ -47,9 +49,22 @@ object LogFileTab {
logFileTab
}

private def mkOpenInFinderItem(pathAsString : String): MenuItem = {
val text = if (OsUtil.isWin) {
"Show Log in Explorer"
} else if (OsUtil.isMac) {
"Show Log in Finder"
} else {
"Show Log ..."
}
val mi = new MenuItem(text)
mi.setOnAction(e => {
Desktop.getDesktop.open(Paths.get(pathAsString).getParent.toFile)
})
mi
}
}


/**
* Represents a single 'document' UI approach for a log file.
*
Expand All @@ -61,6 +76,11 @@ class LogFileTab(val pathAsString: String
, val logEntries: ObservableList[LogEntry])
extends Tab with TimerCode with CanLog {

val openInFinderItem = LogFileTab.mkOpenInFinderItem(pathAsString)

val cm = new ContextMenu(openInFinderItem)
setContextMenu(cm)

// lazy since only if autoscroll is set start tailer
private lazy val logTailer = LogTailer(pathAsString, logEntries)

Expand Down

0 comments on commit 533542b

Please sign in to comment.