Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jadx
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
jadx
Commits
c4cdd851
Commit
c4cdd851
authored
Jul 23, 2013
by
Skylot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gui: add fields and methods to tree
parent
25b2c8fe
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
230 additions
and
25 deletions
+230
-25
NOTICE
NOTICE
+36
-2
MainWindow.java
jadx-gui/src/main/java/jadx/gui/MainWindow.java
+21
-19
JClass.java
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
+34
-4
JField.java
jadx-gui/src/main/java/jadx/gui/treemodel/JField.java
+57
-0
JMethod.java
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
+57
-0
JNode.java
jadx-gui/src/main/java/jadx/gui/treemodel/JNode.java
+4
-0
JPackage.java
jadx-gui/src/main/java/jadx/gui/treemodel/JPackage.java
+11
-0
JRoot.java
jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java
+10
-0
field_default_obj.png
jadx-gui/src/main/resources/icons-16/field_default_obj.png
+0
-0
No files found.
NOTICE
View file @
c4cdd851
...
@@ -2,7 +2,7 @@ The majority of jadx is written and copyrighted by me (Skylot)
...
@@ -2,7 +2,7 @@ The majority of jadx is written and copyrighted by me (Skylot)
and released under the Apache 2.0 license:
and released under the Apache 2.0 license:
*******************************************************************************
*******************************************************************************
Copyright 2013 Skylot
Copyright 2013
,
Skylot
Licensed under the Apache License, Version 2.0 (the "License");
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
you may not use this file except in compliance with the License.
...
@@ -105,7 +105,41 @@ as published by the Free Software Foundation.
...
@@ -105,7 +105,41 @@ as published by the Free Software Foundation.
*******************************************************************************
*******************************************************************************
GUI icons copied from several places:
Jadx-gui components
===================
RSyntaxTextArea library licensed under modified BSD liense:
*******************************************************************************
Copyright (c) 2012, Robert Futrell
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
Icons copied from several places:
- Eclipse Project (JDT UI) - licensed under EPL v1.0 (http://www.eclipse.org/legal/epl-v10.html)
- Eclipse Project (JDT UI) - licensed under EPL v1.0 (http://www.eclipse.org/legal/epl-v10.html)
- famfamfam silk icon set (http://www.famfamfam.com/lab/icons/silk/) - licensed under Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/)
- famfamfam silk icon set (http://www.famfamfam.com/lab/icons/silk/) - licensed under Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/)
jadx-gui/src/main/java/jadx/gui/MainWindow.java
View file @
c4cdd851
package
jadx
.
gui
;
package
jadx
.
gui
;
import
jadx.api.JavaClass
;
import
jadx.cli.JadxArgs
;
import
jadx.cli.JadxArgs
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JRoot
;
import
jadx.gui.treemodel.JRoot
;
...
@@ -23,10 +21,10 @@ import javax.swing.event.TreeSelectionEvent;
...
@@ -23,10 +21,10 @@ import javax.swing.event.TreeSelectionEvent;
import
javax.swing.event.TreeSelectionListener
;
import
javax.swing.event.TreeSelectionListener
;
import
javax.swing.filechooser.FileFilter
;
import
javax.swing.filechooser.FileFilter
;
import
javax.swing.filechooser.FileNameExtensionFilter
;
import
javax.swing.filechooser.FileNameExtensionFilter
;
import
javax.swing.text.BadLocationException
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeCellRenderer
;
import
javax.swing.tree.DefaultTreeCellRenderer
;
import
javax.swing.tree.DefaultTreeModel
;
import
javax.swing.tree.DefaultTreeModel
;
import
javax.swing.tree.TreePath
;
import
javax.swing.tree.TreeSelectionModel
;
import
javax.swing.tree.TreeSelectionModel
;
import
java.awt.BorderLayout
;
import
java.awt.BorderLayout
;
import
java.awt.Color
;
import
java.awt.Color
;
...
@@ -76,7 +74,6 @@ public class MainWindow extends JFrame {
...
@@ -76,7 +74,6 @@ public class MainWindow extends JFrame {
treeModel
.
setRoot
(
treeRoot
);
treeModel
.
setRoot
(
treeRoot
);
treeModel
.
reload
();
treeModel
.
reload
();
tree
.
expandRow
(
0
);
tree
.
expandRow
(
0
);
// expandTree();
}
}
private
void
toggleFlattenPackage
()
{
private
void
toggleFlattenPackage
()
{
...
@@ -89,15 +86,26 @@ public class MainWindow extends JFrame {
...
@@ -89,15 +86,26 @@ public class MainWindow extends JFrame {
}
}
}
}
private
void
expandTree
()
{
private
void
treeClickAction
()
{
DefaultMutableTreeNode
currentNode
=
((
DefaultMutableTreeNode
)
tree
.
getModel
().
getRoot
()).
getNextNode
();
Object
obj
=
tree
.
getLastSelectedPathComponent
();
do
{
if
(
obj
instanceof
JNode
)
{
if
(
currentNode
.
getLevel
()
==
1
)
{
JNode
node
=
(
JNode
)
obj
;
tree
.
expandPath
(
new
TreePath
(
currentNode
.
getPath
()));
if
(
node
.
getJParent
()
!=
null
)
{
textArea
.
setText
(
node
.
getJParent
().
getCode
());
scrollToLine
(
node
.
getLine
());
}
}
currentNode
=
currentNode
.
getNextNode
();
}
}
while
(
currentNode
!=
null
);
}
private
void
scrollToLine
(
int
line
)
{
if
(
line
<
2
)
{
return
;
}
try
{
textArea
.
setCaretPosition
(
textArea
.
getLineStartOffset
(
line
-
1
));
}
catch
(
BadLocationException
e
)
{
LOG
.
error
(
"Can't scroll to "
+
line
,
e
);
}
}
}
private
void
initMenuAndToolbar
()
{
private
void
initMenuAndToolbar
()
{
...
@@ -165,14 +173,8 @@ public class MainWindow extends JFrame {
...
@@ -165,14 +173,8 @@ public class MainWindow extends JFrame {
tree
.
getSelectionModel
().
setSelectionMode
(
TreeSelectionModel
.
SINGLE_TREE_SELECTION
);
tree
.
getSelectionModel
().
setSelectionMode
(
TreeSelectionModel
.
SINGLE_TREE_SELECTION
);
tree
.
addTreeSelectionListener
(
new
TreeSelectionListener
()
{
tree
.
addTreeSelectionListener
(
new
TreeSelectionListener
()
{
@Override
@Override
public
void
valueChanged
(
TreeSelectionEvent
e
)
{
public
void
valueChanged
(
TreeSelectionEvent
event
)
{
Object
obj
=
tree
.
getLastSelectedPathComponent
();
treeClickAction
();
if
(
obj
instanceof
JClass
)
{
JavaClass
jc
=
((
JClass
)
obj
).
getCls
();
String
code
=
jc
.
getCode
();
textArea
.
setText
(
code
);
textArea
.
setCaretPosition
(
0
);
}
}
}
});
});
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JClass.java
View file @
c4cdd851
package
jadx
.
gui
.
treemodel
;
package
jadx
.
gui
.
treemodel
;
import
jadx.api.JavaClass
;
import
jadx.api.JavaClass
;
import
jadx.api.JavaField
;
import
jadx.api.JavaMethod
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.gui.Utils
;
import
jadx.gui.Utils
;
...
@@ -19,10 +21,10 @@ public class JClass extends DefaultMutableTreeNode implements JNode {
...
@@ -19,10 +21,10 @@ public class JClass extends DefaultMutableTreeNode implements JNode {
private
static
final
ImageIcon
ICON_ANNOTATION
=
Utils
.
openIcon
(
"annotation_obj"
);
private
static
final
ImageIcon
ICON_ANNOTATION
=
Utils
.
openIcon
(
"annotation_obj"
);
private
final
JavaClass
cls
;
private
final
JavaClass
cls
;
private
JClass
jParrent
;
public
JClass
(
JavaClass
cls
)
{
public
JClass
(
JavaClass
cls
)
{
this
.
cls
=
cls
;
this
.
cls
=
cls
;
updateChilds
();
}
}
public
JavaClass
getCls
()
{
public
JavaClass
getCls
()
{
...
@@ -31,9 +33,23 @@ public class JClass extends DefaultMutableTreeNode implements JNode {
...
@@ -31,9 +33,23 @@ public class JClass extends DefaultMutableTreeNode implements JNode {
@Override
@Override
public
void
updateChilds
()
{
public
void
updateChilds
()
{
// for (JavaClass javaClass : cls.getInnerClasses()) {
JClass
currentParent
=
jParrent
==
null
?
this
:
jParrent
;
// add(new JClass(javaClass));
for
(
JavaClass
javaClass
:
cls
.
getInnerClasses
())
{
// }
JClass
child
=
new
JClass
(
javaClass
);
child
.
setJParent
(
currentParent
);
child
.
updateChilds
();
add
(
child
);
}
for
(
JavaField
f
:
cls
.
getFields
())
{
add
(
new
JField
(
f
,
currentParent
));
}
for
(
JavaMethod
m
:
cls
.
getMethods
())
{
add
(
new
JMethod
(
m
,
currentParent
));
}
}
public
String
getCode
(){
return
cls
.
getCode
();
}
}
@Override
@Override
...
@@ -57,6 +73,20 @@ public class JClass extends DefaultMutableTreeNode implements JNode {
...
@@ -57,6 +73,20 @@ public class JClass extends DefaultMutableTreeNode implements JNode {
}
}
}
}
public
void
setJParent
(
JClass
parent
)
{
this
.
jParrent
=
parent
;
}
@Override
public
JClass
getJParent
()
{
return
jParrent
;
}
@Override
public
int
getLine
()
{
return
cls
.
getDecompiledLine
();
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
cls
.
getShortName
();
return
cls
.
getShortName
();
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JField.java
0 → 100644
View file @
c4cdd851
package
jadx
.
gui
.
treemodel
;
import
jadx.api.JavaField
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.gui.Utils
;
import
javax.swing.Icon
;
import
javax.swing.ImageIcon
;
import
javax.swing.tree.DefaultMutableTreeNode
;
public
class
JField
extends
DefaultMutableTreeNode
implements
JNode
{
private
static
final
ImageIcon
ICON_FLD_DEF
=
Utils
.
openIcon
(
"field_default_obj"
);
private
static
final
ImageIcon
ICON_FLD_PRI
=
Utils
.
openIcon
(
"field_private_obj"
);
private
static
final
ImageIcon
ICON_FLD_PRO
=
Utils
.
openIcon
(
"field_protected_obj"
);
private
static
final
ImageIcon
ICON_FLD_PUB
=
Utils
.
openIcon
(
"field_public_obj"
);
private
final
JavaField
field
;
private
final
JClass
jParent
;
public
JField
(
JavaField
javaField
,
JClass
jClass
)
{
this
.
field
=
javaField
;
this
.
jParent
=
jClass
;
}
@Override
public
void
updateChilds
()
{
}
@Override
public
JClass
getJParent
()
{
return
jParent
;
}
@Override
public
int
getLine
()
{
return
field
.
getDecompiledLine
();
}
@Override
public
Icon
getIcon
()
{
AccessInfo
af
=
field
.
getAccessFlags
();
if
(
af
.
isPublic
()){
return
ICON_FLD_PUB
;
}
else
if
(
af
.
isPrivate
())
{
return
ICON_FLD_PRI
;
}
else
if
(
af
.
isProtected
())
{
return
ICON_FLD_PRO
;
}
else
{
return
ICON_FLD_DEF
;
}
}
@Override
public
String
toString
()
{
return
field
.
getName
();
}
}
jadx-gui/src/main/java/jadx/gui/treemodel/JMethod.java
0 → 100644
View file @
c4cdd851
package
jadx
.
gui
.
treemodel
;
import
jadx.api.JavaMethod
;
import
jadx.core.dex.info.AccessInfo
;
import
jadx.gui.Utils
;
import
javax.swing.Icon
;
import
javax.swing.ImageIcon
;
import
javax.swing.tree.DefaultMutableTreeNode
;
public
class
JMethod
extends
DefaultMutableTreeNode
implements
JNode
{
private
static
final
ImageIcon
ICON_MTH_DEF
=
Utils
.
openIcon
(
"methdef_obj"
);
private
static
final
ImageIcon
ICON_MTH_PRI
=
Utils
.
openIcon
(
"methpri_obj"
);
private
static
final
ImageIcon
ICON_MTH_PRO
=
Utils
.
openIcon
(
"methpro_obj"
);
private
static
final
ImageIcon
ICON_MTH_PUB
=
Utils
.
openIcon
(
"methpub_obj"
);
private
final
JavaMethod
mth
;
private
final
JClass
jparent
;
public
JMethod
(
JavaMethod
javaMethod
,
JClass
jClass
)
{
this
.
mth
=
javaMethod
;
this
.
jparent
=
jClass
;
}
@Override
public
void
updateChilds
()
{
}
@Override
public
JClass
getJParent
()
{
return
jparent
;
}
@Override
public
int
getLine
()
{
return
mth
.
getDecompiledLine
();
}
@Override
public
Icon
getIcon
()
{
AccessInfo
af
=
mth
.
getAccessFlags
();
if
(
af
.
isPublic
())
{
return
ICON_MTH_PUB
;
}
else
if
(
af
.
isPrivate
())
{
return
ICON_MTH_PRI
;
}
else
if
(
af
.
isProtected
())
{
return
ICON_MTH_PRO
;
}
else
{
return
ICON_MTH_DEF
;
}
}
@Override
public
String
toString
()
{
return
mth
.
getName
();
}
}
jadx-gui/src/main/java/jadx/gui/treemodel/JNode.java
View file @
c4cdd851
...
@@ -4,6 +4,10 @@ import javax.swing.Icon;
...
@@ -4,6 +4,10 @@ import javax.swing.Icon;
public
interface
JNode
{
public
interface
JNode
{
JClass
getJParent
();
int
getLine
();
void
updateChilds
();
void
updateChilds
();
Icon
getIcon
();
Icon
getIcon
();
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JPackage.java
View file @
c4cdd851
...
@@ -40,6 +40,7 @@ public class JPackage extends DefaultMutableTreeNode implements JNode, Comparabl
...
@@ -40,6 +40,7 @@ public class JPackage extends DefaultMutableTreeNode implements JNode, Comparabl
add
(
pkg
);
add
(
pkg
);
}
}
for
(
JClass
cls
:
classes
)
{
for
(
JClass
cls
:
classes
)
{
cls
.
updateChilds
();
add
(
cls
);
add
(
cls
);
}
}
}
}
...
@@ -66,6 +67,16 @@ public class JPackage extends DefaultMutableTreeNode implements JNode, Comparabl
...
@@ -66,6 +67,16 @@ public class JPackage extends DefaultMutableTreeNode implements JNode, Comparabl
}
}
@Override
@Override
public
JClass
getJParent
()
{
return
null
;
}
@Override
public
int
getLine
()
{
return
0
;
}
@Override
public
int
compareTo
(
JPackage
o
)
{
public
int
compareTo
(
JPackage
o
)
{
return
name
.
compareTo
(
o
.
name
);
return
name
.
compareTo
(
o
.
name
);
}
}
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JRoot.java
View file @
c4cdd851
...
@@ -119,6 +119,16 @@ public class JRoot extends DefaultMutableTreeNode implements JNode {
...
@@ -119,6 +119,16 @@ public class JRoot extends DefaultMutableTreeNode implements JNode {
}
}
@Override
@Override
public
JClass
getJParent
()
{
return
null
;
}
@Override
public
int
getLine
()
{
return
0
;
}
@Override
public
String
toString
()
{
public
String
toString
()
{
File
file
=
wrapper
.
getOpenFile
();
File
file
=
wrapper
.
getOpenFile
();
return
file
!=
null
?
file
.
getName
()
:
"File not open"
;
return
file
!=
null
?
file
.
getName
()
:
"File not open"
;
...
...
jadx-gui/src/main/resources/icons-16/field_default_obj.png
0 → 100644
View file @
c4cdd851
218 Bytes
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment