diff options
| author | 2020-06-03 13:39:42 -0400 | |
|---|---|---|
| committer | 2020-06-03 18:39:42 +0100 | |
| commit | 0f47403d0220757fed189b76e2071e25b1025cb8 (patch) | |
| tree | 879bf72c4476f0a5e0d82da99d7ff2b2276bcaca /src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java | |
| parent | Fix search dialog hanging for a short time sometimes (#250) (diff) | |
| download | enigma-fork-0f47403d0220757fed189b76e2071e25b1025cb8.tar.gz enigma-fork-0f47403d0220757fed189b76e2071e25b1025cb8.tar.xz enigma-fork-0f47403d0220757fed189b76e2071e25b1025cb8.zip | |
Split GUI code to separate module (#242)
* Split into modules
* Post merge compile fixes
Co-authored-by: modmuss50 <modmuss50@gmail.com>
Diffstat (limited to 'src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java | 72 |
1 files changed, 0 insertions, 72 deletions
diff --git a/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java b/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java deleted file mode 100644 index 7904c5f..0000000 --- a/src/main/java/cuchaz/enigma/analysis/ClassInheritanceTreeNode.java +++ /dev/null | |||
| @@ -1,72 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma.analysis; | ||
| 13 | |||
| 14 | import com.google.common.collect.Lists; | ||
| 15 | import cuchaz.enigma.analysis.index.InheritanceIndex; | ||
| 16 | import cuchaz.enigma.translation.Translator; | ||
| 17 | import cuchaz.enigma.translation.representation.entry.ClassEntry; | ||
| 18 | |||
| 19 | import javax.swing.tree.DefaultMutableTreeNode; | ||
| 20 | import java.util.List; | ||
| 21 | |||
| 22 | public class ClassInheritanceTreeNode extends DefaultMutableTreeNode { | ||
| 23 | private final Translator translator; | ||
| 24 | private final ClassEntry obfClassEntry; | ||
| 25 | |||
| 26 | public ClassInheritanceTreeNode(Translator translator, String obfClassName) { | ||
| 27 | this.translator = translator; | ||
| 28 | this.obfClassEntry = new ClassEntry(obfClassName); | ||
| 29 | } | ||
| 30 | |||
| 31 | public static ClassInheritanceTreeNode findNode(ClassInheritanceTreeNode node, ClassEntry entry) { | ||
| 32 | // is this the node? | ||
| 33 | if (node.getObfClassName().equals(entry.getFullName())) { | ||
| 34 | return node; | ||
| 35 | } | ||
| 36 | |||
| 37 | // recurse | ||
| 38 | for (int i = 0; i < node.getChildCount(); i++) { | ||
| 39 | ClassInheritanceTreeNode foundNode = findNode((ClassInheritanceTreeNode) node.getChildAt(i), entry); | ||
| 40 | if (foundNode != null) { | ||
| 41 | return foundNode; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | return null; | ||
| 45 | } | ||
| 46 | |||
| 47 | public String getObfClassName() { | ||
| 48 | return this.obfClassEntry.getFullName(); | ||
| 49 | } | ||
| 50 | |||
| 51 | @Override | ||
| 52 | public String toString() { | ||
| 53 | return translator.translate(obfClassEntry).getFullName(); | ||
| 54 | } | ||
| 55 | |||
| 56 | public void load(InheritanceIndex ancestries, boolean recurse) { | ||
| 57 | // get all the child nodes | ||
| 58 | List<ClassInheritanceTreeNode> nodes = Lists.newArrayList(); | ||
| 59 | for (ClassEntry inheritor : ancestries.getChildren(this.obfClassEntry)) { | ||
| 60 | nodes.add(new ClassInheritanceTreeNode(translator, inheritor.getFullName())); | ||
| 61 | } | ||
| 62 | |||
| 63 | // add them to this node | ||
| 64 | nodes.forEach(this::add); | ||
| 65 | |||
| 66 | if (recurse) { | ||
| 67 | for (ClassInheritanceTreeNode node : nodes) { | ||
| 68 | node.load(ancestries, true); | ||
| 69 | } | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } | ||