-
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: implements a basic autoscroll behavior for TextView
- Loading branch information
1 parent
dd259c2
commit 83a0b45
Showing
21 changed files
with
276 additions
and
97 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package app.logorrr.model | ||
|
||
trait LogIdAware { | ||
|
||
def pathAsString: String | ||
} |
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 was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package app.logorrr.views.autoscroll | ||
|
||
import app.logorrr.conf.LogoRRRGlobals | ||
import app.logorrr.model.LogIdAware | ||
import javafx.scene.control.{CheckBox, Tooltip} | ||
|
||
|
||
class AutoScrollCheckBox(val pathAsString: String) extends CheckBox with LogIdAware { | ||
setTooltip(new Tooltip("autoscroll")) | ||
|
||
selectedProperty().bindBidirectional(LogoRRRGlobals.getLogFileSettings(pathAsString).autoScrollProperty) | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/scala/app/logorrr/views/autoscroll/AutoScroller.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,13 @@ | ||
package app.logorrr.views.autoscroll | ||
|
||
import app.logorrr.conf.LogoRRRGlobals | ||
import app.logorrr.model.LogIdAware | ||
|
||
trait AutoScroller { | ||
autoScroller: LogIdAware => | ||
|
||
def setAutoScroll(autoScroll: Boolean): Unit = LogoRRRGlobals.getLogFileSettings(pathAsString).setAutoScroll(autoScroll) | ||
|
||
def isAutoScroll(): Boolean = LogoRRRGlobals.getLogFileSettings(pathAsString).isAutoScroll() | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
...a/app/logorrr/util/LogEntryListener.scala → ...r/views/autoscroll/LogEntryListener.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
43 changes: 43 additions & 0 deletions
43
app/src/main/scala/app/logorrr/views/autoscroll/LogTailer.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,43 @@ | ||
package app.logorrr.views.autoscroll | ||
|
||
import app.logorrr.model.LogEntry | ||
import app.logorrr.util.CanLog | ||
import javafx.collections.ObservableList | ||
import org.apache.commons.io.input.Tailer | ||
|
||
import java.nio.file.Paths | ||
|
||
/** | ||
* If active, this class adds entries to the given logEntries observable list. | ||
* @param pathAsString path to log file | ||
* @param logEntries list which will be modified if log file changes | ||
*/ | ||
case class LogTailer(pathAsString: String | ||
, logEntries: ObservableList[LogEntry]) | ||
extends CanLog { | ||
|
||
var currentTailer: Option[Tailer] = None | ||
|
||
private def mkTailer(): Tailer = new Tailer(Paths.get(pathAsString).toFile, new LogEntryListener(pathAsString, logEntries), 40, true) | ||
|
||
/** start observing log file for changes */ | ||
def start(): Unit = synchronized { | ||
currentTailer match { | ||
case Some(value) => logWarn("Not starting new LogTailer, already one in progress ...") | ||
case None => | ||
currentTailer = Option(mkTailer()) | ||
timeR(currentTailer.foreach(t => new Thread(t).start()), s"Started LogTailer for file $pathAsString") | ||
} | ||
} | ||
|
||
def stop(): Unit = timeR({ | ||
currentTailer match { | ||
case Some(tailer) => | ||
tailer.stop() | ||
currentTailer = None | ||
case None => | ||
logWarn("No LogTailer was active, ignoring ...") | ||
} | ||
}, s"Stopped LogTailer for file $pathAsString") | ||
|
||
} |
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
4 changes: 2 additions & 2 deletions
4
app/src/main/scala/app/logorrr/views/text/HasFontSizeProperty.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
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
Oops, something went wrong.