1 19 package org.netbeans.modules.xml.refactoring.spi; 20 21 import java.io.IOException ; 22 import java.util.Collections ; 23 import java.util.List ; 24 import org.netbeans.modules.xml.refactoring.DeleteRequest; 25 import org.netbeans.modules.xml.refactoring.ErrorItem; 26 import org.netbeans.modules.xml.refactoring.RefactorRequest; 27 import org.netbeans.modules.xml.refactoring.UsageGroup; 28 import org.netbeans.modules.xml.xam.Component; 29 import org.netbeans.modules.xml.xam.Model; 30 import org.netbeans.modules.xml.xam.Referenceable; 31 import org.openide.filesystems.FileObject; 32 33 40 41 public abstract class RefactoringEngine { 42 48 public abstract Component getSearchRoot(FileObject file) throws IOException ; 49 50 59 public abstract List <UsageGroup> findUsages(Component target, Component searchRoot); 60 61 70 public abstract List <UsageGroup> findUsages(Model target, Component searchRoot); 71 72 80 public List <UsageGroup> findUsages(Component target, FileObject file) { 81 if (! (target instanceof Referenceable)) { 82 return null; 83 } 84 ErrorItem error = null; 85 Component searchRoot = null; 86 try { 87 searchRoot = getSearchRoot(file); 88 } catch (Exception e) { 89 error = new ErrorItem(file, e.getMessage()); 90 } 91 92 if (error == null) { 93 if (searchRoot != null) { 94 return findUsages(target, searchRoot); 95 } else { 96 return Collections.emptyList(); 97 } 98 } else { 99 UsageGroup usages = new UsageGroup(this, file, (Referenceable) target); 100 usages.addError(error); 101 return Collections.singletonList(usages); 102 } 103 } 104 105 110 public UIHelper getUIHelper() { 111 return new UIHelper(); 112 } 113 114 118 public void precheck(RefactorRequest request) { 119 if (request instanceof DeleteRequest) { 120 SharedUtils.addCascadeDeleteErrors((DeleteRequest)request, this); 121 } 122 } 123 124 128 public void refactorUsages(RefactorRequest request) throws IOException { 129 } 130 131 137 public String getModelReference(Component component) { 138 return null; 139 } 140 } 141 | Popular Tags |