diff options
| author | 2020-10-11 20:10:48 +0200 | |
|---|---|---|
| committer | 2020-10-11 20:10:48 +0200 | |
| commit | c6b53f392b8f85b2197d04c95620864d209a3ae6 (patch) | |
| tree | 391e545dcacc0f918b3a519be649a3f2660f25c8 /enigma-swing/src/main/java | |
| parent | Revert "Only conflict when both methods are not synthetic" (diff) | |
| download | enigma-fork-c6b53f392b8f85b2197d04c95620864d209a3ae6.tar.gz enigma-fork-c6b53f392b8f85b2197d04c95620864d209a3ae6.tar.xz enigma-fork-c6b53f392b8f85b2197d04c95620864d209a3ae6.zip | |
Add popup menu to deobf panel to quickly rename a package/class
Diffstat (limited to 'enigma-swing/src/main/java')
| -rw-r--r-- | enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java | 20 | ||||
| -rw-r--r-- | enigma-swing/src/main/java/cuchaz/enigma/gui/elements/DeobfPanelPopupMenu.java | 34 |
2 files changed, 50 insertions, 4 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java index 323d304..cbc9688 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -37,10 +37,7 @@ import cuchaz.enigma.gui.config.UiConfig; | |||
| 37 | import cuchaz.enigma.gui.dialog.CrashDialog; | 37 | import cuchaz.enigma.gui.dialog.CrashDialog; |
| 38 | import cuchaz.enigma.gui.dialog.JavadocDialog; | 38 | import cuchaz.enigma.gui.dialog.JavadocDialog; |
| 39 | import cuchaz.enigma.gui.dialog.SearchDialog; | 39 | import cuchaz.enigma.gui.dialog.SearchDialog; |
| 40 | import cuchaz.enigma.gui.elements.CollapsibleTabbedPane; | 40 | import cuchaz.enigma.gui.elements.*; |
| 41 | import cuchaz.enigma.gui.elements.EditorTabPopupMenu; | ||
| 42 | import cuchaz.enigma.gui.elements.MenuBar; | ||
| 43 | import cuchaz.enigma.gui.elements.ValidatableUi; | ||
| 44 | import cuchaz.enigma.gui.events.EditorActionListener; | 41 | import cuchaz.enigma.gui.events.EditorActionListener; |
| 45 | import cuchaz.enigma.gui.panels.*; | 42 | import cuchaz.enigma.gui.panels.*; |
| 46 | import cuchaz.enigma.gui.util.History; | 43 | import cuchaz.enigma.gui.util.History; |
| @@ -107,6 +104,7 @@ public class Gui implements LanguageChangeListener { | |||
| 107 | private JLabel statusLabel; | 104 | private JLabel statusLabel; |
| 108 | 105 | ||
| 109 | private final EditorTabPopupMenu editorTabPopupMenu; | 106 | private final EditorTabPopupMenu editorTabPopupMenu; |
| 107 | private final DeobfPanelPopupMenu deobfPanelPopupMenu; | ||
| 110 | private final JTabbedPane openFiles; | 108 | private final JTabbedPane openFiles; |
| 111 | private final HashBiMap<ClassEntry, EditorPanel> editors = HashBiMap.create(); | 109 | private final HashBiMap<ClassEntry, EditorPanel> editors = HashBiMap.create(); |
| 112 | 110 | ||
| @@ -292,6 +290,19 @@ public class Gui implements LanguageChangeListener { | |||
| 292 | } | 290 | } |
| 293 | }); | 291 | }); |
| 294 | 292 | ||
| 293 | deobfPanelPopupMenu = new DeobfPanelPopupMenu(this); | ||
| 294 | deobfPanel.deobfClasses.addMouseListener(new MouseAdapter() { | ||
| 295 | @Override | ||
| 296 | public void mousePressed(MouseEvent e) { | ||
| 297 | if (SwingUtilities.isRightMouseButton(e)) { | ||
| 298 | int i = deobfPanel.deobfClasses.getRowForPath(deobfPanel.deobfClasses.getSelectionPath()); | ||
| 299 | if (i != -1) { | ||
| 300 | deobfPanelPopupMenu.show(deobfPanel.deobfClasses, e.getX(), e.getY()); | ||
| 301 | } | ||
| 302 | } | ||
| 303 | } | ||
| 304 | }); | ||
| 305 | |||
| 295 | // layout controls | 306 | // layout controls |
| 296 | JPanel centerPanel = new JPanel(); | 307 | JPanel centerPanel = new JPanel(); |
| 297 | centerPanel.setLayout(new BorderLayout()); | 308 | centerPanel.setLayout(new BorderLayout()); |
| @@ -893,6 +904,7 @@ public class Gui implements LanguageChangeListener { | |||
| 893 | this.menuBar.retranslateUi(); | 904 | this.menuBar.retranslateUi(); |
| 894 | this.obfPanel.retranslateUi(); | 905 | this.obfPanel.retranslateUi(); |
| 895 | this.deobfPanel.retranslateUi(); | 906 | this.deobfPanel.retranslateUi(); |
| 907 | this.deobfPanelPopupMenu.retranslateUi(); | ||
| 896 | this.infoPanel.retranslateUi(); | 908 | this.infoPanel.retranslateUi(); |
| 897 | this.editors.values().forEach(EditorPanel::retranslateUi); | 909 | this.editors.values().forEach(EditorPanel::retranslateUi); |
| 898 | } | 910 | } |
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/DeobfPanelPopupMenu.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/DeobfPanelPopupMenu.java new file mode 100644 index 0000000..a4d749c --- /dev/null +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/DeobfPanelPopupMenu.java | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | package cuchaz.enigma.gui.elements; | ||
| 2 | |||
| 3 | import cuchaz.enigma.gui.ClassSelector; | ||
| 4 | import cuchaz.enigma.gui.Gui; | ||
| 5 | import cuchaz.enigma.utils.I18n; | ||
| 6 | |||
| 7 | import javax.swing.*; | ||
| 8 | import java.awt.*; | ||
| 9 | |||
| 10 | public class DeobfPanelPopupMenu { | ||
| 11 | |||
| 12 | private final JPopupMenu ui; | ||
| 13 | private final JMenuItem rename; | ||
| 14 | |||
| 15 | public DeobfPanelPopupMenu(Gui gui) { | ||
| 16 | this.ui = new JPopupMenu(); | ||
| 17 | |||
| 18 | ClassSelector deobfClasses = gui.getDeobfPanel().deobfClasses; | ||
| 19 | |||
| 20 | this.rename = new JMenuItem(); | ||
| 21 | this.rename.addActionListener(a -> deobfClasses.getUI().startEditingAtPath(deobfClasses, deobfClasses.getSelectionPath())); | ||
| 22 | this.ui.add(this.rename); | ||
| 23 | |||
| 24 | this.retranslateUi(); | ||
| 25 | } | ||
| 26 | |||
| 27 | public void show(Component invoker, int x, int y) { | ||
| 28 | this.ui.show(invoker, x, y); | ||
| 29 | } | ||
| 30 | |||
| 31 | public void retranslateUi() { | ||
| 32 | this.rename.setText(I18n.translate("popup_menu.deobf_panel.rename")); | ||
| 33 | } | ||
| 34 | } | ||