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.awt.Image;
25 import java.io.IOException;
26 import javax.swing.ImageIcon;
27 import org.netbeans.api.project.Project;
28 import org.netbeans.api.project.ProjectManager;
29 import org.netbeans.spi.project.ProjectFactory;
30 import org.netbeans.spi.project.ProjectFactory2;
31 import org.netbeans.spi.project.ProjectState;
32 import org.openide.filesystems.FileObject;
33 import org.openide.util.ImageUtilities;
34 import org.openide.util.lookup.ServiceProvider;
35
36
37
38
39
40
41
42 @ServiceProvider(service = ProjectFactory.class)
43 public class WorkProjectFactory implements ProjectFactory2 {
44
45
46 @Override
47 public final ProjectManager.Result isProject2(
48 final FileObject projectDirectory) {
49
50 if (isProject(projectDirectory)) {
51 Image image = ImageUtilities.loadImage(WorkProject.PROJECT_ICON);
52 return new ProjectManager.Result(new ImageIcon(image));
53 }
54 return null;
55 }
56
57
58 @Override
59 public final boolean isProject(final FileObject projectDirectory) {
60 return projectDirectory.getFileObject(WorkProject.PROJECT_FILE) != null;
61 }
62
63
64 @Override
65 public final Project loadProject(final FileObject projectDirectory,
66 final ProjectState state) throws IOException {
67
68 if (isProject(projectDirectory)) {
69 return new WorkProject(projectDirectory, state);
70 }
71 return null;
72 }
73
74
75 @Override
76 public void saveProject(final Project project) throws IOException {
77
78 }
79 }