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 ad3d68014..f51829c1c 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 @@ -84,8 +84,7 @@ public class ProjectAssetManager extends DesktopAssetManager { private final List folderNames = new LinkedList(); private final List jarItems = new LinkedList(); private URLClassLoader loader; - private boolean disableAbsolutePaths; - + public ProjectAssetManager(Project prj, String folderName) { super(true); this.project = prj; @@ -98,13 +97,13 @@ public class ProjectAssetManager extends DesktopAssetManager { } /** - * Creates ProjectAssetManager for dummy projects. - * - * @param path Path on disk to find assets from - * @param disableAbsolutePaths If true, absolute asset paths won't - * be used and the filename is loaded from the path argument directly. + * Creates + * ProjectAssetManager for dummy projects. + * + * @param path Path on disk to find assets from and the filename is loaded + * from the path argument directly. */ - public ProjectAssetManager(FileObject path, boolean disableAbsolutePaths) { + public ProjectAssetManager(FileObject path) { super(true); if (path == null) { this.project = new DummyProject(this); @@ -113,12 +112,7 @@ public class ProjectAssetManager extends DesktopAssetManager { } String projectRootPath = project.getProjectDirectory().getPath(); logger.log(Level.INFO, "Add locator: {0}", projectRootPath); - this.disableAbsolutePaths = disableAbsolutePaths; - if (disableAbsolutePaths) { - registerLocator(projectRootPath, RelativeOnlyFileLocator.class); - } else { - registerLocator(projectRootPath, "com.jme3.asset.plugins.FileLocator"); - } + registerLocator(projectRootPath, "com.jme3.asset.plugins.FileLocator"); for (AssetManagerConfigurator di : Lookup.getDefault().lookupAll(AssetManagerConfigurator.class)) { di.prepareManager(this); } @@ -126,33 +120,19 @@ public class ProjectAssetManager extends DesktopAssetManager { } public ProjectAssetManager() { - this(null, false); + this(null); } - - /** - * If true, then this ProjectAssetManager ignores - * absolute asset paths. - * The assumption that asset paths are present physically under the assets - * folder root does not hold true in this case. - */ - public boolean isAbsolutePathsDisabled() { - return disableAbsolutePaths; - } - + /** - * Returns the FileObject for a given asset key, or null - * if no such asset exists. - * + * Returns the + * FileObject for a given asset key, or null if no such asset + * exists. TODO: Only works for real files in the asset folder atm + * * @param assetKey The asset key to get the file object for * @return Either a FileObject for the asset or null if not found. */ public FileObject getAssetFileObject(AssetKey assetKey) { - if (isAbsolutePathsDisabled()) { - String fileName = assetKey.getName().substring(assetKey.getFolder().length()); - return getAssetFolder().getFileObject(fileName); - } else { - return getAssetFolder().getFileObject(assetKey.getName()); - } + return getAssetFolder().getFileObject(assetKey.getName()); } private void clearClassLoader() { diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java index a5b8638d0..11257b9de 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ImportModel.java @@ -101,19 +101,7 @@ public final class ImportModel implements ActionListener { } } - private String correctImportPathLetterCase(String importPath, List assetKeys) { - for (AssetKey key : assetKeys) { - if (importPath.equalsIgnoreCase(key.getFolder())) { - // Recommend using the folder letter case from asset key. - return key.getFolder(); - } - } - // No assets or none match the path. Use original. - return importPath; - } - private void copyModel(WizardDescriptor wiz) { -// String path = (String) wiz.getProperty("path"); AssetKey modelKey = (AssetKey) wiz.getProperty("mainkey"); boolean keepFiles = (Boolean) wiz.getProperty("keepfiles"); @@ -126,27 +114,12 @@ public final class ImportModel implements ActionListener { if (manager == null) { throw new IllegalStateException("Cannot find project AssetManager!"); } - - // Try to correct letter case in import path (this fixes case mismatch issues in Windows) - importPath = correctImportPathLetterCase(importPath, assetKeys); - + List deleteList = new LinkedList(); - int i = 0; - for (FileObject source : assetList) { - AssetKey assetKey = assetKeys.get(i++); + for (Iterator it = assetList.iterator(); it.hasNext();) { + FileObject source = it.next(); + String folderName = importPath + "/" + importManager.getRelativeAssetPath(source.getParent().getPath()); try { - String folderName; - // Put it in the user's import path if we use relative paths - // (asset keys have folders) - // or loading the model portion of the asset. - // If we are loading dependent assets of J3O or J3M (absolute paths), - // put them in the expected absolute paths. - if (assetKey.equals(modelKey) || assetKey.getFolder().equals("")) { - folderName = importPath + "/" + importManager.getRelativeAssetPath(source.getParent().getPath()); - } else { - folderName = assetKey.getFolder(); - } - FileObject dest = manager.getAssetFolder().getFileObject(folderName); if (dest == null) { dest = FileUtil.createFolder(manager.getAssetFolder(), folderName); @@ -170,6 +143,7 @@ public final class ImportModel implements ActionListener { if (fileObj != null) { DataObject obj = DataObject.find(fileObj); AssetData data = obj.getLookup().lookup(AssetData.class); + AssetKey assetKey = data.getAssetKey(); if (data != null) { if (obj instanceof SpatialAssetDataObject) { // Delete models that are not J3O. diff --git a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java index 3fdc4a8dc..d2a2a7c22 100644 --- a/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java +++ b/sdk/jme3-model-importer/src/com/jme3/gde/modelimporter/ModelImporterVisualPanel1.java @@ -80,7 +80,7 @@ public final class ModelImporterVisualPanel1 extends JPanel { manager = null; dataObject = null; data = null; - manager = new ProjectAssetManager(FileUtil.toFileObject(path).getParent(), true); + manager = new ProjectAssetManager(FileUtil.toFileObject(path).getParent()); try { dataObject = DataObject.find(FileUtil.toFileObject(path)); data = dataObject != null ? dataObject.getLookup().lookup(AssetData.class) : null;