diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/Gui.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/Gui.java | 45 |
1 files changed, 45 insertions, 0 deletions
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 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.gui; | 12 | package cuchaz.enigma.gui; |
| 13 | 13 | ||
| 14 | import com.google.common.base.Strings; | ||
| 14 | import com.google.common.collect.Lists; | 15 | import com.google.common.collect.Lists; |
| 15 | import cuchaz.enigma.Constants; | 16 | import cuchaz.enigma.Constants; |
| 16 | import cuchaz.enigma.EnigmaProfile; | 17 | import cuchaz.enigma.EnigmaProfile; |
| @@ -19,6 +20,7 @@ import cuchaz.enigma.analysis.*; | |||
| 19 | import cuchaz.enigma.config.Config; | 20 | import cuchaz.enigma.config.Config; |
| 20 | import cuchaz.enigma.config.Themes; | 21 | import cuchaz.enigma.config.Themes; |
| 21 | import cuchaz.enigma.gui.dialog.CrashDialog; | 22 | import cuchaz.enigma.gui.dialog.CrashDialog; |
| 23 | import cuchaz.enigma.gui.dialog.JavadocDialog; | ||
| 22 | import cuchaz.enigma.gui.elements.MenuBar; | 24 | import cuchaz.enigma.gui.elements.MenuBar; |
| 23 | import cuchaz.enigma.gui.elements.PopupMenuBar; | 25 | import cuchaz.enigma.gui.elements.PopupMenuBar; |
| 24 | import cuchaz.enigma.gui.filechooser.FileChooserAny; | 26 | import cuchaz.enigma.gui.filechooser.FileChooserAny; |
| @@ -82,6 +84,7 @@ public class Gui { | |||
| 82 | private JTabbedPane tabs; | 84 | private JTabbedPane tabs; |
| 83 | 85 | ||
| 84 | public JTextField renameTextField; | 86 | public JTextField renameTextField; |
| 87 | public JTextArea javadocTextArea; | ||
| 85 | 88 | ||
| 86 | public void setEditorTheme(Config.LookAndFeel feel) { | 89 | public void setEditorTheme(Config.LookAndFeel feel) { |
| 87 | if (editor != null && (editorFeel == null || editorFeel != feel)) { | 90 | if (editor != null && (editorFeel == null || editorFeel != feel)) { |
| @@ -559,6 +562,7 @@ public class Gui { | |||
| 559 | } | 562 | } |
| 560 | 563 | ||
| 561 | this.popupMenu.renameMenu.setEnabled(isRenamable); | 564 | this.popupMenu.renameMenu.setEnabled(isRenamable); |
| 565 | this.popupMenu.editJavadocMenu.setEnabled(isRenamable); | ||
| 562 | this.popupMenu.showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); | 566 | this.popupMenu.showInheritanceMenu.setEnabled(isClassEntry || isMethodEntry || isConstructorEntry); |
| 563 | this.popupMenu.showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); | 567 | this.popupMenu.showImplementationsMenu.setEnabled(isClassEntry || isMethodEntry); |
| 564 | this.popupMenu.showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); | 568 | this.popupMenu.showCallsMenu.setEnabled(isClassEntry || isFieldEntry || isMethodEntry || isConstructorEntry); |
| @@ -575,6 +579,47 @@ public class Gui { | |||
| 575 | } | 579 | } |
| 576 | } | 580 | } |
| 577 | 581 | ||
| 582 | public void startDocChange() { | ||
| 583 | |||
| 584 | // init the text box | ||
| 585 | javadocTextArea = new JTextArea(10, 40); | ||
| 586 | |||
| 587 | EntryReference<Entry<?>, Entry<?>> translatedReference = controller.project.getMapper().deobfuscate(cursorReference); | ||
| 588 | javadocTextArea.setText(Strings.nullToEmpty(translatedReference.entry.getJavadocs())); | ||
| 589 | |||
| 590 | JavadocDialog.init(frame, javadocTextArea, this::finishDocChange); | ||
| 591 | javadocTextArea.grabFocus(); | ||
| 592 | |||
| 593 | redraw(); | ||
| 594 | } | ||
| 595 | |||
| 596 | private void finishDocChange(JFrame ui, boolean saveName) { | ||
| 597 | String newName = javadocTextArea.getText(); | ||
| 598 | if (saveName) { | ||
| 599 | try { | ||
| 600 | this.controller.changeDocs(cursorReference, newName); | ||
| 601 | } catch (IllegalNameException ex) { | ||
| 602 | javadocTextArea.setBorder(BorderFactory.createLineBorder(Color.red, 1)); | ||
| 603 | javadocTextArea.setToolTipText(ex.getReason()); | ||
| 604 | Utils.showToolTipNow(javadocTextArea); | ||
| 605 | return; | ||
| 606 | } | ||
| 607 | |||
| 608 | ui.setVisible(false); | ||
| 609 | showCursorReference(cursorReference); | ||
| 610 | return; | ||
| 611 | } | ||
| 612 | |||
| 613 | // abort the jd change | ||
| 614 | javadocTextArea = null; | ||
| 615 | ui.setVisible(false); | ||
| 616 | showCursorReference(cursorReference); | ||
| 617 | |||
| 618 | this.editor.grabFocus(); | ||
| 619 | |||
| 620 | redraw(); | ||
| 621 | } | ||
| 622 | |||
| 578 | public void startRename() { | 623 | public void startRename() { |
| 579 | 624 | ||
| 580 | // init the text box | 625 | // init the text box |