diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java index 40cf0ce43..b5890f4bb 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/AbstractFilterNode.java @@ -115,7 +115,7 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN }; } - + @Override public Action getPreferredAction() { return Actions.alwaysEnabled(new EnableFiterAction(this), "Toggle enabled", "", false); @@ -171,7 +171,7 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN } - /** + /** * @param saveCookie the saveCookie to set */ public AbstractFilterNode setReadOnly(boolean readOnly) { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java index bfafb8505..d7209b118 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterExplorerTopComponent.java @@ -80,15 +80,13 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex initComponents(); setName(NbBundle.getMessage(FilterExplorerTopComponent.class, "CTL_FilterExplorerTopComponent")); setToolTipText(NbBundle.getMessage(FilterExplorerTopComponent.class, "HINT_FilterExplorerTopComponent")); - ActionMap map=getActionMap(); - map.put("delete", ExplorerUtils.actionDelete(explorerManager, true)); - map.put("moveup", new MoveUpAction()); - map.put("movedown", new MoveDownAction()); + ActionMap map = getActionMap(); + map.put("delete", ExplorerUtils.actionDelete(explorerManager, true)); + map.put("moveup", new MoveUpAction()); + map.put("movedown", new MoveDownAction()); associateLookup(ExplorerUtils.createLookup(explorerManager, map)); - + } - - /** This method is called from within the constructor to * initialize the form. @@ -152,7 +150,7 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex } public void loadFile(FilterDataObject object) { - explorerManager.setRootContext(object.getLookup().lookup(FilterPostProcessorNode.class)); + explorerManager.setRootContext(object.getLookup().lookup(FilterPostProcessorNode.class)); node = object.getLookup().lookup(FilterPostProcessorNode.class); setActivatedNodes(new Node[]{object.getNodeDelegate()}); open(); @@ -179,14 +177,14 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex SceneApplication.getApplication().getViewPort().addProcessor(fpp); Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Enabled post filters"); } else { - for (Iterator it = SceneApplication.getApplication().getViewPort().getProcessors().iterator(); it.hasNext();) { + for (Iterator it = SceneApplication.getApplication().getViewPort().getProcessors().iterator(); it.hasNext();) { SceneProcessor proc = it.next(); if (proc instanceof FilterPostProcessor) { it.remove(); proc.cleanup(); } } - // SceneApplication.getApplication().getViewPort().removeProcessor(fpp); + // SceneApplication.getApplication().getViewPort().removeProcessor(fpp); Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Disabled post filters"); } return null; diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java index 04ac36e20..c707d514f 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterIndexSupport.java @@ -20,8 +20,6 @@ public class FilterIndexSupport extends Index.Support { FilterChildren children; public FilterIndexSupport() { - - } @Override @@ -41,15 +39,14 @@ public class FilterIndexSupport extends Index.Support { public void setFilterPostProcessorNode(FilterPostProcessorNode fppNode) { this.fppNode = fppNode; } - @Override public void reorder(final int[] perm) { - - SceneApplication.getApplication().enqueue(new Callable() { + + SceneApplication.getApplication().enqueue(new Callable() { public Object call() throws Exception { - List filters=new ArrayList(); + List filters = new ArrayList(); for (Iterator it = fppNode.getFilterPostProcessor().getFilterIterator(); it.hasNext();) { Filter f = it.next(); filters.add(f); diff --git a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java index 5c94b6d12..105a6f821 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/filters/FilterPostProcessorNode.java @@ -37,6 +37,8 @@ import com.jme3.gde.core.scene.SceneApplication; import com.jme3.post.Filter; import com.jme3.post.FilterPostProcessor; import java.awt.Image; +import java.awt.datatransfer.Transferable; +import java.io.IOException; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -45,11 +47,12 @@ import java.util.concurrent.ExecutionException; import javax.swing.Action; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; -import org.openide.nodes.Index; import org.openide.nodes.Node; +import org.openide.nodes.NodeTransfer; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; import org.openide.util.Lookup; +import org.openide.util.datatransfer.PasteType; import org.openide.util.lookup.Lookups; /** @@ -63,16 +66,17 @@ public class FilterPostProcessorNode extends AbstractNode { ImageUtilities.loadImage("com/jme3/gde/core/filters/icons/eye.gif"); private FilterPostProcessor fpp; - public FilterPostProcessorNode(FilterDataObject dataObject) { - super(new FilterChildren(dataObject),Lookups.singleton(new FilterIndexSupport())); - - //Lookups.singleton(new FilterIndexSupport((FilterChildren)this.getChildren())); + public FilterPostProcessorNode(FilterDataObject dataObject) { + super(new FilterChildren(dataObject), Lookups.singleton(new FilterIndexSupport())); + + //Lookups.singleton(new FilterIndexSupport((FilterChildren)this.getChildren())); this.dataObject = dataObject; - setName(dataObject.getName()); + setName(dataObject.getName()); getLookup().lookup(FilterIndexSupport.class).setFilterPostProcessorNode(this); ((FilterChildren) getChildren()).setFilterPostProcessorNode(this); + } @Override @@ -92,6 +96,28 @@ public class FilterPostProcessorNode extends AbstractNode { return fpp; } + //this allow the reordering on drop of a Node + @Override + public PasteType getDropType(Transferable t, int action, final int index) { + + final Node node = NodeTransfer.node(t, action); + return new PasteType() { + + @Override + public Transferable paste() throws IOException { + FilterIndexSupport indexSupport = getLookup().lookup(FilterIndexSupport.class); + int nodeIndex = indexSupport.indexOf(node); + if (nodeIndex < index) { + indexSupport.move(index - 1, nodeIndex); + } else { + indexSupport.move(index, nodeIndex); + } + + return null; + } + }; + } + public void refresh() { java.awt.EventQueue.invokeLater(new Runnable() { @@ -166,11 +192,11 @@ public class FilterPostProcessorNode extends AbstractNode { protected void doRefresh() { refresh(); } - - protected void reorderNotify() { + + protected void reorderNotify() { setKeys(createKeys()); } - + protected List createKeys() { try { return SceneApplication.getApplication().enqueue(new Callable>() { @@ -205,7 +231,5 @@ public class FilterPostProcessorNode extends AbstractNode { } return new Node[]{}; } - } - }