Sanity check when creating ShaderNode editor metadata.

experimental
Nehon 10 years ago
parent 4668621c95
commit b0995bcf55
  1. 2
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/EditableMatDefFile.java
  2. 8
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/MatDefDataObject.java
  3. 2
      sdk/jme3-materialeditor/src/com/jme3/gde/materialdefinition/MatDefMetaData.java

@ -97,9 +97,11 @@ public class EditableMatDefFile {
lock = matDefFile.lock();
List<Statement> sta = BlockLanguageParser.parse(obj.getPrimaryFile().getInputStream());
matDefStructure = new MatDefBlock(sta.get(0));
if(assetManager!=null){
AssetKey<MaterialDef> matDefKey = new AssetKey<MaterialDef>(assetManager.getRelativeAssetPath(assetManager.getRelativeAssetPath(matDefFile.getPath())));
assetManager.deleteFromCache(matDefKey);
materialDef = (MaterialDef) assetManager.loadAsset(assetManager.getRelativeAssetPath(matDefFile.getPath()));
}
lock.releaseLock();
} catch (Exception ex) {
Throwable t = ex.getCause();

@ -36,6 +36,8 @@ import com.jme3.gde.materialdefinition.navigator.MatDefNavigatorPanel;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.text.EditorKit;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectManager;
import org.netbeans.core.spi.multiview.MultiViewElement;
@ -52,6 +54,7 @@ import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectExistsException;
import org.openide.loaders.MultiDataObject;
import org.openide.loaders.MultiFileLoader;
import org.openide.text.CloneableEditorSupport;
import org.openide.util.Lookup;
import org.openide.util.NbBundle.Messages;
import org.openide.util.lookup.AbstractLookup;
@ -228,8 +231,11 @@ public class MatDefDataObject extends MultiDataObject {
@Override
public void componentDeactivated() {
super.componentDeactivated();
JEditorPane editorPane = getEditorPane();
if (editorPane != null) {
getEditorPane().removeKeyListener(listener);
}
}
@Override
public void componentClosed() {
@ -245,7 +251,9 @@ public class MatDefDataObject extends MultiDataObject {
@Override
protected void handleDelete() throws IOException {
MatDefMetaData metaData = lookup.lookup(MatDefMetaData.class);
if(metaData != null){
metaData.cleanup();
}
super.handleDelete();
}

@ -390,8 +390,10 @@ public class MatDefMetaData {
FileObject jmedataFolder = root.getFileObject("/nbproject/jme3Data");
if (jmedataFolder == null) {
jmedataFolder = root.getFileObject("/nbproject");
if(jmedataFolder!=null){
jmedataFolder = jmedataFolder.createFolder("jme3Data");
}
}
return jmedataFolder;
}
}

Loading…
Cancel
Save