diff --git a/sdk/jme3-android/release/libs/jMonkeyEngine3-android.jar b/sdk/jme3-android/release/libs/jMonkeyEngine3-android.jar index f0abfcc86..a71900ecb 100644 Binary files a/sdk/jme3-android/release/libs/jMonkeyEngine3-android.jar and b/sdk/jme3-android/release/libs/jMonkeyEngine3-android.jar differ diff --git a/sdk/jme3-android/src/com/jme3/gde/android/ImportantFilesNode.java b/sdk/jme3-android/src/com/jme3/gde/android/ImportantFilesNode.java index 8fb6de704..b82873d92 100644 --- a/sdk/jme3-android/src/com/jme3/gde/android/ImportantFilesNode.java +++ b/sdk/jme3-android/src/com/jme3/gde/android/ImportantFilesNode.java @@ -4,6 +4,10 @@ */ package com.jme3.gde.android; +import java.awt.Image; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; import org.netbeans.api.project.Project; import org.netbeans.spi.project.LookupProvider; import org.netbeans.spi.project.ui.support.NodeFactory; @@ -12,26 +16,43 @@ import org.netbeans.spi.project.ui.support.NodeList; import org.openide.filesystems.FileObject; import org.openide.loaders.DataObject; import org.openide.loaders.DataObjectNotFoundException; -import org.openide.nodes.FilterNode; +import org.openide.nodes.AbstractNode; +import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.util.Exceptions; +import org.openide.util.ImageUtilities; import org.openide.util.Lookup; import org.openide.util.lookup.Lookups; +import org.openide.xml.XMLUtil; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; /** * * @author normenhansen */ -public class ImportantFilesNode extends FilterNode { +public class ImportantFilesNode extends AbstractNode { + + private static Image smallImage = + ImageUtilities.loadImage("com/jme3/gde/android/properties/Phone_16.gif"); public ImportantFilesNode(Project proj) throws DataObjectNotFoundException { -// super(DataObject.find(proj.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml")).getNodeDelegate()); - super(Node.EMPTY); + super(new ImportantFilesChildren(proj)); } @Override public String getDisplayName() { - return "Android Manifest"; + return "Android Files"; + } + + @Override + public Image getIcon(int type) { + return smallImage; + } + + @Override + public Image getOpenedIcon(int type) { + return smallImage; } public static class LookupProviderImpl implements LookupProvider { @@ -81,4 +102,59 @@ public class ImportantFilesNode extends FilterNode { public ImportantFilesLookupItem(Project prj) { } } + + public static class ImportantFilesChildren extends Children.Keys { + + private Project project; + + public ImportantFilesChildren(Project project) { + this.project = project; + } + + protected List createKeys() { +// package="com.mycompany.mygame" + 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"; + in.close(); + } catch (Exception ex) { + Exceptions.printStackTrace(ex); + } finally { + } + } + ArrayList list = new ArrayList(); + addFileObject(project.getProjectDirectory().getFileObject(mainActivity), list); + addFileObject(project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml"), list); + addFileObject(project.getProjectDirectory().getFileObject("mobile/build.properties"), list); + return list; + } + + private void addFileObject(FileObject file, List list) { + if (file != null) { + list.add(file); + } + } + + @Override + protected void addNotify() { + super.addNotify(); + setKeys(createKeys()); + } + + @Override + protected Node[] createNodes(FileObject key) { + try { + DataObject obj = DataObject.find(key); + return new Node[]{obj.getNodeDelegate()}; + } catch (DataObjectNotFoundException ex) { + Exceptions.printStackTrace(ex); + } + return new Node[]{}; + } + } } \ No newline at end of file diff --git a/sdk/jme3-android/src/com/jme3/gde/android/XmlHelper.java b/sdk/jme3-android/src/com/jme3/gde/android/XmlHelper.java new file mode 100644 index 000000000..d846b3f5f --- /dev/null +++ b/sdk/jme3-android/src/com/jme3/gde/android/XmlHelper.java @@ -0,0 +1,73 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.jme3.gde.android; + +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * + * @author normenhansen + */ +public class XmlHelper { + public static Element findFirstChildElement(Element parent) { + org.w3c.dom.Node ret = parent.getFirstChild(); + while (ret != null && (!(ret instanceof Element))) { + ret = ret.getNextSibling(); + } + return (Element) ret; + } + + public static Element findChildElement(Element parent, String name) { + if (parent == null) { + return null; + } + org.w3c.dom.Node ret = parent.getFirstChild(); + while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) { + ret = ret.getNextSibling(); + } + return (Element) ret; + } + + public static Element findNextElement(Node ret, String name) { + ret = ret.getNextSibling(); + while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name))) { + ret = ret.getNextSibling(); + } + return (Element) ret; + } + + public static Element findChildElementWithAttribute(Element parent, String name, String attribute, String value) { + if (parent == null) { + return null; + } + org.w3c.dom.Node ret = parent.getFirstChild(); + while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name) || ((Element)ret).getAttribute(attribute)==null || !((Element)ret).getAttribute(attribute).equals(value))) { + ret = ret.getNextSibling(); + } + return (Element) ret; + } + + public static Element findNextElementWithAttribute(Node ret, String name, String attribute, String value) { + ret = ret.getNextSibling(); + while (ret != null && (!(ret instanceof Element) || !ret.getNodeName().equals(name) || ((Element)ret).getAttribute(attribute)==null || !((Element)ret).getAttribute(attribute).equals(value))) { + ret = ret.getNextSibling(); + } + return (Element) ret; + } + + public static Element findNextSiblingElement(Element current) { + org.w3c.dom.Node ret = current.getNextSibling(); + while (ret != null) { + if (ret instanceof Element) { + return (Element) ret; + } + ret = ret.getNextSibling(); + } + return null; + } + +} diff --git a/sdk/jme3-android/src/com/jme3/gde/android/layer.xml b/sdk/jme3-android/src/com/jme3/gde/android/layer.xml index 61e92eda9..9e48ca31c 100644 --- a/sdk/jme3-android/src/com/jme3/gde/android/layer.xml +++ b/sdk/jme3-android/src/com/jme3/gde/android/layer.xml @@ -1,7 +1,7 @@ - +