1 19 20 package org.netbeans.modules.refactoring.plugins; 21 22 import java.util.Map ; 23 import java.util.WeakHashMap ; 24 import org.netbeans.modules.refactoring.api.RefactoringElement; 25 import org.netbeans.modules.refactoring.spi.ui.TreeElement; 26 import org.netbeans.modules.refactoring.spi.ui.TreeElementFactoryImplementation; 27 import org.openide.filesystems.FileObject; 28 29 30 34 public class TreeElementFactoryImpl implements TreeElementFactoryImplementation { 35 36 private Map <Object , TreeElement> map = new WeakHashMap (); 37 38 public TreeElement getTreeElement(Object o) { 39 TreeElement result = map.get(o); 40 if (result!= null) 41 return result; 42 if (o instanceof RefactoringElement) { 43 if (((RefactoringElement) o).getComposite() instanceof FileObject) { 44 result = new RefactoringTreeElement((RefactoringElement) o); 45 } 46 } 47 if (result != null) { 48 map.put(o, result); 49 } 50 return result; 51 } 52 53 public void cleanUp() { 54 map.clear(); 55 } 56 } 57 | Popular Tags |