From 5f95807432aaba5b13fae85b4b1e409241cb775b Mon Sep 17 00:00:00 2001 From: "bre..om" Date: Tue, 5 Mar 2013 18:20:27 +0000 Subject: [PATCH] MaterialBrowser will remember browse path. Removed commented out code from TextureBrowser git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10467 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/gde/core/properties/TextureBrowser.java | 1 - .../com/jme3/gde/materials/MaterialBrowser.java | 14 +++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java index bd0c903f8..c199fe39a 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java @@ -69,7 +69,6 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection private ProjectAssetManager assetManager; private TexturePropertyEditor editor; private DDSPreview ddsPreview; - //private static TreePath lastSelectedTexture; private Preferences prefs; private static final String PREF_LAST_SELECTED = "lastSelectedTexture"; diff --git a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.java b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.java index f25294d8c..541d22bc8 100644 --- a/sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.java +++ b/sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.java @@ -22,6 +22,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.logging.Logger; +import java.util.prefs.Preferences; import javax.swing.event.TreeSelectionEvent; import javax.swing.event.TreeSelectionListener; import javax.swing.tree.DefaultMutableTreeNode; @@ -37,11 +38,14 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio private ProjectAssetManager assetManager; private MaterialPropertyEditor editor; + private Preferences prefs; + private static final String PREF_LAST_SELECTED = "lastSelectedMaterial"; /** Creates new form MaterialBrowser */ public MaterialBrowser(java.awt.Frame parent, boolean modal, ProjectAssetManager assetManager, MaterialPropertyEditor editor) { this.assetManager = assetManager; this.editor = editor; + prefs = Preferences.userNodeForPackage(this.getClass()); initComponents(); loadAvailableMaterials(); setSelectedMaterial((Material) editor.getValue()); @@ -85,6 +89,13 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio jTree1.expandPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, true)); jTree1.getSelectionModel().setSelectionPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, false)); + } else { + String lastSelected = prefs.get(PREF_LAST_SELECTED, null); + if (lastSelected != null) { + TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot()); + TreePath selectedTreePath = TreeUtil.buildTreePath(jTree1, parent, ("/"+lastSelected).split("/"), 0, true); + jTree1.expandPath(selectedTreePath); + } } } @@ -109,10 +120,11 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio fr.read(b); materialTextPreview.setText(new String(b).trim()); } + prefs.put(PREF_LAST_SELECTED, selected); } catch (IOException ex) { Exceptions.printStackTrace(ex); } - + } else { materialPreviewWidget1.clear(); materialTextPreview.setText("");