summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui/elements
diff options
context:
space:
mode:
authorGravatar Gegy2019-01-24 14:48:32 +0200
committerGravatar Adrian Siekierka2019-01-24 13:48:32 +0100
commit00fcd0550fcdda621c2e4662f6ddd55ce673b931 (patch)
tree6f9e4c24dbcc6d118fceec56adf7bf9d747a485c /src/main/java/cuchaz/enigma/gui/elements
parentmark as 0.13.0-SNAPSHOT for preliminary development (diff)
downloadenigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.gz
enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.tar.xz
enigma-fork-00fcd0550fcdda621c2e4662f6ddd55ce673b931.zip
[WIP] Mapping rework (#91)
* Move packages * Mapping & entry refactor: first pass * Fix deobf -> obf tree remapping * Resolve various issues * Give all entries the potential for parents and treat inner classes as children * Deobf UI tree elements * Tests pass * Sort mapping output * Fix delta tracking * Index separation and first pass for #97 * Keep track of remapped jar index * Fix child entries not being remapped * Drop non-root entries * Track dropped mappings * Fix enigma mapping ordering * EntryTreeNode interface * Small tweaks * Naive full index remap on rename * Entries can resolve to more than one root entry * Support alternative resolution strategies * Bridge method resolution * Tests pass * Fix mappings being used where there are none * Fix methods with different descriptors being considered unique. closes #89
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/elements')
-rw-r--r--src/main/java/cuchaz/enigma/gui/elements/MenuBar.java45
1 files changed, 12 insertions, 33 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
index 609aecb..f4f0277 100644
--- a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
+++ b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java
@@ -5,6 +5,7 @@ import cuchaz.enigma.config.Themes;
5import cuchaz.enigma.gui.Gui; 5import cuchaz.enigma.gui.Gui;
6import cuchaz.enigma.gui.dialog.AboutDialog; 6import cuchaz.enigma.gui.dialog.AboutDialog;
7import cuchaz.enigma.throwables.MappingParseException; 7import cuchaz.enigma.throwables.MappingParseException;
8import cuchaz.enigma.translation.mapping.serde.MappingFormat;
8 9
9import javax.swing.*; 10import javax.swing.*;
10import java.awt.event.InputEvent; 11import java.awt.event.InputEvent;
@@ -23,7 +24,6 @@ public class MenuBar extends JMenuBar {
23 public final JMenuItem saveMappingEnigmaDirectoryMenu; 24 public final JMenuItem saveMappingEnigmaDirectoryMenu;
24 public final JMenuItem saveMappingsSrgMenu; 25 public final JMenuItem saveMappingsSrgMenu;
25 public final JMenuItem closeMappingsMenu; 26 public final JMenuItem closeMappingsMenu;
26 public final JMenuItem rebuildMethodNamesMenu;
27 public final JMenuItem exportSourceMenu; 27 public final JMenuItem exportSourceMenu;
28 public final JMenuItem exportJarMenu; 28 public final JMenuItem exportJarMenu;
29 private final Gui gui; 29 private final Gui gui;
@@ -68,7 +68,9 @@ public class MenuBar extends JMenuBar {
68 item.addActionListener(event -> { 68 item.addActionListener(event -> {
69 if (this.gui.enigmaMappingsFileChooser.showOpenDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 69 if (this.gui.enigmaMappingsFileChooser.showOpenDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
70 try { 70 try {
71 this.gui.getController().openEnigmaMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile()); 71 File selectedFile = this.gui.enigmaMappingsFileChooser.getSelectedFile();
72 MappingFormat format = selectedFile.isDirectory() ? MappingFormat.ENIGMA_DIRECTORY : MappingFormat.ENIGMA_FILE;
73 this.gui.getController().openMappings(format, selectedFile.toPath());
72 } catch (IOException ex) { 74 } catch (IOException ex) {
73 throw new Error(ex); 75 throw new Error(ex);
74 } catch (MappingParseException ex) { 76 } catch (MappingParseException ex) {
@@ -85,7 +87,7 @@ public class MenuBar extends JMenuBar {
85 File file = new File(this.gui.tinyMappingsFileChooser.getDirectory() + File.separator + this.gui.tinyMappingsFileChooser.getFile()); 87 File file = new File(this.gui.tinyMappingsFileChooser.getDirectory() + File.separator + this.gui.tinyMappingsFileChooser.getFile());
86 if (file.exists()) { 88 if (file.exists()) {
87 try { 89 try {
88 this.gui.getController().openTinyMappings(file); 90 this.gui.getController().openMappings(MappingFormat.TINY_FILE, file.toPath());
89 } catch (IOException ex) { 91 } catch (IOException ex) {
90 throw new Error(ex); 92 throw new Error(ex);
91 } catch (MappingParseException ex) { 93 } catch (MappingParseException ex) {
@@ -99,11 +101,7 @@ public class MenuBar extends JMenuBar {
99 JMenuItem item = new JMenuItem("Save Mappings"); 101 JMenuItem item = new JMenuItem("Save Mappings");
100 menu.add(item); 102 menu.add(item);
101 item.addActionListener(event -> { 103 item.addActionListener(event -> {
102 try { 104 this.gui.getController().saveMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath());
103 this.gui.getController().saveMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile());
104 } catch (IOException ex) {
105 throw new Error(ex);
106 }
107 }); 105 });
108 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK)); 106 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
109 this.saveMappingsMenu = item; 107 this.saveMappingsMenu = item;
@@ -116,12 +114,8 @@ public class MenuBar extends JMenuBar {
116 item.addActionListener(event -> { 114 item.addActionListener(event -> {
117 // TODO: Use a specific file chooser for it 115 // TODO: Use a specific file chooser for it
118 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 116 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
119 try { 117 this.gui.getController().saveMappings(MappingFormat.ENIGMA_FILE, this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath());
120 this.gui.getController().saveEnigmaMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile(), false); 118 this.saveMappingsMenu.setEnabled(true);
121 this.saveMappingsMenu.setEnabled(true);
122 } catch (IOException ex) {
123 throw new Error(ex);
124 }
125 } 119 }
126 }); 120 });
127 this.saveMappingEnigmaFileMenu = item; 121 this.saveMappingEnigmaFileMenu = item;
@@ -132,12 +126,8 @@ public class MenuBar extends JMenuBar {
132 item.addActionListener(event -> { 126 item.addActionListener(event -> {
133 // TODO: Use a specific file chooser for it 127 // TODO: Use a specific file chooser for it
134 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 128 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
135 try { 129 this.gui.getController().saveMappings(MappingFormat.ENIGMA_DIRECTORY, this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath());
136 this.gui.getController().saveEnigmaMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile(), true); 130 this.saveMappingsMenu.setEnabled(true);
137 this.saveMappingsMenu.setEnabled(true);
138 } catch (IOException ex) {
139 throw new Error(ex);
140 }
141 } 131 }
142 }); 132 });
143 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); 133 item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
@@ -149,12 +139,8 @@ public class MenuBar extends JMenuBar {
149 item.addActionListener(event -> { 139 item.addActionListener(event -> {
150 // TODO: Use a specific file chooser for it 140 // TODO: Use a specific file chooser for it
151 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { 141 if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) {
152 try { 142 this.gui.getController().saveMappings(MappingFormat.SRG_FILE, this.gui.enigmaMappingsFileChooser.getSelectedFile().toPath());
153 this.gui.getController().saveSRGMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile()); 143 this.saveMappingsMenu.setEnabled(true);
154 this.saveMappingsMenu.setEnabled(true);
155 } catch (IOException ex) {
156 throw new Error(ex);
157 }
158 } 144 }
159 }); 145 });
160 this.saveMappingsSrgMenu = item; 146 this.saveMappingsSrgMenu = item;
@@ -184,13 +170,6 @@ public class MenuBar extends JMenuBar {
184 } 170 }
185 menu.addSeparator(); 171 menu.addSeparator();
186 { 172 {
187 JMenuItem item = new JMenuItem("Rebuild Method Names");
188 menu.add(item);
189 item.addActionListener(event -> this.gui.getController().rebuildMethodNames());
190 this.rebuildMethodNamesMenu = item;
191 }
192 menu.addSeparator();
193 {
194 JMenuItem item = new JMenuItem("Export Source..."); 173 JMenuItem item = new JMenuItem("Export Source...");
195 menu.add(item); 174 menu.add(item);
196 item.addActionListener(event -> { 175 item.addActionListener(event -> {