- You can now select a material  in material browser by double clicking it

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7987 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 14 years ago
parent d216390a00
commit 6432543395
  1. 3
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.form
  2. 26
      sdk/jme3-materialeditor/src/com/jme3/gde/materials/MaterialBrowser.java

@ -61,6 +61,9 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTree" name="jTree1">
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jTree1MouseClicked"/>
</Events>
</Component>
</SubComponents>
</Container>

@ -13,6 +13,7 @@ package com.jme3.gde.materials;
import com.jme3.gde.core.assets.ProjectAssetManager;
import com.jme3.gde.core.util.TreeUtil;
import com.jme3.material.Material;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.FileReader;
@ -55,7 +56,7 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio
jTree1.addTreeSelectionListener(this);
}
private void setMaterial() {
private boolean setMaterial() {
DefaultMutableTreeNode node = (DefaultMutableTreeNode) jTree1.getLastSelectedPathComponent();
if (node != null && node.isLeaf()) {
@ -64,11 +65,11 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio
Material mat = assetManager.loadMaterial(selected);
editor.setValue(mat);
editor.setAsText(selected);
} else {
editor.setValue(null);
editor.setAsText(null);
return true;
}
return false;
}
private void setSelectedMaterial(Material material) {
@ -136,6 +137,11 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle(org.openide.util.NbBundle.getMessage(MaterialBrowser.class, "MaterialBrowser.title")); // NOI18N
jTree1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jTree1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jTree1);
jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
@ -218,15 +224,25 @@ public class MaterialBrowser extends javax.swing.JDialog implements TreeSelectio
}// </editor-fold>//GEN-END:initComponents
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
setMaterial();
if (setMaterial()) {
dispose();
materialPreviewWidget1.cleanUp();
}
}//GEN-LAST:event_okButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
dispose();
materialPreviewWidget1.cleanUp();
}//GEN-LAST:event_cancelButtonActionPerformed
private void jTree1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTree1MouseClicked
if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
if (setMaterial()) {
dispose();
}
}
}//GEN-LAST:event_jTree1MouseClicked
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JPanel jPanel1;

Loading…
Cancel
Save