Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
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
f8039733
Commit
f8039733
authored
Apr 20, 2019
by
Ahmed Ashour
Committed by
skylot
Apr 20, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(gui): save tree expansions in project (PR #605)
parent
87ca14af
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
4 deletions
+92
-4
JavaClass.java
jadx-core/src/main/java/jadx/api/JavaClass.java
+1
-1
JadxProject.java
jadx-gui/src/main/java/jadx/gui/settings/JadxProject.java
+22
-0
MainWindow.java
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
+68
-2
PathTypeAdapter.java
jadx-gui/src/main/java/jadx/gui/utils/PathTypeAdapter.java
+1
-1
No files found.
jadx-core/src/main/java/jadx/api/JavaClass.java
View file @
f8039733
...
...
@@ -68,7 +68,7 @@ public final class JavaClass implements JavaNode {
cls
.
unload
();
}
ClassNode
getClassNode
()
{
public
ClassNode
getClassNode
()
{
return
cls
;
}
...
...
jadx-gui/src/main/java/jadx/gui/settings/JadxProject.java
View file @
f8039733
...
...
@@ -3,7 +3,9 @@ package jadx.gui.settings;
import
java.io.BufferedWriter
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Iterator
;
import
java.util.List
;
import
org.slf4j.Logger
;
...
...
@@ -29,6 +31,8 @@ public class JadxProject {
private
transient
String
name
=
"New Project"
;
private
transient
Path
projectPath
;
private
List
<
Path
>
filesPath
;
private
List
<
String
[]>
treeExpansions
=
new
ArrayList
<>();
private
transient
boolean
saved
;
private
transient
boolean
initial
=
true
;
...
...
@@ -63,6 +67,24 @@ public class JadxProject {
}
}
public
List
<
String
[]>
getTreeExpansions
()
{
return
treeExpansions
;
}
public
void
addTreeExpansion
(
String
[]
expansion
)
{
treeExpansions
.
add
(
expansion
);
changed
();
}
public
void
removeTreeExpansion
(
String
[]
expansion
)
{
for
(
Iterator
<
String
[]>
it
=
treeExpansions
.
iterator
();
it
.
hasNext
();
)
{
if
(
Arrays
.
equals
(
it
.
next
(),
expansion
))
{
it
.
remove
();
}
}
changed
();
}
private
void
changed
()
{
if
(
settings
.
isAutoSaveProject
())
{
save
();
...
...
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
View file @
f8039733
...
...
@@ -23,7 +23,9 @@ import java.io.FileInputStream;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Timer
;
import
java.util.TimerTask
;
...
...
@@ -130,6 +132,7 @@ public class MainWindow extends JFrame {
private
JRoot
treeRoot
;
private
TabbedPane
tabbedPane
;
private
HeapUsageBar
heapUsageBar
;
private
transient
boolean
treeReloading
;
private
boolean
isFlattenPackage
;
private
JToggleButton
flatPkgButton
;
...
...
@@ -431,8 +434,34 @@ public class MainWindow extends JFrame {
}
private
void
reloadTree
()
{
treeReloading
=
true
;
treeModel
.
reload
();
tree
.
expandRow
(
1
);
List
<
String
[]>
treeExpansions
=
project
.
getTreeExpansions
();
if
(!
treeExpansions
.
isEmpty
())
{
expand
(
treeRoot
,
treeExpansions
);
}
else
{
tree
.
expandRow
(
1
);
}
treeReloading
=
false
;
}
private
void
expand
(
TreeNode
node
,
List
<
String
[]>
treeExpansions
)
{
TreeNode
[]
pathNodes
=
treeModel
.
getPathToRoot
(
node
);
if
(
pathNodes
==
null
)
{
return
;
}
TreePath
path
=
new
TreePath
(
pathNodes
);
for
(
String
[]
expansion
:
treeExpansions
)
{
if
(
Arrays
.
equals
(
expansion
,
getPathExpansion
(
path
)))
{
tree
.
expandPath
(
path
);
break
;
}
}
for
(
int
i
=
node
.
getChildCount
()
-
1
;
i
>=
0
;
i
--)
{
expand
(
node
.
getChildAt
(
i
),
treeExpansions
);
}
}
private
void
toggleFlattenPackage
()
{
...
...
@@ -824,11 +853,18 @@ public class MainWindow extends JFrame {
if
(
node
instanceof
JLoadableNode
)
{
((
JLoadableNode
)
node
).
loadNode
();
}
if
(!
treeReloading
)
{
project
.
addTreeExpansion
(
getPathExpansion
(
event
.
getPath
()));
update
();
}
}
@Override
public
void
treeWillCollapse
(
TreeExpansionEvent
event
)
{
// ignore
if
(!
treeReloading
)
{
project
.
removeTreeExpansion
(
getPathExpansion
(
event
.
getPath
()));
update
();
}
}
});
...
...
@@ -851,6 +887,36 @@ public class MainWindow extends JFrame {
setTitle
(
DEFAULT_TITLE
);
}
private
static
String
[]
getPathExpansion
(
TreePath
path
)
{
List
<
String
>
pathList
=
new
ArrayList
<>();
while
(
path
!=
null
)
{
Object
node
=
path
.
getLastPathComponent
();
String
name
;
if
(
node
instanceof
JClass
)
{
name
=
((
JClass
)
node
).
getCls
().
getClassNode
().
getClassInfo
().
getFullName
();
}
else
{
name
=
node
.
toString
();
}
pathList
.
add
(
name
);
path
=
path
.
getParentPath
();
}
return
pathList
.
toArray
(
new
String
[
pathList
.
size
()]);
}
public
static
void
getExpandedPaths
(
JTree
tree
,
TreePath
path
,
List
<
TreePath
>
list
)
{
if
(
tree
.
isExpanded
(
path
))
{
list
.
add
(
path
);
TreeNode
node
=
(
TreeNode
)
path
.
getLastPathComponent
();
for
(
int
i
=
node
.
getChildCount
()
-
1
;
i
>=
0
;
i
--)
{
TreeNode
n
=
node
.
getChildAt
(
i
);
TreePath
child
=
path
.
pathByAddingChild
(
n
);
getExpandedPaths
(
tree
,
child
,
list
);
}
}
}
public
void
setLocationAndPosition
()
{
if
(
this
.
settings
.
loadWindowPos
(
this
))
{
return
;
...
...
jadx-gui/src/main/java/jadx/gui/utils/PathTypeAdapter.java
View file @
f8039733
...
...
@@ -9,7 +9,7 @@ import com.google.gson.stream.JsonReader;
import
com.google.gson.stream.JsonToken
;
import
com.google.gson.stream.JsonWriter
;
public
class
PathTypeAdapter
{
public
class
PathTypeAdapter
{
private
static
TypeAdapter
<
Path
>
SINGLETON
;
...
...
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