From 254e212aef43d393ca210ba529efe462adcc2f87 Mon Sep 17 00:00:00 2001 From: 2xsaiko Date: Thu, 18 Jun 2020 22:23:09 +0200 Subject: Refactor PopupMenuBar -> EditorPopupMenu --- .../enigma/gui/elements/EditorPopupMenu.java | 174 +++++++++++++++++++++ .../cuchaz/enigma/gui/elements/PopupMenuBar.java | 130 --------------- .../java/cuchaz/enigma/gui/panels/EditorPanel.java | 110 ++++--------- 3 files changed, 208 insertions(+), 206 deletions(-) create mode 100644 enigma-swing/src/main/java/cuchaz/enigma/gui/elements/EditorPopupMenu.java delete mode 100644 enigma-swing/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java (limited to 'enigma-swing/src/main/java') diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/EditorPopupMenu.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/EditorPopupMenu.java new file mode 100644 index 0000000..86d920e --- /dev/null +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/EditorPopupMenu.java @@ -0,0 +1,174 @@ +package cuchaz.enigma.gui.elements; + +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import javax.swing.JMenuItem; +import javax.swing.JPopupMenu; +import javax.swing.KeyStroke; + +import cuchaz.enigma.analysis.EntryReference; +import cuchaz.enigma.gui.Gui; +import cuchaz.enigma.gui.GuiController; +import cuchaz.enigma.gui.panels.EditorPanel; +import cuchaz.enigma.translation.representation.entry.ClassEntry; +import cuchaz.enigma.translation.representation.entry.Entry; +import cuchaz.enigma.translation.representation.entry.FieldEntry; +import cuchaz.enigma.translation.representation.entry.MethodEntry; +import cuchaz.enigma.utils.I18n; + +public class EditorPopupMenu { + + private final JPopupMenu ui = new JPopupMenu(); + + private final JMenuItem renameItem = new JMenuItem(I18n.translate("popup_menu.rename")); + private final JMenuItem editJavadocItem = new JMenuItem(I18n.translate("popup_menu.javadoc")); + private final JMenuItem showInheritanceItem = new JMenuItem(I18n.translate("popup_menu.inheritance")); + private final JMenuItem showImplementationsItem = new JMenuItem(I18n.translate("popup_menu.implementations")); + private final JMenuItem showCallsItem = new JMenuItem(I18n.translate("popup_menu.calls")); + private final JMenuItem showCallsSpecificItem = new JMenuItem(I18n.translate("popup_menu.calls.specific")); + private final JMenuItem openEntryItem = new JMenuItem(I18n.translate("popup_menu.declaration")); + private final JMenuItem openPreviousItem = new JMenuItem(I18n.translate("popup_menu.back")); + private final JMenuItem openNextItem = new JMenuItem(I18n.translate("popup_menu.forward")); + private final JMenuItem toggleMappingItem = new JMenuItem(I18n.translate("popup_menu.mark_deobfuscated")); + private final JMenuItem zoomInItem = new JMenuItem(I18n.translate("popup_menu.zoom.in")); + private final JMenuItem zoomOutMenu = new JMenuItem(I18n.translate("popup_menu.zoom.out")); + private final JMenuItem resetZoomItem = new JMenuItem(I18n.translate("popup_menu.zoom.reset")); + + private final EditorPanel editor; + private final Gui gui; + + public EditorPopupMenu(EditorPanel editor, Gui gui) { + this.editor = editor; + this.gui = gui; + + this.ui.add(this.renameItem); + this.ui.add(this.editJavadocItem); + this.ui.add(this.showInheritanceItem); + this.ui.add(this.showImplementationsItem); + this.ui.add(this.showCallsItem); + this.ui.add(this.showCallsSpecificItem); + this.ui.add(this.openEntryItem); + this.ui.add(this.openPreviousItem); + this.ui.add(this.openNextItem); + this.ui.add(this.toggleMappingItem); + this.ui.addSeparator(); + this.ui.add(this.zoomInItem); + this.ui.add(this.zoomOutMenu); + this.ui.add(this.resetZoomItem); + + this.renameItem.setEnabled(false); + this.editJavadocItem.setEnabled(false); + this.showInheritanceItem.setEnabled(false); + this.showImplementationsItem.setEnabled(false); + this.showCallsItem.setEnabled(false); + this.showCallsSpecificItem.setEnabled(false); + this.openEntryItem.setEnabled(false); + this.openPreviousItem.setEnabled(false); + this.openNextItem.setEnabled(false); + this.toggleMappingItem.setEnabled(false); + + this.renameItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)); + this.editJavadocItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)); + this.showInheritanceItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)); + this.showImplementationsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK)); + this.showCallsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); + this.showCallsSpecificItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK + InputEvent.SHIFT_DOWN_MASK)); + this.openEntryItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK)); + this.openPreviousItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)); + this.openNextItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK)); + this.toggleMappingItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); + this.zoomInItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK)); + this.zoomOutMenu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK)); + + this.renameItem.addActionListener(event -> gui.startRename(editor)); + this.editJavadocItem.addActionListener(event -> gui.startDocChange(editor)); + this.showInheritanceItem.addActionListener(event -> gui.showInheritance(editor)); + this.showImplementationsItem.addActionListener(event -> gui.showImplementations(editor)); + this.showCallsItem.addActionListener(event -> gui.showCalls(editor, true)); + this.showCallsSpecificItem.addActionListener(event -> gui.showCalls(editor, false)); + this.openEntryItem.addActionListener(event -> gui.getController().navigateTo(editor.getCursorReference().entry)); + this.openPreviousItem.addActionListener(event -> gui.getController().openPreviousReference()); + this.openNextItem.addActionListener(event -> gui.getController().openNextReference()); + this.toggleMappingItem.addActionListener(event -> gui.toggleMapping(editor)); + this.zoomInItem.addActionListener(event -> editor.offsetEditorZoom(2)); + this.zoomOutMenu.addActionListener(event -> editor.offsetEditorZoom(-2)); + this.resetZoomItem.addActionListener(event -> editor.resetEditorZoom()); + } + + // TODO have editor redirect key event to menu so that the actions get + // triggered without having to hardcode them here, because this + // is a hack + public boolean handleKeyEvent(KeyEvent event) { + if (event.isControlDown()) { + switch (event.getKeyCode()) { + case KeyEvent.VK_I: + this.showInheritanceItem.doClick(); + return true; + case KeyEvent.VK_M: + this.showImplementationsItem.doClick(); + return true; + case KeyEvent.VK_N: + this.openEntryItem.doClick(); + return true; + case KeyEvent.VK_P: + this.openPreviousItem.doClick(); + return true; + case KeyEvent.VK_E: + this.openNextItem.doClick(); + return true; + case KeyEvent.VK_C: + if (event.isShiftDown()) { + this.showCallsSpecificItem.doClick(); + } else { + this.showCallsItem.doClick(); + } + return true; + case KeyEvent.VK_O: + this.toggleMappingItem.doClick(); + return true; + case KeyEvent.VK_R: + this.renameItem.doClick(); + return true; + case KeyEvent.VK_D: + this.editJavadocItem.doClick(); + return true; + } + } + return false; + } + + public void updateUiState() { + EntryReference, Entry> ref = this.editor.getCursorReference(); + Entry referenceEntry = ref == null ? null : ref.entry; + GuiController controller = this.gui.getController(); + + boolean isClassEntry = referenceEntry instanceof ClassEntry; + boolean isFieldEntry = referenceEntry instanceof FieldEntry; + boolean isMethodEntry = referenceEntry instanceof MethodEntry && !((MethodEntry) referenceEntry).isConstructor(); + boolean isConstructorEntry = referenceEntry instanceof MethodEntry && ((MethodEntry) referenceEntry).isConstructor(); + boolean isRenamable = ref != null && controller.project.isRenamable(ref); + + this.renameItem.setEnabled(isRenamable); + this.editJavadocItem.setEnabled(isRenamable); + this.showInheritanceItem.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); + this.showImplementationsItem.setEnabled(isClassEntry || isMethodEntry); + this.showCallsItem.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); + this.showCallsSpecificItem.setEnabled(isMethodEntry); + this.openEntryItem.setEnabled(isRenamable && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry)); + this.openPreviousItem.setEnabled(controller.hasPreviousReference()); + this.openNextItem.setEnabled(controller.hasNextReference()); + this.toggleMappingItem.setEnabled(isRenamable); + + if (referenceEntry != null && this.gui.getController().project.getMapper().extendedDeobfuscate(referenceEntry).isDeobfuscated()) { + this.toggleMappingItem.setText(I18n.translate("popup_menu.reset_obfuscated")); + } else { + this.toggleMappingItem.setText(I18n.translate("popup_menu.mark_deobfuscated")); + } + } + + public JPopupMenu getUi() { + return ui; + } + +} diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java deleted file mode 100644 index ad6dac6..0000000 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/elements/PopupMenuBar.java +++ /dev/null @@ -1,130 +0,0 @@ -package cuchaz.enigma.gui.elements; - -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; - -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JSeparator; -import javax.swing.KeyStroke; - -import cuchaz.enigma.gui.Gui; -import cuchaz.enigma.gui.panels.EditorPanel; -import cuchaz.enigma.utils.I18n; - -public class PopupMenuBar extends JPopupMenu { - - public final JMenuItem renameMenu; - public final JMenuItem editJavadocMenu; - public final JMenuItem showInheritanceMenu; - public final JMenuItem showImplementationsMenu; - public final JMenuItem showCallsMenu; - public final JMenuItem showCallsSpecificMenu; - public final JMenuItem openEntryMenu; - public final JMenuItem openPreviousMenu; - public final JMenuItem openNextMenu; - public final JMenuItem toggleMappingMenu; - - public PopupMenuBar(EditorPanel editor, Gui gui) { - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.rename")); - menu.addActionListener(event -> gui.startRename(editor)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.renameMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.javadoc")); - menu.addActionListener(event -> gui.startDocChange(editor)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.editJavadocMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.inheritance")); - menu.addActionListener(event -> gui.showInheritance(editor)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.showInheritanceMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.implementations")); - menu.addActionListener(event -> gui.showImplementations(editor)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.showImplementationsMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.calls")); - menu.addActionListener(event -> gui.showCalls(editor, true)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.showCallsMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.calls.specific")); - menu.addActionListener(event -> gui.showCalls(editor, false)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK + InputEvent.SHIFT_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.showCallsSpecificMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.declaration")); - menu.addActionListener(event -> gui.getController().navigateTo(editor.getCursorReference().entry)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.openEntryMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.back")); - menu.addActionListener(event -> gui.getController().openPreviousReference()); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.openPreviousMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.forward")); - menu.addActionListener(event -> gui.getController().openNextReference()); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.openNextMenu = menu; - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.mark_deobfuscated")); - menu.addActionListener(event -> gui.toggleMapping(editor)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK)); - menu.setEnabled(false); - this.add(menu); - this.toggleMappingMenu = menu; - } - { - this.add(new JSeparator()); - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.zoom.in")); - menu.addActionListener(event -> editor.offsetEditorZoom(2)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, InputEvent.CTRL_DOWN_MASK)); - this.add(menu); - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.zoom.out")); - menu.addActionListener(event -> editor.offsetEditorZoom(-2)); - menu.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK)); - this.add(menu); - } - { - JMenuItem menu = new JMenuItem(I18n.translate("popup_menu.zoom.reset")); - menu.addActionListener(event -> editor.resetEditorZoom()); - this.add(menu); - } - } -} diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java index ab9de33..bd1fae0 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/panels/EditorPanel.java @@ -1,21 +1,40 @@ package cuchaz.enigma.gui.panels; -import java.awt.*; -import java.awt.event.*; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.GridLayout; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; import java.util.ArrayList; import java.util.Collection; import java.util.List; import java.util.Map; import javax.annotation.Nullable; -import javax.swing.*; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JEditorPane; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JScrollPane; +import javax.swing.JSeparator; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; +import javax.swing.Timer; import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.Highlighter; import javax.swing.text.Highlighter.HighlightPainter; -import de.sciss.syntaxpane.DefaultSyntaxKit; - import cuchaz.enigma.EnigmaProject; import cuchaz.enigma.analysis.EntryReference; import cuchaz.enigma.classhandle.ClassHandle; @@ -27,7 +46,7 @@ import cuchaz.enigma.gui.GuiController; import cuchaz.enigma.gui.config.LookAndFeel; import cuchaz.enigma.gui.config.Themes; import cuchaz.enigma.gui.config.UiConfig; -import cuchaz.enigma.gui.elements.PopupMenuBar; +import cuchaz.enigma.gui.elements.EditorPopupMenu; import cuchaz.enigma.gui.events.EditorActionListener; import cuchaz.enigma.gui.events.ThemeChangeListener; import cuchaz.enigma.gui.highlight.BoxHighlightPainter; @@ -42,17 +61,16 @@ import cuchaz.enigma.translation.mapping.EntryResolver; import cuchaz.enigma.translation.mapping.ResolutionStrategy; import cuchaz.enigma.translation.representation.entry.ClassEntry; import cuchaz.enigma.translation.representation.entry.Entry; -import cuchaz.enigma.translation.representation.entry.FieldEntry; -import cuchaz.enigma.translation.representation.entry.MethodEntry; import cuchaz.enigma.utils.I18n; import cuchaz.enigma.utils.Result; +import de.sciss.syntaxpane.DefaultSyntaxKit; public class EditorPanel { private final JPanel ui = new JPanel(); private final JEditorPane editor = new JEditorPane(); private final JScrollPane editorScrollPane = new JScrollPane(this.editor); - private final PopupMenuBar popupMenu; + private final EditorPopupMenu popupMenu; // progress UI private final JLabel decompilingLabel = new JLabel(I18n.translate("editor.decompiling"), JLabel.CENTER); @@ -102,8 +120,8 @@ public class EditorPanel { kit.toggleComponent(this.editor, "de.sciss.syntaxpane.components.TokenMarker"); // init editor popup menu - this.popupMenu = new PopupMenuBar(this, gui); - this.editor.setComponentPopupMenu(this.popupMenu); + this.popupMenu = new EditorPopupMenu(this, gui); + this.editor.setComponentPopupMenu(this.popupMenu.getUi()); this.decompilingLabel.setFont(ScaleUtil.getFont(this.decompilingLabel.getFont().getFontName(), Font.BOLD, 26)); this.decompilingProgressBar.setIndeterminate(true); @@ -141,47 +159,8 @@ public class EditorPanel { public void keyPressed(KeyEvent event) { if (event.isControlDown()) { EditorPanel.this.shouldNavigateOnClick = false; + if (EditorPanel.this.popupMenu.handleKeyEvent(event)) return; switch (event.getKeyCode()) { - case KeyEvent.VK_I: - EditorPanel.this.popupMenu.showInheritanceMenu.doClick(); - break; - - case KeyEvent.VK_M: - EditorPanel.this.popupMenu.showImplementationsMenu.doClick(); - break; - - case KeyEvent.VK_N: - EditorPanel.this.popupMenu.openEntryMenu.doClick(); - break; - - case KeyEvent.VK_P: - EditorPanel.this.popupMenu.openPreviousMenu.doClick(); - break; - - case KeyEvent.VK_E: - EditorPanel.this.popupMenu.openNextMenu.doClick(); - break; - - case KeyEvent.VK_C: - if (event.isShiftDown()) { - EditorPanel.this.popupMenu.showCallsSpecificMenu.doClick(); - } else { - EditorPanel.this.popupMenu.showCallsMenu.doClick(); - } - break; - - case KeyEvent.VK_O: - EditorPanel.this.popupMenu.toggleMappingMenu.doClick(); - break; - - case KeyEvent.VK_R: - EditorPanel.this.popupMenu.renameMenu.doClick(); - break; - - case KeyEvent.VK_D: - EditorPanel.this.popupMenu.editJavadocMenu.doClick(); - break; - case KeyEvent.VK_F5: if (EditorPanel.this.classHandle != null) { EditorPanel.this.classHandle.invalidateMapped(); @@ -211,7 +190,9 @@ public class EditorPanel { @Override public void keyTyped(KeyEvent event) { - if (!EditorPanel.this.popupMenu.renameMenu.isEnabled()) return; + EntryReference, Entry> ref = EditorPanel.this.getCursorReference(); + if (ref == null) return; + if (!EditorPanel.this.controller.project.isRenamable(ref)) return; if (!event.isControlDown() && !event.isAltDown() && Character.isJavaIdentifierPart(event.getKeyChar())) { EnigmaProject project = gui.getController().project; @@ -431,30 +412,7 @@ public class EditorPanel { private void setCursorReference(EntryReference, Entry> ref) { this.cursorReference = ref; - Entry referenceEntry = ref == null ? null : ref.entry; - - boolean isClassEntry = referenceEntry instanceof ClassEntry; - boolean isFieldEntry = referenceEntry instanceof FieldEntry; - boolean isMethodEntry = referenceEntry instanceof MethodEntry && !((MethodEntry) referenceEntry).isConstructor(); - boolean isConstructorEntry = referenceEntry instanceof MethodEntry && ((MethodEntry) referenceEntry).isConstructor(); - boolean isRenamable = ref != null && this.controller.project.isRenamable(ref); - - this.popupMenu.renameMenu.setEnabled(isRenamable); - this.popupMenu.editJavadocMenu.setEnabled(isRenamable); - this.popupMenu.showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); - this.popupMenu.showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); - this.popupMenu.showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); - this.popupMenu.showCallsSpecificMenu.setEnabled(isMethodEntry); - this.popupMenu.openEntryMenu.setEnabled(isRenamable && (isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry)); - this.popupMenu.openPreviousMenu.setEnabled(this.controller.hasPreviousReference()); - this.popupMenu.openNextMenu.setEnabled(this.controller.hasNextReference()); - this.popupMenu.toggleMappingMenu.setEnabled(isRenamable); - - if (referenceEntry != null && this.controller.project.getMapper().extendedDeobfuscate(referenceEntry).isDeobfuscated()) { - this.popupMenu.toggleMappingMenu.setText(I18n.translate("popup_menu.reset_obfuscated")); - } else { - this.popupMenu.toggleMappingMenu.setText(I18n.translate("popup_menu.mark_deobfuscated")); - } + this.popupMenu.updateUiState(); this.listeners.forEach(l -> l.onCursorReferenceChanged(this, ref)); } -- cgit v1.2.3