/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.jme3.gde.android;

import com.jme3.gde.core.importantfiles.ImportantFiles;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import org.netbeans.api.project.Project;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;

/**
 *
 * @author normenhansen
 */
@org.openide.util.lookup.ServiceProvider(service = ImportantFiles.class)
public class AndroidImportantFiles implements ImportantFiles {

    @Override
    public Node[] getNodes(Project project) {
        FileObject manifest = project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml");
        String mainActivity = "mobile/src";
        if (manifest != null) {
            InputStream in = null;
            try {
                in = manifest.getInputStream();
                Document configuration = XMLUtil.parse(new InputSource(in), false, false, null, null);
                mainActivity = "mobile/src/" + configuration.getDocumentElement().getAttribute("package").replaceAll("\\.", "/") + "/MainActivity.java";
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            } finally {
                try {
                    if (in != null) {
                        in.close();
                    }
                } catch (IOException ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        }
        ArrayList<Node> list = new ArrayList<Node>();
        try {
            FileObject mainAct = project.getProjectDirectory().getFileObject(mainActivity);
            if (mainAct != null) {
                Node node = DataObject.find(mainAct).getNodeDelegate();
                node.setDisplayName("Android Main Activity");
                list.add(node);
            }
            FileObject manif = project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml");
            if (manif != null) {
                Node node = DataObject.find(manif).getNodeDelegate();
                node.setDisplayName("Android Manifest");
                list.add(node);
            }
            FileObject buildProp = project.getProjectDirectory().getFileObject("mobile/ant.properties");
            if (buildProp != null) {
                Node node = DataObject.find(buildProp).getNodeDelegate();
                node.setDisplayName("Android Properties");
                list.add(node);
            }
        } catch (DataObjectNotFoundException ex) {
            Exceptions.printStackTrace(ex);
        }
        return list.toArray(new Node[list.size()]);
    }

    @Override
    public boolean hasFiles(Project proj) {
        if (proj.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml") != null) {
            return true;
        }
        return false;
    }
}

@@ -2738,32 +2738,665 @@
 ;%0A            %7D%0A
+            FileObject layout = project.getProjectDirectory().getFileObject(%22mobile/res/layout/main.xml%22);%0A            if (layout != null) %7B%0A                Node node = DataObject.find(layout).getNodeDelegate();%0A                node.setDisplayName(%22Android Layout%22);%0A                list.add(node);%0A            %7D%0A            FileObject strings = project.getProjectDirectory().getFileObject(%22mobile/res/values/strings.xml%22);%0A            if (strings != null) %7B%0A                Node node = DataObject.find(strings).getNodeDelegate();%0A                node.setDisplayName(%22Android Strings%22);%0A                list.add(node);%0A            %7D%0A
         %7D catch 

Add layout.xml and strings.xml to Important Files node in Android projects. Useful to quickly modify the layout for the upcoming switch to Android Fragments.