From 028ef6d0cfb1db3a1faa28d2a26647c2c67a13ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Sat, 6 Mar 2021 16:33:10 +0100 Subject: [PATCH] #1371 Go to character id (Ctrl+G in tag tree) --- CHANGELOG.md | 2 ++ .../jpexs/decompiler/flash/gui/MainPanel.java | 31 +++++++++++++++++++ src/com/jpexs/decompiler/flash/gui/View.java | 9 ++++++ .../flash/gui/locales/MainFrame.properties | 7 ++++- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c2f7537..03e2dae0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file. ### Added - [#1645] Scrollbar to recent searches dropdown - [#1639] Clearing search results for current file +- [#1371] Go to character id (Ctrl+G in tag tree) ### Changed - [#1471] Import script menuitem renamed to Import scripts. @@ -2079,6 +2080,7 @@ All notable changes to this project will be documented in this file. [alpha 7]: https://github.com/jindrapetrik/jpexs-decompiler/releases/tag/alpha7 [#1645]: https://www.free-decompiler.com/flash/issues/1645 [#1639]: https://www.free-decompiler.com/flash/issues/1639 +[#1371]: https://www.free-decompiler.com/flash/issues/1371 [#1471]: https://www.free-decompiler.com/flash/issues/1471 [#1396]: https://www.free-decompiler.com/flash/issues/1396 [#1254]: https://www.free-decompiler.com/flash/issues/1254 diff --git a/src/com/jpexs/decompiler/flash/gui/MainPanel.java b/src/com/jpexs/decompiler/flash/gui/MainPanel.java index a61589ae6..c41cb64bd 100644 --- a/src/com/jpexs/decompiler/flash/gui/MainPanel.java +++ b/src/com/jpexs/decompiler/flash/gui/MainPanel.java @@ -739,6 +739,37 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se searchPanel.setVisible(true); filterField.requestFocusInWindow(); } + if ((e.getKeyCode() == 'G') && (e.isControlDown())) { + SWF swf = getCurrentSwf(); + if (swf != null) { + String val = ""; + boolean valid; + int characterId = -1; + do { + val = View.showInputDialog(MainPanel.this, translate("message.input.gotoCharacter"), translate("message.input.gotoCharacter.title"), val); + if (val == null) { + break; + } + try { + characterId = Integer.parseInt(val); + } catch (NumberFormatException nfe) { + characterId = -1; + } + } while (characterId <= 0); + + if (characterId > 0) { + CharacterTag tag = swf.getCharacter(characterId); + if (tag == null) { + View.showMessageDialog(MainPanel.this, translate("message.character.notfound").replace("%characterid%", "" + characterId), translate("error"), JOptionPane.ERROR_MESSAGE); + } else { + TreePath path = tagTree.getModel().getTreePath(tag); + if (path != null) { + tagTree.setSelectionPath(path); + } + } + } + } + } } }); detailPanel.setVisible(false); diff --git a/src/com/jpexs/decompiler/flash/gui/View.java b/src/com/jpexs/decompiler/flash/gui/View.java index dcb8eb61f..ca1337a57 100644 --- a/src/com/jpexs/decompiler/flash/gui/View.java +++ b/src/com/jpexs/decompiler/flash/gui/View.java @@ -67,6 +67,7 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenuItem; import javax.swing.JOptionPane; +import static javax.swing.JOptionPane.QUESTION_MESSAGE; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JRootPane; @@ -572,6 +573,14 @@ public class View { return ret[0]; } + public static String showInputDialog(Component parentComponent, final Object message, final String title, final Object initialSelection) { + final String[] ret = new String[1]; + execInEventDispatch(() -> { + ret[0] = (String) JOptionPane.showInputDialog(parentComponent, message, title, JOptionPane.QUESTION_MESSAGE, null, null, initialSelection); + }); + return ret[0]; + } + public static SubstanceColorScheme getColorScheme() { return SubstanceColorSchemeUtilities.getActiveColorScheme(new JButton(), ComponentState.ENABLED); } diff --git a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties index 8345c8266..4612a94cc 100644 --- a/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties +++ b/src/com/jpexs/decompiler/flash/gui/locales/MainFrame.properties @@ -797,4 +797,9 @@ menu.recentSearches = Recent searches for current file menu.recentSearches.empty = Recent searches list is empty menu.tools.otherTools.clearRecentSearches = Clear all recent searches menu.recentSearches.clear = clear search results -message.confirm.recentSearches.clear = Do you really want to clear recent searches for current file? \ No newline at end of file +message.confirm.recentSearches.clear = Do you really want to clear recent searches for current file? + +message.input.gotoCharacter.title = Go to character +message.input.gotoCharacter = Enter character id + +message.character.notfound = Character %characterid% not found. \ No newline at end of file