77import javax .swing .*;
88import javax .swing .border .TitledBorder ;
99
10+ import com .javadeobfuscator .deobfuscator .ui .component .SwingConfiguration ;
11+ import com .javadeobfuscator .deobfuscator .ui .component .SwingConfiguration .ConfigItem ;
1012import com .javadeobfuscator .deobfuscator .ui .util .FallbackException ;
1113import com .javadeobfuscator .deobfuscator .ui .util .InvalidJarException ;
1214import com .javadeobfuscator .deobfuscator .ui .wrap .Config ;
@@ -35,10 +37,11 @@ public static void main(String[] args)
3537 e .printStackTrace ();
3638 }
3739 loadWrappers ();
40+ List <ConfigItem > fields = new SwingConfiguration (config .get ()).fieldsList ;
3841 //Initial frame
3942 JFrame frame = new JFrame ();
4043 frame .setTitle ("Deobfuscator GUI" );
41- frame .setBounds (100 , 100 , 580 , 560 );
44+ frame .setBounds (100 , 100 , 580 , 650 );
4245 frame .getContentPane ().setLayout (new GridBagLayout ());
4346 frame .setDefaultCloseOperation (WindowConstants .EXIT_ON_CLOSE );
4447
@@ -53,23 +56,26 @@ public static void main(String[] args)
5356 inputPnl .setBorder (new TitledBorder ("Deobfuscator Input" ));
5457 frame .getContentPane ().add (inputPnl , gbc_IPanel );
5558 inputPnl .setLayout (new GridBagLayout ());
56- //TODO Options are loaded below
59+
5760 int gridy = 0 ;
58- for (gridy = 0 ; gridy < 2 ; gridy ++ )
61+ for (ConfigItem i : fields )
5962 {
63+ if (i .type != SwingConfiguration .ItemType .FILE )
64+ continue ;
6065 GridBagConstraints gbc_Label = new GridBagConstraints ();
6166 gbc_Label .anchor = GridBagConstraints .PAGE_START ;
6267 gbc_Label .insets = new Insets (5 , 2 , 2 , 2 );
6368 gbc_Label .gridx = 0 ;
6469 gbc_Label .gridy = gridy ;
65- inputPnl .add (new JLabel (gridy == 0 ? "Input:" : "Output :" ), gbc_Label );
70+ inputPnl .add (new JLabel (i . getDisplayName () + " :" ), gbc_Label );
6671 GridBagConstraints gbc_Text = new GridBagConstraints ();
6772 gbc_Text .insets = new Insets (5 , 2 , 2 , 2 );
6873 gbc_Text .gridx = 1 ;
6974 gbc_Text .gridy = gridy ;
7075 gbc_Text .weightx = 1 ;
7176 gbc_Text .fill = GridBagConstraints .HORIZONTAL ;
7277 JTextField textField = new JTextField ();
78+ i .component = textField ;
7379 inputPnl .add (textField , gbc_Text );
7480 GridBagConstraints gbc_Select = new GridBagConstraints ();
7581 gbc_Select .insets = new Insets (5 , 7 , 2 , 2 );
@@ -78,16 +84,21 @@ public static void main(String[] args)
7884 gbc_Select .ipadx = 15 ;
7985 JButton button = new JButton ("Select" );
8086 inputPnl .add (button , gbc_Select );
87+ gridy ++;
8188 }
82- for (gridy = 2 ; gridy < 4 ; gridy ++ )
89+ for (ConfigItem i : fields )
8390 {
91+ if (i .type != SwingConfiguration .ItemType .BOOLEAN )
92+ continue ;
8493 GridBagConstraints gbc_box = new GridBagConstraints ();
8594 gbc_box .anchor = GridBagConstraints .FIRST_LINE_START ;
8695 gbc_box .insets = new Insets (5 , 2 , 2 , 2 );
8796 gbc_box .gridx = 0 ;
8897 gbc_box .gridy = gridy ;
89- JCheckBox checkBox = new JCheckBox (gridy == 2 ? "Verify" : "Detect" );
98+ JCheckBox checkBox = new JCheckBox (i .getDisplayName ());
99+ i .component = checkBox ;
90100 inputPnl .add (checkBox , gbc_box );
101+ gridy ++;
91102 }
92103
93104 //Other Options
@@ -189,125 +200,135 @@ public static void main(String[] args)
189200 panel3 .add (remove , gbc_remove );
190201 tabbedPane .addTab ("Transformers" , transformersPanel );
191202
192- //TODO: FILE LIST
193- JPanel libPanel = new JPanel ();
194- libPanel .setLayout (new GridBagLayout ());
195- JScrollPane libListScroll = new JScrollPane ();
196- DefaultListModel <String > librariesList = new DefaultListModel <>();
197- JList <String > libJList = new JList <>(librariesList );
198- libJList .setSelectionMode (ListSelectionModel .MULTIPLE_INTERVAL_SELECTION );
199- libJList .setModel (librariesList );
200- libListScroll .setViewportView (libJList );
201- GridBagConstraints gbl_libraries = new GridBagConstraints ();
202- gbl_libraries .gridx = 0 ;
203- gbl_libraries .gridy = 0 ;
204- gbl_libraries .gridheight = 4 ;
205- gbl_libraries .anchor = GridBagConstraints .FIRST_LINE_START ;
206- gbl_libraries .fill = GridBagConstraints .BOTH ;
207- gbl_libraries .insets = new Insets (20 , 20 , 20 , 20 );
208- gbl_libraries .weightx = 1 ;
209- gbl_libraries .weighty = 1 ;
210- libPanel .add (libListScroll , gbl_libraries );
211- //Buttons
212- //4 panels to position buttons correctly
213- JPanel libPanel1 = new JPanel ();
214- GridBagConstraints gbc_libPanel1 = new GridBagConstraints ();
215- gbc_libPanel1 .gridx = 1 ;
216- gbc_libPanel1 .weighty = 0.5 ;
217- libPanel .add (libPanel1 , gbc_libPanel1 );
218- JPanel libPanel2 = new JPanel ();
219- libPanel2 .setLayout (new GridBagLayout ());
220- GridBagConstraints gbc_libPanel2 = new GridBagConstraints ();
221- gbc_libPanel2 .gridx = 1 ;
222- gbc_libPanel2 .weighty = 0.5 ;
223- libPanel .add (libPanel2 , gbc_libPanel2 );
224- JPanel libPanel3 = new JPanel ();
225- libPanel3 .setLayout (new GridBagLayout ());
226- GridBagConstraints gbc_libPanel3 = new GridBagConstraints ();
227- gbc_libPanel3 .gridx = 1 ;
228- gbc_libPanel3 .weighty = 0.5 ;
229- libPanel .add (libPanel3 , gbc_libPanel3 );
230- JPanel libPanel4 = new JPanel ();
231- GridBagConstraints gbc_libPanel4 = new GridBagConstraints ();
232- gbc_libPanel4 .gridx = 1 ;
233- gbc_libPanel4 .weighty = 0.5 ;
234- libPanel .add (libPanel4 , gbc_libPanel4 );
235- JButton addLib = new JButton (" Add " );
236- GridBagConstraints gbc_addLib = new GridBagConstraints ();
237- gbc_addLib .anchor = GridBagConstraints .CENTER ;
238- gbc_addLib .insets = new Insets (5 , 5 , 5 , 20 );
239- libPanel2 .add (addLib , gbc_addLib );
240- JButton removeLib = new JButton ("Remove" );
241- GridBagConstraints gbc_removeLib = new GridBagConstraints ();
242- gbc_removeLib .anchor = GridBagConstraints .CENTER ;
243- gbc_removeLib .insets = new Insets (5 , 5 , 5 , 20 );
244- libPanel3 .add (removeLib , gbc_removeLib );
245- tabbedPane .addTab ("Libraries" , libPanel );
203+ for (ConfigItem i : fields )
204+ {
205+ if (i .type != SwingConfiguration .ItemType .FILELIST )
206+ continue ;
207+ JPanel libPanel = new JPanel ();
208+ libPanel .setLayout (new GridBagLayout ());
209+ JScrollPane libListScroll = new JScrollPane ();
210+ DefaultListModel <String > librariesList = new DefaultListModel <>();
211+ i .component = librariesList ;
212+ JList <String > libJList = new JList <>(librariesList );
213+ libJList .setSelectionMode (ListSelectionModel .MULTIPLE_INTERVAL_SELECTION );
214+ libJList .setModel (librariesList );
215+ libListScroll .setViewportView (libJList );
216+ GridBagConstraints gbl_libraries = new GridBagConstraints ();
217+ gbl_libraries .gridx = 0 ;
218+ gbl_libraries .gridy = 0 ;
219+ gbl_libraries .gridheight = 4 ;
220+ gbl_libraries .anchor = GridBagConstraints .FIRST_LINE_START ;
221+ gbl_libraries .fill = GridBagConstraints .BOTH ;
222+ gbl_libraries .insets = new Insets (20 , 20 , 20 , 20 );
223+ gbl_libraries .weightx = 1 ;
224+ gbl_libraries .weighty = 1 ;
225+ libPanel .add (libListScroll , gbl_libraries );
226+ //Buttons
227+ //4 panels to position buttons correctly
228+ JPanel libPanel1 = new JPanel ();
229+ GridBagConstraints gbc_libPanel1 = new GridBagConstraints ();
230+ gbc_libPanel1 .gridx = 1 ;
231+ gbc_libPanel1 .weighty = 0.5 ;
232+ libPanel .add (libPanel1 , gbc_libPanel1 );
233+ JPanel libPanel2 = new JPanel ();
234+ libPanel2 .setLayout (new GridBagLayout ());
235+ GridBagConstraints gbc_libPanel2 = new GridBagConstraints ();
236+ gbc_libPanel2 .gridx = 1 ;
237+ gbc_libPanel2 .weighty = 0.5 ;
238+ libPanel .add (libPanel2 , gbc_libPanel2 );
239+ JPanel libPanel3 = new JPanel ();
240+ libPanel3 .setLayout (new GridBagLayout ());
241+ GridBagConstraints gbc_libPanel3 = new GridBagConstraints ();
242+ gbc_libPanel3 .gridx = 1 ;
243+ gbc_libPanel3 .weighty = 0.5 ;
244+ libPanel .add (libPanel3 , gbc_libPanel3 );
245+ JPanel libPanel4 = new JPanel ();
246+ GridBagConstraints gbc_libPanel4 = new GridBagConstraints ();
247+ gbc_libPanel4 .gridx = 1 ;
248+ gbc_libPanel4 .weighty = 0.5 ;
249+ libPanel .add (libPanel4 , gbc_libPanel4 );
250+ JButton addLib = new JButton (" Add " );
251+ GridBagConstraints gbc_addLib = new GridBagConstraints ();
252+ gbc_addLib .anchor = GridBagConstraints .CENTER ;
253+ gbc_addLib .insets = new Insets (5 , 5 , 5 , 20 );
254+ libPanel2 .add (addLib , gbc_addLib );
255+ JButton removeLib = new JButton ("Remove" );
256+ GridBagConstraints gbc_removeLib = new GridBagConstraints ();
257+ gbc_removeLib .anchor = GridBagConstraints .CENTER ;
258+ gbc_removeLib .insets = new Insets (5 , 5 , 5 , 20 );
259+ libPanel3 .add (removeLib , gbc_removeLib );
260+ tabbedPane .addTab (i .getDisplayName (), libPanel );
261+ }
246262
247- //TODO: String list
248- JPanel stringPanel = new JPanel ();
249- stringPanel .setLayout (new GridBagLayout ());
250- JScrollPane stringListScroll = new JScrollPane ();
251- DefaultListModel <String > stringList = new DefaultListModel <>();
252- JList <String > stringJList = new JList <>(stringList );
253- stringJList .setSelectionMode (ListSelectionModel .MULTIPLE_INTERVAL_SELECTION );
254- stringJList .setModel (stringList );
255- stringListScroll .setViewportView (stringJList );
256- GridBagConstraints gbl_string = new GridBagConstraints ();
257- gbl_string .gridx = 0 ;
258- gbl_string .gridy = 0 ;
259- gbl_string .gridheight = 4 ;
260- gbl_string .anchor = GridBagConstraints .FIRST_LINE_START ;
261- gbl_string .fill = GridBagConstraints .BOTH ;
262- gbl_string .insets = new Insets (0 , 20 , 0 , 20 );
263- gbl_string .weightx = 1 ;
264- gbl_string .weighty = 1 ;
265- stringPanel .add (stringListScroll , gbl_string );
266- //Buttons
267- //4 panels to position buttons correctly
268- JPanel stringPanel1 = new JPanel ();
269- GridBagConstraints gbc_stringPanel1 = new GridBagConstraints ();
270- gbc_stringPanel1 .gridx = 1 ;
271- gbc_stringPanel1 .weighty = 0.5 ;
272- stringPanel .add (stringPanel1 , gbc_stringPanel1 );
273- JPanel stringPanel2 = new JPanel ();
274- stringPanel2 .setLayout (new GridBagLayout ());
275- GridBagConstraints gbc_stringPanel2 = new GridBagConstraints ();
276- gbc_stringPanel2 .gridx = 1 ;
277- gbc_stringPanel2 .weighty = 0.5 ;
278- stringPanel .add (stringPanel2 , gbc_stringPanel2 );
279- JPanel stringPanel3 = new JPanel ();
280- stringPanel3 .setLayout (new GridBagLayout ());
281- GridBagConstraints gbc_stringPanel3 = new GridBagConstraints ();
282- gbc_stringPanel3 .gridx = 1 ;
283- gbc_stringPanel3 .weighty = 0.5 ;
284- stringPanel .add (stringPanel3 , gbc_stringPanel3 );
285- JPanel stringPanel4 = new JPanel ();
286- GridBagConstraints gbc_stringPanel4 = new GridBagConstraints ();
287- gbc_stringPanel4 .gridx = 1 ;
288- gbc_stringPanel4 .weighty = 0.5 ;
289- stringPanel .add (stringPanel4 , gbc_stringPanel4 );
290- JButton addString = new JButton (" Add " );
291- GridBagConstraints gbc_addString = new GridBagConstraints ();
292- gbc_addString .anchor = GridBagConstraints .CENTER ;
293- gbc_addString .insets = new Insets (5 , 5 , 5 , 20 );
294- stringPanel2 .add (addString , gbc_addString );
295- JButton removeString = new JButton ("Remove" );
296- GridBagConstraints gbc_removeString = new GridBagConstraints ();
297- gbc_removeString .anchor = GridBagConstraints .CENTER ;
298- gbc_removeString .insets = new Insets (5 , 5 , 5 , 20 );
299- stringPanel3 .add (removeString , gbc_removeString );
300- //Text pane
301- JTextField textPane = new JTextField ();
302- GridBagConstraints gbl_text = new GridBagConstraints ();
303- gbl_text .gridx = 0 ;
304- gbl_text .gridy = 4 ;
305- gbl_text .anchor = GridBagConstraints .FIRST_LINE_START ;
306- gbl_text .fill = GridBagConstraints .HORIZONTAL ;
307- gbl_text .insets = new Insets (0 , 20 , 20 , 20 );
308- gbl_text .weightx = 1 ;
309- stringPanel .add (textPane , gbl_text );
310- tabbedPane .addTab ("Ignored Classes" , stringPanel );
263+ for (ConfigItem i : fields )
264+ {
265+ if (i .type != SwingConfiguration .ItemType .STRINGLIST )
266+ continue ;
267+ JPanel stringPanel = new JPanel ();
268+ stringPanel .setLayout (new GridBagLayout ());
269+ JScrollPane stringListScroll = new JScrollPane ();
270+ DefaultListModel <String > stringList = new DefaultListModel <>();
271+ i .component = stringList ;
272+ JList <String > stringJList = new JList <>(stringList );
273+ stringJList .setSelectionMode (ListSelectionModel .MULTIPLE_INTERVAL_SELECTION );
274+ stringJList .setModel (stringList );
275+ stringListScroll .setViewportView (stringJList );
276+ GridBagConstraints gbl_string = new GridBagConstraints ();
277+ gbl_string .gridx = 0 ;
278+ gbl_string .gridy = 0 ;
279+ gbl_string .gridheight = 4 ;
280+ gbl_string .anchor = GridBagConstraints .FIRST_LINE_START ;
281+ gbl_string .fill = GridBagConstraints .BOTH ;
282+ gbl_string .insets = new Insets (0 , 20 , 0 , 20 );
283+ gbl_string .weightx = 1 ;
284+ gbl_string .weighty = 1 ;
285+ stringPanel .add (stringListScroll , gbl_string );
286+ //Buttons
287+ //4 panels to position buttons correctly
288+ JPanel stringPanel1 = new JPanel ();
289+ GridBagConstraints gbc_stringPanel1 = new GridBagConstraints ();
290+ gbc_stringPanel1 .gridx = 1 ;
291+ gbc_stringPanel1 .weighty = 0.5 ;
292+ stringPanel .add (stringPanel1 , gbc_stringPanel1 );
293+ JPanel stringPanel2 = new JPanel ();
294+ stringPanel2 .setLayout (new GridBagLayout ());
295+ GridBagConstraints gbc_stringPanel2 = new GridBagConstraints ();
296+ gbc_stringPanel2 .gridx = 1 ;
297+ gbc_stringPanel2 .weighty = 0.5 ;
298+ stringPanel .add (stringPanel2 , gbc_stringPanel2 );
299+ JPanel stringPanel3 = new JPanel ();
300+ stringPanel3 .setLayout (new GridBagLayout ());
301+ GridBagConstraints gbc_stringPanel3 = new GridBagConstraints ();
302+ gbc_stringPanel3 .gridx = 1 ;
303+ gbc_stringPanel3 .weighty = 0.5 ;
304+ stringPanel .add (stringPanel3 , gbc_stringPanel3 );
305+ JPanel stringPanel4 = new JPanel ();
306+ GridBagConstraints gbc_stringPanel4 = new GridBagConstraints ();
307+ gbc_stringPanel4 .gridx = 1 ;
308+ gbc_stringPanel4 .weighty = 0.5 ;
309+ stringPanel .add (stringPanel4 , gbc_stringPanel4 );
310+ JButton addString = new JButton (" Add " );
311+ GridBagConstraints gbc_addString = new GridBagConstraints ();
312+ gbc_addString .anchor = GridBagConstraints .CENTER ;
313+ gbc_addString .insets = new Insets (5 , 5 , 5 , 20 );
314+ stringPanel2 .add (addString , gbc_addString );
315+ JButton removeString = new JButton ("Remove" );
316+ GridBagConstraints gbc_removeString = new GridBagConstraints ();
317+ gbc_removeString .anchor = GridBagConstraints .CENTER ;
318+ gbc_removeString .insets = new Insets (5 , 5 , 5 , 20 );
319+ stringPanel3 .add (removeString , gbc_removeString );
320+ //Text pane
321+ JTextField textPane = new JTextField ();
322+ GridBagConstraints gbl_text = new GridBagConstraints ();
323+ gbl_text .gridx = 0 ;
324+ gbl_text .gridy = 4 ;
325+ gbl_text .anchor = GridBagConstraints .FIRST_LINE_START ;
326+ gbl_text .fill = GridBagConstraints .HORIZONTAL ;
327+ gbl_text .insets = new Insets (0 , 20 , 20 , 20 );
328+ gbl_text .weightx = 1 ;
329+ stringPanel .add (textPane , gbl_text );
330+ tabbedPane .addTab (i .getDisplayName (), stringPanel );
331+ }
311332
312333 //Config and Run buttons
313334 GridBagConstraints gbl_loadConfig = new GridBagConstraints ();
@@ -327,6 +348,7 @@ public static void main(String[] args)
327348 gbl_run .anchor = GridBagConstraints .FIRST_LINE_END ;
328349 gbl_run .gridx = 1 ;
329350 gbl_run .gridy = 2 ;
351+ gbl_run .ipadx = 15 ;
330352 gbl_run .insets = new Insets (0 , 10 , 20 , 20 );
331353 JButton run = new JButton ("Run" );
332354 frame .getContentPane ().add (run , gbl_run );
0 commit comments