-
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.
#43: adds new toolbar and sliders to filter based on the timestamp of…
… a log entry
- Loading branch information
1 parent
52b9c61
commit 65e4bc5
Showing
8 changed files
with
162 additions
and
34 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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package app.logorrr.views.ops | ||
|
||
import app.logorrr.views.ops.time.TimeOpsToolBar | ||
import app.logorrr.views.search.{FiltersToolBar, OpsToolBar} | ||
import javafx.geometry.Pos | ||
import javafx.scene.layout.HBox | ||
import javafx.scene.layout.VBox | ||
|
||
|
||
/** | ||
* Container to horizontally align search, filters and settings | ||
*/ | ||
class OpsRegion(opsToolBar: OpsToolBar, filtersToolBar: FiltersToolBar) extends HBox { | ||
|
||
HBox.setHgrow(filtersToolBar, javafx.scene.layout.Priority.ALWAYS) | ||
setAlignment(Pos.CENTER_LEFT) | ||
opsToolBar.setMaxHeight(Double.PositiveInfinity) | ||
filtersToolBar.setMaxHeight(Double.PositiveInfinity) | ||
getChildren.addAll(opsToolBar, filtersToolBar) | ||
class OpsRegion(opsToolBar: OpsToolBar | ||
, filtersToolBar: FiltersToolBar | ||
, timeOpsToolBar: TimeOpsToolBar) extends VBox { | ||
getChildren.addAll(timeOpsToolBar, new StdOpsToolBar(opsToolBar, filtersToolBar)) | ||
|
||
} | ||
|
||
|
||
|
||
|
15 changes: 15 additions & 0 deletions
15
app/src/main/scala/app/logorrr/views/ops/StdOpsToolBar.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,15 @@ | ||
package app.logorrr.views.ops | ||
|
||
import app.logorrr.views.search.{FiltersToolBar, OpsToolBar} | ||
import javafx.geometry.Pos | ||
import javafx.scene.layout.HBox | ||
|
||
class StdOpsToolBar(opsToolBar: OpsToolBar, filtersToolBar: FiltersToolBar) extends HBox { | ||
|
||
HBox.setHgrow(filtersToolBar, javafx.scene.layout.Priority.ALWAYS) | ||
setAlignment(Pos.CENTER_LEFT) | ||
opsToolBar.setMaxHeight(Double.PositiveInfinity) | ||
filtersToolBar.setMaxHeight(Double.PositiveInfinity) | ||
getChildren.addAll(opsToolBar, filtersToolBar) | ||
|
||
} |
71 changes: 71 additions & 0 deletions
71
app/src/main/scala/app/logorrr/views/ops/time/TimeOpsToolBar.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,71 @@ | ||
package app.logorrr.views.ops.time | ||
|
||
import app.logorrr.conf.LogoRRRGlobals | ||
import app.logorrr.conf.mut.MutLogFileSettings | ||
import app.logorrr.io.FileId | ||
import app.logorrr.model.LogEntry | ||
import app.logorrr.views.block.ChunkListView | ||
import javafx.collections.ObservableList | ||
import javafx.collections.transformation.FilteredList | ||
import javafx.scene.control.{Label, ToolBar} | ||
|
||
import java.time.format.DateTimeFormatter | ||
|
||
object TimeOpsToolBar { | ||
|
||
private def updateFilteredList(filteredList: FilteredList[LogEntry], lower: Long, higher: Long): Unit = { | ||
filteredList.setPredicate((t: LogEntry) => { | ||
t.someInstant match { | ||
case Some(value) => | ||
val asMilli = value.toEpochMilli | ||
lower <= asMilli && asMilli <= higher | ||
case None => false | ||
} | ||
}) | ||
} | ||
|
||
} | ||
|
||
class TimeOpsToolBar(mutLogFileSettings: MutLogFileSettings | ||
, chunkListView: ChunkListView | ||
, logEntries: ObservableList[LogEntry] | ||
, filteredList: FilteredList[LogEntry]) extends ToolBar { | ||
|
||
val formatter: DateTimeFormatter = mutLogFileSettings.someLogEntrySettingsProperty.get().map(_.dateTimeFormatter).getOrElse(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")) | ||
val fileId: FileId = mutLogFileSettings.getFileId | ||
|
||
/** | ||
* To configure the logformat of the timestamp used in a logfile | ||
*/ | ||
val timestampSettingsButton = new TimestampSettingsButton(LogoRRRGlobals.getLogFileSettings(fileId), chunkListView, logEntries) | ||
|
||
val lowSlider = new TimerSlider(filteredList) | ||
lowSlider.setValue(lowSlider.getMin) | ||
lowSlider.disableProperty().bind(mutLogFileSettings.hasLogEntrySettingBinding.not) | ||
val highSlider = new TimerSlider(filteredList) | ||
highSlider.setValue(highSlider.getMax) | ||
highSlider.disableProperty().bind(mutLogFileSettings.hasLogEntrySettingBinding.not) | ||
val leftLabel = new Label() | ||
leftLabel.setText(TimerSlider.format(lowSlider.getValue.longValue(), formatter)) | ||
leftLabel.visibleProperty().bind(mutLogFileSettings.hasLogEntrySettingBinding) | ||
val rightLabel = new Label() | ||
rightLabel.setText(TimerSlider.format(highSlider.getValue.longValue(), formatter)) | ||
rightLabel.visibleProperty().bind(mutLogFileSettings.hasLogEntrySettingBinding) | ||
lowSlider.valueProperty.addListener((_, _, newValue) => { | ||
if (newValue.doubleValue > highSlider.getValue) lowSlider.setValue(highSlider.getValue) | ||
leftLabel.setText(TimerSlider.format(newValue.longValue, formatter)) | ||
TimeOpsToolBar.updateFilteredList(filteredList, newValue.longValue(), highSlider.getValue.longValue) | ||
}) | ||
|
||
highSlider.valueProperty.addListener((_, _, newValue) => { | ||
if (newValue.doubleValue < lowSlider.getValue) highSlider.setValue(lowSlider.getValue) | ||
rightLabel.setText(TimerSlider.format(newValue.longValue, formatter)) | ||
TimeOpsToolBar.updateFilteredList(filteredList, lowSlider.getValue.longValue, newValue.longValue()) | ||
}) | ||
|
||
getItems.addAll(Seq(timestampSettingsButton, leftLabel, lowSlider, highSlider, rightLabel): _*) | ||
|
||
} | ||
|
||
|
||
|
52 changes: 52 additions & 0 deletions
52
app/src/main/scala/app/logorrr/views/ops/time/TimerSlider.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,52 @@ | ||
package app.logorrr.views.ops.time | ||
|
||
import app.logorrr.model.LogEntry | ||
import javafx.collections.ObservableList | ||
import javafx.scene.control.Slider | ||
|
||
import java.time.format.DateTimeFormatter | ||
import java.time.{Instant, LocalDateTime, ZoneId} | ||
|
||
object TimerSlider { | ||
def format(epochMilli: Long, formatter: DateTimeFormatter): String = { | ||
val instant = Instant.ofEpochMilli(epochMilli) | ||
val dateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault) | ||
dateTime.format(formatter) | ||
} | ||
} | ||
|
||
class TimerSlider(filteredList: ObservableList[LogEntry]) extends Slider { | ||
/* | ||
def onChange(c: ListChangeListener.Change[_ <: LogEntry]): Unit = { | ||
while (c.next()) { | ||
updateMinMax() | ||
} | ||
} */ | ||
|
||
private def updateMinMax(): Unit = { | ||
if (2 <= filteredList.size) { | ||
var minInstant = Instant.MAX | ||
var maxInstant = Instant.MIN | ||
filteredList.forEach((e: LogEntry) => { | ||
e.someInstant match { | ||
case Some(instant) => | ||
if (instant.isBefore(minInstant)) { | ||
minInstant = instant | ||
} | ||
if (instant.isAfter(maxInstant)) { | ||
maxInstant = instant | ||
} | ||
case None => | ||
} | ||
}) | ||
setMin(minInstant.toEpochMilli.toDouble) | ||
setMax(maxInstant.toEpochMilli.toDouble) | ||
} | ||
} | ||
|
||
setPrefWidth(500) | ||
updateMinMax() | ||
// filteredList.addListener(JfxUtils.mkListChangeListener(onChange)) | ||
|
||
|
||
} |
2 changes: 1 addition & 1 deletion
2
...iews/search/TimestampSettingsButton.scala → ...ws/ops/time/TimestampSettingsButton.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