From 12ce96bd3f766f73d77a6579652ae1e3bf3ef687 Mon Sep 17 00:00:00 2001 From: rememberber Date: Fri, 6 Dec 2024 22:42:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=89=8B=E8=AE=B0=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E5=8C=85=E5=90=AB=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../luoboduner/moo/tool/dao/TQuickNoteMapper.java | 2 ++ .../moo/tool/ui/form/func/QuickNoteForm.java | 14 +++++++++++++- .../tool/ui/listener/func/QuickNoteListener.java | 5 +++++ src/main/resources/mapper/TQuickNoteMapper.xml | 8 ++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/luoboduner/moo/tool/dao/TQuickNoteMapper.java b/src/main/java/com/luoboduner/moo/tool/dao/TQuickNoteMapper.java index 2b405321..f413640a 100644 --- a/src/main/java/com/luoboduner/moo/tool/dao/TQuickNoteMapper.java +++ b/src/main/java/com/luoboduner/moo/tool/dao/TQuickNoteMapper.java @@ -26,4 +26,6 @@ public interface TQuickNoteMapper { int updateAll(TQuickNote tQuickNote); List selectAllByFilter(String titleFilterKeyWord); + + List selectAllByFilterContainsContent(String titleFilterKeyWord); } \ No newline at end of file diff --git a/src/main/java/com/luoboduner/moo/tool/ui/form/func/QuickNoteForm.java b/src/main/java/com/luoboduner/moo/tool/ui/form/func/QuickNoteForm.java index c404752e..5ec3d727 100644 --- a/src/main/java/com/luoboduner/moo/tool/ui/form/func/QuickNoteForm.java +++ b/src/main/java/com/luoboduner/moo/tool/ui/form/func/QuickNoteForm.java @@ -100,6 +100,7 @@ public class QuickNoteForm { private JCheckBox commaDoubleQuotesToEnterCheckBox; private JToggleButton colorButton; + private JCheckBox searchContentCheckBox; private JToolBar toolBar; public final static String[] COLOR_KEYS = { @@ -122,6 +123,7 @@ private QuickNoteForm() { colorButton.setEnabled(true); toolBar = new JToolBar(); + searchContentCheckBox = new JCheckBox(); UndoUtil.register(this); } @@ -155,6 +157,9 @@ private static void initUi() { quickNoteForm.getSearchTextField().putClientProperty(FlatClientProperties.PLACEHOLDER_TEXT, "搜索"); quickNoteForm.getSearchTextField().putClientProperty(FlatClientProperties.TEXT_FIELD_LEADING_ICON, new FlatSearchIcon()); + quickNoteForm.getSearchContentCheckBox().setToolTipText("包含内容"); + quickNoteForm.getSearchTextField().putClientProperty(FlatClientProperties.TEXT_FIELD_TRAILING_COMPONENT, quickNoteForm.getSearchContentCheckBox()); + quickNoteForm.getAddButton().setIcon(new FlatSVGIcon("icon/add.svg")); quickNoteForm.getSaveButton().setIcon(new FlatSVGIcon("icon/save.svg")); quickNoteForm.getFindButton().setIcon(new FlatSVGIcon("icon/find.svg")); @@ -363,7 +368,14 @@ public static void initNoteListTable() { String titleFilterKeyWord = quickNoteForm.getSearchTextField().getText(); titleFilterKeyWord = "%" + titleFilterKeyWord + "%"; - List quickNoteList = quickNoteMapper.selectAllByFilter(titleFilterKeyWord); + boolean searchContent = quickNoteForm.getSearchContentCheckBox().isSelected(); + + List quickNoteList; + if (searchContent && StringUtils.isNotBlank(titleFilterKeyWord)) { + quickNoteList = quickNoteMapper.selectAllByFilterContainsContent(titleFilterKeyWord); + } else { + quickNoteList = quickNoteMapper.selectAllByFilter(titleFilterKeyWord); + } for (TQuickNote tQuickNote : quickNoteList) { data = new Object[2]; diff --git a/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java b/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java index cfdcfceb..1220bb02 100644 --- a/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java +++ b/src/main/java/com/luoboduner/moo/tool/ui/listener/func/QuickNoteListener.java @@ -413,6 +413,11 @@ public void changedUpdate(DocumentEvent e) { // QuickNoteForm.initNoteListTable(); } }); + + // 搜索框包含内容checkbox变更事件 + quickNoteForm.getSearchContentCheckBox().addActionListener(e -> { + QuickNoteForm.initNoteListTable(); + }); } public static void showFindPanel() { diff --git a/src/main/resources/mapper/TQuickNoteMapper.xml b/src/main/resources/mapper/TQuickNoteMapper.xml index 26eda843..aa8b740f 100644 --- a/src/main/resources/mapper/TQuickNoteMapper.xml +++ b/src/main/resources/mapper/TQuickNoteMapper.xml @@ -181,6 +181,14 @@ where name like #{titleFilterKeyWord,jdbcType=VARCHAR} order by modified_time desc + update t_quick_note