| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package net.sf.webphotos.netbeans.project; |
| 17 | |
|
| 18 | |
import java.io.IOException; |
| 19 | |
import org.netbeans.api.project.Project; |
| 20 | |
import org.netbeans.spi.project.ProjectFactory; |
| 21 | |
import org.netbeans.spi.project.ProjectState; |
| 22 | |
import org.openide.filesystems.FileObject; |
| 23 | |
import org.openide.util.lookup.ServiceProvider; |
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
@ServiceProvider(service = ProjectFactory.class) |
| 30 | 6 | public class WebPhotosProjectFactory implements ProjectFactory { |
| 31 | |
|
| 32 | |
public static final String[] PROJECT_ARCHIVES; |
| 33 | |
|
| 34 | |
static { |
| 35 | 3 | PROJECT_ARCHIVES = new String[]{ |
| 36 | |
Constants.ProjectFactory.CONFIG_WEBPHOTOS_PROPERTIES, Constants.ProjectFactory.ALBUNS_WEBPHOTOS_XML |
| 37 | |
}; |
| 38 | 3 | } |
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public boolean isProject(FileObject projectDirectory) { |
| 49 | 6 | if(projectDirectory == null) { |
| 50 | 0 | return false; |
| 51 | |
} |
| 52 | 6 | boolean isProject = true; |
| 53 | 18 | for (String file : PROJECT_ARCHIVES) { |
| 54 | 12 | isProject = (isProject && projectDirectory.getFileObject(file) != null); |
| 55 | |
} |
| 56 | 6 | return isProject; |
| 57 | |
} |
| 58 | |
|
| 59 | |
@Override |
| 60 | |
public Project loadProject(FileObject dir, ProjectState state) throws IOException { |
| 61 | 3 | return isProject(dir) ? new WebPhotosProject(dir, state) : null; |
| 62 | |
} |
| 63 | |
|
| 64 | |
@Override |
| 65 | |
public void saveProject(Project project) throws IOException, ClassCastException { |
| 66 | 0 | if (project != null && !isProject(project.getProjectDirectory())) { |
| 67 | 0 | throw new IOException("Project dir " + project.getProjectDirectory().getPath() |
| 68 | |
+ " deleted," |
| 69 | |
+ " cannot save project"); |
| 70 | |
} |
| 71 | 0 | throw new UnsupportedOperationException("Not supported yet."); |
| 72 | |
} |
| 73 | |
} |