1 package info.mikethomas.fahview.v6project;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import java.io.IOException;
25 import java.util.Collections;
26 import java.util.HashSet;
27 import java.util.Set;
28 import javax.swing.event.ChangeListener;
29 import org.netbeans.api.project.Project;
30 import org.netbeans.api.project.ProjectManager;
31 import org.netbeans.spi.project.SubprojectProvider;
32 import org.openide.filesystems.FileObject;
33 import org.openide.util.Exceptions;
34
35
36
37
38
39
40
41 public class ClientSubprojectProvider implements SubprojectProvider {
42
43
44 private final Project project;
45
46
47
48
49
50
51 public ClientSubprojectProvider(final Project parentProject) {
52 this.project = parentProject;
53 }
54
55
56 @Override
57 public final Set<?extends Project> getSubprojects() {
58 Set<Project> newProjects = new HashSet<Project>();
59 FileObject dir = project.getProjectDirectory();
60 if (dir != null) {
61 for (FileObject childFolder : dir.getChildren()) {
62 try {
63 Project subp = ProjectManager.getDefault().
64 findProject(childFolder);
65 if (subp != null) {
66 newProjects.add(subp);
67 }
68 } catch (IOException ex) {
69 Exceptions.printStackTrace(ex);
70 } catch (IllegalArgumentException ex) {
71
72 }
73 }
74 }
75 return Collections.unmodifiableSet(newProjects);
76 }
77
78
79 @Override
80 public void addChangeListener(final ChangeListener listener) { }
81
82
83 @Override
84 public void removeChangeListener(final ChangeListener listener) { }
85 }