• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

jiangxincode / ApkToolBoxGUI / #1295

15 Nov 2025 09:45AM UTC coverage: 2.849% (-0.002%) from 2.851%
#1295

push

jiangxincode
split color table and color converter

0 of 57 new or added lines in 3 files covered. (0.0%)

2 existing lines in 1 file now uncovered.

248 of 8706 relevant lines covered (2.85%)

0.03 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/edu/jiangxin/apktoolbox/main/MainFrame.java
1
package edu.jiangxin.apktoolbox.main;
2

3
import edu.jiangxin.apktoolbox.Version;
4
import edu.jiangxin.apktoolbox.android.dumpsys.DumpsysPanel;
5
import edu.jiangxin.apktoolbox.convert.base.BaseConvertPanel;
6
import edu.jiangxin.apktoolbox.convert.color.ColorConvertPanel;
7
import edu.jiangxin.apktoolbox.convert.color.ColorPickerPanel;
8
import edu.jiangxin.apktoolbox.convert.color.ColorTablePanel;
9
import edu.jiangxin.apktoolbox.convert.encoding.GarbledTextRecoveryPanel;
10
import edu.jiangxin.apktoolbox.convert.protobuf.supervised.SupervisedProtobufConvertPanel;
11
import edu.jiangxin.apktoolbox.convert.protobuf.unsupervised.UnsupervisedProtobufConvertPanel;
12
import edu.jiangxin.apktoolbox.convert.relationship.RelationShipConvertPanel;
13
import edu.jiangxin.apktoolbox.convert.time.TimeConvertPanel;
14
import edu.jiangxin.apktoolbox.convert.zh2unicode.Zh2UnicodeConvertPanel;
15
import edu.jiangxin.apktoolbox.file.batchrename.BatchRenamePanel;
16
import edu.jiangxin.apktoolbox.file.EncodeConvertPanel;
17
import edu.jiangxin.apktoolbox.file.OsConvertPanel;
18
import edu.jiangxin.apktoolbox.file.checksum.ChecksumPanel;
19
import edu.jiangxin.apktoolbox.file.password.recovery.RecoveryPanel;
20
import edu.jiangxin.apktoolbox.file.duplicate.DuplicateSearchPanel;
21
import edu.jiangxin.apktoolbox.file.zhconvert.ZhConvertPanel;
22
import edu.jiangxin.apktoolbox.help.*;
23
import edu.jiangxin.apktoolbox.android.i18n.I18nAddPanel;
24
import edu.jiangxin.apktoolbox.android.i18n.I18nFindLongestPanel;
25
import edu.jiangxin.apktoolbox.android.i18n.I18nRemovePanel;
26
import edu.jiangxin.apktoolbox.android.monkey.MonkeyPanel;
27
import edu.jiangxin.apktoolbox.help.settings.SettingsPanel;
28
import edu.jiangxin.apktoolbox.pdf.finder.PdfFinderPanel;
29
import edu.jiangxin.apktoolbox.pdf.passwordremover.PdfPasswordRemoverPanel;
30
import edu.jiangxin.apktoolbox.pdf.pic2pdf.Pic2PdfPanel;
31
import edu.jiangxin.apktoolbox.pdf.stat.PdfStatPanel;
32
import edu.jiangxin.apktoolbox.reverse.*;
33
import edu.jiangxin.apktoolbox.android.screenshot.ScreenShotPanel;
34
import edu.jiangxin.apktoolbox.reverse.ApktoolPanel;
35
import edu.jiangxin.apktoolbox.swing.extend.EasyFrame;
36
import edu.jiangxin.apktoolbox.swing.extend.EasyPanel;
37
import edu.jiangxin.apktoolbox.swing.extend.listener.ChangeMenuListener;
38
import edu.jiangxin.apktoolbox.swing.extend.listener.ChangeMenuToUrlListener;
39
import edu.jiangxin.apktoolbox.swing.extend.listener.IPreChangeMenuCallBack;
40
import edu.jiangxin.apktoolbox.swing.extend.plugin.ChangeMenuPreparePluginController;
41
import edu.jiangxin.apktoolbox.swing.extend.plugin.PluginPanel;
42
import edu.jiangxin.apktoolbox.swing.keeper.UiStateKeeper;
43
import edu.jiangxin.apktoolbox.utils.Utils;
44
import org.apache.commons.configuration2.Configuration;
45
import org.apache.commons.lang3.StringUtils;
46
import org.apache.logging.log4j.LogManager;
47
import org.apache.logging.log4j.Logger;
48

49
import javax.swing.*;
50
import javax.swing.border.EmptyBorder;
51
import java.awt.*;
52
import java.awt.event.*;
53
import java.io.Serial;
54
import java.lang.reflect.InvocationTargetException;
55
import java.text.MessageFormat;
56
import java.util.Locale;
57
import java.util.Objects;
58

59
/**
60
 * @author jiangxin
61
 * @author 2018-08-19
62
 */
63
public final class MainFrame extends EasyFrame {
64

65
    @Serial
66
    private static final long serialVersionUID = 1L;
67

68
    private JPanel contentPane;
69
    private EasyPanel currentEasyPanel = null;
×
70
    private JMenuBar menuBar;
71

72
    public static void main(String[] args) {
73
        final Logger logger = LogManager.getLogger(MainFrame.class.getSimpleName());
×
74
        boolean isEnvironmentOk = Utils.checkAndInitEnvironment();
×
75
        if (!isEnvironmentOk) {
×
76
            logger.error("Environment is not ready, exit");
×
77
            return;
×
78
        }
79
        EventQueue.invokeLater(() -> {
×
80
            Configuration conf = Utils.getConfiguration();
×
81
            String lookAndFeelClassName = conf.getString("look.and.feel.class.name");
×
82
            if (StringUtils.isEmpty(lookAndFeelClassName)) {
×
83
                lookAndFeelClassName = "com.formdev.flatlaf.FlatDarculaLaf";
×
84
                conf.setProperty("look.and.feel.class.name", lookAndFeelClassName);
×
85
            }
86
            try {
87
                UIManager.setLookAndFeel(lookAndFeelClassName);
×
88
            } catch (UnsupportedLookAndFeelException | ClassNotFoundException | InstantiationException | IllegalAccessException e) {
×
89
                logger.error("setLookAndFeel failed, use default instead", e);
×
90
            }
×
91

92
            String currentLocaleLanguage = conf.getString("locale.language");
×
93
            if (StringUtils.isEmpty(currentLocaleLanguage)) {
×
94
                currentLocaleLanguage = Locale.ENGLISH.getLanguage();
×
95
                conf.setProperty("locale.language", currentLocaleLanguage);
×
96
            }
97
            Locale.setDefault(Locale.forLanguageTag(currentLocaleLanguage));
×
98

99
            MainFrame frame = new MainFrame();
×
100

101
            boolean isAlwaysOnTop = conf.getBoolean("always.on.top", false);
×
102
            conf.setProperty("always.on.top", isAlwaysOnTop);
×
103
            frame.setAlwaysOnTop(isAlwaysOnTop);
×
104

105
            frame.setVisible(true);
×
106
        });
×
107
    }
×
108

109
    public MainFrame() {
110
        super();
×
111
        initialize();
×
112
        if (SystemTray.isSupported()) {
×
113
            configSystemTray();
×
114
        }
115

116
        setTitle(MessageFormat.format(bundle.getString("main.title"), Version.VERSION));
×
117
        setDefaultCloseOperation(EXIT_ON_CLOSE);
×
118
        setMenuBar();
×
119
        contentPane = new JPanel();
×
120
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
×
121
        contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
×
122
        contentPane.add(Box.createVerticalGlue());
×
123
        EasyPanel initPanel = new AboutPanel();
×
124
        initPanel.init();
×
125
        initPanel.setBorder(BorderFactory.createTitledBorder(bundle.getString("help.about.title")));
×
126
        contentPane.add(initPanel);
×
127
        contentPane.add(Box.createVerticalGlue());
×
128
        setContentPane(contentPane);
×
129
        refreshSizeAndLocation();
×
130
    }
×
131

132
    private void configSystemTray() {
133
        SystemTray systemTray = SystemTray.getSystemTray();
×
134
        PopupMenu popupMenu = new PopupMenu();
×
135
        final MenuItem show = new MenuItem("Open");
×
136
        final MenuItem exit = new MenuItem("Close");
×
137
        ActionListener actionListener = e -> {
×
138
            if (e.getSource() == show) {
×
139
                setExtendedState(NORMAL);
×
140
                setVisible(true);
×
141
            }
142
            if (e.getSource() == exit) {
×
143
                dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
×
144
            }
145
        };
×
146
        exit.addActionListener(actionListener);
×
147
        show.addActionListener(actionListener);
×
148
        popupMenu.add(show);
×
149
        popupMenu.add(exit);
×
150
        TrayIcon trayIcon = new TrayIcon(image, "系统托盘", popupMenu);
×
151
        trayIcon.setImageAutoSize(true);
×
152
        try {
153
            systemTray.add(trayIcon);
×
154
        } catch (AWTException e) {
×
155
            logger.error("add icon to tray failed");
×
156
        }
×
157
        trayIcon.addMouseListener(new MouseAdapter() {
×
158
            @Override
159
            public void mouseClicked(MouseEvent e) {
160
                if (e.getClickCount() == 2) {
×
161
                    setExtendedState(NORMAL);
×
162
                    setVisible(true);
×
163
                }
164
            }
×
165
        });
166
    }
×
167

168
    private void setMenuBar() {
169
        menuBar = new JMenuBar();
×
170
        setJMenuBar(menuBar);
×
171

172
        createReverseMenu();
×
173

174
        createAndroidMenu();
×
175

176
        createPdfMenu();
×
177

178
        createFileMenu();
×
179

180
        createConvertMenu();
×
181

182
        createHelpMenu();
×
183
    }
×
184

185
    private void createHelpMenu() {
186
        JMenu helpMenu = new JMenu(bundle.getString("help.title"));
×
187
        menuBar.add(helpMenu);
×
188

189
        JMenuItem documentMenuItem = new JMenuItem(bundle.getString("help.document.title"));
×
190
        documentMenuItem.addActionListener(new ChangeMenuToUrlListener(Constant.URL_DOCUMENT));
×
191
        helpMenu.add(documentMenuItem);
×
192

193
        JMenuItem settingsMenuItem = new JMenuItem(bundle.getString("help.settings.title"));
×
194
        settingsMenuItem.addActionListener(new ChangeMenuToPanelListener(SettingsPanel.class, settingsMenuItem.getText()));
×
195
        helpMenu.add(settingsMenuItem);
×
196

197
        JMenuItem feedbackMenuItem = new JMenuItem(bundle.getString("help.feedback.title"));
×
198
        feedbackMenuItem.addActionListener(new ChangeMenuToUrlListener(Constant.URL_FEEDBACK));
×
199
        helpMenu.add(feedbackMenuItem);
×
200

201
        JMenuItem checkUpdateMenuItem = new JMenuItem(bundle.getString("help.checkupdate.title"));
×
202
        checkUpdateMenuItem.addActionListener(new CheckUpdateActionListener(this));
×
203
        helpMenu.add(checkUpdateMenuItem);
×
204

205
        JMenuItem contributeMenuItem = new JMenuItem(bundle.getString("help.contribute.title"));
×
206
        contributeMenuItem.addActionListener(new ChangeMenuToUrlListener(Constant.URL_CONTRIBUTE));
×
207
        helpMenu.add(contributeMenuItem);
×
208

209
        JMenuItem aboutMenuItem = new JMenuItem(bundle.getString("help.about.title"));
×
210
        aboutMenuItem.addActionListener(new ChangeMenuToPanelListener(AboutPanel.class, aboutMenuItem.getText()));
×
211
        helpMenu.add(aboutMenuItem);
×
212
    }
×
213

214
    private void createPdfMenu() {
215
        JMenu pdfMenu = new JMenu(bundle.getString("pdf.title"));
×
216
        menuBar.add(pdfMenu);
×
217

218
        JMenuItem pdfStatMenuItem = new JMenuItem(bundle.getString("pdf.stat.title"));
×
219
        pdfStatMenuItem.addActionListener(new ChangeMenuToPanelListener(PdfStatPanel.class, pdfStatMenuItem.getText()));
×
220
        pdfMenu.add(pdfStatMenuItem);
×
221

222
        JMenuItem pdfFinderMenuItem = new JMenuItem(bundle.getString("pdf.finder.title"));
×
223
        pdfFinderMenuItem.addActionListener(new ChangeMenuToPanelListener(PdfFinderPanel.class, pdfFinderMenuItem.getText()));
×
224
        pdfMenu.add(pdfFinderMenuItem);
×
225

226
        JMenuItem pdfPasswordRemoverMenuItem = new JMenuItem(bundle.getString("pdf.password.remover.title"));
×
227
        pdfPasswordRemoverMenuItem.addActionListener(new ChangeMenuToPanelListener(PdfPasswordRemoverPanel.class, pdfPasswordRemoverMenuItem.getText()));
×
228
        pdfMenu.add(pdfPasswordRemoverMenuItem);
×
229

230
        JMenuItem pic2PdfMenuItem = new JMenuItem(bundle.getString("pictures.to.pdf.title"));
×
231
        pic2PdfMenuItem.addActionListener(new ChangeMenuToPanelListener(Pic2PdfPanel.class, pic2PdfMenuItem.getText()));
×
232
        pdfMenu.add(pic2PdfMenuItem);
×
233
    }
×
234

235
    private void createFileMenu() {
236
        JMenu fileMenu = new JMenu(bundle.getString("file.title"));
×
237
        menuBar.add(fileMenu);
×
238

239
        JMenuItem osConvertMenuItem = new JMenuItem(bundle.getString("file.os.convert.title"));
×
240
        osConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(OsConvertPanel.class, osConvertMenuItem.getText()));
×
241
        fileMenu.add(osConvertMenuItem);
×
242

243
        JMenuItem encodeConvertMenuItem = new JMenuItem(bundle.getString("file.encode.convert.title"));
×
244
        encodeConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(EncodeConvertPanel.class, encodeConvertMenuItem.getText()));
×
245
        fileMenu.add(encodeConvertMenuItem);
×
246

247
        JMenuItem zhConvertMenuItem = new JMenuItem(bundle.getString("file.zh.convert.title"));
×
248
        zhConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(ZhConvertPanel.class, zhConvertMenuItem.getText()));
×
249
        fileMenu.add(zhConvertMenuItem);
×
250

251
        JMenuItem duplicateFindMenuItem = new JMenuItem(bundle.getString("file.duplicate.title"));
×
252
        duplicateFindMenuItem.addActionListener(new ChangeMenuToPanelListener(DuplicateSearchPanel.class, duplicateFindMenuItem.getText()));
×
253
        fileMenu.add(duplicateFindMenuItem);
×
254

255
        JMenuItem batchRenameMenuItem = new JMenuItem(bundle.getString("file.batch.rename.title"));
×
256
        batchRenameMenuItem.addActionListener(new ChangeMenuToPanelListener(BatchRenamePanel.class, batchRenameMenuItem.getText()));
×
257
        fileMenu.add(batchRenameMenuItem);
×
258

259
        JMenuItem checkSumMenuItem = new JMenuItem(bundle.getString("file.check.summary.title"));
×
260
        checkSumMenuItem.addActionListener(new ChangeMenuToPanelListener(ChecksumPanel.class, checkSumMenuItem.getText()));
×
261
        fileMenu.add(checkSumMenuItem);
×
262

263
        JMenuItem recoveryMenuItem = new JMenuItem(bundle.getString("file.password.recovery.title"));
×
264
        recoveryMenuItem.addActionListener(new ChangeMenuToPanelListener(RecoveryPanel.class, recoveryMenuItem.getText()));
×
265
        fileMenu.add(recoveryMenuItem);
×
266
    }
×
267

268
    private void createConvertMenu() {
269
        JMenu convertMenu = new JMenu(bundle.getString("convert.title"));
×
270
        menuBar.add(convertMenu);
×
271

272
        JMenuItem timeConvertMenuItem = new JMenuItem(bundle.getString("convert.time.title"));
×
273
        timeConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(TimeConvertPanel.class, timeConvertMenuItem.getText()));
×
274
        convertMenu.add(timeConvertMenuItem);
×
275

276
        JMenuItem colorConvertMenuItem = new JMenuItem(bundle.getString("convert.color.title"));
×
277
        colorConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(ColorConvertPanel.class, colorConvertMenuItem.getText()));
×
278
        convertMenu.add(colorConvertMenuItem);
×
279

NEW
280
        JMenuItem colorTableMenuItem = new JMenuItem(bundle.getString("table.color.title"));
×
NEW
281
        colorTableMenuItem.addActionListener(new ChangeMenuToPanelListener(ColorTablePanel.class, colorTableMenuItem.getText()));
×
NEW
282
        convertMenu.add(colorTableMenuItem);
×
283

284
        JMenuItem colorPickerMenuItem = new JMenuItem(bundle.getString("picker.color.title"));
×
285
        colorPickerMenuItem.addActionListener(new ChangeMenuToPanelListener(ColorPickerPanel.class, colorPickerMenuItem.getText()));
×
286
        convertMenu.add(colorPickerMenuItem);
×
287

288
        JMenuItem baseConvertMenuItem = new JMenuItem(bundle.getString("convert.base.title"));
×
289
        baseConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(BaseConvertPanel.class, baseConvertMenuItem.getText()));
×
290
        convertMenu.add(baseConvertMenuItem);
×
291

292
        JMenuItem unicodeConvertMenuItem = new JMenuItem(bundle.getString("convert.unicode.title"));
×
293
        unicodeConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(Zh2UnicodeConvertPanel.class, unicodeConvertMenuItem.getText()));
×
294
        convertMenu.add(unicodeConvertMenuItem);
×
295

296
        JMenuItem encodingRecoveryMenuItem = new JMenuItem(bundle.getString("garbled.text.recovery.title"));
×
297
        encodingRecoveryMenuItem.addActionListener(new ChangeMenuToPanelListener(GarbledTextRecoveryPanel.class, encodingRecoveryMenuItem.getText()));
×
298
        convertMenu.add(encodingRecoveryMenuItem);
×
299

300
        JMenuItem relationShipConvertMenuItem = new JMenuItem(bundle.getString("convert.relationship.title"));
×
301
        relationShipConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(RelationShipConvertPanel.class, relationShipConvertMenuItem.getText()));
×
302
        convertMenu.add(relationShipConvertMenuItem);
×
303

304
        JMenuItem unsupervisedProtobufConvertMenuItem = new JMenuItem(bundle.getString("convert.protobuf.unsupervised.title"));
×
305
        unsupervisedProtobufConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(UnsupervisedProtobufConvertPanel.class, unsupervisedProtobufConvertMenuItem.getText()));
×
306
        convertMenu.add(unsupervisedProtobufConvertMenuItem);
×
307

308
        JMenuItem supervisedProtobufConvertMenuItem = new JMenuItem(bundle.getString("convert.protobuf.supervised.title"));
×
309
        supervisedProtobufConvertMenuItem.addActionListener(new ChangeMenuToPanelListener(SupervisedProtobufConvertPanel.class, supervisedProtobufConvertMenuItem.getText()));
×
310
        convertMenu.add(supervisedProtobufConvertMenuItem);
×
311
    }
×
312

313
    private void createAndroidMenu() {
314
        JMenu androidMenu = new JMenu(bundle.getString("android.title"));
×
315
        menuBar.add(androidMenu);
×
316

317
        JMenuItem i18nAddMenuItem = new JMenuItem(bundle.getString("android.i18n.add.title"));
×
318
        i18nAddMenuItem.addActionListener(new ChangeMenuToPanelListener(I18nAddPanel.class, i18nAddMenuItem.getText()));
×
319
        androidMenu.add(i18nAddMenuItem);
×
320

321
        JMenuItem i18nFindLongestMenuItem = new JMenuItem(bundle.getString("android.i18n.longest.title"));
×
322
        i18nFindLongestMenuItem.addActionListener(new ChangeMenuToPanelListener(I18nFindLongestPanel.class, i18nFindLongestMenuItem.getText()));
×
323
        androidMenu.add(i18nFindLongestMenuItem);
×
324

325
        JMenuItem i18nRemoveMenuItem = new JMenuItem(bundle.getString("android.i18n.remove.title"));
×
326
        i18nRemoveMenuItem.addActionListener(new ChangeMenuToPanelListener(I18nRemovePanel.class, i18nRemoveMenuItem.getText()));
×
327
        androidMenu.add(i18nRemoveMenuItem);
×
328

329
        JMenuItem screenShotMenuItem = new JMenuItem(bundle.getString("android.screenshot.title"));
×
330
        screenShotMenuItem.addActionListener(new ChangeMenuToPanelListener(ScreenShotPanel.class, screenShotMenuItem.getText()));
×
331
        screenShotMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
×
332
        androidMenu.add(screenShotMenuItem);
×
333

334
        JMenuItem monkeyMenuItem = new JMenuItem(bundle.getString("android.monkey.title"));
×
335
        monkeyMenuItem.addActionListener(new ChangeMenuToPanelListener(MonkeyPanel.class, monkeyMenuItem.getText()));
×
336
        androidMenu.add(monkeyMenuItem);
×
337

338
        JMenuItem dumpsysMenuItem = new JMenuItem(bundle.getString("android.dumpsys.title"));
×
339
        dumpsysMenuItem.addActionListener(new ChangeMenuToPanelListener(DumpsysPanel.class, dumpsysMenuItem.getText()));
×
340
        androidMenu.add(dumpsysMenuItem);
×
341
    }
×
342

343
    private void createReverseMenu() {
344
        JMenu reverseMenu = new JMenu(bundle.getString("reverse.title"));
×
345
        reverseMenu.setMnemonic(KeyEvent.VK_R);
×
346
        menuBar.add(reverseMenu);
×
347

348
        JMenuItem pluginVersionMenuItem = new JMenuItem(bundle.getString("reverse.plugin.version.title"));
×
349
        pluginVersionMenuItem.addActionListener(new ChangeMenuToUrlListener(Constant.URL_PLUGIN_VERSION));
×
350
        reverseMenu.add(pluginVersionMenuItem);
×
351

352
        JMenuItem apktoolMenuItem = new JMenuItem(bundle.getString("reverse.apktool.title"), KeyEvent.VK_D);
×
353
        apktoolMenuItem.addActionListener(new ChangeMenuToPanelListener(ApktoolPanel.class, apktoolMenuItem.getText()));
×
354
        reverseMenu.add(apktoolMenuItem);
×
355

356
        JMenuItem apkSignMenuItem = new JMenuItem(bundle.getString("reverse.apksigner.title"));
×
357
        apkSignMenuItem.addActionListener(new ChangeMenuToPanelListener(ApkSignerPanel.class, apkSignMenuItem.getText()));
×
358
        reverseMenu.add(apkSignMenuItem);
×
359

360
        JMenuItem jDMenuItem = new JMenuItem(bundle.getString("reverse.jd.gui.title"));
×
361
        jDMenuItem.addActionListener(new ChangeMenToPluginJdListener());
×
362
        reverseMenu.add(jDMenuItem);
×
363

364
        JMenuItem bytecodeViewerMenuItem = new JMenuItem(bundle.getString("reverse.bytecode.viewer.title"));
×
365
        bytecodeViewerMenuItem.addActionListener(new ChangeMenuToPluginBytecodeViewerListener());
×
366
        reverseMenu.add(bytecodeViewerMenuItem);
×
367

368
        JMenuItem luytenMenuItem = new JMenuItem(bundle.getString("reverse.luyten.title"));
×
369
        luytenMenuItem.addActionListener(new ChangeMenuToPluginLuytenListener());
×
370
        reverseMenu.add(luytenMenuItem);
×
371

372
        JMenuItem jdDuoMenuItem = new JMenuItem(bundle.getString("reverse.jd.duo.title"));
×
373
        jdDuoMenuItem.addActionListener(new ChangeMenuToPluginJdDuoListener());
×
374
        reverseMenu.add(jdDuoMenuItem);
×
375

376
        JMenuItem jdaMenuItem = new JMenuItem(bundle.getString("reverse.jda.title"));
×
377
        jdaMenuItem.addActionListener(new ChangeMenuToPluginJdaListener());
×
378
        reverseMenu.add(jdaMenuItem);
×
379

380
        JMenuItem jADXMenuItem = new JMenuItem(bundle.getString("reverse.jadx.title"));
×
381
        jADXMenuItem.addActionListener(new ChangeMenuToPluginJadxListener());
×
382
        reverseMenu.add(jADXMenuItem);
×
383

384
        JMenuItem aXMLPrinter = new JMenuItem(bundle.getString("reverse.axmlprinter.title"));
×
385
        aXMLPrinter.addActionListener(new ChangeMenuToPanelListener(AxmlPrinterPanel.class, aXMLPrinter.getText()));
×
386
        reverseMenu.add(aXMLPrinter);
×
387
    }
×
388

389
    class ChangeMenuToPanelListener implements ChangeMenuListener {
390

391
        Class<? extends EasyPanel> easyPanelClass;
392

393
        EasyPanel panel = null;
×
394

395
        String title;
396

397
        public ChangeMenuToPanelListener(Class<? extends EasyPanel> easyPanelClass, String title) {
×
398
            this.easyPanelClass = easyPanelClass;
×
399
            this.title = title;
×
400
            panel = createEasyPanel();
×
401
        }
×
402

403
        @Override
404
        public boolean isNeedPreChangeMenu() {
405
            return panel.isNeedPreChangeMenu();
×
406
        }
407

408
        @Override
409
        public void onPreChangeMenu(IPreChangeMenuCallBack callBack) {
410
            if (panel instanceof PluginPanel pluginPanel) {
×
411
                pluginPanel.preparePlugin(new ChangeMenuPreparePluginController(pluginPanel.getPluginFilename(), pluginPanel.isPluginNeedUnzip(), pluginPanel.isPluginNeedUnzipToSeparateDir(), callBack));
×
412
            }
413
        }
×
414

415
        @Override
416
        public void onChangeMenu() {
417
            UiStateKeeper.save(currentEasyPanel);
×
418
            contentPane.removeAll();
×
419
            contentPane.add(Box.createVerticalGlue());
×
420
            panel.init();
×
421
            panel.setBorder(BorderFactory.createTitledBorder(title));
×
422
            contentPane.add(panel);
×
423
            logger.info("Panel changed: " + panel.getClass().getSimpleName());
×
424
            contentPane.add(Box.createVerticalGlue());
×
425
            contentPane.revalidate();
×
426
            contentPane.repaint();
×
427
            refreshSizeAndLocation();
×
428
            panel.afterPainted();
×
429
            UiStateKeeper.restore(panel);
×
430
            currentEasyPanel = panel;
×
431
        }
×
432

433
        private EasyPanel createEasyPanel() {
434
            if (easyPanelClass == null) {
×
435
                return new EasyPanel();
×
436
            }
437
            EasyPanel retEasyPanel = null;
×
438
            try {
439
                retEasyPanel = easyPanelClass.getDeclaredConstructor().newInstance();
×
440
            } catch (InstantiationException | IllegalAccessException | InvocationTargetException |
×
441
                     NoSuchMethodException e) {
442
                logger.info("createEasyPanel failed: {}", e.getMessage());
×
443
            }
×
444
            return Objects.requireNonNullElseGet(retEasyPanel, EasyPanel::new);
×
445
        }
446
    }
447

448
    @Override
449
    protected void onWindowClosing(WindowEvent e) {
450
        super.onWindowClosing(e);
×
451
        UiStateKeeper.save(currentEasyPanel);
×
452
    }
×
453

454
    @Override
455
    protected void onWindowIconified(WindowEvent e) {
456
        super.onWindowIconified(e);
×
457
        UiStateKeeper.save(currentEasyPanel);
×
458
    }
×
459
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc