Skip to content

Commit

Permalink
#114: cleanup ops region
Browse files Browse the repository at this point in the history
  • Loading branch information
rladstaetter committed Oct 29, 2022
1 parent d425a5e commit e8f4921
Show file tree
Hide file tree
Showing 20 changed files with 290 additions and 271 deletions.
43 changes: 23 additions & 20 deletions app/src/main/scala/app/logorrr/views/LogFileTab.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package app.logorrr.views
import app.logorrr.conf.{BlockSettings, LogoRRRGlobals}
import app.logorrr.model.{LogEntry, LogFileSettings}
import app.logorrr.util._
import app.logorrr.views.search.{Filter, FiltersToolBar, Fltr, SearchToolBar}
import app.logorrr.views.ops.{OpsRegion, SettingsOps}
import app.logorrr.views.search.{Filter, FiltersToolBar, Fltr, OpsToolBar}
import app.logorrr.views.text.LogTextView
import app.logorrr.views.visual.LogVisualView
import javafx.beans.binding.{Bindings, StringExpression}
Expand Down Expand Up @@ -103,20 +104,22 @@ class LogFileTab(val pathAsString: String
/** list which holds all entries, default to display all (can be changed via buttons) */
val filteredList = new FilteredList[LogEntry](logEntries)

private val searchToolBar = new SearchToolBar(addFilter)
private val opsToolBar = {
val op = new OpsToolBar(pathAsString, addFilter)
op.blockSizeProperty.set(LogoRRRGlobals.getLogFileSettings(pathAsString).blockWidthSettingsProperty.get())
op
}

private val filtersToolBar = {
val fbtb = new FiltersToolBar(filteredList, removeFilter)
fbtb.filtersProperty.bind(filtersListProperty)
fbtb
}

val settingsToolBar = new SettingsToolBar(pathAsString)
val settingsOps = new SettingsOps(pathAsString)

val opsBorderPane: OpsBorderPane = {
val op = new OpsBorderPane(pathAsString, searchToolBar, filtersToolBar, settingsToolBar)
op.blockSizeProperty.set(LogoRRRGlobals.getLogFileSettings(pathAsString).blockWidthSettingsProperty.get())
op.fontSizeProperty.set(LogoRRRGlobals.getLogFileSettings(pathAsString).fontSizeProperty.get())
val opsRegion: OpsRegion = {
val op = new OpsRegion(opsToolBar, filtersToolBar, settingsOps)
op
}

Expand Down Expand Up @@ -163,20 +166,20 @@ class LogFileTab(val pathAsString: String

/** top component for log view */
val borderPane = new BorderPane()
borderPane.setTop(opsBorderPane)
borderPane.setTop(opsRegion)
borderPane.setCenter(splitPane)
setContent(borderPane)

logVisualView.blockViewPane.blockSizeProperty.bind(opsBorderPane.blockSizeProperty)
logVisualView.blockViewPane.blockSizeProperty.bind(opsRegion.opsToolBar.blockSizeProperty)
logVisualView.blockViewPane.blockSizeProperty.addListener(JfxUtils.onNew[Number](n => {
LogoRRRGlobals.setBlockSettings(pathAsString, BlockSettings(n.intValue()))
}))

/* change active text field depending on visible tab */
selectedProperty().addListener(JfxUtils.onNew[java.lang.Boolean](b => {
if (b) {
LogoRRRAccelerators.setActiveSearchTextField(searchToolBar.searchTextField)
LogoRRRAccelerators.setActiveRegexToggleButton(searchToolBar.regexToggleButton)
LogoRRRAccelerators.setActiveSearchTextField(opsToolBar.searchTextField)
LogoRRRAccelerators.setActiveRegexToggleButton(opsToolBar.regexToggleButton)
JfxUtils.execOnUiThread(repaint())
} else {
}
Expand Down Expand Up @@ -237,15 +240,15 @@ class LogFileTab(val pathAsString: String

def removeFilter(filter: Filter): Unit = filtersListProperty.remove(filter)


def getVisualViewWidth(): Double = {
val w = splitPane.getDividers.get(0).getPosition * splitPane.getWidth
if (w != 0.0) {
w
} else {
initialWidth.doubleValue()
/*
def getVisualViewWidth(): Double = {
val w = splitPane.getDividers.get(0).getPosition * splitPane.getWidth
if (w != 0.0) {
w
} else {
initialWidth.doubleValue()
}
}
}

*/

}
95 changes: 0 additions & 95 deletions app/src/main/scala/app/logorrr/views/OpsBorderPane.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import javafx.scene.layout.VBox
import scala.collection.mutable.ListBuffer




class BlockViewPane[Elem <: BlockView.E]
extends ScrollPane
with HasBlockSizeProperty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ trait HasBlockSizeProperty {

def getBlockSize(): Int = blockSizeProperty.get()


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

import app.logorrr.views.block.HasBlockSizeProperty
import app.logorrr.views.search.OpsToolBar
import javafx.beans.property.SimpleIntegerProperty
import javafx.scene.paint.Color

class DecreaseBlockSizeButton(val blockSizeProperty: SimpleIntegerProperty) extends
RectButton(2 * OpsToolBar.blockSizeStep
, 2 * OpsToolBar.blockSizeStep
, Color.GRAY
, "decrease block size") with HasBlockSizeProperty {

setOnAction(_ => {
if (getBlockSize() - OpsToolBar.blockSizeStep > 0) {
setBlockSize(getBlockSize() - OpsToolBar.blockSizeStep)
}
})

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

import app.logorrr.views.block.HasBlockSizeProperty
import app.logorrr.views.search.OpsToolBar
import javafx.beans.property.SimpleIntegerProperty
import javafx.scene.paint.Color

class IncreaseBlockSizeButton(val blockSizeProperty: SimpleIntegerProperty) extends
RectButton(2 * OpsToolBar.blockSizeStep
, 2 * OpsToolBar.blockSizeStep
, Color.GRAY
, "increase block size") with HasBlockSizeProperty {

setOnAction(_ => {
if (getBlockSize() + OpsToolBar.blockSizeStep < 10 * OpsToolBar.blockSizeStep) {
setBlockSize(getBlockSize() + OpsToolBar.blockSizeStep)
}
})

}
22 changes: 22 additions & 0 deletions app/src/main/scala/app/logorrr/views/ops/OpsRegion.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package app.logorrr.views.ops

import app.logorrr.views.search.{FiltersToolBar, OpsToolBar}
import javafx.geometry.Pos
import javafx.scene.layout.HBox


/**
* Container to horizontally align search, filters and settings
*/
class OpsRegion(val opsToolBar: OpsToolBar
, filtersToolBar: FiltersToolBar
, settingsToolBar: SettingsOps)
extends HBox {

opsToolBar.setMaxHeight(Double.PositiveInfinity)
filtersToolBar.setMaxHeight(Double.PositiveInfinity)
setAlignment(Pos.CENTER_LEFT)
getChildren.addAll(opsToolBar, filtersToolBar)

}

Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package app.logorrr.views.block
package app.logorrr.views.ops

import app.logorrr.util.ColorUtil
import javafx.event.{ActionEvent, EventHandler}
import javafx.scene.control.Button
import javafx.scene.control.{Button, Tooltip}
import javafx.scene.input.{KeyCode, KeyEvent}
import javafx.scene.paint.Color

Expand All @@ -14,12 +13,14 @@ import javafx.scene.paint.Color
* @param color color of rectangle
* @param eventHandler
*/
class RectButton(width: Int
, height: Int
, color: Color
, eventHandler: EventHandler[ActionEvent]) extends Button {
abstract class RectButton(width: Int
, height: Int
, color: Color
, tooltipMessage: String) extends Button {

setTooltip(new Tooltip(tooltipMessage))

setGraphic(ColorUtil.mkR(width, height, color))
setOnAction(eventHandler)
setOnKeyPressed((event: KeyEvent) => {
if (event.getCode == KeyCode.ENTER) {
fire()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package app.logorrr.views
package app.logorrr.views.ops

import app.logorrr.model.LogEntryInstantFormat
import app.logorrr.util.JfxUtils
import app.logorrr.views.SettingsBorderPane
import javafx.scene.Scene
import javafx.scene.control.{Button, ToolBar}
import javafx.stage.{Modality, Stage}


/* container to host settings button, positioned to the right of the application / separate for each log view */
class SettingsToolBar(pathAsString: String) extends ToolBar {
class SettingsOps(pathAsString: String) extends ToolBar {
private val settingsButton = new Button("Settings")
settingsButton.setOnAction(_ => {
val stage = new Stage()
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/scala/app/logorrr/views/ops/TextSizeButton.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package app.logorrr.views.ops

import app.logorrr.util.LogoRRRFonts
import app.logorrr.views.text.HasFontSizeProperty
import javafx.scene.control.{Button, Label, Tooltip}
import javafx.scene.input.{KeyCode, KeyEvent}
import javafx.scene.paint.Color

abstract class TextSizeButton(size: Int, tooltipMessage: String)
extends Button
with HasFontSizeProperty {

private val label = new Label("T")
label.setStyle(LogoRRRFonts.jetBrainsMono(size))
label.setTextFill(Color.DARKGREY)
setGraphic(label)
setTooltip(new Tooltip(tooltipMessage))
setOnKeyPressed((event: KeyEvent) => {
if (event.getCode == KeyCode.ENTER) {
fire()
}
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app.logorrr.views.search

import app.logorrr.model.LogEntry
import app.logorrr.util.JfxUtils
import app.logorrr.views.search
import javafx.beans.property.SimpleListProperty
import javafx.collections.ListChangeListener
import javafx.collections.transformation.FilteredList
Expand Down Expand Up @@ -38,7 +37,7 @@ object FiltersToolBar {
class FiltersToolBar(filteredList: FilteredList[LogEntry]
, removeFilter: Filter => Unit) extends ToolBar {

// setStyle(FiltersToolBar.BackgroundSelectedStyle)
// setStyle(FiltersToolBar.BackgroundSelectedStyle)

val filtersProperty = new SimpleListProperty[Filter]()

Expand Down Expand Up @@ -92,7 +91,7 @@ class FiltersToolBar(filteredList: FilteredList[LogEntry]

private def addSearchTag(filter: Filter): Unit = {
updateOccurrences(filter)
val searchTag = search.SearchTag(filter, occurrences, updateActiveFilter, removeFilter)
val searchTag = SearchTag(filter, occurrences, updateActiveFilter, removeFilter)
getItems.add(searchTag)
filterButtons = filterButtons + (filter -> searchTag)
}
Expand Down
Loading

0 comments on commit e8f4921

Please sign in to comment.