- make opening blender default action for .blend files
- improve blender window open cycle

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10248 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent e113ed5dbb
commit adccdd425d
  1. 9
      sdk/jme3-blender/src/com/jme3/gde/blender/BlenderTool.java
  2. 9
      sdk/jme3-blender/src/com/jme3/gde/blender/OpenInBlender.java

@ -356,11 +356,11 @@ public class BlenderTool {
return true; return true;
} }
private static boolean runBlender(final String options, boolean async) { private static boolean runBlender(final String file, boolean async) {
if (!checkBlenderFolders()) { if (!checkBlenderFolders()) {
logger.log(Level.SEVERE, "Could not create blender settings folders!"); logger.log(Level.SEVERE, "Could not create blender settings folders!");
} }
logger.log(Level.INFO, "Running blender with options {0}", options); logger.log(Level.INFO, "Running blender with options {0}", file);
if (blenderOpened.getAndSet(true)) { if (blenderOpened.getAndSet(true)) {
logger.log(Level.INFO, "Blender seems to be running"); logger.log(Level.INFO, "Blender seems to be running");
return false; return false;
@ -379,7 +379,7 @@ public class BlenderTool {
public void run() { public void run() {
try { try {
String command = exe.getAbsolutePath(); String command = exe.getAbsolutePath();
ProcessBuilder buildr = new ProcessBuilder(command, options); ProcessBuilder buildr = new ProcessBuilder(command, file);
buildr.directory(getBlenderRootFolder()); buildr.directory(getBlenderRootFolder());
buildr.environment().put("BLENDER_USER_CONFIG", getConfigEnv()); buildr.environment().put("BLENDER_USER_CONFIG", getConfigEnv());
buildr.environment().put("BLENDER_SYSTEM_SCRIPTS", getScriptsEnv()); buildr.environment().put("BLENDER_SYSTEM_SCRIPTS", getScriptsEnv());
@ -404,6 +404,7 @@ public class BlenderTool {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
public void run() { public void run() {
mainWin.setState(Frame.NORMAL); mainWin.setState(Frame.NORMAL);
mainWin.requestFocus();
} }
}); });
successful.set(false); successful.set(false);
@ -419,7 +420,7 @@ public class BlenderTool {
} }
public static boolean openInBlender(FileObject file) { public static boolean openInBlender(FileObject file) {
String path = "'" + file.getPath().replace("/", File.separator) + "'"; String path = file.getPath().replace("/", File.separator);
return runBlender(path, true); return runBlender(path, true);
} }

@ -6,8 +6,8 @@ package com.jme3.gde.blender;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import org.openide.DialogDisplayer; import java.util.logging.Level;
import org.openide.NotifyDescriptor; import java.util.logging.Logger;
import org.openide.awt.ActionID; import org.openide.awt.ActionID;
import org.openide.awt.ActionReference; import org.openide.awt.ActionReference;
import org.openide.awt.ActionReferences; import org.openide.awt.ActionReferences;
@ -23,11 +23,12 @@ displayName = "#CTL_OpenInBlender")
@ActionReferences({ @ActionReferences({
@ActionReference(path = "Menu/Tools", position = 3333), @ActionReference(path = "Menu/Tools", position = 3333),
@ActionReference(path = "Toolbars/File", position = 335), @ActionReference(path = "Toolbars/File", position = 335),
@ActionReference(path = "Loaders/application/blender/Actions", position = 30) @ActionReference(path = "Loaders/application/blender/Actions", position = 9)
}) })
@Messages("CTL_OpenInBlender=Open in Blender") @Messages("CTL_OpenInBlender=Open in Blender")
public final class OpenInBlender implements ActionListener { public final class OpenInBlender implements ActionListener {
private static final Logger logger = Logger.getLogger(OpenInBlender.class.getName());
private final BlenderDataObject context; private final BlenderDataObject context;
public OpenInBlender(BlenderDataObject context) { public OpenInBlender(BlenderDataObject context) {
@ -37,7 +38,7 @@ public final class OpenInBlender implements ActionListener {
@Override @Override
public void actionPerformed(ActionEvent ev) { public void actionPerformed(ActionEvent ev) {
if (!BlenderTool.openInBlender(context.getPrimaryFile())) { if (!BlenderTool.openInBlender(context.getPrimaryFile())) {
DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message("Error opening Blender with file " + context.getPrimaryFile().getNameExt())); logger.log(Level.INFO, "Could not open file in blender, already running?");
} }
} }
} }

Loading…
Cancel
Save