-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#104: implements a button to reset log entries in auto scroll mode
- Loading branch information
1 parent
1868689
commit 26c0144
Showing
3 changed files
with
32 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 25 additions & 4 deletions
29
app/src/main/scala/app/logorrr/views/autoscroll/AutoScrollCheckBox.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
})) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters