11package jadx .plugins .stringdecoder ;
22
3+ import java .awt .BorderLayout ;
4+ import java .awt .Component ;
35import java .util .List ;
46import java .util .stream .Collectors ;
57
68import javax .swing .BoxLayout ;
79import javax .swing .JComponent ;
10+ import javax .swing .JLabel ;
811import javax .swing .JPanel ;
912
1013import jadx .api .plugins .JadxPlugin ;
@@ -46,6 +49,32 @@ public void init(JadxPluginContext context) {
4649 }
4750 }
4851
52+ private static JComponent buildSection (JadxGuiContext guiCtx , String title ,
53+ List <OptionDescription > opts , String note ) {
54+ JComponent panel = guiCtx .settings ().buildSettingsGroupForOptions (title , opts ).buildComponent ();
55+ // panel is a BorderLayout JPanel with a TitledBorder; the option grid sits at PAGE_START.
56+ // Pull the grid out, wrap it with the note label, and re-insert so the note is inside the border.
57+ if (panel .getLayout () instanceof BorderLayout ) {
58+ BorderLayout bl = (BorderLayout ) panel .getLayout ();
59+ Component grid = bl .getLayoutComponent (BorderLayout .PAGE_START );
60+ if (grid != null ) {
61+ panel .remove (grid );
62+ JLabel noteLabel = new JLabel (note );
63+ noteLabel .setEnabled (false );
64+ noteLabel .setAlignmentX (Component .LEFT_ALIGNMENT );
65+ if (grid instanceof JComponent ) {
66+ ((JComponent ) grid ).setAlignmentX (Component .LEFT_ALIGNMENT );
67+ }
68+ JPanel inner = new JPanel ();
69+ inner .setLayout (new BoxLayout (inner , BoxLayout .PAGE_AXIS ));
70+ inner .add (noteLabel );
71+ inner .add (grid );
72+ panel .add (inner , BorderLayout .PAGE_START );
73+ }
74+ }
75+ return panel ;
76+ }
77+
4978 private void setupCustomSettingsGroup (JadxGuiContext guiCtx ) {
5079 guiCtx .settings ().setCustomSettingsGroup (new ISettingsGroup () {
5180 private JPanel panel ;
@@ -66,17 +95,12 @@ public JComponent buildComponent() {
6695 .filter (o -> o .name ().contains ("ByteArray" ))
6796 .collect (Collectors .toList ());
6897
69- JComponent b64Panel = guiCtx .settings ()
70- .buildSettingsGroupForOptions ("B64 String Decoder" , b64Opts )
71- .buildComponent ();
72- JComponent byteArrayPanel = guiCtx .settings ()
73- .buildSettingsGroupForOptions ("Byte Array String Decoder" , byteArrayOpts )
74- .buildComponent ();
75-
7698 panel = new JPanel ();
7799 panel .setLayout (new BoxLayout (panel , BoxLayout .PAGE_AXIS ));
78- panel .add (b64Panel );
79- panel .add (byteArrayPanel );
100+ panel .add (JadxStringDecoderPlugin .buildSection (guiCtx , "B64 String Decoder" , b64Opts ,
101+ "* Adds // b64: <DECODED_VALUE> comments to Base64-encoded string/field initializers." ));
102+ panel .add (JadxStringDecoderPlugin .buildSection (guiCtx , "Byte Array String Decoder" , byteArrayOpts ,
103+ "* Adds // bytes: <DECODED_VALUE> comments to byte[] fields that decode to printable strings." ));
80104 }
81105 return panel ;
82106 }
0 commit comments