From 308c8f6c08a4a2ad160acc89e5bc03c2876b3fc8 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Fri, 18 Jan 2013 00:39:00 +0000 Subject: [PATCH] SDK: - AssetCompletionProvider: add support for sounds and nifty xml git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10091 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../gde/core/assets/ProjectAssetManager.java | 4 +++ .../completion/AssetCompletionProvider.java | 35 ++++++++++++++++--- 2 files changed, 34 insertions(+), 5 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 e2a256408..b30ead0ba 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 @@ -330,6 +330,10 @@ public class ProjectAssetManager extends DesktopAssetManager { return filesWithSuffix("j3md"); } + public String[] getFilesWithSuffix(String string){ + return filesWithSuffix(string); + } + private String[] filesWithSuffix(String string){ List list=collectFilesWithSuffix(string); return list.toArray(new String[list.size()]); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java b/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java index 0df02ce32..17c3187c7 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java @@ -71,6 +71,8 @@ public class AssetCompletionProvider implements CompletionProvider { new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/assets.gif")); private static ImageIcon modelIcon = new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/model.gif")); + private static ImageIcon soundIcon = + new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/sound.gif")); private static ImageIcon materialIcon = new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/material.gif")); private static ImageIcon matDefIcon = @@ -80,7 +82,7 @@ public class AssetCompletionProvider implements CompletionProvider { private enum AssetType { - Invalid, Model, Material, MatDef, Texture, Asset + Invalid, Model, Material, MatDef, Texture, Sound, Xml, Asset } public AssetCompletionProvider() { @@ -124,7 +126,6 @@ public class AssetCompletionProvider implements CompletionProvider { for (String string : manager.getModels()) { if (string.startsWith(filter)) { completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); - Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string); } } break; @@ -132,7 +133,6 @@ public class AssetCompletionProvider implements CompletionProvider { for (String string : manager.getMaterials()) { if (string.startsWith(filter)) { completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); - Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string); } } break; @@ -140,7 +140,6 @@ public class AssetCompletionProvider implements CompletionProvider { for (String string : manager.getMatDefs()) { if (string.startsWith(filter)) { completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); - Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string); } } break; @@ -148,7 +147,20 @@ public class AssetCompletionProvider implements CompletionProvider { for (String string : manager.getTextures()) { if (string.startsWith(filter)) { completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); - Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string); + } + } + break; + case Sound: + for (String string : manager.getSounds()) { + if (string.startsWith(filter)) { + completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); + } + } + break; + case Xml: + for (String string : manager.getFilesWithSuffix("xml")) { + if (string.startsWith(filter)) { + completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); } } break; @@ -178,8 +190,16 @@ public class AssetCompletionProvider implements CompletionProvider { return AssetType.Material; } else if (hasLastCommand(line, ".loadTexture(\"")) { return AssetType.Texture; + } else if (hasLastCommand(line, ".addXml(\"")) { + return AssetType.Xml; + } else if (hasLastCommand(line, ".fromXml(\"")) { + return AssetType.Xml; + } else if (hasLastCommand(line, ".loadSound(\"")) { + return AssetType.Sound; } else if (hasLastCommand(line, "new Material(")) { return AssetType.MatDef; + } else if (hasLastCommand(line, "new AudioNode(")) { + return AssetType.Sound; } } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); @@ -301,11 +321,16 @@ public class AssetCompletionProvider implements CompletionProvider { case Texture: icon = textureIcon; break; + case Sound: + icon = soundIcon; + break; case Asset: icon = assetIcon; break; case Invalid: break; + default: + //icon = assetIcon; } CompletionUtilities.renderHtml(icon, text, null, g, defaultFont, (selected ? Color.white : fieldColor), width, height, selected);