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
1c874133
Unverified
Commit
1c874133
authored
Mar 20, 2019
by
skylot
Committed by
GitHub
Mar 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
GUI: disable package if "excluded" (#477)
parents
3019ee56
a3ff03c8
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
36 deletions
+144
-36
JadxWrapper.java
jadx-gui/src/main/java/jadx/gui/JadxWrapper.java
+24
-5
JadxSettings.java
jadx-gui/src/main/java/jadx/gui/settings/JadxSettings.java
+1
-0
JadxSettingsWindow.java
...i/src/main/java/jadx/gui/settings/JadxSettingsWindow.java
+4
-0
JPackage.java
jadx-gui/src/main/java/jadx/gui/treemodel/JPackage.java
+35
-10
JSources.java
jadx-gui/src/main/java/jadx/gui/treemodel/JSources.java
+3
-3
MainWindow.java
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
+77
-18
No files found.
jadx-gui/src/main/java/jadx/gui/JadxWrapper.java
View file @
1c874133
package
jadx
.
gui
;
package
jadx
.
gui
;
import
javax.swing.*
;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.swing.ProgressMonitor
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -78,14 +81,13 @@ public class JadxWrapper {
...
@@ -78,14 +81,13 @@ public class JadxWrapper {
*/
*/
public
List
<
JavaClass
>
getIncludedClasses
()
{
public
List
<
JavaClass
>
getIncludedClasses
()
{
List
<
JavaClass
>
classList
=
decompiler
.
getClasses
();
List
<
JavaClass
>
classList
=
decompiler
.
getClasses
();
String
excludedPackages
=
settings
.
getExcludedPackages
().
trim
();
List
<
String
>
excludedPackages
=
getExcludedPackages
();
if
(
excludedPackages
.
length
()
==
0
)
{
if
(
excludedPackages
.
isEmpty
()
)
{
return
classList
;
return
classList
;
}
}
String
[]
excluded
=
excludedPackages
.
split
(
"[ ]+"
);
return
classList
.
stream
().
filter
(
cls
->
{
return
classList
.
stream
().
filter
(
cls
->
{
for
(
String
exclude
:
excluded
)
{
for
(
String
exclude
:
excluded
Packages
)
{
if
(
cls
.
getFullName
().
startsWith
(
exclude
))
{
if
(
cls
.
getFullName
().
startsWith
(
exclude
))
{
return
false
;
return
false
;
}
}
...
@@ -94,6 +96,23 @@ public class JadxWrapper {
...
@@ -94,6 +96,23 @@ public class JadxWrapper {
}).
collect
(
Collectors
.
toList
());
}).
collect
(
Collectors
.
toList
());
}
}
public
List
<
String
>
getExcludedPackages
()
{
String
excludedPackages
=
settings
.
getExcludedPackages
().
trim
();
return
Arrays
.
asList
(
excludedPackages
.
split
(
"[ ]+"
));
}
public
void
addExcludedPackage
(
String
packageToExclude
)
{
settings
.
setExcludedPackages
(
settings
.
getExcludedPackages
()
+
' '
+
packageToExclude
);
settings
.
sync
();
}
public
void
removeExcludedPackage
(
String
packageToRemoveFromExclusion
)
{
List
<
String
>
list
=
new
ArrayList
<>(
getExcludedPackages
());
list
.
remove
(
packageToRemoveFromExclusion
);
settings
.
setExcludedPackages
(
String
.
join
(
" "
,
list
));
settings
.
sync
();
}
public
List
<
JavaPackage
>
getPackages
()
{
public
List
<
JavaPackage
>
getPackages
()
{
return
decompiler
.
getPackages
();
return
decompiler
.
getPackages
();
}
}
...
...
jadx-gui/src/main/java/jadx/gui/settings/JadxSettings.java
View file @
1c874133
...
@@ -333,4 +333,5 @@ public class JadxSettings extends JadxCLIArgs {
...
@@ -333,4 +333,5 @@ public class JadxSettings extends JadxCLIArgs {
settingsVersion
=
CURRENT_SETTINGS_VERSION
;
settingsVersion
=
CURRENT_SETTINGS_VERSION
;
sync
();
sync
();
}
}
}
}
jadx-gui/src/main/java/jadx/gui/settings/JadxSettingsWindow.java
View file @
1c874133
...
@@ -247,10 +247,14 @@ public class JadxSettingsWindow extends JDialog {
...
@@ -247,10 +247,14 @@ public class JadxSettingsWindow extends JDialog {
JButton
editExcludedPackages
=
new
JButton
(
NLS
.
str
(
"preferences.excludedPackages.button"
));
JButton
editExcludedPackages
=
new
JButton
(
NLS
.
str
(
"preferences.excludedPackages.button"
));
editExcludedPackages
.
addActionListener
(
event
->
{
editExcludedPackages
.
addActionListener
(
event
->
{
String
oldExcludedPackages
=
settings
.
getExcludedPackages
();
String
result
=
JOptionPane
.
showInputDialog
(
this
,
NLS
.
str
(
"preferences.excludedPackages.editDialog"
),
String
result
=
JOptionPane
.
showInputDialog
(
this
,
NLS
.
str
(
"preferences.excludedPackages.editDialog"
),
settings
.
getExcludedPackages
());
settings
.
getExcludedPackages
());
if
(
result
!=
null
)
{
if
(
result
!=
null
)
{
settings
.
setExcludedPackages
(
result
);
settings
.
setExcludedPackages
(
result
);
if
(!
oldExcludedPackages
.
equals
(
result
))
{
needReload
();
}
}
}
});
});
...
...
jadx-gui/src/main/java/jadx/gui/treemodel/JPackage.java
View file @
1c874133
package
jadx
.
gui
.
treemodel
;
package
jadx
.
gui
.
treemodel
;
import
javax.swing.*
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
javax.swing.Icon
;
import
javax.swing.ImageIcon
;
import
org.jetbrains.annotations.NotNull
;
import
org.jetbrains.annotations.NotNull
;
import
jadx.api.JavaClass
;
import
jadx.api.JavaClass
;
import
jadx.api.JavaPackage
;
import
jadx.api.JavaPackage
;
import
jadx.gui.JadxWrapper
;
import
jadx.gui.utils.Utils
;
import
jadx.gui.utils.Utils
;
public
class
JPackage
extends
JNode
implements
Comparable
<
JPackage
>
{
public
class
JPackage
extends
JNode
implements
Comparable
<
JPackage
>
{
...
@@ -15,12 +18,16 @@ public class JPackage extends JNode implements Comparable<JPackage> {
...
@@ -15,12 +18,16 @@ public class JPackage extends JNode implements Comparable<JPackage> {
private
static
final
ImageIcon
PACKAGE_ICON
=
Utils
.
openIcon
(
"package_obj"
);
private
static
final
ImageIcon
PACKAGE_ICON
=
Utils
.
openIcon
(
"package_obj"
);
private
final
String
fullName
;
private
String
name
;
private
String
name
;
private
boolean
enabled
;
private
final
List
<
JClass
>
classes
;
private
final
List
<
JClass
>
classes
;
private
final
List
<
JPackage
>
innerPackages
=
new
ArrayList
<>(
1
);
private
final
List
<
JPackage
>
innerPackages
=
new
ArrayList
<>(
1
);
public
JPackage
(
JavaPackage
pkg
)
{
public
JPackage
(
JavaPackage
pkg
,
JadxWrapper
wrapper
)
{
this
.
fullName
=
pkg
.
getName
();
this
.
name
=
pkg
.
getName
();
this
.
name
=
pkg
.
getName
();
setEnabled
(
wrapper
);
List
<
JavaClass
>
javaClasses
=
pkg
.
getClasses
();
List
<
JavaClass
>
javaClasses
=
pkg
.
getClasses
();
this
.
classes
=
new
ArrayList
<>(
javaClasses
.
size
());
this
.
classes
=
new
ArrayList
<>(
javaClasses
.
size
());
for
(
JavaClass
javaClass
:
javaClasses
)
{
for
(
JavaClass
javaClass
:
javaClasses
)
{
...
@@ -29,13 +36,22 @@ public class JPackage extends JNode implements Comparable<JPackage> {
...
@@ -29,13 +36,22 @@ public class JPackage extends JNode implements Comparable<JPackage> {
update
();
update
();
}
}
public
JPackage
(
String
name
)
{
public
JPackage
(
String
name
,
JadxWrapper
wrapper
)
{
this
.
fullName
=
name
;
this
.
name
=
name
;
this
.
name
=
name
;
setEnabled
(
wrapper
);
this
.
classes
=
new
ArrayList
<>(
1
);
this
.
classes
=
new
ArrayList
<>(
1
);
}
}
private
void
setEnabled
(
JadxWrapper
wrapper
)
{
List
<
String
>
excludedPackages
=
wrapper
.
getExcludedPackages
();
this
.
enabled
=
excludedPackages
.
isEmpty
()
||
excludedPackages
.
stream
().
filter
(
p
->
!
p
.
isEmpty
()).
noneMatch
(
p
->
name
.
startsWith
(
p
));
}
public
final
void
update
()
{
public
final
void
update
()
{
removeAllChildren
();
removeAllChildren
();
if
(
isEnabled
())
{
for
(
JPackage
pkg
:
innerPackages
)
{
for
(
JPackage
pkg
:
innerPackages
)
{
pkg
.
update
();
pkg
.
update
();
add
(
pkg
);
add
(
pkg
);
...
@@ -45,12 +61,17 @@ public class JPackage extends JNode implements Comparable<JPackage> {
...
@@ -45,12 +61,17 @@ public class JPackage extends JNode implements Comparable<JPackage> {
add
(
cls
);
add
(
cls
);
}
}
}
}
}
@Override
@Override
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
public
String
getFullName
()
{
return
fullName
;
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
...
@@ -108,4 +129,8 @@ public class JPackage extends JNode implements Comparable<JPackage> {
...
@@ -108,4 +129,8 @@ public class JPackage extends JNode implements Comparable<JPackage> {
public
String
makeLongString
()
{
public
String
makeLongString
()
{
return
name
;
return
name
;
}
}
public
boolean
isEnabled
()
{
return
enabled
;
}
}
}
jadx-gui/src/main/java/jadx/gui/treemodel/JSources.java
View file @
1c874133
...
@@ -33,7 +33,7 @@ public class JSources extends JNode {
...
@@ -33,7 +33,7 @@ public class JSources extends JNode {
removeAllChildren
();
removeAllChildren
();
if
(
flatPackages
)
{
if
(
flatPackages
)
{
for
(
JavaPackage
pkg
:
wrapper
.
getPackages
())
{
for
(
JavaPackage
pkg
:
wrapper
.
getPackages
())
{
add
(
new
JPackage
(
pkg
));
add
(
new
JPackage
(
pkg
,
wrapper
));
}
}
}
else
{
}
else
{
// build packages hierarchy
// build packages hierarchy
...
@@ -54,7 +54,7 @@ public class JSources extends JNode {
...
@@ -54,7 +54,7 @@ public class JSources extends JNode {
List
<
JPackage
>
getHierarchyPackages
(
List
<
JavaPackage
>
packages
)
{
List
<
JPackage
>
getHierarchyPackages
(
List
<
JavaPackage
>
packages
)
{
Map
<
String
,
JPackage
>
pkgMap
=
new
HashMap
<>();
Map
<
String
,
JPackage
>
pkgMap
=
new
HashMap
<>();
for
(
JavaPackage
pkg
:
packages
)
{
for
(
JavaPackage
pkg
:
packages
)
{
addPackage
(
pkgMap
,
new
JPackage
(
pkg
));
addPackage
(
pkgMap
,
new
JPackage
(
pkg
,
wrapper
));
}
}
// merge packages without classes
// merge packages without classes
boolean
repeat
;
boolean
repeat
;
...
@@ -114,7 +114,7 @@ public class JSources extends JNode {
...
@@ -114,7 +114,7 @@ public class JSources extends JNode {
pkg
.
setName
(
shortName
);
pkg
.
setName
(
shortName
);
JPackage
prevPkg
=
pkgs
.
get
(
prevPart
);
JPackage
prevPkg
=
pkgs
.
get
(
prevPart
);
if
(
prevPkg
==
null
)
{
if
(
prevPkg
==
null
)
{
prevPkg
=
new
JPackage
(
prevPart
);
prevPkg
=
new
JPackage
(
prevPart
,
wrapper
);
addPackage
(
pkgs
,
prevPkg
);
addPackage
(
pkgs
,
prevPkg
);
}
}
prevPkg
.
getInnerPackages
().
add
(
pkg
);
prevPkg
.
getInnerPackages
().
add
(
pkg
);
...
...
jadx-gui/src/main/java/jadx/gui/ui/MainWindow.java
View file @
1c874133
package
jadx
.
gui
.
ui
;
package
jadx
.
gui
.
ui
;
import
javax.swing.*
;
import
static
javax
.
swing
.
KeyStroke
.
getKeyStroke
;
import
javax.swing.event.MenuEvent
;
import
javax.swing.event.MenuListener
;
import
java.awt.BorderLayout
;
import
javax.swing.event.TreeExpansionEvent
;
import
java.awt.Component
;
import
javax.swing.event.TreeWillExpandListener
;
import
java.awt.DisplayMode
;
import
javax.swing.filechooser.FileNameExtensionFilter
;
import
java.awt.Font
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
java.awt.GraphicsDevice
;
import
javax.swing.tree.DefaultTreeCellRenderer
;
import
java.awt.GraphicsEnvironment
;
import
javax.swing.tree.DefaultTreeModel
;
import
javax.swing.tree.TreeNode
;
import
javax.swing.tree.TreePath
;
import
javax.swing.tree.TreeSelectionModel
;
import
java.awt.*
;
import
java.awt.dnd.DnDConstants
;
import
java.awt.dnd.DnDConstants
;
import
java.awt.dnd.DropTarget
;
import
java.awt.dnd.DropTarget
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionEvent
;
...
@@ -23,12 +18,42 @@ import java.awt.event.MouseAdapter;
...
@@ -23,12 +18,42 @@ import java.awt.event.MouseAdapter;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseEvent
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Timer
;
import
java.util.Timer
;
import
java.util.TimerTask
;
import
java.util.TimerTask
;
import
javax.swing.AbstractAction
;
import
javax.swing.Action
;
import
javax.swing.Box
;
import
javax.swing.ImageIcon
;
import
javax.swing.JCheckBoxMenuItem
;
import
javax.swing.JFileChooser
;
import
javax.swing.JFrame
;
import
javax.swing.JMenu
;
import
javax.swing.JMenuBar
;
import
javax.swing.JMenuItem
;
import
javax.swing.JPanel
;
import
javax.swing.JPopupMenu
;
import
javax.swing.JScrollPane
;
import
javax.swing.JSplitPane
;
import
javax.swing.JToggleButton
;
import
javax.swing.JToolBar
;
import
javax.swing.JTree
;
import
javax.swing.ProgressMonitor
;
import
javax.swing.SwingUtilities
;
import
javax.swing.WindowConstants
;
import
javax.swing.event.MenuEvent
;
import
javax.swing.event.MenuListener
;
import
javax.swing.event.TreeExpansionEvent
;
import
javax.swing.event.TreeWillExpandListener
;
import
javax.swing.filechooser.FileNameExtensionFilter
;
import
javax.swing.tree.DefaultMutableTreeNode
;
import
javax.swing.tree.DefaultTreeCellRenderer
;
import
javax.swing.tree.DefaultTreeModel
;
import
javax.swing.tree.TreeNode
;
import
javax.swing.tree.TreePath
;
import
javax.swing.tree.TreeSelectionModel
;
import
org.fife.ui.rsyntaxtextarea.Theme
;
import
org.fife.ui.rsyntaxtextarea.Theme
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -46,6 +71,7 @@ import jadx.gui.treemodel.JCertificate;
...
@@ -46,6 +71,7 @@ import jadx.gui.treemodel.JCertificate;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JClass
;
import
jadx.gui.treemodel.JLoadableNode
;
import
jadx.gui.treemodel.JLoadableNode
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JNode
;
import
jadx.gui.treemodel.JPackage
;
import
jadx.gui.treemodel.JResource
;
import
jadx.gui.treemodel.JResource
;
import
jadx.gui.treemodel.JRoot
;
import
jadx.gui.treemodel.JRoot
;
import
jadx.gui.update.JadxUpdate
;
import
jadx.gui.update.JadxUpdate
;
...
@@ -57,8 +83,6 @@ import jadx.gui.utils.Link;
...
@@ -57,8 +83,6 @@ import jadx.gui.utils.Link;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.NLS
;
import
jadx.gui.utils.Utils
;
import
jadx.gui.utils.Utils
;
import
static
javax
.
swing
.
KeyStroke
.
getKeyStroke
;
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
MainWindow
extends
JFrame
{
public
class
MainWindow
extends
JFrame
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MainWindow
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MainWindow
.
class
);
...
@@ -315,6 +339,14 @@ public class MainWindow extends JFrame {
...
@@ -315,6 +339,14 @@ public class MainWindow extends JFrame {
}
}
}
}
private
void
treeRightClickAction
(
MouseEvent
e
)
{
Object
obj
=
tree
.
getLastSelectedPathComponent
();
if
(
obj
instanceof
JPackage
)
{
JPackagePopUp
menu
=
new
JPackagePopUp
((
JPackage
)
obj
);
menu
.
show
(
e
.
getComponent
(),
e
.
getX
(),
e
.
getY
());
}
}
private
void
syncWithEditor
()
{
private
void
syncWithEditor
()
{
ContentPanel
selectedContentPanel
=
tabbedPane
.
getSelectedCodePanel
();
ContentPanel
selectedContentPanel
=
tabbedPane
.
getSelectedCodePanel
();
if
(
selectedContentPanel
==
null
)
{
if
(
selectedContentPanel
==
null
)
{
...
@@ -574,8 +606,13 @@ public class MainWindow extends JFrame {
...
@@ -574,8 +606,13 @@ public class MainWindow extends JFrame {
tree
.
addMouseListener
(
new
MouseAdapter
()
{
tree
.
addMouseListener
(
new
MouseAdapter
()
{
@Override
@Override
public
void
mouseClicked
(
MouseEvent
e
)
{
public
void
mouseClicked
(
MouseEvent
e
)
{
if
(
SwingUtilities
.
isRightMouseButton
(
e
))
{
treeRightClickAction
(
e
);
}
else
{
treeClickAction
();
treeClickAction
();
}
}
}
});
});
tree
.
addKeyListener
(
new
KeyAdapter
()
{
tree
.
addKeyListener
(
new
KeyAdapter
()
{
@Override
@Override
...
@@ -594,6 +631,9 @@ public class MainWindow extends JFrame {
...
@@ -594,6 +631,9 @@ public class MainWindow extends JFrame {
if
(
value
instanceof
JNode
)
{
if
(
value
instanceof
JNode
)
{
setIcon
(((
JNode
)
value
).
getIcon
());
setIcon
(((
JNode
)
value
).
getIcon
());
}
}
if
(
value
instanceof
JPackage
)
{
setEnabled
(((
JPackage
)
value
).
isEnabled
());
}
return
c
;
return
c
;
}
}
});
});
...
@@ -740,4 +780,23 @@ public class MainWindow extends JFrame {
...
@@ -740,4 +780,23 @@ public class MainWindow extends JFrame {
public
void
menuCanceled
(
MenuEvent
e
)
{
public
void
menuCanceled
(
MenuEvent
e
)
{
}
}
}
}
private
class
JPackagePopUp
extends
JPopupMenu
{
JMenuItem
excludeItem
=
new
JCheckBoxMenuItem
(
"Exclude"
);
public
JPackagePopUp
(
JPackage
pkg
)
{
excludeItem
.
setSelected
(!
pkg
.
isEnabled
());
add
(
excludeItem
);
excludeItem
.
addItemListener
(
e
->
{
String
fullName
=
pkg
.
getFullName
();
if
(
excludeItem
.
isSelected
())
{
wrapper
.
addExcludedPackage
(
fullName
);
}
else
{
wrapper
.
removeExcludedPackage
(
fullName
);
}
reOpenFile
();
});
}
}
}
}
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