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();
 | 
							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
 | 
						 * 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() {
 | 
						public final List<RocketComponent> getChildAssemblies() {
 | 
				
			||||||
		checkState();
 | 
							checkState();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		List<RocketComponent> children = getChildrenRecursive();
 | 
							Iterator<RocketComponent> children = iterator(false);
 | 
				
			||||||
		if (children == null) {
 | 
					 | 
				
			||||||
			return null;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		List<RocketComponent> result = new ArrayList<>();
 | 
							List<RocketComponent> result = new ArrayList<>();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (RocketComponent child : children) {
 | 
							while (children.hasNext()) {
 | 
				
			||||||
 | 
								RocketComponent child = children.next();
 | 
				
			||||||
			if (child instanceof ComponentAssembly) {
 | 
								if (child instanceof ComponentAssembly) {
 | 
				
			||||||
				result.add(child);
 | 
									result.add(child);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
				
			|||||||
@ -38,9 +38,7 @@ public class StageSelector extends JPanel implements StateChangeListener {
 | 
				
			|||||||
		buttons.clear();
 | 
							buttons.clear();
 | 
				
			||||||
		this.removeAll();
 | 
							this.removeAll();
 | 
				
			||||||
		List<RocketComponent> assemblies = configuration.getRocket().getChildAssemblies();
 | 
							List<RocketComponent> assemblies = configuration.getRocket().getChildAssemblies();
 | 
				
			||||||
		if (assemblies == null) {
 | 
					
 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		for (RocketComponent stage : assemblies) {
 | 
							for (RocketComponent stage : assemblies) {
 | 
				
			||||||
			if (!(stage instanceof AxialStage)) continue;
 | 
								if (!(stage instanceof AxialStage)) continue;
 | 
				
			||||||
			JToggleButton button = new SelectColorToggleButton(new StageAction((AxialStage) stage));
 | 
								JToggleButton button = new SelectColorToggleButton(new StageAction((AxialStage) stage));
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user