1 11 package org.eclipse.ltk.internal.ui.refactoring; 12 13 import java.util.ArrayList ; 14 import java.util.List ; 15 16 import org.eclipse.ltk.core.refactoring.Change; 17 import org.eclipse.ltk.core.refactoring.CompositeChange; 18 19 import org.eclipse.jface.resource.ImageDescriptor; 20 21 public class CompositeChangeNode extends AbstractChangeNode { 22 23 private final RefactoringPreviewChangeFilter fFilter; 24 25 public CompositeChangeNode(PreviewNode parent, RefactoringPreviewChangeFilter filter, CompositeChange change) { 26 super(parent, change); 27 fFilter= filter; 28 } 29 30 int getActive() { 31 return getCompositeChangeActive(); 32 } 33 34 public ImageDescriptor getImageDescriptor() { 35 return RefactoringPluginImages.DESC_OBJS_COMPOSITE_CHANGE; 36 } 37 38 PreviewNode[] doCreateChildren() { 39 List children= new ArrayList (); 40 getFlattendedChildren(children, this, (CompositeChange)getChange()); 41 return (PreviewNode[])children.toArray(new PreviewNode[children.size()]); 42 } 43 44 private void getFlattendedChildren(List result, CompositeChangeNode parent, CompositeChange focus) { 45 Change[] changes= focus.getChildren(); 46 for (int i= 0; i < changes.length; i++) { 47 Change change= changes[i]; 48 if (fFilter == null || fFilter.select(change)) { 49 if (change instanceof CompositeChange && ((CompositeChange) change).isSynthetic()) { 50 getFlattendedChildren(result, parent, (CompositeChange) change); 51 } else { 52 result.add(createNode(parent, change)); 53 } 54 } 55 } 56 } 57 } | Popular Tags |