diff options
Diffstat (limited to 'enigma-swing')
| -rw-r--r-- | enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java | 51 |
1 files changed, 42 insertions, 9 deletions
diff --git a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java index 3609427d..a9795bce 100644 --- a/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/enigma-swing/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -46,6 +46,8 @@ import cuchaz.enigma.analysis.MethodInheritanceTreeNode; | |||
| 46 | import cuchaz.enigma.analysis.MethodReferenceTreeNode; | 46 | import cuchaz.enigma.analysis.MethodReferenceTreeNode; |
| 47 | import cuchaz.enigma.analysis.StructureTreeNode; | 47 | import cuchaz.enigma.analysis.StructureTreeNode; |
| 48 | import cuchaz.enigma.analysis.StructureTreeOptions; | 48 | import cuchaz.enigma.analysis.StructureTreeOptions; |
| 49 | import cuchaz.enigma.api.DataInvalidationEvent; | ||
| 50 | import cuchaz.enigma.api.DataInvalidationListener; | ||
| 49 | import cuchaz.enigma.api.service.ObfuscationTestService; | 51 | import cuchaz.enigma.api.service.ObfuscationTestService; |
| 50 | import cuchaz.enigma.api.view.GuiView; | 52 | import cuchaz.enigma.api.view.GuiView; |
| 51 | import cuchaz.enigma.api.view.entry.EntryReferenceView; | 53 | import cuchaz.enigma.api.view.entry.EntryReferenceView; |
| @@ -94,7 +96,7 @@ import cuchaz.enigma.utils.Utils; | |||
| 94 | import cuchaz.enigma.utils.validation.PrintValidatable; | 96 | import cuchaz.enigma.utils.validation.PrintValidatable; |
| 95 | import cuchaz.enigma.utils.validation.ValidationContext; | 97 | import cuchaz.enigma.utils.validation.ValidationContext; |
| 96 | 98 | ||
| 97 | public class GuiController implements ClientPacketHandler, GuiView { | 99 | public class GuiController implements ClientPacketHandler, GuiView, DataInvalidationListener { |
| 98 | private final Gui gui; | 100 | private final Gui gui; |
| 99 | public final Enigma enigma; | 101 | public final Enigma enigma; |
| 100 | 102 | ||
| @@ -132,6 +134,7 @@ public class GuiController implements ClientPacketHandler, GuiView { | |||
| 132 | 134 | ||
| 133 | return ProgressDialog.runOffThread(gui.getFrame(), progress -> { | 135 | return ProgressDialog.runOffThread(gui.getFrame(), progress -> { |
| 134 | project = enigma.openJars(jarPaths, new ClasspathClassProvider(), progress); | 136 | project = enigma.openJars(jarPaths, new ClasspathClassProvider(), progress); |
| 137 | project.addDataInvalidationListener(this); | ||
| 135 | indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); | 138 | indexTreeBuilder = new IndexTreeBuilder(project.getJarIndex()); |
| 136 | chp = new ClassHandleProvider(project, UiConfig.getDecompiler().service); | 139 | chp = new ClassHandleProvider(project, UiConfig.getDecompiler().service); |
| 137 | SwingUtilities.invokeLater(() -> { | 140 | SwingUtilities.invokeLater(() -> { |
| @@ -177,7 +180,7 @@ public class GuiController implements ClientPacketHandler, GuiView { | |||
| 177 | loadedMappingPath = path; | 180 | loadedMappingPath = path; |
| 178 | 181 | ||
| 179 | refreshClasses(); | 182 | refreshClasses(); |
| 180 | chp.invalidateJavadoc(); | 183 | project.invalidateData(DataInvalidationEvent.InvalidationType.JAVADOC); |
| 181 | } catch (MappingParseException e) { | 184 | } catch (MappingParseException e) { |
| 182 | JOptionPane.showMessageDialog(gui.getFrame(), e.getMessage()); | 185 | JOptionPane.showMessageDialog(gui.getFrame(), e.getMessage()); |
| 183 | } | 186 | } |
| @@ -192,7 +195,7 @@ public class GuiController implements ClientPacketHandler, GuiView { | |||
| 192 | 195 | ||
| 193 | project.setMappings(mappings); | 196 | project.setMappings(mappings); |
| 194 | refreshClasses(); | 197 | refreshClasses(); |
| 195 | chp.invalidateJavadoc(); | 198 | project.invalidateData(DataInvalidationEvent.InvalidationType.JAVADOC); |
| 196 | } | 199 | } |
| 197 | 200 | ||
| 198 | public MappingFormat getLoadedMappingFormat() { | 201 | public MappingFormat getLoadedMappingFormat() { |
| @@ -252,7 +255,7 @@ public class GuiController implements ClientPacketHandler, GuiView { | |||
| 252 | 255 | ||
| 253 | this.gui.setMappingsFile(null); | 256 | this.gui.setMappingsFile(null); |
| 254 | refreshClasses(); | 257 | refreshClasses(); |
| 255 | chp.invalidateJavadoc(); | 258 | project.invalidateData(DataInvalidationEvent.InvalidationType.JAVADOC); |
| 256 | } | 259 | } |
| 257 | 260 | ||
| 258 | public void reloadAll() { | 261 | public void reloadAll() { |
| @@ -573,12 +576,11 @@ public class GuiController implements ClientPacketHandler, GuiView { | |||
| 573 | this.gui.moveClassTree(target, prev.targetName() == null, mapping.targetName() == null); | 576 | this.gui.moveClassTree(target, prev.targetName() == null, mapping.targetName() == null); |
| 574 | } | 577 | } |
| 575 | 578 | ||
| 576 | if (!Objects.equals(prev.targetName(), mapping.targetName())) { | ||
| 577 | this.chp.invalidateMapped(); | ||
| 578 | } | ||
| 579 | |||
| 580 | if (!Objects.equals(prev.javadoc(), mapping.javadoc())) { | 579 | if (!Objects.equals(prev.javadoc(), mapping.javadoc())) { |
| 581 | this.chp.invalidateJavadoc(target.getTopLevelClass()); | 580 | project.invalidateData(target.getTopLevelClass().getFullName(), DataInvalidationEvent.InvalidationType.JAVADOC); |
| 581 | // invalidateJavadoc implies invalidateMapped, so no need to check for that too | ||
| 582 | } else if (!Objects.equals(prev.targetName(), mapping.targetName())) { | ||
| 583 | project.invalidateData(DataInvalidationEvent.InvalidationType.MAPPINGS); | ||
| 582 | } | 584 | } |
| 583 | 585 | ||
| 584 | gui.showStructure(gui.getActiveEditor()); | 586 | gui.showStructure(gui.getActiveEditor()); |
| @@ -677,4 +679,35 @@ public class GuiController implements ClientPacketHandler, GuiView { | |||
| 677 | public void updateUserList(List<String> users) { | 679 | public void updateUserList(List<String> users) { |
| 678 | gui.setUserList(users); | 680 | gui.setUserList(users); |
| 679 | } | 681 | } |
| 682 | |||
| 683 | @Override | ||
| 684 | public void onDataInvalidated(DataInvalidationEvent event) { | ||
| 685 | Objects.requireNonNull(project, "Invalidating data when no project is open"); | ||
| 686 | |||
| 687 | if (event.getClasses() == null) { | ||
| 688 | switch (event.getType()) { | ||
| 689 | case MAPPINGS -> chp.invalidateMapped(); | ||
| 690 | case JAVADOC -> chp.invalidateJavadoc(); | ||
| 691 | case DECOMPILE -> chp.invalidate(); | ||
| 692 | } | ||
| 693 | } else { | ||
| 694 | switch (event.getType()) { | ||
| 695 | case MAPPINGS -> { | ||
| 696 | for (String clazz : event.getClasses()) { | ||
| 697 | chp.invalidateMapped(new ClassEntry(clazz)); | ||
| 698 | } | ||
| 699 | } | ||
| 700 | case JAVADOC -> { | ||
| 701 | for (String clazz : event.getClasses()) { | ||
| 702 | chp.invalidateJavadoc(new ClassEntry(clazz)); | ||
| 703 | } | ||
| 704 | } | ||
| 705 | case DECOMPILE -> { | ||
| 706 | for (String clazz : event.getClasses()) { | ||
| 707 | chp.invalidate(new ClassEntry(clazz)); | ||
| 708 | } | ||
| 709 | } | ||
| 710 | } | ||
| 711 | } | ||
| 712 | } | ||
| 680 | } | 713 | } |