From ab04648718763ed73a8becd4509f3eca4cbcc67e Mon Sep 17 00:00:00 2001 From: hyungjun Date: Fri, 26 Feb 2021 11:26:00 +0900 Subject: [PATCH] add pattern condition about match case --- .../kotlinstudy/lognote/LogTableModel.kt | 79 +++++++++++++------ .../blogspot/kotlinstudy/lognote/MainUI.kt | 18 +++++ 2 files changed, 73 insertions(+), 24 deletions(-) diff --git a/src/com/blogspot/kotlinstudy/lognote/LogTableModel.kt b/src/com/blogspot/kotlinstudy/lognote/LogTableModel.kt index dc933cb3..096d0525 100644 --- a/src/com/blogspot/kotlinstudy/lognote/LogTableModel.kt +++ b/src/com/blogspot/kotlinstudy/lognote/LogTableModel.kt @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 } @@ -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 @@ -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) @@ -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) } } }) @@ -729,7 +760,7 @@ class LogTableModel() : AbstractTableModel() { } if (!skip) { - mPatternPrintValue = Pattern.compile(filterPrintValue, Pattern.CASE_INSENSITIVE) + mPatternPrintValue = Pattern.compile(filterPrintValue, mPatternCase) mBaseModel?.mPatternPrintValue = mPatternPrintValue } } diff --git a/src/com/blogspot/kotlinstudy/lognote/MainUI.kt b/src/com/blogspot/kotlinstudy/lognote/MainUI.kt index 5ec05ac7..d9da349d 100644 --- a/src/com/blogspot/kotlinstudy/lognote/MainUI.kt +++ b/src/com/blogspot/kotlinstudy/lognote/MainUI.kt @@ -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 private lateinit var mShowLogCheck: JCheckBox @@ -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) @@ -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) @@ -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) @@ -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) @@ -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") @@ -1472,6 +1488,8 @@ class MainUI(title: String) : JFrame() { } else { mFilteredTableModel.mFilterTid = "" } + } else if (p0?.source == mMatchCaseBtn) { + mFilteredTableModel.mMatchCase = mMatchCaseBtn.isSelected } } }