Main repository of MikuMikuStudio
修订版 | 200f7f0aa40da89053ea1e3601284dd2d3a6d6fd (tree) |
---|---|
时间 | 2013-03-06 03:20:27 |
作者 | brentowens@gmail.com <brentowens@gmai...> |
Commiter | brentowens@gmail.com |
MaterialBrowser will remember browse path. Removed commented out code from TextureBrowser
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10467 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -69,7 +69,6 @@ public class TextureBrowser extends javax.swing.JDialog implements TreeSelection | ||
69 | 69 | private ProjectAssetManager assetManager; |
70 | 70 | private TexturePropertyEditor editor; |
71 | 71 | private DDSPreview ddsPreview; |
72 | - //private static TreePath lastSelectedTexture; | |
73 | 72 | private Preferences prefs; |
74 | 73 | private static final String PREF_LAST_SELECTED = "lastSelectedTexture"; |
75 | 74 |
@@ -22,6 +22,7 @@ import java.util.Arrays; | ||
22 | 22 | import java.util.Collections; |
23 | 23 | import java.util.List; |
24 | 24 | import java.util.logging.Logger; |
25 | +import java.util.prefs.Preferences; | |
25 | 26 | import javax.swing.event.TreeSelectionEvent; |
26 | 27 | import javax.swing.event.TreeSelectionListener; |
27 | 28 | import javax.swing.tree.DefaultMutableTreeNode; |
@@ -37,11 +38,14 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio | ||
37 | 38 | |
38 | 39 | private ProjectAssetManager assetManager; |
39 | 40 | private MaterialPropertyEditor editor; |
41 | + private Preferences prefs; | |
42 | + private static final String PREF_LAST_SELECTED = "lastSelectedMaterial"; | |
40 | 43 | |
41 | 44 | /** Creates new form MaterialBrowser */ |
42 | 45 | public MaterialBrowser(java.awt.Frame parent, boolean modal, ProjectAssetManager assetManager, MaterialPropertyEditor editor) { |
43 | 46 | this.assetManager = assetManager; |
44 | 47 | this.editor = editor; |
48 | + prefs = Preferences.userNodeForPackage(this.getClass()); | |
45 | 49 | initComponents(); |
46 | 50 | loadAvailableMaterials(); |
47 | 51 | setSelectedMaterial((Material) editor.getValue()); |
@@ -85,6 +89,13 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio | ||
85 | 89 | jTree1.expandPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, true)); |
86 | 90 | jTree1.getSelectionModel().setSelectionPath(TreeUtil.buildTreePath(jTree1, parent, path, 0, false)); |
87 | 91 | |
92 | + } else { | |
93 | + String lastSelected = prefs.get(PREF_LAST_SELECTED, null); | |
94 | + if (lastSelected != null) { | |
95 | + TreePath parent = new TreePath((TreeNode) jTree1.getModel().getRoot()); | |
96 | + TreePath selectedTreePath = TreeUtil.buildTreePath(jTree1, parent, ("/"+lastSelected).split("/"), 0, true); | |
97 | + jTree1.expandPath(selectedTreePath); | |
98 | + } | |
88 | 99 | } |
89 | 100 | } |
90 | 101 |
@@ -109,10 +120,11 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio | ||
109 | 120 | fr.read(b); |
110 | 121 | materialTextPreview.setText(new String(b).trim()); |
111 | 122 | } |
123 | + prefs.put(PREF_LAST_SELECTED, selected); | |
112 | 124 | } catch (IOException ex) { |
113 | 125 | Exceptions.printStackTrace(ex); |
114 | 126 | } |
115 | - | |
127 | + | |
116 | 128 | } else { |
117 | 129 | materialPreviewWidget1.clear(); |
118 | 130 | materialTextPreview.setText(""); |