From 6bf538d87b73f611b9d17f25532823da5cc6e99a Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Thu, 4 Oct 2012 11:10:43 +0000 Subject: [PATCH] SDK: - Material Editor now shows all j3md files on the classpath (thanks to @H) git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9832 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/core/assets/ProjectAssetManager.java | 47 ++++++++++++++----- .../multiview/MaterialEditorTopComponent.form | 6 +-- .../multiview/MaterialEditorTopComponent.java | 14 +++--- .../nbproject/genfiles.properties | 4 +- 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java b/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java index d494c1b9a..f16353fd7 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java @@ -85,7 +85,6 @@ public class ProjectAssetManager extends DesktopAssetManager { } addFolderLocator(folderName); ProjectManager.mutex().postWriteRequest(new Runnable() { - public void run() { updateClassLoader(); } @@ -144,7 +143,6 @@ public class ProjectAssetManager extends DesktopAssetManager { for (FileObject fileObject : roots) { if (!fileObject.equals(getAssetFolder())) { FileChangeListener listener = new FileChangeListener() { - public void fileFolderCreated(FileEvent fe) { // notifyClassPathListeners(); } @@ -200,7 +198,6 @@ public class ProjectAssetManager extends DesktopAssetManager { private void prepAssetEventListeners() { super.setAssetEventListener(new AssetEventListener() { - public void assetLoaded(AssetKey ak) { synchronized (assetEventListeners) { for (AssetEventListener assetEventListener : assetEventListeners) { @@ -312,18 +309,45 @@ public class ProjectAssetManager extends DesktopAssetManager { } public String[] getMatDefs() { + return collectFilesWithSuffix("j3md"); + } + + /** + * Collects files over the asset folder(s) and classpath + * @param suffix + * @return + */ + private String[] collectFilesWithSuffix(String suffix) { + ArrayList list = new ArrayList(); FileObject assetsFolder = getAssetFolder(); - if (assetsFolder == null) { - return new String[]{}; + if (assetsFolder != null) { + Enumeration assets = (Enumeration) assetsFolder.getChildren(true); + while (assets.hasMoreElements()) { + FileObject asset = assets.nextElement(); + if (asset.getExt().equalsIgnoreCase(suffix)) { + list.add(getRelativeAssetPath(asset.getPath())); + } + } } - Enumeration assets = (Enumeration) assetsFolder.getChildren(true); - ArrayList list = new ArrayList(); - while (assets.hasMoreElements()) { - FileObject asset = assets.nextElement(); - if (asset.getExt().equalsIgnoreCase("j3md")) { - list.add(getRelativeAssetPath(asset.getPath())); + + if (classPathItems != null) { + // TODO I need to find out if classPathItems contains all jars added to a project + Iterator classPathItemsIter = classPathItems.iterator(); + while (classPathItemsIter.hasNext()) { + ClassPathItem classPathItem = classPathItemsIter.next(); + FileObject jarFile = classPathItem.object; + + Enumeration jarEntry = (Enumeration) jarFile.getChildren(true); + while (jarEntry.hasMoreElements()) { + FileObject jarEntryAsset = jarEntry.nextElement(); + if (jarEntryAsset.getExt().equalsIgnoreCase(suffix)) { + list.add(jarEntryAsset.getPath()); + } + } + } } + return list.toArray(new String[list.size()]); } @@ -400,7 +424,6 @@ public class ProjectAssetManager extends DesktopAssetManager { updateClassLoader(); final ProjectAssetManager pm = this; java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { synchronized (classPathListeners) { for (ClassPathChangeListener classPathChangeListener : classPathListeners) { diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.form b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.form index 14fb68d7e..646514076 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.form +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.form @@ -1,4 +1,4 @@ - +
@@ -120,7 +120,7 @@ - + @@ -276,7 +276,7 @@ - + diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.java index 963093218..e85107c64 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/multiview/MaterialEditorTopComponent.java @@ -534,13 +534,13 @@ public final class MaterialEditorTopComponent extends CloneableTopComponent impl jComboBox1.addItem(string); } - jComboBox1.addItem("Common/MatDefs/Light/Lighting.j3md"); - jComboBox1.addItem("Common/MatDefs/Misc/Unshaded.j3md"); - jComboBox1.addItem("Common/MatDefs/Misc/Particle.j3md"); - jComboBox1.addItem("Common/MatDefs/Misc/Sky.j3md"); - jComboBox1.addItem("Common/MatDefs/Gui/Gui.j3md"); - jComboBox1.addItem("Common/MatDefs/Terrain/TerrainLighting.j3md"); - jComboBox1.addItem("Common/MatDefs/Terrain/Terrain.j3md"); +// jComboBox1.addItem("Common/MatDefs/Light/Lighting.j3md"); +// jComboBox1.addItem("Common/MatDefs/Misc/Unshaded.j3md"); +// jComboBox1.addItem("Common/MatDefs/Misc/Particle.j3md"); +// jComboBox1.addItem("Common/MatDefs/Misc/Sky.j3md"); +// jComboBox1.addItem("Common/MatDefs/Gui/Gui.j3md"); +// jComboBox1.addItem("Common/MatDefs/Terrain/TerrainLighting.j3md"); +// jComboBox1.addItem("Common/MatDefs/Terrain/Terrain.j3md"); // jComboBox1.addItem("Common/MatDefs/Misc/ShowNormals.j3md"); jComboBox1.setSelectedItem(selected); materialFile = prop; diff --git a/sdk/jme3-model-importer/nbproject/genfiles.properties b/sdk/jme3-model-importer/nbproject/genfiles.properties index 19a2ee3ec..aaa106237 100644 --- a/sdk/jme3-model-importer/nbproject/genfiles.properties +++ b/sdk/jme3-model-importer/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=ae2392d0 +build.xml.data.CRC32=35b10250 build.xml.script.CRC32=b6310686 build.xml.stylesheet.CRC32=a56c6a5b@2.50.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=ae2392d0 +nbproject/build-impl.xml.data.CRC32=35b10250 nbproject/build-impl.xml.script.CRC32=4db64ed5 nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1