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
3.0
bre..om 12 years ago
parent 48a6c4745d
commit 5f95807432
  1. 1
      sdk/jme3-core/src/com/jme3/gde/core/properties/TextureBrowser.java
  2. 14
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.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";

@ -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("");

Loading…
Cancel
Save