Use component iterator instead of self-written childrenRecursive
This commit is contained in:
		
							parent
							
								
									06f220d6a9
								
							
						
					
					
						commit
						91b43317f3
					
				@ -1599,28 +1599,6 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
 | 
			
		||||
		return children.clone();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns all children of this component, as well as the children of the children etc.
 | 
			
		||||
	 * @return all the children (direct and indirect) of this component
 | 
			
		||||
	 */
 | 
			
		||||
	public final List<RocketComponent> getChildrenRecursive() {
 | 
			
		||||
		checkState();
 | 
			
		||||
		List<RocketComponent> children = getChildren();
 | 
			
		||||
 | 
			
		||||
		if (children == null) {
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (RocketComponent child : new ArrayList<>(children)) {
 | 
			
		||||
			List<RocketComponent> temp = child.getChildrenRecursive();
 | 
			
		||||
			if (temp != null && temp.size() > 0) {
 | 
			
		||||
				children.addAll(temp);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return children;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Returns the position of the child in this components child list, or -1 if the
 | 
			
		||||
@ -1720,14 +1698,12 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
 | 
			
		||||
	public final List<RocketComponent> getChildAssemblies() {
 | 
			
		||||
		checkState();
 | 
			
		||||
 | 
			
		||||
		List<RocketComponent> children = getChildrenRecursive();
 | 
			
		||||
		if (children == null) {
 | 
			
		||||
			return null;
 | 
			
		||||
		}
 | 
			
		||||
		Iterator<RocketComponent> children = iterator(false);
 | 
			
		||||
 | 
			
		||||
		List<RocketComponent> result = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
		for (RocketComponent child : children) {
 | 
			
		||||
		while (children.hasNext()) {
 | 
			
		||||
			RocketComponent child = children.next();
 | 
			
		||||
			if (child instanceof ComponentAssembly) {
 | 
			
		||||
				result.add(child);
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@ -38,9 +38,7 @@ public class StageSelector extends JPanel implements StateChangeListener {
 | 
			
		||||
		buttons.clear();
 | 
			
		||||
		this.removeAll();
 | 
			
		||||
		List<RocketComponent> assemblies = configuration.getRocket().getChildAssemblies();
 | 
			
		||||
		if (assemblies == null) {
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		for (RocketComponent stage : assemblies) {
 | 
			
		||||
			if (!(stage instanceof AxialStage)) continue;
 | 
			
		||||
			JToggleButton button = new SelectColorToggleButton(new StageAction((AxialStage) stage));
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user