-
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.
#112: introduces a dedicated button to clear the log file
- Loading branch information
1 parent
186ec2a
commit 395be60
Showing
4 changed files
with
27 additions
and
30 deletions.
There are no files selected for viewing
29 changes: 4 additions & 25 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,34 +1,13 @@ | ||
package app.logorrr.views.autoscroll | ||
|
||
import app.logorrr.conf.LogoRRRGlobals | ||
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 | ||
import app.logorrr.model.LogIdAware | ||
import javafx.scene.control.{CheckBox, Tooltip} | ||
|
||
class ClearLogMenuItem(logEntries: ObservableList[LogEntry]) extends MenuItem("clear log") { | ||
setOnAction(_ => { | ||
logEntries.clear() | ||
}) | ||
setGraphic(new FontIcon(FontAwesomeSolid.TRASH)) | ||
} | ||
|
||
class AutoScrollCheckBox(val pathAsString: String | ||
, logEntries: ObservableList[LogEntry]) extends CheckBox with LogIdAware { | ||
class AutoScrollCheckBox(val pathAsString: String) 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) | ||
} | ||
})) | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
app/src/main/scala/app/logorrr/views/ops/ClearLogButton.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package app.logorrr.views.ops | ||
|
||
import app.logorrr.model.LogEntry | ||
import javafx.collections.ObservableList | ||
import javafx.scene.control.{Button, Tooltip} | ||
import org.kordamp.ikonli.fontawesome5.FontAwesomeSolid | ||
import org.kordamp.ikonli.javafx.FontIcon | ||
|
||
class ClearLogButton(logEntries: ObservableList[LogEntry]) extends Button { | ||
private val icon = new FontIcon(FontAwesomeSolid.TRASH) | ||
setGraphic(icon) | ||
setTooltip(new Tooltip("clear log file")) | ||
setOnAction(_ => { | ||
logEntries.clear() | ||
}) | ||
} |
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
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