// Path: src/org/gololang/netbeans/project/GoloProject.java
// public final class Info implements ProjectInformation {
//     
//     @StaticResource()
//     public static final String GOLO_ICON = "org/gololang/netbeans/golo_icon_16px.png";
// 
//     @Override
//     public Icon getIcon() {
//         return new ImageIcon(ImageUtilities.loadImage(GOLO_ICON));
//     }
// 
//     @Override
//     public String getName() {
//         return getProjectDirectory().getName();
//     }
// 
//     @Override
//     public String getDisplayName() {
//         return getName();
//     }
// 
//     @Override
//     public void addPropertyChangeListener(PropertyChangeListener pcl) {
//         //do nothing, won't change
//     }
// 
//     @Override
//     public void removePropertyChangeListener(PropertyChangeListener pcl) {
//         //do nothing, won't change
//     }
// 
//     @Override
//     public Project getProject() {
//         return GoloProject.this;
//     }
// }


import java.io.IOException;
import javax.swing.ImageIcon;
import org.gololang.netbeans.project.GoloProject.Info;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.spi.project.ProjectFactory;
import org.netbeans.spi.project.ProjectFactory2;
import org.netbeans.spi.project.ProjectState;
import org.openide.filesystems.FileObject;
import org.openide.util.ImageUtilities;
import org.openide.util.lookup.ServiceProvider;
/*
 *  Copyright 2013 SERLI (www.serli.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */

package org.gololang.netbeans.project;


/**
 *
 * @author Julien Déray
 */

@ServiceProvider(service=ProjectFactory.class)
public class GoloProjectFactory implements ProjectFactory2 {

    public static final String PROJECT_FILE = "golo.project";

    // Specifies when a project is a project, i.e.,
    // if "golo.project" is present in a folder:
    @Override
    public boolean isProject(FileObject projectDirectory) {
        return projectDirectory.getFileObject(PROJECT_FILE) != null;
    }

    // Specifies when the project will be opened, i.e., if the project exists:
    @Override
    public Project loadProject(FileObject dir, ProjectState state) throws IOException {
        return isProject(dir) ? new GoloProject(dir, state) : null;
    }

    @Override
    public void saveProject(final Project project) throws IOException, ClassCastException {
        // leave unimplemented for the moment
    }

    @Override
    public ProjectManager.Result isProject2(FileObject fo) {
        return isProject(fo) ? 
// Path: src/org/gololang/netbeans/project/GoloProject.java
// public final class Info implements ProjectInformation {
//     
//     @StaticResource()
//     public static final String GOLO_ICON = "org/gololang/netbeans/golo_icon_16px.png";
// 
//     @Override
//     public Icon getIcon() {
//         return new ImageIcon(ImageUtilities.loadImage(GOLO_ICON));
//     }
// 
//     @Override
//     public String getName() {
//         return getProjectDirectory().getName();
//     }
// 
//     @Override
//     public String getDisplayName() {
//         return getName();
//     }
// 
//     @Override
//     public void addPropertyChangeListener(PropertyChangeListener pcl) {
//         //do nothing, won't change
//     }
// 
//     @Override
//     public void removePropertyChangeListener(PropertyChangeListener pcl) {
//         //do nothing, won't change
//     }
// 
//     @Override
//     public Project getProject() {
//         return GoloProject.this;
//     }
// }


// Path: src/org/gololang/netbeans/project/GoloProjectFactory.java
import java.io.IOException;
import javax.swing.ImageIcon;
import org.gololang.netbeans.project.GoloProject.Info;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.spi.project.ProjectFactory;
import org.netbeans.spi.project.ProjectFactory2;
import org.netbeans.spi.project.ProjectState;
import org.openide.filesystems.FileObject;
import org.openide.util.ImageUtilities;
import org.openide.util.lookup.ServiceProvider;

/*
 *  Copyright 2013 SERLI (www.serli.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */

package org.gololang.netbeans.project;


/**
 *
 * @author Julien Déray
 */

@ServiceProvider(service=ProjectFactory.class)
public class GoloProjectFactory implements ProjectFactory2 {

    public static final String PROJECT_FILE = "golo.project";

    // Specifies when a project is a project, i.e.,
    // if "golo.project" is present in a folder:
    @Override
    public boolean isProject(FileObject projectDirectory) {
        return projectDirectory.getFileObject(PROJECT_FILE) != null;
    }

    // Specifies when the project will be opened, i.e., if the project exists:
    @Override
    public Project loadProject(FileObject dir, ProjectState state) throws IOException {
        return isProject(dir) ? new GoloProject(dir, state) : null;
    }

    @Override
    public void saveProject(final Project project) throws IOException, ClassCastException {
        // leave unimplemented for the moment
    }

    @Override
    public ProjectManager.Result isProject2(FileObject fo) {
        return isProject(fo) ? 
            new ProjectManager.Result(new ImageIcon(ImageUtilities.loadImage(Info.GOLO_ICON))) :