- make ImportantFiles functionality more flexible
- give more descriptive names to android ImportantFiles and build.xml git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8749 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
b5dccedb0b
commit
76fef5cbae
@ -9,6 +9,9 @@ import java.io.InputStream;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.netbeans.api.project.Project;
|
import org.netbeans.api.project.Project;
|
||||||
import org.openide.filesystems.FileObject;
|
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.util.Exceptions;
|
||||||
import org.openide.xml.XMLUtil;
|
import org.openide.xml.XMLUtil;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
@ -22,7 +25,7 @@ import org.xml.sax.InputSource;
|
|||||||
public class AndroidImportantFiles implements ImportantFiles {
|
public class AndroidImportantFiles implements ImportantFiles {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileObject[] getFiles(Project project) {
|
public Node[] getNodes(Project project) {
|
||||||
FileObject manifest = project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml");
|
FileObject manifest = project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml");
|
||||||
String mainActivity = "mobile/src";
|
String mainActivity = "mobile/src";
|
||||||
if (manifest != null) {
|
if (manifest != null) {
|
||||||
@ -37,19 +40,38 @@ public class AndroidImportantFiles implements ImportantFiles {
|
|||||||
} finally {
|
} finally {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArrayList<FileObject> list = new ArrayList<FileObject>();
|
ArrayList<Node> list = new ArrayList<Node>();
|
||||||
|
try {
|
||||||
FileObject mainAct = project.getProjectDirectory().getFileObject(mainActivity);
|
FileObject mainAct = project.getProjectDirectory().getFileObject(mainActivity);
|
||||||
if (mainAct != null) {
|
if (mainAct != null) {
|
||||||
list.add(mainAct);
|
Node node = DataObject.find(mainAct).getNodeDelegate();
|
||||||
|
node.setDisplayName("Android Main Activity");
|
||||||
|
list.add(node);
|
||||||
}
|
}
|
||||||
FileObject manif = project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml");
|
FileObject manif = project.getProjectDirectory().getFileObject("mobile/AndroidManifest.xml");
|
||||||
if (manif != null) {
|
if (manif != null) {
|
||||||
list.add(manif);
|
Node node = DataObject.find(manif).getNodeDelegate();
|
||||||
|
node.setDisplayName("Android Manifest");
|
||||||
|
list.add(node);
|
||||||
}
|
}
|
||||||
FileObject buildProp = project.getProjectDirectory().getFileObject("mobile/ant.properties");
|
FileObject buildProp = project.getProjectDirectory().getFileObject("mobile/ant.properties");
|
||||||
if (buildProp != null) {
|
if (buildProp != null) {
|
||||||
list.add(buildProp);
|
Node node = DataObject.find(buildProp).getNodeDelegate();
|
||||||
|
node.setDisplayName("Android Properties");
|
||||||
|
list.add(node);
|
||||||
}
|
}
|
||||||
return list.toArray(new FileObject[list.size()]);
|
} 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,11 @@ import com.jme3.gde.core.j2seproject.ProjectExtensionProperties;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipInputStream;
|
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
import org.netbeans.api.project.Project;
|
import org.netbeans.api.project.Project;
|
||||||
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
|
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
|
||||||
import org.openide.filesystems.FileObject;
|
import org.openide.filesystems.FileObject;
|
||||||
import org.openide.filesystems.FileUtil;
|
|
||||||
|
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
@ -104,30 +99,5 @@ public class MobileCompositeProvider implements ProjectCustomizer.CompositeCateg
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
|
|
||||||
try {
|
|
||||||
ZipInputStream str = new ZipInputStream(source);
|
|
||||||
ZipEntry entry;
|
|
||||||
while ((entry = str.getNextEntry()) != null) {
|
|
||||||
if (entry.isDirectory()) {
|
|
||||||
FileUtil.createFolder(projectRoot, entry.getName());
|
|
||||||
} else {
|
|
||||||
FileObject fo = FileUtil.createData(projectRoot, entry.getName());
|
|
||||||
writeFile(str, fo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
source.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeFile(ZipInputStream str, FileObject fo) throws IOException {
|
|
||||||
OutputStream out = fo.getOutputStream();
|
|
||||||
try {
|
|
||||||
FileUtil.copy(str, out);
|
|
||||||
} finally {
|
|
||||||
out.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,21 @@
|
|||||||
package com.jme3.gde.core.importantfiles;
|
package com.jme3.gde.core.importantfiles;
|
||||||
|
|
||||||
import org.netbeans.api.project.Project;
|
import org.netbeans.api.project.Project;
|
||||||
import org.openide.filesystems.FileObject;
|
import org.openide.nodes.Node;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author normenhansen
|
* @author normenhansen
|
||||||
*/
|
*/
|
||||||
public interface ImportantFiles {
|
public interface ImportantFiles {
|
||||||
public FileObject[] getFiles(Project proj);
|
/**
|
||||||
|
* should return true if given project contains files relevant to this project
|
||||||
|
*/
|
||||||
|
public boolean hasFiles(Project proj);
|
||||||
|
/**
|
||||||
|
* get the node(s) for the configuration files, can also be a node containing children
|
||||||
|
* @param proj
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Node[] getNodes(Project proj);
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,7 @@ import org.netbeans.spi.project.ui.support.NodeList;
|
|||||||
import org.openide.filesystems.FileAttributeEvent;
|
import org.openide.filesystems.FileAttributeEvent;
|
||||||
import org.openide.filesystems.FileChangeListener;
|
import org.openide.filesystems.FileChangeListener;
|
||||||
import org.openide.filesystems.FileEvent;
|
import org.openide.filesystems.FileEvent;
|
||||||
import org.openide.filesystems.FileObject;
|
|
||||||
import org.openide.filesystems.FileRenameEvent;
|
import org.openide.filesystems.FileRenameEvent;
|
||||||
import org.openide.loaders.DataObject;
|
|
||||||
import org.openide.loaders.DataObjectNotFoundException;
|
import org.openide.loaders.DataObjectNotFoundException;
|
||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
@ -105,7 +103,6 @@ public class ImportantFilesNode extends AbstractNode implements FileChangeListen
|
|||||||
// return Lookups.fixed(new ImportantFilesLookupItem(prj));
|
// return Lookups.fixed(new ImportantFilesLookupItem(prj));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public static class ImportantFilesNodeFactoryImpl implements NodeFactory {
|
public static class ImportantFilesNodeFactoryImpl implements NodeFactory {
|
||||||
|
|
||||||
public NodeList createNodes(Project project) {
|
public NodeList createNodes(Project project) {
|
||||||
@ -129,8 +126,7 @@ public class ImportantFilesNode extends AbstractNode implements FileChangeListen
|
|||||||
// public ImportantFilesLookupItem(Project prj) {
|
// public ImportantFilesLookupItem(Project prj) {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
public static class ImportantFilesChildren extends Children.Keys<ImportantFiles> {
|
||||||
public static class ImportantFilesChildren extends Children.Keys<FileObject[]> {
|
|
||||||
|
|
||||||
private Project project;
|
private Project project;
|
||||||
|
|
||||||
@ -138,11 +134,12 @@ public class ImportantFilesNode extends AbstractNode implements FileChangeListen
|
|||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<FileObject[]> createKeys() {
|
protected List<ImportantFiles> createKeys() {
|
||||||
ArrayList<FileObject[]> list = new ArrayList<FileObject[]>();
|
ArrayList<ImportantFiles> list = new ArrayList<ImportantFiles>();
|
||||||
for (ImportantFiles di : Lookup.getDefault().lookupAll(ImportantFiles.class)) {
|
for (ImportantFiles di : Lookup.getDefault().lookupAll(ImportantFiles.class)) {
|
||||||
FileObject[] nodes = di.getFiles(project);
|
if (di.hasFiles(project)) {
|
||||||
list.add(nodes);
|
list.add(di);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -154,17 +151,8 @@ public class ImportantFilesNode extends AbstractNode implements FileChangeListen
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Node[] createNodes(FileObject[] key) {
|
protected Node[] createNodes(ImportantFiles key) {
|
||||||
Node[] nodes= new Node[key.length];
|
Node[] nodes = key.getNodes(project);
|
||||||
for (int i = 0; i < key.length; i++) {
|
|
||||||
FileObject fileObject = key[i];
|
|
||||||
try {
|
|
||||||
nodes[i] = DataObject.find(fileObject).getNodeDelegate();
|
|
||||||
} catch (DataObjectNotFoundException ex) {
|
|
||||||
nodes[i] = Node.EMPTY;
|
|
||||||
Exceptions.printStackTrace(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,10 @@ import com.jme3.gde.core.importantfiles.ImportantFiles;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.netbeans.api.project.Project;
|
import org.netbeans.api.project.Project;
|
||||||
import org.openide.filesystems.FileObject;
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -16,12 +20,25 @@ import org.openide.filesystems.FileObject;
|
|||||||
@org.openide.util.lookup.ServiceProvider(service = ImportantFiles.class)
|
@org.openide.util.lookup.ServiceProvider(service = ImportantFiles.class)
|
||||||
public class J2seImportantFiles implements ImportantFiles {
|
public class J2seImportantFiles implements ImportantFiles {
|
||||||
|
|
||||||
@Override
|
public Node[] getNodes(Project proj) {
|
||||||
public FileObject[] getFiles(Project project) {
|
FileObject obj = proj.getProjectDirectory().getFileObject("build.xml");
|
||||||
ArrayList<FileObject> list = new ArrayList<FileObject>();
|
if (obj == null) {
|
||||||
// list.add(project.getProjectDirectory().getFileObject("nbproject/project.properties"));
|
return new Node[]{Node.EMPTY};
|
||||||
list.add(project.getProjectDirectory().getFileObject("build.xml"));
|
}
|
||||||
return list.toArray(new FileObject[list.size()]);
|
Node[] nodes = new Node[1];
|
||||||
|
try {
|
||||||
|
nodes[0] = DataObject.find(obj).getNodeDelegate();
|
||||||
|
nodes[0].setDisplayName("Build File");
|
||||||
|
} catch (DataObjectNotFoundException ex) {
|
||||||
|
Exceptions.printStackTrace(ex);
|
||||||
|
}
|
||||||
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasFiles(Project proj) {
|
||||||
|
if (proj.getProjectDirectory().getFileObject("build.xml") != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user