|
@@ -32,7 +32,6 @@
|
|
package com.jme3.gde.core.sceneexplorer.nodes;
|
|
package com.jme3.gde.core.sceneexplorer.nodes;
|
|
|
|
|
|
import com.jme3.bounding.BoundingVolume;
|
|
import com.jme3.bounding.BoundingVolume;
|
|
-import com.jme3.export.binary.BinaryExporter;
|
|
|
|
import com.jme3.gde.core.properties.UserDataProperty;
|
|
import com.jme3.gde.core.properties.UserDataProperty;
|
|
import com.jme3.gde.core.scene.SceneApplication;
|
|
import com.jme3.gde.core.scene.SceneApplication;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.actions.AddUserDataAction;
|
|
import com.jme3.gde.core.sceneexplorer.nodes.actions.AddUserDataAction;
|
|
@@ -50,10 +49,8 @@ import com.jme3.scene.Spatial.CullHint;
|
|
import java.awt.datatransfer.DataFlavor;
|
|
import java.awt.datatransfer.DataFlavor;
|
|
import java.awt.datatransfer.Transferable;
|
|
import java.awt.datatransfer.Transferable;
|
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
|
import java.awt.datatransfer.UnsupportedFlavorException;
|
|
-import java.io.ByteArrayOutputStream;
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
-import java.util.Iterator;
|
|
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.Callable;
|
|
import java.util.concurrent.ExecutionException;
|
|
import java.util.concurrent.ExecutionException;
|
|
import javax.swing.Action;
|
|
import javax.swing.Action;
|
|
@@ -77,6 +74,9 @@ import org.openide.util.actions.SystemAction;
|
|
public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
|
|
|
|
protected Spatial spatial;
|
|
protected Spatial spatial;
|
|
|
|
+ /* DataFlavor is a kind of metadata/mime-type
|
|
|
|
+ * (https://docs.oracle.com/javase/7/docs/api/java/awt/datatransfer/DataFlavor.html)
|
|
|
|
+ */
|
|
protected final DataFlavor SPATIAL_FLAVOR = new DataFlavor(ClipboardSpatial.class, "Spatial");
|
|
protected final DataFlavor SPATIAL_FLAVOR = new DataFlavor(ClipboardSpatial.class, "Spatial");
|
|
|
|
|
|
public JmeSpatial() {
|
|
public JmeSpatial() {
|
|
@@ -108,8 +108,7 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
}
|
|
}
|
|
|
|
|
|
Node[] children = getChildren().getNodes();
|
|
Node[] children = getChildren().getNodes();
|
|
- for (int i = 0; i < children.length; i++) {
|
|
|
|
- Node node = children[i];
|
|
|
|
|
|
+ for (Node node: children) {
|
|
if (node instanceof JmeSpatial) {
|
|
if (node instanceof JmeSpatial) {
|
|
JmeSpatial jmeSpatial = (JmeSpatial) node;
|
|
JmeSpatial jmeSpatial = (JmeSpatial) node;
|
|
JmeSpatial found = jmeSpatial.getChild(spat);
|
|
JmeSpatial found = jmeSpatial.getChild(spat);
|
|
@@ -156,6 +155,7 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean canCopy() {
|
|
public boolean canCopy() {
|
|
|
|
+ // @TODO: Is readOnly really relevant here?
|
|
return !((JmeSpatialChildren) jmeChildren).readOnly;
|
|
return !((JmeSpatialChildren) jmeChildren).readOnly;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -186,6 +186,7 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
fireSave(true);
|
|
fireSave(true);
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
|
|
|
|
|
|
+ @Override
|
|
public Void call() throws Exception {
|
|
public Void call() throws Exception {
|
|
spatial.setName(s);
|
|
spatial.setName(s);
|
|
return null;
|
|
return null;
|
|
@@ -204,6 +205,7 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
fireSave(true);
|
|
fireSave(true);
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
|
|
|
|
|
|
+ @Override
|
|
public Void call() throws Exception {
|
|
public Void call() throws Exception {
|
|
spatial.removeFromParent();
|
|
spatial.removeFromParent();
|
|
return null;
|
|
return null;
|
|
@@ -225,24 +227,21 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
@Override
|
|
@Override
|
|
public Transferable clipboardCopy() throws IOException {
|
|
public Transferable clipboardCopy() throws IOException {
|
|
Transferable trans = new Transferable() {
|
|
Transferable trans = new Transferable() {
|
|
-
|
|
|
|
|
|
+ @Override
|
|
public DataFlavor[] getTransferDataFlavors() {
|
|
public DataFlavor[] getTransferDataFlavors() {
|
|
- return new DataFlavor[]{SPATIAL_FLAVOR};
|
|
|
|
|
|
+ return new DataFlavor[] { SPATIAL_FLAVOR };
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
|
- if (SPATIAL_FLAVOR.equals(flavor)) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
|
|
+ return SPATIAL_FLAVOR.equals(flavor);
|
|
}
|
|
}
|
|
|
|
|
|
- public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Object getTransferData(DataFlavor flavor)
|
|
|
|
+ throws UnsupportedFlavorException, IOException {
|
|
if (SPATIAL_FLAVOR.equals(flavor)) {
|
|
if (SPATIAL_FLAVOR.equals(flavor)) {
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
- BinaryExporter.getInstance().save(spatial, out);
|
|
|
|
-
|
|
|
|
- return new ClipboardSpatial(out.toByteArray());
|
|
|
|
|
|
+ return new ClipboardSpatial(spatial);
|
|
} else {
|
|
} else {
|
|
throw new UnsupportedFlavorException(flavor);
|
|
throw new UnsupportedFlavorException(flavor);
|
|
}
|
|
}
|
|
@@ -255,38 +254,36 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
public Transferable clipboardCut() throws IOException {
|
|
public Transferable clipboardCut() throws IOException {
|
|
fireSave(true);
|
|
fireSave(true);
|
|
Transferable trans = new Transferable() {
|
|
Transferable trans = new Transferable() {
|
|
-
|
|
|
|
|
|
+ @Override
|
|
public DataFlavor[] getTransferDataFlavors() {
|
|
public DataFlavor[] getTransferDataFlavors() {
|
|
- return new DataFlavor[]{SPATIAL_FLAVOR};
|
|
|
|
|
|
+ return new DataFlavor[]{ SPATIAL_FLAVOR };
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
|
public boolean isDataFlavorSupported(DataFlavor flavor) {
|
|
- if (SPATIAL_FLAVOR.equals(flavor)) {
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- return false;
|
|
|
|
|
|
+ return SPATIAL_FLAVOR.equals(flavor);
|
|
}
|
|
}
|
|
|
|
|
|
- public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Object getTransferData(DataFlavor flavor) throws
|
|
|
|
+ UnsupportedFlavorException, IOException {
|
|
if (SPATIAL_FLAVOR.equals(flavor)) {
|
|
if (SPATIAL_FLAVOR.equals(flavor)) {
|
|
try {
|
|
try {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
SceneApplication.getApplication().enqueue(new Callable<Void>() {
|
|
-
|
|
|
|
|
|
+ @Override
|
|
public Void call() throws Exception {
|
|
public Void call() throws Exception {
|
|
spatial.removeFromParent();
|
|
spatial.removeFromParent();
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
}).get();
|
|
}).get();
|
|
- //TODO: not a good cast
|
|
|
|
|
|
+
|
|
|
|
+ // @TODO: not a good cast
|
|
JmeNode node = ((JmeNode) getParentNode());
|
|
JmeNode node = ((JmeNode) getParentNode());
|
|
if (node != null) {
|
|
if (node != null) {
|
|
node.refresh(false);
|
|
node.refresh(false);
|
|
}
|
|
}
|
|
-// return spatial;
|
|
|
|
- ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
|
- BinaryExporter.getInstance().save(spatial, out);
|
|
|
|
-//
|
|
|
|
- return new ClipboardSpatial(out.toByteArray());
|
|
|
|
|
|
+
|
|
|
|
+ return new ClipboardSpatial(spatial);
|
|
} catch (InterruptedException ex) {
|
|
} catch (InterruptedException ex) {
|
|
Exceptions.printStackTrace(ex);
|
|
Exceptions.printStackTrace(ex);
|
|
} catch (ExecutionException ex) {
|
|
} catch (ExecutionException ex) {
|
|
@@ -305,20 +302,20 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
protected Sheet createSheet() {
|
|
protected Sheet createSheet() {
|
|
Sheet sheet = super.createSheet();
|
|
Sheet sheet = super.createSheet();
|
|
|
|
|
|
- //TODO: multithreading.. but we only read
|
|
|
|
|
|
+ //@TODO: multithreading.. but we only read
|
|
Collection<String> dataKeys = spatial.getUserDataKeys();
|
|
Collection<String> dataKeys = spatial.getUserDataKeys();
|
|
if (dataKeys.size() > 0) {
|
|
if (dataKeys.size() > 0) {
|
|
Sheet.Set set = Sheet.createPropertiesSet();
|
|
Sheet.Set set = Sheet.createPropertiesSet();
|
|
set.setDisplayName("User Data");
|
|
set.setDisplayName("User Data");
|
|
set.setName(Spatial.class.getName() + "_UserData");
|
|
set.setName(Spatial.class.getName() + "_UserData");
|
|
- for (Iterator<String> it = dataKeys.iterator(); it.hasNext();) {
|
|
|
|
- String string = it.next();
|
|
|
|
|
|
+ for (String string : dataKeys) {
|
|
UserDataProperty prop = new UserDataProperty(this, string);
|
|
UserDataProperty prop = new UserDataProperty(this, string);
|
|
prop.addPropertyChangeListener(this);
|
|
prop.addPropertyChangeListener(this);
|
|
set.put(prop);
|
|
set.put(prop);
|
|
}
|
|
}
|
|
sheet.put(set);
|
|
sheet.put(set);
|
|
}
|
|
}
|
|
|
|
+
|
|
Sheet.Set set = Sheet.createPropertiesSet();
|
|
Sheet.Set set = Sheet.createPropertiesSet();
|
|
set.setDisplayName("Spatial");
|
|
set.setDisplayName("Spatial");
|
|
set.setName(Spatial.class.getName());
|
|
set.setName(Spatial.class.getName());
|
|
@@ -355,6 +352,7 @@ public class JmeSpatial extends AbstractSceneExplorerNode {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
public Class<?> getExplorerObjectClass() {
|
|
public Class<?> getExplorerObjectClass() {
|
|
return Spatial.class;
|
|
return Spatial.class;
|
|
}
|
|
}
|