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(); lock = matDefFile.lock();
List<Statement> sta = BlockLanguageParser.parse(obj.getPrimaryFile().getInputStream()); List<Statement> sta = BlockLanguageParser.parse(obj.getPrimaryFile().getInputStream());
matDefStructure = new MatDefBlock(sta.get(0)); matDefStructure = new MatDefBlock(sta.get(0));
if(assetManager!=null){
AssetKey<MaterialDef> matDefKey = new AssetKey<MaterialDef>(assetManager.getRelativeAssetPath(assetManager.getRelativeAssetPath(matDefFile.getPath()))); AssetKey<MaterialDef> matDefKey = new AssetKey<MaterialDef>(assetManager.getRelativeAssetPath(assetManager.getRelativeAssetPath(matDefFile.getPath())));
assetManager.deleteFromCache(matDefKey); assetManager.deleteFromCache(matDefKey);
materialDef = (MaterialDef) assetManager.loadAsset(assetManager.getRelativeAssetPath(matDefFile.getPath())); materialDef = (MaterialDef) assetManager.loadAsset(assetManager.getRelativeAssetPath(matDefFile.getPath()));
}
lock.releaseLock(); lock.releaseLock();
} catch (Exception ex) { } catch (Exception ex) {
Throwable t = ex.getCause(); Throwable t = ex.getCause();

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

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

Loading…
Cancel
Save