From a9e03fa0e75b5b338021de982acbbb8277e08706 Mon Sep 17 00:00:00 2001 From: Fudge Date: Mon, 2 Dec 2019 15:43:23 +0200 Subject: Allow attaching class, method, field, and parameter javadocs (#185) * bring liach pr to modern enigma * bump version * fuck off vscode * switch to COMMENT and write comments before * it was already after, what do you want * oops * put inner classes at the end * remove indents and use all caps * add refreshmappings command * Update src/main/java/cuchaz/enigma/translation/mapping/serde/EnigmaMappingsWriter.java * Delete RefreshEnigmaMappingsCommand.java * Update CommandMain.java * ok --- src/main/java/cuchaz/enigma/gui/Gui.java | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (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 3ab1cee..1ea3e44 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java @@ -11,6 +11,7 @@ package cuchaz.enigma.gui; +import com.google.common.base.Strings; import com.google.common.collect.Lists; import cuchaz.enigma.Constants; import cuchaz.enigma.EnigmaProfile; @@ -19,6 +20,7 @@ import cuchaz.enigma.analysis.*; 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.elements.MenuBar; import cuchaz.enigma.gui.elements.PopupMenuBar; import cuchaz.enigma.gui.filechooser.FileChooserAny; @@ -82,6 +84,7 @@ public class Gui { private JTabbedPane tabs; public JTextField renameTextField; + public JTextArea javadocTextArea; public void setEditorTheme(Config.LookAndFeel feel) { if (editor != null && (editorFeel == null || editorFeel != feel)) { @@ -559,6 +562,7 @@ public class Gui { } 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); @@ -575,6 +579,47 @@ public class Gui { } } + public void startDocChange() { + + // init the text box + javadocTextArea = new JTextArea(10, 40); + + EntryReference, Entry> translatedReference = controller.project.getMapper().deobfuscate(cursorReference); + javadocTextArea.setText(Strings.nullToEmpty(translatedReference.entry.getJavadocs())); + + JavadocDialog.init(frame, javadocTextArea, this::finishDocChange); + javadocTextArea.grabFocus(); + + redraw(); + } + + private void finishDocChange(JFrame ui, boolean saveName) { + String newName = javadocTextArea.getText(); + if (saveName) { + try { + this.controller.changeDocs(cursorReference, newName); + } catch (IllegalNameException ex) { + javadocTextArea.setBorder(BorderFactory.createLineBorder(Color.red, 1)); + javadocTextArea.setToolTipText(ex.getReason()); + Utils.showToolTipNow(javadocTextArea); + return; + } + + ui.setVisible(false); + showCursorReference(cursorReference); + return; + } + + // abort the jd change + javadocTextArea = null; + ui.setVisible(false); + showCursorReference(cursorReference); + + this.editor.grabFocus(); + + redraw(); + } + public void startRename() { // init the text box -- cgit v1.2.3