From 0eff06096bc4852f2580f20a0c5bf970ecf66987 Mon Sep 17 00:00:00 2001 From: 2xsaiko Date: Wed, 29 Apr 2020 18:24:29 +0200 Subject: Rewrite search dialog (#233) * Fix searching * Make buttons use localization * Fix rename field opening when pressing shift+space * Tweak search algorithm * Add a bit of documentation * Remove duplicate example line * Use max() when building the inner map instead of overwriting the old value * Keep search dialog state * Formatting * Fix cursor key selection not scrolling to selected item * Don't set font size * Rename close0 to exit * Fix wrong scrolling when selecting search dialog entry--- src/main/java/cuchaz/enigma/gui/Gui.java | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java') diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 8f0d6fa..3412cd5 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java @@ -33,6 +33,7 @@ import cuchaz.enigma.config.Config; import cuchaz.enigma.config.Themes; import cuchaz.enigma.gui.dialog.CrashDialog; import cuchaz.enigma.gui.dialog.JavadocDialog; +import cuchaz.enigma.gui.dialog.SearchDialog; import cuchaz.enigma.gui.elements.MenuBar; import cuchaz.enigma.gui.elements.PopupMenuBar; import cuchaz.enigma.gui.filechooser.FileChooserAny; @@ -67,6 +68,7 @@ public class Gui { public FileDialog jarFileChooser; public FileDialog tinyMappingsFileChooser; + public SearchDialog searchDialog; public JFileChooser enigmaMappingsFileChooser; public JFileChooser exportSourceFileChooser; public FileDialog exportJarFileChooser; @@ -811,16 +813,15 @@ public class Gui { public void close() { if (!this.controller.isDirty()) { // everything is saved, we can exit safely - this.frame.dispose(); - System.exit(0); + exit(); } else { // ask to save before closing showDiscardDiag((response) -> { if (response == JOptionPane.YES_OPTION) { this.saveMapping(); - this.frame.dispose(); + exit(); } else if (response == JOptionPane.NO_OPTION) { - this.frame.dispose(); + exit(); } return null; @@ -828,6 +829,14 @@ public class Gui { } } + private void exit() { + if (searchDialog != null) { + searchDialog.dispose(); + } + this.frame.dispose(); + System.exit(0); + } + public void redraw() { this.frame.validate(); this.frame.repaint(); @@ -892,6 +901,10 @@ public class Gui { this.obfPanel.obfClasses.restoreExpansionState(this.obfPanel.obfClasses, stateObf); } + public PanelObf getObfPanel() { + return obfPanel; + } + public PanelDeobf getDeobfPanel() { return deobfPanel; } @@ -899,4 +912,12 @@ public class Gui { public void setShouldNavigateOnClick(boolean shouldNavigateOnClick) { this.shouldNavigateOnClick = shouldNavigateOnClick; } + + public SearchDialog getSearchDialog() { + if (searchDialog == null) { + searchDialog = new SearchDialog(this); + } + return searchDialog; + } + } -- cgit v1.2.3