1 19 20 package org.netbeans.modules.ruby.spi.project.support.rake; 21 22 import java.io.IOException ; 23 import java.util.Collections ; 24 import java.util.HashSet ; 25 import java.util.Iterator ; 26 import java.util.Set ; 27 import javax.swing.event.ChangeListener ; 28 import org.netbeans.api.project.Project; 29 import org.netbeans.api.project.ProjectManager; 30 import org.netbeans.spi.project.SubprojectProvider; 31 import org.openide.ErrorManager; 32 import org.openide.filesystems.FileObject; 33 import org.openide.util.Mutex; 34 35 40 final class SubprojectProviderImpl implements SubprojectProvider { 41 42 private final ReferenceHelper helper; 43 44 SubprojectProviderImpl(ReferenceHelper helper) { 45 this.helper = helper; 46 } 47 48 public Set <? extends Project> getSubprojects() { 49 return ProjectManager.mutex().readAccess(new Mutex.Action<Set <? extends Project>>() { 50 public Set <? extends Project> run() { 51 Set <String > foreignProjectNames = new HashSet <String >(); 53 for (ReferenceHelper.RawReference ref : helper.getRawReferences()) { 54 foreignProjectNames.add(ref.getForeignProjectName()); 55 } 56 Set <Project> foreignProjects = new HashSet <Project>(); 57 for (String foreignProjectName : foreignProjectNames) { 58 String prop = "project." + foreignProjectName; RakeProjectHelper h = helper.getRakeProjectHelper(); 60 String foreignProjectDirS = helper.eval.getProperty(prop); 61 if (foreignProjectDirS == null) { 62 continue; 64 } 65 FileObject foreignProjectDir = h.resolveFileObject(foreignProjectDirS); 66 if (foreignProjectDir == null) { 67 continue; 69 } 70 try { 71 Project p = ProjectManager.getDefault().findProject(foreignProjectDir); 72 if (p != null) { 73 foreignProjects.add(p); 75 } 76 } catch (IOException e) { 77 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e); 78 } 80 } 81 return foreignProjects; 82 } 83 }); 84 } 85 86 public void addChangeListener(ChangeListener listener) { 87 } 89 90 public void removeChangeListener(ChangeListener listener) { 91 } 93 94 } 95 | Popular Tags |