- AssetCompletionProvider: add support for sounds and nifty xml

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10091 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent bb0a7befc5
commit 308c8f6c08
  1. 4
      sdk/jme3-core/src/com/jme3/gde/core/assets/ProjectAssetManager.java
  2. 35
      sdk/jme3-core/src/com/jme3/gde/core/completion/AssetCompletionProvider.java

@ -330,6 +330,10 @@ public class ProjectAssetManager extends DesktopAssetManager {
return filesWithSuffix("j3md"); return filesWithSuffix("j3md");
} }
public String[] getFilesWithSuffix(String string){
return filesWithSuffix(string);
}
private String[] filesWithSuffix(String string){ private String[] filesWithSuffix(String string){
List<String> list=collectFilesWithSuffix(string); List<String> list=collectFilesWithSuffix(string);
return list.toArray(new String[list.size()]); return list.toArray(new String[list.size()]);

@ -71,6 +71,8 @@ public class AssetCompletionProvider implements CompletionProvider {
new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/assets.gif")); new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/assets.gif"));
private static ImageIcon modelIcon = private static ImageIcon modelIcon =
new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/model.gif")); 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 = private static ImageIcon materialIcon =
new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/material.gif")); new ImageIcon(ImageUtilities.loadImage("com/jme3/gde/core/assets/nodes/icons/material.gif"));
private static ImageIcon matDefIcon = private static ImageIcon matDefIcon =
@ -80,7 +82,7 @@ public class AssetCompletionProvider implements CompletionProvider {
private enum AssetType { private enum AssetType {
Invalid, Model, Material, MatDef, Texture, Asset Invalid, Model, Material, MatDef, Texture, Sound, Xml, Asset
} }
public AssetCompletionProvider() { public AssetCompletionProvider() {
@ -124,7 +126,6 @@ public class AssetCompletionProvider implements CompletionProvider {
for (String string : manager.getModels()) { for (String string : manager.getModels()) {
if (string.startsWith(filter)) { if (string.startsWith(filter)) {
completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset));
Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string);
} }
} }
break; break;
@ -132,7 +133,6 @@ public class AssetCompletionProvider implements CompletionProvider {
for (String string : manager.getMaterials()) { for (String string : manager.getMaterials()) {
if (string.startsWith(filter)) { if (string.startsWith(filter)) {
completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset));
Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string);
} }
} }
break; break;
@ -140,7 +140,6 @@ public class AssetCompletionProvider implements CompletionProvider {
for (String string : manager.getMatDefs()) { for (String string : manager.getMatDefs()) {
if (string.startsWith(filter)) { if (string.startsWith(filter)) {
completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset));
Logger.getLogger(AssetCompletionProvider.class.getName()).log(Level.FINE, "Added item {0}", string);
} }
} }
break; break;
@ -148,7 +147,20 @@ public class AssetCompletionProvider implements CompletionProvider {
for (String string : manager.getTextures()) { for (String string : manager.getTextures()) {
if (string.startsWith(filter)) { if (string.startsWith(filter)) {
completionResultSet.addItem(new AssetCompletionItem(type, string, startOffset, caretOffset)); 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; break;
@ -178,8 +190,16 @@ public class AssetCompletionProvider implements CompletionProvider {
return AssetType.Material; return AssetType.Material;
} else if (hasLastCommand(line, ".loadTexture(\"")) { } else if (hasLastCommand(line, ".loadTexture(\"")) {
return AssetType.Texture; 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(")) { } else if (hasLastCommand(line, "new Material(")) {
return AssetType.MatDef; return AssetType.MatDef;
} else if (hasLastCommand(line, "new AudioNode(")) {
return AssetType.Sound;
} }
} catch (BadLocationException ex) { } catch (BadLocationException ex) {
Exceptions.printStackTrace(ex); Exceptions.printStackTrace(ex);
@ -301,11 +321,16 @@ public class AssetCompletionProvider implements CompletionProvider {
case Texture: case Texture:
icon = textureIcon; icon = textureIcon;
break; break;
case Sound:
icon = soundIcon;
break;
case Asset: case Asset:
icon = assetIcon; icon = assetIcon;
break; break;
case Invalid: case Invalid:
break; break;
default:
//icon = assetIcon;
} }
CompletionUtilities.renderHtml(icon, text, null, g, defaultFont, CompletionUtilities.renderHtml(icon, text, null, g, defaultFont,
(selected ? Color.white : fieldColor), width, height, selected); (selected ? Color.white : fieldColor), width, height, selected);

Loading…
Cancel
Save