fix(gui): disable all components on saving the settings (PR #586)

This commit is contained in:
Ahmed Ashour
2019-04-12 17:10:16 +02:00
committed by skylot
parent 74a72a5ce0
commit ac1d1a5858
@@ -83,18 +83,22 @@ public class JadxSettingsWindow extends JDialog {
JButton saveBtn = new JButton(NLS.str("preferences.save"));
saveBtn.addActionListener(event -> {
settings.sync();
if (needReload) {
mainWindow.reOpenFile();
}
if (!settings.getLangLocale().equals(prevLang)) {
JOptionPane.showMessageDialog(
this,
NLS.str("msg.language_changed", settings.getLangLocale()),
NLS.str("msg.language_changed_title", settings.getLangLocale()),
JOptionPane.INFORMATION_MESSAGE
);
}
dispose();
enableComponents(this, false);
SwingUtilities.invokeLater(() -> {
if (needReload) {
mainWindow.reOpenFile();
}
if (!settings.getLangLocale().equals(prevLang)) {
JOptionPane.showMessageDialog(
this,
NLS.str("msg.language_changed", settings.getLangLocale()),
NLS.str("msg.language_changed_title", settings.getLangLocale()),
JOptionPane.INFORMATION_MESSAGE
);
}
dispose();
});
});
JButton cancelButton = new JButton(NLS.str("preferences.cancel"));
cancelButton.addActionListener(event -> {
@@ -139,6 +143,15 @@ public class JadxSettingsWindow extends JDialog {
getRootPane().setDefaultButton(saveBtn);
}
private static void enableComponents(Container container, boolean enable) {
for (Component component : container.getComponents()) {
if (component instanceof Container) {
enableComponents((Container) component, enable);
}
component.setEnabled(enable);
}
}
private SettingsGroup makeDeobfuscationGroup() {
JCheckBox deobfOn = new JCheckBox();
deobfOn.setSelected(settings.isDeobfuscationOn());