diff options
| author | 2015-03-08 11:17:52 -0400 | |
|---|---|---|
| committer | 2015-03-08 11:17:52 -0400 | |
| commit | 42b2f3e6cf1e5c5c25055e1c05b083d099542b7a (patch) | |
| tree | 8247e46c370aec592d64f9cee0771c36ee6986da | |
| parent | ui improvements (diff) | |
| download | enigma-42b2f3e6cf1e5c5c25055e1c05b083d099542b7a.tar.gz enigma-42b2f3e6cf1e5c5c25055e1c05b083d099542b7a.tar.xz enigma-42b2f3e6cf1e5c5c25055e1c05b083d099542b7a.zip | |
Closing branch: default
| -rw-r--r-- | src/cuchaz/enigma/gui/MatchingGui.java | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/cuchaz/enigma/gui/MatchingGui.java b/src/cuchaz/enigma/gui/MatchingGui.java index 04dbd7a7..f1da25aa 100644 --- a/src/cuchaz/enigma/gui/MatchingGui.java +++ b/src/cuchaz/enigma/gui/MatchingGui.java | |||
| @@ -10,6 +10,7 @@ import java.util.ArrayList; | |||
| 10 | import java.util.Arrays; | 10 | import java.util.Arrays; |
| 11 | import java.util.Collection; | 11 | import java.util.Collection; |
| 12 | import java.util.Collections; | 12 | import java.util.Collections; |
| 13 | import java.util.Enumeration; | ||
| 13 | import java.util.List; | 14 | import java.util.List; |
| 14 | import java.util.Map; | 15 | import java.util.Map; |
| 15 | 16 | ||
| @@ -26,6 +27,7 @@ import javax.swing.JScrollPane; | |||
| 26 | import javax.swing.JSplitPane; | 27 | import javax.swing.JSplitPane; |
| 27 | import javax.swing.SwingConstants; | 28 | import javax.swing.SwingConstants; |
| 28 | import javax.swing.WindowConstants; | 29 | import javax.swing.WindowConstants; |
| 30 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 29 | import javax.swing.tree.TreePath; | 31 | import javax.swing.tree.TreePath; |
| 30 | 32 | ||
| 31 | import com.beust.jcommander.internal.Lists; | 33 | import com.beust.jcommander.internal.Lists; |
| @@ -276,7 +278,7 @@ public class MatchingGui { | |||
| 276 | } | 278 | } |
| 277 | 279 | ||
| 278 | protected void setSourceClass(ClassEntry classEntry) { | 280 | protected void setSourceClass(ClassEntry classEntry) { |
| 279 | 281 | ||
| 280 | // update the current source class | 282 | // update the current source class |
| 281 | m_sourceClass = classEntry; | 283 | m_sourceClass = classEntry; |
| 282 | m_sourceClassLabel.setText(m_sourceClass != null ? m_sourceClass.getName() : ""); | 284 | m_sourceClassLabel.setText(m_sourceClass != null ? m_sourceClass.getName() : ""); |
| @@ -457,17 +459,11 @@ public class MatchingGui { | |||
| 457 | // add them as matched classes | 459 | // add them as matched classes |
| 458 | m_matches.add(new ClassMatch(obfSource, obfDest)); | 460 | m_matches.add(new ClassMatch(obfSource, obfDest)); |
| 459 | 461 | ||
| 460 | // remember where we were in the source tree | ||
| 461 | TreePath path = m_sourceClasses.getSelectionPath(); | ||
| 462 | |||
| 463 | save(); | 462 | save(); |
| 464 | updateMatches(); | 463 | updateMatches(); |
| 465 | 464 | ||
| 466 | // put the tree back to where it was | ||
| 467 | m_sourceClasses.expandPath(path); | ||
| 468 | |||
| 469 | if (m_advanceCheck.isSelected()) { | 465 | if (m_advanceCheck.isSelected()) { |
| 470 | 466 | advance(); | |
| 471 | } | 467 | } |
| 472 | } | 468 | } |
| 473 | 469 | ||
| @@ -489,7 +485,33 @@ public class MatchingGui { | |||
| 489 | setDestClass(null); | 485 | setDestClass(null); |
| 490 | m_destClasses.setClasses(null); | 486 | m_destClasses.setClasses(null); |
| 491 | updateMatchButton(); | 487 | updateMatchButton(); |
| 488 | |||
| 489 | // remember where we were in the source tree | ||
| 490 | String packageName = null; | ||
| 491 | if (!m_sourceClasses.isSelectionEmpty()) { | ||
| 492 | packageName = m_sourceClasses.getSelectionPath().getParentPath().getLastPathComponent().toString(); | ||
| 493 | } | ||
| 494 | |||
| 492 | setSourceType(m_sourceType); | 495 | setSourceType(m_sourceType); |
| 496 | |||
| 497 | if (packageName != null) { | ||
| 498 | // find the corresponding path in the new tree | ||
| 499 | TreePath path = null; | ||
| 500 | DefaultMutableTreeNode root = (DefaultMutableTreeNode)m_sourceClasses.getModel().getRoot(); | ||
| 501 | Enumeration<?> children = root.children(); | ||
| 502 | while (children.hasMoreElements()) { | ||
| 503 | Object child = children.nextElement(); | ||
| 504 | if (child.toString().equals(packageName)) { | ||
| 505 | path = new TreePath(new Object[] {root, child}); | ||
| 506 | break; | ||
| 507 | } | ||
| 508 | } | ||
| 509 | |||
| 510 | if (path != null) { | ||
| 511 | // put the tree back to where it was | ||
| 512 | m_sourceClasses.expandPath(path); | ||
| 513 | } | ||
| 514 | } | ||
| 493 | } | 515 | } |
| 494 | 516 | ||
| 495 | private void save() { | 517 | private void save() { |
| @@ -518,4 +540,8 @@ public class MatchingGui { | |||
| 518 | save(); | 540 | save(); |
| 519 | updateMatches(); | 541 | updateMatches(); |
| 520 | } | 542 | } |
| 543 | |||
| 544 | private void advance() { | ||
| 545 | // TODO: find a likely match | ||
| 546 | } | ||
| 521 | } | 547 | } |