Skip to content

Commit

Permalink
add pattern condition about match case
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcsgit committed Feb 26, 2021
1 parent 183db8b commit ab04648
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 24 deletions.
79 changes: 55 additions & 24 deletions src/com/blogspot/kotlinstudy/lognote/LogTableModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterShowLog: String = ""
set(value) {
try {
mPatternShowLog = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternShowLog = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -100,7 +100,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterHideLog: String = ""
set(value) {
try {
mPatternHideLog = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternHideLog = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -112,7 +112,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterHighlightLog: String = ""
set(value) {
try {
mPatternHighlightLog = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternHighlightLog = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -132,7 +132,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterShowTag: String = ""
set(value) {
try {
mPatternShowTag = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternShowTag = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -144,7 +144,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterHideTag: String = ""
set(value) {
try {
mPatternHideTag = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternHideTag = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -164,7 +164,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterShowPid: String = ""
set(value) {
try {
mPatternShowPid = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternShowPid = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -173,10 +173,11 @@ class LogTableModel() : AbstractTableModel() {
ex.printStackTrace()
}
}

var mFilterHidePid: String = ""
set(value) {
try {
mPatternHidePid = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternHidePid = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -196,7 +197,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterShowTid: String = ""
set(value) {
try {
mPatternShowTid = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternShowTid = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -208,7 +209,7 @@ class LogTableModel() : AbstractTableModel() {
var mFilterHideTid: String = ""
set(value) {
try {
mPatternHideTid = Pattern.compile(value, Pattern.CASE_INSENSITIVE)
mPatternHideTid = Pattern.compile(value, mPatternCase)
if (field != value) {
mIsFilterUpdated = true
}
Expand All @@ -218,6 +219,32 @@ class LogTableModel() : AbstractTableModel() {
}
}

private var mPatternCase = Pattern.CASE_INSENSITIVE
var mMatchCase: Boolean = false
set(value) {
if (field != value) {
if (value == false) {
mPatternCase = Pattern.CASE_INSENSITIVE
} else {
mPatternCase = 0
}

mPatternShowLog = Pattern.compile(mFilterShowLog, mPatternCase)
mPatternHideLog = Pattern.compile(mFilterHideLog, mPatternCase)
mPatternHighlightLog = Pattern.compile(mFilterHighlightLog, mPatternCase)
mPatternShowTag = Pattern.compile(mFilterShowTag, mPatternCase)
mPatternHideTag = Pattern.compile(mFilterHideTag, mPatternCase)
mPatternShowPid = Pattern.compile(mFilterShowPid, mPatternCase)
mPatternHidePid = Pattern.compile(mFilterHidePid, mPatternCase)
mPatternShowTid = Pattern.compile(mFilterShowTid, mPatternCase)
mPatternHideTid = Pattern.compile(mFilterHideTid, mPatternCase)

mIsFilterUpdated = true

field = value
}
}

var mGoToLast = true
// set(value) {
// field = value
Expand Down Expand Up @@ -270,15 +297,15 @@ class LogTableModel() : AbstractTableModel() {
field = value
}

var mPatternShowLog = Pattern.compile(mFilterShowLog, Pattern.CASE_INSENSITIVE)
var mPatternHideLog = Pattern.compile(mFilterHideLog, Pattern.CASE_INSENSITIVE)
var mPatternHighlightLog = Pattern.compile(mFilterHighlightLog, Pattern.CASE_INSENSITIVE)
var mPatternShowTag = Pattern.compile(mFilterShowTag, Pattern.CASE_INSENSITIVE)
var mPatternHideTag = Pattern.compile(mFilterHideTag, Pattern.CASE_INSENSITIVE)
var mPatternShowPid = Pattern.compile(mFilterShowPid, Pattern.CASE_INSENSITIVE)
var mPatternHidePid = Pattern.compile(mFilterHidePid, Pattern.CASE_INSENSITIVE)
var mPatternShowTid = Pattern.compile(mFilterShowTid, Pattern.CASE_INSENSITIVE)
var mPatternHideTid = Pattern.compile(mFilterHideTid, Pattern.CASE_INSENSITIVE)
var mPatternShowLog = Pattern.compile(mFilterShowLog, mPatternCase)
var mPatternHideLog = Pattern.compile(mFilterHideLog, mPatternCase)
var mPatternHighlightLog = Pattern.compile(mFilterHighlightLog, mPatternCase)
var mPatternShowTag = Pattern.compile(mFilterShowTag, mPatternCase)
var mPatternHideTag = Pattern.compile(mFilterHideTag, mPatternCase)
var mPatternShowPid = Pattern.compile(mFilterShowPid, mPatternCase)
var mPatternHidePid = Pattern.compile(mFilterHidePid, mPatternCase)
var mPatternShowTid = Pattern.compile(mFilterShowTid, mPatternCase)
var mPatternHideTid = Pattern.compile(mFilterHideTid, mPatternCase)

private val COLOR_NONE = Color(0x00, 0x00, 0x00)
private val COLOR_VERBOSE = Color(0x00, 0x00, 0x00)
Expand Down Expand Up @@ -378,12 +405,16 @@ class LogTableModel() : AbstractTableModel() {
mFilteredItemsThread = Thread(Runnable {
run {
while (true) {
if (mIsFilterUpdated) {
mMainUI?.markLine()
makeFilteredItems()
mMainUI?.goToMarkedLine()
try {
if (mIsFilterUpdated) {
mMainUI?.markLine()
makeFilteredItems()
mMainUI?.goToMarkedLine()
}
Thread.sleep(100)
} catch (e:Exception) {
println("loadItems thread e : $e")
}
Thread.sleep(100)
}
}
})
Expand Down Expand Up @@ -729,7 +760,7 @@ class LogTableModel() : AbstractTableModel() {
}

if (!skip) {
mPatternPrintValue = Pattern.compile(filterPrintValue, Pattern.CASE_INSENSITIVE)
mPatternPrintValue = Pattern.compile(filterPrintValue, mPatternCase)
mBaseModel?.mPatternPrintValue = mPatternPrintValue
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/com/blogspot/kotlinstudy/lognote/MainUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class MainUI(title: String) : JFrame() {

private lateinit var mLogPanel: JPanel
private lateinit var mShowLogPanel: JPanel
private lateinit var mMatchCaseBtn: ColorToggleButton
private lateinit var mShowLogLabel: JLabel
private lateinit var mShowLogCombo: ColorComboBox<String>
private lateinit var mShowLogCheck: JCheckBox
Expand Down Expand Up @@ -463,6 +464,9 @@ class MainUI(title: String) : JFrame() {
mAdbDisconnectBtn = ColorButton("Disconnect")
mAdbDisconnectBtn.addActionListener(mActionHandler)

mMatchCaseBtn = ColorToggleButton("Aa")
mMatchCaseBtn.addItemListener(mItemHandler)

mShowLogPanel.layout = BorderLayout()
mShowLogPanel.add(mShowLogLabel, BorderLayout.WEST)
mShowLogCombo.border = BorderFactory.createEmptyBorder(3, 3, 3, 3)
Expand Down Expand Up @@ -567,6 +571,9 @@ class MainUI(title: String) : JFrame() {
addVSeparator(mLogToolBar)
mLogToolBar.add(mRotationBtn)

addVSeparator(mLogToolBar)
mLogToolBar.add(mMatchCaseBtn)

val toolBarPanel = JPanel(FlowLayout(FlowLayout.LEFT, 0, 0))
toolBarPanel.addMouseListener(mMouseHandler)
toolBarPanel.add(mLogToolBar)
Expand Down Expand Up @@ -778,6 +785,13 @@ class MainUI(title: String) : JFrame() {
}
mFilteredTableModel.mScrollbackSplitFile = mScrollbackSplitFileCheck.isSelected

check = mConfigManager.mProperties.get(mConfigManager.ITEM_MATCH_CASE) as? String
if (!check.isNullOrEmpty()) {
mMatchCaseBtn.isSelected = check.toBoolean()
} else {
mMatchCaseBtn.isSelected = false
}
mFilteredTableModel.mMatchCase = mMatchCaseBtn.isSelected

add(mFilterPanel, BorderLayout.NORTH)
add(mLogSplitPane, BorderLayout.CENTER)
Expand Down Expand Up @@ -839,6 +853,7 @@ class MainUI(title: String) : JFrame() {

val ITEM_SCROLLBACK = "SCROLLBACK"
val ITEM_SCROLLBACK_SPLIT_FILE = "SCROLLBACK_SPLIT_FILE"
val ITEM_MATCH_CASE = "MATCH_CASE"

private fun setDefaultConfig() {
mProperties.put(ITEM_LOG_LEVEL, VERBOSE)
Expand Down Expand Up @@ -965,6 +980,7 @@ class MainUI(title: String) : JFrame() {

mProperties.put(ITEM_SCROLLBACK, mScrollbackTextField.text)
mProperties.put(ITEM_SCROLLBACK_SPLIT_FILE, mScrollbackSplitFileCheck.isSelected.toString())
mProperties.put(ITEM_MATCH_CASE, mMatchCaseBtn.isSelected.toString())

try {
fileOutput = FileOutputStream("config.xml")
Expand Down Expand Up @@ -1472,6 +1488,8 @@ class MainUI(title: String) : JFrame() {
} else {
mFilteredTableModel.mFilterTid = ""
}
} else if (p0?.source == mMatchCaseBtn) {
mFilteredTableModel.mMatchCase = mMatchCaseBtn.isSelected
}
}
}
Expand Down

0 comments on commit ab04648

Please sign in to comment.