- Add "Android Files" node to project with MainActivity.java, AndroidManifest.xml and build.properties

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8203 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 14 years ago
parent 8f2c0adefc
commit 72a8006a11
  1. BIN
      sdk/jme3-android/release/libs/jMonkeyEngine3-android.jar
  2. 86
      sdk/jme3-android/src/com/jme3/gde/android/ImportantFilesNode.java
  3. 73
      sdk/jme3-android/src/com/jme3/gde/android/XmlHelper.java
  4. 6
      sdk/jme3-android/src/com/jme3/gde/android/layer.xml

@ -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<FileObject> {
private Project project;
public ImportantFilesChildren(Project project) {
this.project = project;
}
protected List<FileObject> 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<FileObject> list = new ArrayList<FileObject>();
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<FileObject> 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[]{};
}
}
}

@ -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;
}
}

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<!--folder name="Projects">
<folder name="Projects">
<folder name="org-netbeans-modules-java-j2seproject">
@ -11,13 +11,13 @@
<folder name="Nodes">
<file name="com.jme3.gde.android.ImportantFilesNode$ImportantFilesNodeFactoryImpl.instance">
<attr name="position" intvalue="1210"/>
<attr name="position" intvalue="210"/>
</file>
</folder>
</folder>
</folder-->
</folder>
<folder name="org-netbeans-api-project-libraries">
<folder name="Libraries">
<file name="jme3-android.xml" url="jme3-android.xml"/>

Loading…
Cancel
Save