diff options
| author | 2015-03-10 00:55:03 -0400 | |
|---|---|---|
| committer | 2015-03-10 00:55:03 -0400 | |
| commit | 430df87ba5d855ca29bc53a5765a2862d2209098 (patch) | |
| tree | ee427f009da8b29e7a66a4b4ce882120f9bb2cbf /src/cuchaz/enigma/gui/ClassMatchingGui.java | |
| parent | field matcher is starting to be useful (diff) | |
| download | enigma-fork-430df87ba5d855ca29bc53a5765a2862d2209098.tar.gz enigma-fork-430df87ba5d855ca29bc53a5765a2862d2209098.tar.xz enigma-fork-430df87ba5d855ca29bc53a5765a2862d2209098.zip | |
tweaks and improvements to field matching gui
Diffstat (limited to 'src/cuchaz/enigma/gui/ClassMatchingGui.java')
| -rw-r--r-- | src/cuchaz/enigma/gui/ClassMatchingGui.java | 24 |
1 files changed, 3 insertions, 21 deletions
diff --git a/src/cuchaz/enigma/gui/ClassMatchingGui.java b/src/cuchaz/enigma/gui/ClassMatchingGui.java index 6943c3e..9e210ec 100644 --- a/src/cuchaz/enigma/gui/ClassMatchingGui.java +++ b/src/cuchaz/enigma/gui/ClassMatchingGui.java | |||
| @@ -6,7 +6,6 @@ import java.awt.Dimension; | |||
| 6 | import java.awt.FlowLayout; | 6 | import java.awt.FlowLayout; |
| 7 | import java.awt.event.ActionEvent; | 7 | import java.awt.event.ActionEvent; |
| 8 | import java.awt.event.ActionListener; | 8 | import java.awt.event.ActionListener; |
| 9 | import java.util.Arrays; | ||
| 10 | import java.util.Collection; | 9 | import java.util.Collection; |
| 11 | import java.util.List; | 10 | import java.util.List; |
| 12 | import java.util.Map; | 11 | import java.util.Map; |
| @@ -421,17 +420,17 @@ public class ClassMatchingGui { | |||
| 421 | boolean isMatched = uniqueMatches.containsKey(obfSource) && uniqueMatches.containsValue(obfDest); | 420 | boolean isMatched = uniqueMatches.containsKey(obfSource) && uniqueMatches.containsValue(obfDest); |
| 422 | boolean canMatch = !uniqueMatches.containsKey(obfSource) && ! uniqueMatches.containsValue(obfDest); | 421 | boolean canMatch = !uniqueMatches.containsKey(obfSource) && ! uniqueMatches.containsValue(obfDest); |
| 423 | 422 | ||
| 424 | deactivateButton(m_matchButton); | 423 | GuiTricks.deactivateButton(m_matchButton); |
| 425 | if (twoSelected) { | 424 | if (twoSelected) { |
| 426 | if (isMatched) { | 425 | if (isMatched) { |
| 427 | activateButton(m_matchButton, "Unmatch", new ActionListener() { | 426 | GuiTricks.activateButton(m_matchButton, "Unmatch", new ActionListener() { |
| 428 | @Override | 427 | @Override |
| 429 | public void actionPerformed(ActionEvent event) { | 428 | public void actionPerformed(ActionEvent event) { |
| 430 | onUnmatchClick(); | 429 | onUnmatchClick(); |
| 431 | } | 430 | } |
| 432 | }); | 431 | }); |
| 433 | } else if (canMatch) { | 432 | } else if (canMatch) { |
| 434 | activateButton(m_matchButton, "Match", new ActionListener() { | 433 | GuiTricks.activateButton(m_matchButton, "Match", new ActionListener() { |
| 435 | @Override | 434 | @Override |
| 436 | public void actionPerformed(ActionEvent event) { | 435 | public void actionPerformed(ActionEvent event) { |
| 437 | onMatchClick(); | 436 | onMatchClick(); |
| @@ -440,23 +439,6 @@ public class ClassMatchingGui { | |||
| 440 | } | 439 | } |
| 441 | } | 440 | } |
| 442 | } | 441 | } |
| 443 | |||
| 444 | private void deactivateButton(JButton button) { | ||
| 445 | button.setEnabled(false); | ||
| 446 | button.setText(""); | ||
| 447 | for (ActionListener listener : Arrays.asList(button.getActionListeners())) { | ||
| 448 | button.removeActionListener(listener); | ||
| 449 | } | ||
| 450 | } | ||
| 451 | |||
| 452 | private void activateButton(JButton button, String text, ActionListener newListener) { | ||
| 453 | button.setText(text); | ||
| 454 | button.setEnabled(true); | ||
| 455 | for (ActionListener listener : Arrays.asList(button.getActionListeners())) { | ||
| 456 | button.removeActionListener(listener); | ||
| 457 | } | ||
| 458 | button.addActionListener(newListener); | ||
| 459 | } | ||
| 460 | 442 | ||
| 461 | private void onMatchClick() { | 443 | private void onMatchClick() { |
| 462 | // precondition: source and dest classes are set correctly | 444 | // precondition: source and dest classes are set correctly |