Skip to content

Commit

Permalink
Merge pull request #214 from CorbinH/unified-file-filtering
Browse files Browse the repository at this point in the history
Unified file filtering
  • Loading branch information
paul-griffith authored Jan 11, 2025
2 parents 5e40f10 + c37dd45 commit 5f3e4b2
Show file tree
Hide file tree
Showing 34 changed files with 1,739 additions and 475 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class MainPanel : JPanel(MigLayout("ins 6, fill, hidemode 3")) {

private val tabs = object : TabStrip() {
init {
name = "MainTabStrip"
isVisible = false

if (SystemInfo.isMacFullWindowContentSupported) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import io.github.inductiveautomation.kindling.core.DetailsPane
import io.github.inductiveautomation.kindling.core.Tool
import io.github.inductiveautomation.kindling.core.ToolOpeningException
import io.github.inductiveautomation.kindling.core.ToolPanel
import io.github.inductiveautomation.kindling.utils.ColorPalette
import io.github.inductiveautomation.kindling.utils.EDT_SCOPE
import io.github.inductiveautomation.kindling.utils.FileFilter
import io.github.inductiveautomation.kindling.utils.ReifiedJXTable
Expand All @@ -23,7 +24,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import net.miginfocom.swing.MigLayout
import org.jdesktop.swingx.JXSearchField
import org.jdesktop.swingx.decorator.ColorHighlighter
import java.awt.Color
import java.nio.file.Path
import javax.swing.JLabel
Expand Down Expand Up @@ -53,14 +53,10 @@ class AlarmCacheView(path: Path) : ToolPanel() {
).apply {
alarmStateColors.forEach { (state, colorPalette) ->
addHighlighter(
ColorHighlighter(
{ _, adapter ->
val viewRow = convertRowIndexToModel(adapter.row)
state == model[viewRow].state
},
colorPalette.background,
colorPalette.foreground,
),
colorPalette.toHighLighter { _, adapter ->
val viewRow = convertRowIndexToModel(adapter.row)
state == model[viewRow].state
},
)
}
}
Expand Down Expand Up @@ -153,17 +149,12 @@ class AlarmCacheView(path: Path) : ToolPanel() {
}
}

private data class AlarmStateColorPalette(
val background: Color,
val foreground: Color,
)

companion object {
private val alarmStateColors = mapOf(
AlarmState.ActiveAcked to AlarmStateColorPalette(Color(0xAB0000), Color(0xD0D0D0)),
AlarmState.ActiveUnacked to AlarmStateColorPalette(Color(0xEC2215), Color(0xD0D0D0)),
AlarmState.ClearAcked to AlarmStateColorPalette(Color(0xDCDCFE), Color(0x262626)),
AlarmState.ClearUnacked to AlarmStateColorPalette(Color(0x49ABAB), Color(0x262626)),
private val alarmStateColors: Map<AlarmState, ColorPalette> = mapOf(
AlarmState.ActiveAcked to ColorPalette(Color(0xAB0000), Color(0xD0D0D0)),
AlarmState.ActiveUnacked to ColorPalette(Color(0xEC2215), Color(0xD0D0D0)),
AlarmState.ClearAcked to ColorPalette(Color(0xDCDCFE), Color(0x262626)),
AlarmState.ClearUnacked to ColorPalette(Color(0x49ABAB), Color(0x262626)),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import javax.swing.JComponent
import javax.swing.JPopupMenu
import javax.swing.event.EventListenerList

fun interface Filter<T> {
fun interface Filter<in T> {
/**
* Return true if this filter should display this item.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,14 @@ data object Kindling {
},
)

val HighlightByDefault = preference(
name = "Highlight",
default = true,
editor = {
PreferenceCheckbox("Enable table highlighting by default for multiple log files.")
},
)

override val displayName: String = "General"
override val serialKey: String = "general"
override val preferences: List<Preference<*>> = listOf(
Expand All @@ -154,6 +162,7 @@ data object Kindling {
ShowFullLoggerNames,
ShowLogTree,
UseHyperlinks,
HighlightByDefault,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract class ToolPanel(
layoutConstraints: String = "ins 6, fill, hidemode 3",
) : JPanel(MigLayout(layoutConstraints)), FloatableComponent, PopupMenuCustomizer {
abstract override val icon: Icon?
override val tabName: String get() = name
override val tabName: String get() = name ?: this.paramString()
override val tabTooltip: String get() = toolTipText

override fun customizePopupMenu(menu: JPopupMenu) = Unit
Expand Down Expand Up @@ -61,7 +61,7 @@ abstract class ToolPanel(
}
}

@Suppress("ktlint:trailing-comma-on-declaration-site")
@Suppress("ktlint:standard:trailing-comma-on-declaration-site")
private enum class ExportFormat(
description: String,
val extension: String,
Expand Down
Loading

0 comments on commit 5f3e4b2

Please sign in to comment.