Skip to content

Commit

Permalink
Merge pull request #195 from rladstaetter/188-close-all-log-files-sta…
Browse files Browse the repository at this point in the history
…rt-screen-is-not-shown

188 close all log files start screen is not shown
  • Loading branch information
rladstaetter authored Dec 27, 2023
2 parents cd3a52a + 63152a2 commit f7e40d1
Show file tree
Hide file tree
Showing 10 changed files with 167 additions and 147 deletions.
11 changes: 4 additions & 7 deletions app/src/main/scala/app/logorrr/views/logfiletab/LogFileTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import app.logorrr.model.LogEntry
import app.logorrr.util._
import app.logorrr.views.LogoRRRAccelerators
import app.logorrr.views.autoscroll.LogTailer
import app.logorrr.views.logfiletab.actions._
import app.logorrr.views.search.Fltr
import javafx.beans.binding.Bindings
import javafx.collections.{ListChangeListener, ObservableList}
Expand Down Expand Up @@ -99,7 +100,7 @@ class LogFileTab(val mutLogFileSettings: MutLogFileSettings
})


def recalculateChunkListViewAndScrollToActiveElement() :Unit = {
def recalculateChunkListViewAndScrollToActiveElement(): Unit = {
logFileTabContent.recalculateChunkListView()
logFileTabContent.scrollToActiveElement()
}
Expand All @@ -114,7 +115,7 @@ class LogFileTab(val mutLogFileSettings: MutLogFileSettings
logFileTabContent.init()

/** don't monitor file anymore if tab is closed, free listeners */
setOnCloseRequest((_: Event) => cleanupBeforeClose())
setOnCloseRequest((_: Event) => shutdown())

if (mutLogFileSettings.isAutoScrollActive) {
startTailer()
Expand Down Expand Up @@ -166,11 +167,6 @@ class LogFileTab(val mutLogFileSettings: MutLogFileSettings
menu
}

def cleanupBeforeClose(): Unit = {
shutdown()
LogoRRRGlobals.removeLogFile(pathAsString)
}

private def addListeners(): Unit = {
selectedProperty().addListener(selectedListener)

Expand All @@ -195,6 +191,7 @@ class LogFileTab(val mutLogFileSettings: MutLogFileSettings
stopTailer()
}
removeListeners()
LogoRRRGlobals.removeLogFile(pathAsString)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import javafx.scene.layout.BorderPane
class LogFileTabContent(mutLogFileSettings: MutLogFileSettings
, val entries: ObservableList[LogEntry]) extends BorderPane {

// make sure we have a white background for our tabs - see https://github.com/rladstaetter/LogoRRR/issues/188
setStyle("-fx-background-color: white;")

/** list which holds all entries, default to display all (can be changed via buttons) */
private val filteredList = new FilteredList[LogEntry](entries)

Expand All @@ -34,7 +37,7 @@ class LogFileTabContent(mutLogFileSettings: MutLogFileSettings

def addTailerListener(): Unit = filteredList.addListener(scrollToEndEventListener)

def removeTailerListener() = filteredList.removeListener(scrollToEndEventListener)
def removeTailerListener(): Unit = filteredList.removeListener(scrollToEndEventListener)

val opsToolBar = new OpsToolBar(mutLogFileSettings.getPathAsString(), addFilter, entries, filteredList, mutLogFileSettings.blockSizeProperty)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package app.logorrr.views.logfiletab.actions

import app.logorrr.views.logfiletab.LogFileTab
import javafx.scene.control.{MenuItem, Tab}

import scala.jdk.CollectionConverters.CollectionHasAsScala

class CloseAllFilesMenuItem(fileTab: => LogFileTab) extends MenuItem("Close All Files") {
private val tabPane = fileTab.getTabPane
setOnAction(_ => {
val toBeDeleted: Seq[Tab] = {
tabPane.getTabs.asScala.flatMap { t =>
t.asInstanceOf[LogFileTab].shutdown()
Option(t)
}.toSeq
}
tabPane.getTabs.removeAll(toBeDeleted: _*)
})

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package app.logorrr.views.logfiletab.actions

import app.logorrr.views.logfiletab.LogFileTab
import javafx.scene.control.{MenuItem, Tab}

import scala.jdk.CollectionConverters.CollectionHasAsScala

class CloseLeftFilesMenuItem(fileTab: => LogFileTab) extends MenuItem("Close Files to the Left") {
private val tabPane = fileTab.getTabPane
setOnAction(_ => {
var deletethem = true
val toBeDeleted: Seq[Tab] = {
tabPane.getTabs.asScala.flatMap { t =>
if (t.asInstanceOf[LogFileTab].pathAsString == fileTab.pathAsString) {
deletethem = false
None
} else {
if (deletethem) {
t.asInstanceOf[LogFileTab].shutdown()
Option(t)
} else {
None
}
}
}.toSeq
}
tabPane.getTabs.removeAll(toBeDeleted: _*)
})

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package app.logorrr.views.logfiletab.actions

import app.logorrr.views.logfiletab.LogFileTab
import javafx.scene.control.MenuItem

class CloseMenuItem(fileTab: => LogFileTab) extends MenuItem("Close") {

setOnAction(_ => Option(fileTab.getTabPane.getSelectionModel.getSelectedItem).foreach { t =>
fileTab.shutdown()
fileTab.getTabPane.getTabs.remove(t)
})

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package app.logorrr.views.logfiletab.actions

import app.logorrr.views.logfiletab.LogFileTab
import javafx.scene.control.{MenuItem, Tab}

import scala.jdk.CollectionConverters.CollectionHasAsScala

class CloseOtherFilesMenuItem(fileTab: => LogFileTab) extends MenuItem("Close Other Files") {
private val tabPane = fileTab.getTabPane
setOnAction(_ => {
val toBeDeleted: Seq[Tab] = {
tabPane.getTabs.asScala.flatMap { t =>
if (t.asInstanceOf[LogFileTab].pathAsString == fileTab.pathAsString) {
None
} else {
t.asInstanceOf[LogFileTab].shutdown()
Option(t)
}
}.toSeq
}
tabPane.getTabs.removeAll(toBeDeleted: _*)
})

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package app.logorrr.views.logfiletab.actions

import app.logorrr.views.logfiletab.LogFileTab
import javafx.scene.control.{MenuItem, Tab}

import scala.jdk.CollectionConverters.CollectionHasAsScala


class CloseRightFilesMenuItem(fileTab: => LogFileTab) extends MenuItem("Close Files to the Right") {
private val tabPane = fileTab.getTabPane
setOnAction(_ => {
var deletethem = false
val toBeDeleted: Seq[Tab] = {
tabPane.getTabs.asScala.flatMap { t =>
if (t.asInstanceOf[LogFileTab].pathAsString == fileTab.pathAsString) {
deletethem = true
None
} else {
if (deletethem) {
t.asInstanceOf[LogFileTab].shutdown()
Option(t)
} else {
None
}
}
}.toSeq
}
tabPane.getTabs.removeAll(toBeDeleted: _*)
})

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package app.logorrr.views.logfiletab.actions

import app.logorrr.util.OsUtil
import javafx.scene.control.MenuItem

import java.awt.Desktop
import java.nio.file.Paths

object OpenInFinderMenuItem {
val menuItemText: String = if (OsUtil.isWin) {
"Show Log in Explorer"
} else if (OsUtil.isMac) {
"Show Log in Finder"
} else {
"Show Log ..."
}
}

class OpenInFinderMenuItem(pathAsString: String) extends MenuItem(OpenInFinderMenuItem.menuItemText) {

setOnAction(_ => Desktop.getDesktop.open(Paths.get(pathAsString).getParent.toFile))

}
Loading

0 comments on commit f7e40d1

Please sign in to comment.