Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Quincy379
jadx
提交
6d54945c
J
jadx
项目概览
Quincy379
/
jadx
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jadx
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6d54945c
编写于
4月 03, 2021
作者:
J
Jan Peter Stotz
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(gui): regex search: make searchField background red in case of invalid regex entered
上级
7fa878d3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
9 deletion
+27
-9
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
+16
-5
jadx-gui/src/main/java/jadx/gui/utils/search/SearchSettings.java
...i/src/main/java/jadx/gui/utils/search/SearchSettings.java
+9
-3
jadx-gui/src/main/java/jadx/gui/utils/search/TextSearchIndex.java
.../src/main/java/jadx/gui/utils/search/TextSearchIndex.java
+2
-1
未找到文件。
jadx-gui/src/main/java/jadx/gui/ui/SearchDialog.java
浏览文件 @
6d54945c
package
jadx.gui.ui
;
import
java.awt.BorderLayout
;
import
java.awt.Container
;
import
java.awt.Dimension
;
import
java.awt.FlowLayout
;
import
java.awt.*
;
import
java.awt.event.KeyAdapter
;
import
java.awt.event.KeyEvent
;
import
java.util.Collections
;
...
...
@@ -38,10 +35,12 @@ import jadx.gui.treemodel.JNode;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.TextStandardActions
;
import
jadx.gui.utils.layout.WrapLayout
;
import
jadx.gui.utils.search.SearchSettings
;
import
jadx.gui.utils.search.TextSearchIndex
;
public
class
SearchDialog
extends
CommonSearchDialog
{
private
static
final
long
serialVersionUID
=
-
5105405456969134105L
;
private
static
final
Color
SEARCHFIELD_ERROR_COLOR
=
new
Color
(
255
,
150
,
150
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
SearchDialog
.
class
);
...
...
@@ -81,6 +80,8 @@ public class SearchDialog extends CommonSearchDialog {
private
final
transient
SearchPreset
searchPreset
;
private
final
transient
Set
<
SearchOptions
>
options
;
private
Color
searchFieldDefaultBgColor
;
private
transient
JTextField
searchField
;
private
transient
Disposable
searchDisposable
;
...
...
@@ -183,6 +184,7 @@ public class SearchDialog extends CommonSearchDialog {
private
void
initUI
()
{
searchField
=
new
JTextField
();
searchFieldDefaultBgColor
=
searchField
.
getBackground
();
searchField
.
setAlignmentX
(
LEFT_ALIGNMENT
);
TextStandardActions
.
attach
(
searchField
);
...
...
@@ -304,7 +306,16 @@ public class SearchDialog extends CommonSearchDialog {
}
LOG
.
debug
(
"search event: {}"
,
text
);
showSearchState
();
return
index
.
buildSearch
(
text
,
options
);
try
{
Flowable
<
JNode
>
result
=
index
.
buildSearch
(
text
,
options
);
if
(
searchField
.
getBackground
()
==
SEARCHFIELD_ERROR_COLOR
)
{
searchField
.
setBackground
(
searchFieldDefaultBgColor
);
}
return
result
;
}
catch
(
SearchSettings
.
InvalidSearchTermException
e
)
{
searchField
.
setBackground
(
SEARCHFIELD_ERROR_COLOR
);
return
Flowable
.
empty
();
}
}
private
void
processSearchResults
(
java
.
util
.
List
<
JNode
>
results
)
{
...
...
jadx-gui/src/main/java/jadx/gui/utils/search/SearchSettings.java
浏览文件 @
6d54945c
...
...
@@ -52,14 +52,13 @@ public class SearchSettings {
return
this
.
regexPattern
;
}
public
boolean
preCompile
()
{
public
boolean
preCompile
()
throws
InvalidSearchTermException
{
if
(
useRegex
)
{
try
{
int
flags
=
ignoreCase
?
Pattern
.
CASE_INSENSITIVE
:
0
;
this
.
regexPattern
=
Pattern
.
compile
(
searchString
,
flags
);
}
catch
(
Exception
e
)
{
LOG
.
warn
(
"Invalid Regex: {}"
,
this
.
searchString
,
e
);
return
false
;
throw
new
InvalidSearchTermException
(
"Invalid Regex: "
+
this
.
searchString
,
e
);
}
}
return
true
;
...
...
@@ -105,4 +104,11 @@ public class SearchSettings {
public
void
setActiveCls
(
JClass
activeCls
)
{
this
.
activeCls
=
activeCls
;
}
public
static
class
InvalidSearchTermException
extends
Exception
{
public
InvalidSearchTermException
(
String
message
,
Throwable
cause
)
{
super
(
message
,
cause
);
}
}
}
jadx-gui/src/main/java/jadx/gui/utils/search/TextSearchIndex.java
浏览文件 @
6d54945c
...
...
@@ -109,7 +109,8 @@ public class TextSearchIndex {
this
.
codeIndex
.
removeForCls
(
cls
);
}
public
Flowable
<
JNode
>
buildSearch
(
String
text
,
Set
<
SearchDialog
.
SearchOptions
>
options
)
{
public
Flowable
<
JNode
>
buildSearch
(
String
text
,
Set
<
SearchDialog
.
SearchOptions
>
options
)
throws
SearchSettings
.
InvalidSearchTermException
{
boolean
ignoreCase
=
options
.
contains
(
IGNORE_CASE
);
boolean
useRegex
=
options
.
contains
(
USE_REGEX
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录