Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
keyescgm
jadx
提交
4b73d24d
J
jadx
项目概览
keyescgm
/
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,发现更多精彩内容 >>
提交
4b73d24d
编写于
5月 06, 2019
作者:
J
Jan S
提交者:
skylot
5月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(gui): separate SearchBar for Java and Smali code areas (PR #653)
上级
65818dcc
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
351 addition
and
172 deletion
+351
-172
jadx-gui/src/main/java/jadx/gui/ui/ContentPanel.java
jadx-gui/src/main/java/jadx/gui/ui/ContentPanel.java
+15
-0
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
+14
-7
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
.../src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
+110
-0
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeContentPanel.java
...n/java/jadx/gui/ui/codearea/AbstractCodeContentPanel.java
+18
-0
jadx-gui/src/main/java/jadx/gui/ui/codearea/ClassCodeContentPanel.java
...main/java/jadx/gui/ui/codearea/ClassCodeContentPanel.java
+68
-0
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeArea.java
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeArea.java
+16
-79
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeContentPanel.java
.../src/main/java/jadx/gui/ui/codearea/CodeContentPanel.java
+60
-0
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeLinkGenerator.java
...src/main/java/jadx/gui/ui/codearea/CodeLinkGenerator.java
+3
-2
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodePanel.java
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodePanel.java
+30
-65
jadx-gui/src/main/java/jadx/gui/ui/codearea/FindUsageAction.java
...i/src/main/java/jadx/gui/ui/codearea/FindUsageAction.java
+3
-2
jadx-gui/src/main/java/jadx/gui/ui/codearea/GoToDeclarationAction.java
...main/java/jadx/gui/ui/codearea/GoToDeclarationAction.java
+3
-2
jadx-gui/src/main/java/jadx/gui/ui/codearea/LineNumbers.java
jadx-gui/src/main/java/jadx/gui/ui/codearea/LineNumbers.java
+5
-5
jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
+6
-10
未找到文件。
jadx-gui/src/main/java/jadx/gui/ui/ContentPanel.java
浏览文件 @
4b73d24d
...
...
@@ -2,6 +2,8 @@ package jadx.gui.ui;
import
javax.swing.*
;
import
org.jetbrains.annotations.Nullable
;
import
jadx.gui.treemodel.JNode
;
public
abstract
class
ContentPanel
extends
JPanel
{
...
...
@@ -25,4 +27,17 @@ public abstract class ContentPanel extends JPanel {
public
JNode
getNode
()
{
return
node
;
}
/**
* Allows to show a tool tip on the tab e.g. for displaying a long path of the
* selected entry inside the APK file.
*
* If <code>null</code> is returned no tool tip will be displayed.
*
* @return
*/
@Nullable
public
String
getTabTooltip
()
{
return
null
;
}
}
jadx-gui/src/main/java/jadx/gui/ui/TabbedPane.java
浏览文件 @
4b73d24d
...
...
@@ -23,8 +23,10 @@ import jadx.gui.treemodel.JCertificate;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JResource
;
import
jadx.gui.ui.codearea.CodeArea
;
import
jadx.gui.ui.codearea.CodePanel
;
import
jadx.gui.ui.codearea.AbstractCodeArea
;
import
jadx.gui.ui.codearea.AbstractCodeContentPanel
;
import
jadx.gui.ui.codearea.ClassCodeContentPanel
;
import
jadx.gui.ui.codearea.CodeContentPanel
;
import
jadx.gui.utils.JumpManager
;
import
jadx.gui.utils.JumpPosition
;
import
jadx.gui.utils.NLS
;
...
...
@@ -66,13 +68,13 @@ public class TabbedPane extends JTabbedPane {
}
private
void
showCode
(
final
JumpPosition
pos
)
{
final
CodePanel
contentPanel
=
(
Code
Panel
)
getContentPanel
(
pos
.
getNode
());
final
AbstractCodeContentPanel
contentPanel
=
(
AbstractCodeContent
Panel
)
getContentPanel
(
pos
.
getNode
());
if
(
contentPanel
==
null
)
{
return
;
}
SwingUtilities
.
invokeLater
(()
->
{
setSelectedComponent
(
contentPanel
);
CodeArea
codeArea
=
contentPanel
.
getCodeArea
();
Abstract
CodeArea
codeArea
=
contentPanel
.
getCodeArea
();
int
line
=
pos
.
getLine
();
if
(
line
<
0
)
{
try
{
...
...
@@ -115,8 +117,8 @@ public class TabbedPane extends JTabbedPane {
@Nullable
private
JumpPosition
getCurrentPosition
()
{
ContentPanel
selectedCodePanel
=
getSelectedCodePanel
();
if
(
selectedCodePanel
instanceof
CodePanel
)
{
return
((
CodePanel
)
selectedCodePanel
).
getCodeArea
().
getCurrentPosition
();
if
(
selectedCodePanel
instanceof
Code
Content
Panel
)
{
return
((
Code
Content
Panel
)
selectedCodePanel
).
getCodeArea
().
getCurrentPosition
();
}
return
null
;
}
...
...
@@ -168,6 +170,7 @@ public class TabbedPane extends JTabbedPane {
if
(
resFile
.
getType
()
==
ResourceType
.
IMG
)
{
return
new
ImagePanel
(
this
,
res
);
}
return
new
CodeContentPanel
(
this
,
node
);
}
else
{
return
null
;
}
...
...
@@ -178,7 +181,7 @@ public class TabbedPane extends JTabbedPane {
if
(
node
instanceof
JCertificate
)
{
return
new
CertificatePanel
(
this
,
node
);
}
return
new
C
ode
Panel
(
this
,
node
);
return
new
C
lassCodeContent
Panel
(
this
,
node
);
}
@Nullable
...
...
@@ -194,6 +197,10 @@ public class TabbedPane extends JTabbedPane {
panel
.
setOpaque
(
false
);
final
JLabel
label
=
new
JLabel
(
name
);
String
toolTip
=
contentPanel
.
getTabTooltip
();
if
(
toolTip
!=
null
)
{
label
.
setToolTipText
(
toolTip
);
}
label
.
setBorder
(
BorderFactory
.
createEmptyBorder
(
0
,
0
,
0
,
10
));
label
.
setIcon
(
node
.
getIcon
());
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
0 → 100644
浏览文件 @
4b73d24d
package
jadx.gui.ui.codearea
;
import
java.awt.Dimension
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
javax.swing.JViewport
;
import
javax.swing.SwingUtilities
;
import
javax.swing.text.BadLocationException
;
import
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
;
import
org.jetbrains.annotations.Nullable
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.utils.JumpPosition
;
public
abstract
class
AbstractCodeArea
extends
RSyntaxTextArea
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AbstractCodeArea
.
class
);
protected
final
ContentPanel
contentPanel
;
protected
final
JNode
node
;
public
AbstractCodeArea
(
ContentPanel
contentPanel
)
{
this
.
contentPanel
=
contentPanel
;
this
.
node
=
contentPanel
.
getNode
();
}
/**
* Implement in this method the code that loads and sets the content to be displayed
*/
public
abstract
void
load
();
public
void
loadSettings
()
{
loadCommonSettings
(
contentPanel
.
getTabbedPane
().
getMainWindow
(),
this
);
}
public
void
scrollToLine
(
int
line
)
{
int
lineNum
=
line
-
1
;
if
(
lineNum
<
0
)
{
lineNum
=
0
;
}
setCaretAtLine
(
lineNum
);
centerCurrentLine
();
forceCurrentLineHighlightRepaint
();
}
private
void
setCaretAtLine
(
int
line
)
{
try
{
setCaretPosition
(
getLineStartOffset
(
line
));
}
catch
(
BadLocationException
e
)
{
LOG
.
debug
(
"Can't scroll to {}"
,
line
,
e
);
}
}
public
void
centerCurrentLine
()
{
JViewport
viewport
=
(
JViewport
)
SwingUtilities
.
getAncestorOfClass
(
JViewport
.
class
,
this
);
if
(
viewport
==
null
)
{
return
;
}
try
{
Rectangle
r
=
modelToView
(
getCaretPosition
());
if
(
r
==
null
)
{
return
;
}
int
extentHeight
=
viewport
.
getExtentSize
().
height
;
Dimension
viewSize
=
viewport
.
getViewSize
();
if
(
viewSize
==
null
)
{
return
;
}
int
viewHeight
=
viewSize
.
height
;
int
y
=
Math
.
max
(
0
,
r
.
y
-
extentHeight
/
2
);
y
=
Math
.
min
(
y
,
viewHeight
-
extentHeight
);
viewport
.
setViewPosition
(
new
Point
(
0
,
y
));
}
catch
(
BadLocationException
e
)
{
LOG
.
debug
(
"Can't center current line"
,
e
);
}
}
public
JumpPosition
getCurrentPosition
()
{
return
new
JumpPosition
(
node
,
getCaretLineNumber
()
+
1
);
}
@Nullable
Integer
getSourceLine
(
int
line
)
{
return
node
.
getSourceLine
(
line
);
}
public
ContentPanel
getContentPanel
()
{
return
contentPanel
;
}
public
JNode
getNode
()
{
return
node
;
}
public
static
void
loadCommonSettings
(
MainWindow
mainWindow
,
RSyntaxTextArea
area
)
{
area
.
setAntiAliasingEnabled
(
true
);
mainWindow
.
getEditorTheme
().
apply
(
area
);
JadxSettings
settings
=
mainWindow
.
getSettings
();
area
.
setFont
(
settings
.
getFont
());
}
}
jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeContentPanel.java
0 → 100644
浏览文件 @
4b73d24d
package
jadx.gui.ui.codearea
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.ui.TabbedPane
;
/**
* The abstract base class for a content panel that show text based code or a.g. a resource
*/
public
abstract
class
AbstractCodeContentPanel
extends
ContentPanel
{
protected
AbstractCodeContentPanel
(
TabbedPane
panel
,
JNode
jnode
)
{
super
(
panel
,
jnode
);
}
public
abstract
AbstractCodeArea
getCodeArea
();
}
jadx-gui/src/main/java/jadx/gui/ui/codearea/ClassCodeContentPanel.java
0 → 100644
浏览文件 @
4b73d24d
package
jadx.gui.ui.codearea
;
import
java.awt.BorderLayout
;
import
javax.swing.JTabbedPane
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.TabbedPane
;
import
jadx.gui.utils.NLS
;
/**
* Displays one class with two different view:
*
* <ul>
* <li>Java source code of the selected class (default)</li>
* <li>Smali source code of the selected class</li>
* </ul>
*/
public
final
class
ClassCodeContentPanel
extends
AbstractCodeContentPanel
{
private
static
final
long
serialVersionUID
=
-
7229931102504634591L
;
private
final
CodePanel
javaCodePanel
;
private
final
CodePanel
smaliCodePanel
;
private
JTabbedPane
areaTabbedPane
=
new
JTabbedPane
(
JTabbedPane
.
BOTTOM
);
public
ClassCodeContentPanel
(
TabbedPane
panel
,
JNode
jnode
)
{
super
(
panel
,
jnode
);
javaCodePanel
=
new
CodePanel
(
this
,
new
CodeArea
(
this
));
smaliCodePanel
=
new
CodePanel
(
this
,
new
SmaliArea
(
this
));
setLayout
(
new
BorderLayout
());
areaTabbedPane
.
add
(
javaCodePanel
,
NLS
.
str
(
"tabs.code"
));
areaTabbedPane
.
add
(
smaliCodePanel
,
NLS
.
str
(
"tabs.smali"
));
add
(
areaTabbedPane
);
javaCodePanel
.
load
();
areaTabbedPane
.
addChangeListener
(
e
->
{
CodePanel
selectedPanel
=
(
CodePanel
)
areaTabbedPane
.
getSelectedComponent
();
selectedPanel
.
load
();
});
}
@Override
public
void
loadSettings
()
{
javaCodePanel
.
loadSettings
();
smaliCodePanel
.
loadSettings
();
updateUI
();
}
@Override
public
TabbedPane
getTabbedPane
()
{
return
tabbedPane
;
}
@Override
public
JNode
getNode
()
{
return
node
;
}
@Override
public
AbstractCodeArea
getCodeArea
()
{
return
javaCodePanel
.
getCodeArea
();
}
}
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeArea.java
浏览文件 @
4b73d24d
package
jadx.gui.ui.codearea
;
import
java.awt.Dimension
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.event.MouseAdapter
;
import
java.awt.event.MouseEvent
;
import
javax.swing.JPopupMenu
;
import
javax.swing.JViewport
;
import
javax.swing.SwingUtilities
;
import
javax.swing.text.BadLocationException
;
import
javax.swing.text.Caret
;
import
javax.swing.text.DefaultCaret
;
...
...
@@ -23,23 +17,23 @@ import org.slf4j.LoggerFactory;
import
jadx.api.CodePosition
;
import
jadx.api.JavaNode
;
import
jadx.gui.settings.JadxSettings
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.utils.JumpPosition
;
public
final
class
CodeArea
extends
RSyntaxTextArea
{
/**
* The {@link AbstractCodeArea} implementation used for displaying Java code and text based
* resources (e.g. AndroidManifest.xml)
*/
public
final
class
CodeArea
extends
AbstractCodeArea
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
CodeArea
.
class
);
private
static
final
long
serialVersionUID
=
6312736869579635796L
;
private
final
CodePanel
contentPanel
;
private
final
JNode
node
;
CodeArea
(
CodePanel
panel
)
{
this
.
contentPanel
=
panel
;
this
.
node
=
panel
.
getNode
();
CodeArea
(
ContentPanel
contentPanel
)
{
super
(
contentPanel
);
setMarkOccurrences
(
true
);
setEditable
(
false
);
...
...
@@ -63,7 +57,14 @@ public final class CodeArea extends RSyntaxTextArea {
addMenuItems
(
jClsNode
);
}
registerWordHighlighter
();
setText
(
node
.
getContent
());
}
@Override
public
void
load
()
{
if
(
getText
().
isEmpty
())
{
setText
(
node
.
getContent
());
setCaretPosition
(
0
);
}
}
private
void
registerWordHighlighter
()
{
...
...
@@ -106,18 +107,6 @@ public final class CodeArea extends RSyntaxTextArea {
popup
.
addPopupMenuListener
(
goToDeclaration
);
}
public
void
loadSettings
()
{
loadCommonSettings
(
contentPanel
.
getTabbedPane
().
getMainWindow
(),
this
);
}
public
static
void
loadCommonSettings
(
MainWindow
mainWindow
,
RSyntaxTextArea
area
)
{
area
.
setAntiAliasingEnabled
(
true
);
mainWindow
.
getEditorTheme
().
apply
(
area
);
JadxSettings
settings
=
mainWindow
.
getSettings
();
area
.
setFont
(
settings
.
getFont
());
}
public
static
RSyntaxTextArea
getDefaultArea
(
MainWindow
mainWindow
)
{
RSyntaxTextArea
area
=
new
RSyntaxTextArea
();
loadCommonSettings
(
mainWindow
,
area
);
...
...
@@ -156,56 +145,4 @@ public final class CodeArea extends RSyntaxTextArea {
return
null
;
}
public
JumpPosition
getCurrentPosition
()
{
return
new
JumpPosition
(
node
,
getCaretLineNumber
()
+
1
);
}
@Nullable
Integer
getSourceLine
(
int
line
)
{
return
node
.
getSourceLine
(
line
);
}
public
void
scrollToLine
(
int
line
)
{
int
lineNum
=
line
-
1
;
if
(
lineNum
<
0
)
{
lineNum
=
0
;
}
setCaretAtLine
(
lineNum
);
centerCurrentLine
();
forceCurrentLineHighlightRepaint
();
}
public
void
centerCurrentLine
()
{
JViewport
viewport
=
(
JViewport
)
SwingUtilities
.
getAncestorOfClass
(
JViewport
.
class
,
this
);
if
(
viewport
==
null
)
{
return
;
}
try
{
Rectangle
r
=
modelToView
(
getCaretPosition
());
if
(
r
==
null
)
{
return
;
}
int
extentHeight
=
viewport
.
getExtentSize
().
height
;
Dimension
viewSize
=
viewport
.
getViewSize
();
if
(
viewSize
==
null
)
{
return
;
}
int
viewHeight
=
viewSize
.
height
;
int
y
=
Math
.
max
(
0
,
r
.
y
-
extentHeight
/
2
);
y
=
Math
.
min
(
y
,
viewHeight
-
extentHeight
);
viewport
.
setViewPosition
(
new
Point
(
0
,
y
));
}
catch
(
BadLocationException
e
)
{
LOG
.
debug
(
"Can't center current line"
,
e
);
}
}
private
void
setCaretAtLine
(
int
line
)
{
try
{
setCaretPosition
(
getLineStartOffset
(
line
));
}
catch
(
BadLocationException
e
)
{
LOG
.
debug
(
"Can't scroll to {}"
,
line
,
e
);
}
}
}
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeContentPanel.java
0 → 100644
浏览文件 @
4b73d24d
package
jadx.gui.ui.codearea
;
import
java.awt.BorderLayout
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.TabbedPane
;
public
final
class
CodeContentPanel
extends
AbstractCodeContentPanel
{
private
static
final
long
serialVersionUID
=
5310536092010045565L
;
private
final
CodePanel
codePanel
;
public
CodeContentPanel
(
TabbedPane
panel
,
JNode
jnode
)
{
super
(
panel
,
jnode
);
setLayout
(
new
BorderLayout
());
codePanel
=
new
CodePanel
(
this
,
new
CodeArea
(
this
));
add
(
codePanel
,
BorderLayout
.
CENTER
);
codePanel
.
load
();
}
@Override
public
void
loadSettings
()
{
codePanel
.
loadSettings
();
updateUI
();
}
@Override
public
TabbedPane
getTabbedPane
()
{
return
tabbedPane
;
}
@Override
public
JNode
getNode
()
{
return
node
;
}
SearchBar
getSearchBar
()
{
return
codePanel
.
getSearchBar
();
}
@Override
public
AbstractCodeArea
getCodeArea
()
{
return
codePanel
.
getCodeArea
();
}
@Override
public
String
getTabTooltip
()
{
String
s
=
node
.
getName
();
JNode
n
=
(
JNode
)
node
.
getParent
();
while
(
n
!=
null
)
{
String
name
=
n
.
getName
();
if
(
name
==
null
)
{
break
;
}
s
=
name
+
'/'
+
s
;
n
=
(
JNode
)
n
.
getParent
();
}
return
'/'
+
s
;
}
}
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodeLinkGenerator.java
浏览文件 @
4b73d24d
...
...
@@ -14,16 +14,17 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.utils.JumpPosition
;
public
class
CodeLinkGenerator
implements
LinkGenerator
,
HyperlinkListener
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
CodeLinkGenerator
.
class
);
private
final
Co
de
Panel
contentPanel
;
private
final
Co
ntent
Panel
contentPanel
;
private
final
CodeArea
codeArea
;
private
final
JClass
jCls
;
public
CodeLinkGenerator
(
Co
de
Panel
contentPanel
,
CodeArea
codeArea
,
JClass
cls
)
{
public
CodeLinkGenerator
(
Co
ntent
Panel
contentPanel
,
CodeArea
codeArea
,
JClass
cls
)
{
this
.
contentPanel
=
contentPanel
;
this
.
codeArea
=
codeArea
;
this
.
jCls
=
cls
;
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/CodePanel.java
浏览文件 @
4b73d24d
...
...
@@ -5,60 +5,51 @@ import java.awt.event.ActionEvent;
import
java.awt.event.KeyEvent
;
import
javax.swing.AbstractAction
;
import
javax.swing.JPanel
;
import
javax.swing.JScrollPane
;
import
javax.swing.JTabbedPane
;
import
javax.swing.KeyStroke
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JResource
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.ui.TabbedPane
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.Utils
;
public
final
class
CodePanel
extends
ContentPanel
{
private
static
final
long
serialVersionUID
=
5310536092010045565L
;
/**
* A panel combining a {@link SearchBar and a scollable {@link CodeArea}
*/
public
class
CodePanel
extends
JPanel
{
private
final
SearchBar
searchBar
;
private
final
CodeArea
codeArea
;
private
final
SmaliArea
smaliArea
;
private
final
AbstractCodeArea
codeArea
;
private
final
JScrollPane
codeScrollPane
;
private
final
JScrollPane
smaliScrollPane
;
private
JTabbedPane
areaTabbedPane
=
new
JTabbedPane
(
JTabbedPane
.
BOTTOM
);
public
CodePanel
(
TabbedPane
panel
,
JNode
jnode
)
{
super
(
panel
,
jnode
);
codeArea
=
new
CodeArea
(
this
);
smaliArea
=
new
SmaliArea
(
this
);
public
CodePanel
(
ContentPanel
contentPanel
,
AbstractCodeArea
codeArea
)
{
this
.
codeArea
=
codeArea
;
searchBar
=
new
SearchBar
(
codeArea
);
codeScrollPane
=
new
JScrollPane
(
codeArea
);
smaliScrollPane
=
new
JScrollPane
(
smaliArea
);
initLineNumbers
();
setLayout
(
new
BorderLayout
());
add
(
searchBar
,
BorderLayout
.
NORTH
);
areaTabbedPane
.
add
(
codeScrollPane
,
NLS
.
str
(
"tabs.code"
));
areaTabbedPane
.
add
(
smaliScrollPane
,
NLS
.
str
(
"tabs.smali"
));
add
(
areaTabbedPane
);
add
(
codeScrollPane
,
BorderLayout
.
CENTER
);
initLineNumbers
();
KeyStroke
key
=
KeyStroke
.
getKeyStroke
(
KeyEvent
.
VK_F
,
Utils
.
ctrlButton
());
SearchAction
searchAction
=
new
SearchAction
();
Utils
.
addKeyBinding
(
codeArea
,
key
,
"SearchAction"
,
searchAction
);
Utils
.
addKeyBinding
(
smaliArea
,
key
,
"SearchAction"
,
searchAction
);
areaTabbedPane
.
addChangeListener
(
e
->
{
if
(
areaTabbedPane
.
getSelectedComponent
()
==
smaliScrollPane
)
{
smaliArea
.
load
();
searchBar
.
setRTextArea
(
smaliArea
);
}
else
if
(
areaTabbedPane
.
getSelectedComponent
()
==
codeScrollPane
)
{
searchBar
.
setRTextArea
(
codeArea
);
Utils
.
addKeyBinding
(
codeArea
,
key
,
"SearchAction"
,
new
AbstractAction
()
{
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
searchBar
.
toggle
();
}
});
}
public
void
loadSettings
()
{
codeArea
.
loadSettings
();
initLineNumbers
();
}
public
void
load
()
{
codeArea
.
load
();
}
private
void
initLineNumbers
()
{
// TODO: fix slow line rendering on big files
if
(
codeArea
.
getDocument
().
getLength
()
<=
100_000
)
{
...
...
@@ -69,48 +60,22 @@ public final class CodePanel extends ContentPanel {
}
private
boolean
isUseSourceLines
()
{
if
(
node
instanceof
JClass
)
{
return
true
;
}
if
(
node
instanceof
JResource
)
{
JResource
resNode
=
(
JResource
)
node
;
if
(
codeArea
.
getNode
()
instanceof
JResource
)
{
JResource
resNode
=
(
JResource
)
codeArea
.
getNode
();
return
!
resNode
.
getLineMapping
().
isEmpty
();
}
return
false
;
}
private
class
SearchAction
extends
AbstractAction
{
private
static
final
long
serialVersionUID
=
8650568214755387093L
;
@Override
public
void
actionPerformed
(
ActionEvent
e
)
{
searchBar
.
toggle
();
}
}
@Override
public
void
loadSettings
()
{
codeArea
.
loadSettings
();
initLineNumbers
();
updateUI
();
}
@Override
public
TabbedPane
getTabbedPane
()
{
return
tabbedPane
;
}
@Override
public
JNode
getNode
()
{
return
node
;
}
SearchBar
getSearchBar
()
{
public
SearchBar
getSearchBar
()
{
return
searchBar
;
}
public
CodeArea
getCodeArea
()
{
public
Abstract
CodeArea
getCodeArea
()
{
return
codeArea
;
}
public
JScrollPane
getCodeScrollPane
()
{
return
codeScrollPane
;
}
}
jadx-gui/src/main/java/jadx/gui/ui/codearea/FindUsageAction.java
浏览文件 @
4b73d24d
...
...
@@ -12,6 +12,7 @@ import org.fife.ui.rsyntaxtextarea.Token;
import
jadx.api.JavaNode
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.ui.UsageDialog
;
import
jadx.gui.utils.NLS
;
...
...
@@ -19,13 +20,13 @@ import jadx.gui.utils.NLS;
public
final
class
FindUsageAction
extends
AbstractAction
implements
PopupMenuListener
{
private
static
final
long
serialVersionUID
=
4692546569977976384L
;
private
final
transient
Co
de
Panel
contentPanel
;
private
final
transient
Co
ntent
Panel
contentPanel
;
private
final
transient
CodeArea
codeArea
;
private
final
transient
JClass
jCls
;
private
transient
JavaNode
node
;
public
FindUsageAction
(
Co
de
Panel
contentPanel
,
CodeArea
codeArea
,
JClass
jCls
)
{
public
FindUsageAction
(
Co
ntent
Panel
contentPanel
,
CodeArea
codeArea
,
JClass
jCls
)
{
super
(
NLS
.
str
(
"popup.find_usage"
));
this
.
contentPanel
=
contentPanel
;
this
.
codeArea
=
codeArea
;
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/GoToDeclarationAction.java
浏览文件 @
4b73d24d
...
...
@@ -12,19 +12,20 @@ import org.fife.ui.rsyntaxtextarea.Token;
import
jadx.api.JavaNode
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.ui.MainWindow
;
import
jadx.gui.utils.JumpPosition
;
import
jadx.gui.utils.NLS
;
public
final
class
GoToDeclarationAction
extends
AbstractAction
implements
PopupMenuListener
{
private
static
final
long
serialVersionUID
=
-
1186470538894941301L
;
private
final
transient
Co
de
Panel
contentPanel
;
private
final
transient
Co
ntent
Panel
contentPanel
;
private
final
transient
CodeArea
codeArea
;
private
final
transient
JClass
jCls
;
private
transient
JavaNode
node
;
public
GoToDeclarationAction
(
Co
de
Panel
contentPanel
,
CodeArea
codeArea
,
JClass
jCls
)
{
public
GoToDeclarationAction
(
Co
ntent
Panel
contentPanel
,
CodeArea
codeArea
,
JClass
jCls
)
{
super
(
NLS
.
str
(
"popup.go_to_declaration"
));
this
.
contentPanel
=
contentPanel
;
this
.
codeArea
=
codeArea
;
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/LineNumbers.java
浏览文件 @
4b73d24d
...
...
@@ -33,7 +33,7 @@ public class LineNumbers extends JPanel implements CaretListener {
private
static
final
int
NUM_HEIGHT
=
Integer
.
MAX_VALUE
-
1000000
;
private
static
final
Map
<?,
?>
DESKTOP_HINTS
=
(
Map
<?,
?>)
Toolkit
.
getDefaultToolkit
().
getDesktopProperty
(
"awt.font.desktophints"
);
private
final
CodeArea
codeArea
;
private
final
Abstract
CodeArea
codeArea
;
private
boolean
useSourceLines
=
true
;
private
int
lastDigits
;
...
...
@@ -44,9 +44,9 @@ public class LineNumbers extends JPanel implements CaretListener {
private
final
transient
Color
currentColor
;
private
final
transient
Border
border
;
public
LineNumbers
(
CodeArea
component
)
{
this
.
codeArea
=
co
mponent
;
setFont
(
co
mponent
.
getFont
());
public
LineNumbers
(
AbstractCodeArea
codeArea
)
{
this
.
codeArea
=
co
deArea
;
setFont
(
co
deArea
.
getFont
());
SyntaxScheme
syntaxScheme
=
codeArea
.
getSyntaxScheme
();
numberColor
=
syntaxScheme
.
getStyle
(
Token
.
LITERAL_NUMBER_DECIMAL_INT
).
foreground
;
currentColor
=
syntaxScheme
.
getStyle
(
Token
.
LITERAL_STRING_DOUBLE_QUOTE
).
foreground
;
...
...
@@ -57,7 +57,7 @@ public class LineNumbers extends JPanel implements CaretListener {
setBorderGap
(
5
);
setPreferredWidth
();
co
mponent
.
addCaretListener
(
this
);
co
deArea
.
addCaretListener
(
this
);
addMouseListener
(
new
MouseAdapter
()
{
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
...
...
jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
浏览文件 @
4b73d24d
package
jadx.gui.ui.codearea
;
import
org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
;
import
jadx.gui.ui.ContentPanel
;
import
jadx.gui.treemodel.JNode
;
public
final
class
SmaliArea
extends
RSyntaxTextArea
{
public
final
class
SmaliArea
extends
AbstractCodeArea
{
private
static
final
long
serialVersionUID
=
1334485631870306494L
;
private
final
JNode
node
;
SmaliArea
(
CodePanel
panel
)
{
node
=
panel
.
getNode
();
SmaliArea
(
ContentPanel
contentPanel
)
{
super
(
contentPanel
);
setEditable
(
false
);
}
void
load
()
{
@Override
public
void
load
()
{
if
(
getText
().
isEmpty
())
{
setText
(
node
.
getSmali
());
setCaretPosition
(
0
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录