summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/gui/ClassInheritanceTreeNode.java
blob: 921a1e988e62c54cdc0764653a574fe2a44b4f61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package cuchaz.enigma.gui;

import java.util.List;

import javax.swing.tree.DefaultMutableTreeNode;

import com.beust.jcommander.internal.Lists;

import cuchaz.enigma.mapping.Ancestries;

public class ClassInheritanceTreeNode extends DefaultMutableTreeNode
{
	private static final long serialVersionUID = 4432367405826178490L;
	
	String m_className;
	
	public ClassInheritanceTreeNode( String className )
	{
		m_className = className;
	}
	
	public String getClassName( )
	{
		return m_className;
	}
	
	@Override
	public String toString( )
	{
		return m_className;
	}
	
	public void load( Ancestries ancestries, boolean recurse )
	{
		// get all the child nodes
		List<ClassInheritanceTreeNode> nodes = Lists.newArrayList();
		for( String subclassName : ancestries.getSubclasses( m_className ) )
		{
			nodes.add( new ClassInheritanceTreeNode( subclassName ) );
		}
		
		// add then to this node
		for( ClassInheritanceTreeNode node : nodes )
		{
			this.add( node );
		}
		
		if( recurse )
		{
			for( ClassInheritanceTreeNode node : nodes )
			{
				node.load( ancestries, true );
			}
		}
	}
}