SDK - Filter Editor :
- Filters can now be reordered by drag and drop git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7814 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
87737f96e0
commit
12287736e6
@ -171,7 +171,7 @@ public abstract class AbstractFilterNode extends AbstractNode implements FilterN
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param saveCookie the saveCookie to set
|
* @param saveCookie the saveCookie to set
|
||||||
*/
|
*/
|
||||||
public AbstractFilterNode setReadOnly(boolean readOnly) {
|
public AbstractFilterNode setReadOnly(boolean readOnly) {
|
||||||
|
@ -80,7 +80,7 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex
|
|||||||
initComponents();
|
initComponents();
|
||||||
setName(NbBundle.getMessage(FilterExplorerTopComponent.class, "CTL_FilterExplorerTopComponent"));
|
setName(NbBundle.getMessage(FilterExplorerTopComponent.class, "CTL_FilterExplorerTopComponent"));
|
||||||
setToolTipText(NbBundle.getMessage(FilterExplorerTopComponent.class, "HINT_FilterExplorerTopComponent"));
|
setToolTipText(NbBundle.getMessage(FilterExplorerTopComponent.class, "HINT_FilterExplorerTopComponent"));
|
||||||
ActionMap map=getActionMap();
|
ActionMap map = getActionMap();
|
||||||
map.put("delete", ExplorerUtils.actionDelete(explorerManager, true));
|
map.put("delete", ExplorerUtils.actionDelete(explorerManager, true));
|
||||||
map.put("moveup", new MoveUpAction());
|
map.put("moveup", new MoveUpAction());
|
||||||
map.put("movedown", new MoveDownAction());
|
map.put("movedown", new MoveDownAction());
|
||||||
@ -88,8 +88,6 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/** This method is called from within the constructor to
|
||||||
* initialize the form.
|
* initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is
|
||||||
@ -179,14 +177,14 @@ public final class FilterExplorerTopComponent extends TopComponent implements Ex
|
|||||||
SceneApplication.getApplication().getViewPort().addProcessor(fpp);
|
SceneApplication.getApplication().getViewPort().addProcessor(fpp);
|
||||||
Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Enabled post filters");
|
Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Enabled post filters");
|
||||||
} else {
|
} else {
|
||||||
for (Iterator<SceneProcessor> it = SceneApplication.getApplication().getViewPort().getProcessors().iterator(); it.hasNext();) {
|
for (Iterator<SceneProcessor> it = SceneApplication.getApplication().getViewPort().getProcessors().iterator(); it.hasNext();) {
|
||||||
SceneProcessor proc = it.next();
|
SceneProcessor proc = it.next();
|
||||||
if (proc instanceof FilterPostProcessor) {
|
if (proc instanceof FilterPostProcessor) {
|
||||||
it.remove();
|
it.remove();
|
||||||
proc.cleanup();
|
proc.cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SceneApplication.getApplication().getViewPort().removeProcessor(fpp);
|
// SceneApplication.getApplication().getViewPort().removeProcessor(fpp);
|
||||||
Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Disabled post filters");
|
Logger.getLogger(FilterExplorerTopComponent.class.getName()).log(Level.INFO, "Disabled post filters");
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -20,8 +20,6 @@ public class FilterIndexSupport extends Index.Support {
|
|||||||
FilterChildren children;
|
FilterChildren children;
|
||||||
|
|
||||||
public FilterIndexSupport() {
|
public FilterIndexSupport() {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -42,14 +40,13 @@ public class FilterIndexSupport extends Index.Support {
|
|||||||
this.fppNode = fppNode;
|
this.fppNode = fppNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reorder(final int[] perm) {
|
public void reorder(final int[] perm) {
|
||||||
|
|
||||||
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
||||||
|
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
List<Filter> filters=new ArrayList<Filter>();
|
List<Filter> filters = new ArrayList<Filter>();
|
||||||
for (Iterator<Filter> it = fppNode.getFilterPostProcessor().getFilterIterator(); it.hasNext();) {
|
for (Iterator<Filter> it = fppNode.getFilterPostProcessor().getFilterIterator(); it.hasNext();) {
|
||||||
Filter f = it.next();
|
Filter f = it.next();
|
||||||
filters.add(f);
|
filters.add(f);
|
||||||
|
@ -37,6 +37,8 @@ import com.jme3.gde.core.scene.SceneApplication;
|
|||||||
import com.jme3.post.Filter;
|
import com.jme3.post.Filter;
|
||||||
import com.jme3.post.FilterPostProcessor;
|
import com.jme3.post.FilterPostProcessor;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
|
import java.awt.datatransfer.Transferable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -45,11 +47,12 @@ import java.util.concurrent.ExecutionException;
|
|||||||
import javax.swing.Action;
|
import javax.swing.Action;
|
||||||
import org.openide.nodes.AbstractNode;
|
import org.openide.nodes.AbstractNode;
|
||||||
import org.openide.nodes.Children;
|
import org.openide.nodes.Children;
|
||||||
import org.openide.nodes.Index;
|
|
||||||
import org.openide.nodes.Node;
|
import org.openide.nodes.Node;
|
||||||
|
import org.openide.nodes.NodeTransfer;
|
||||||
import org.openide.util.Exceptions;
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.ImageUtilities;
|
import org.openide.util.ImageUtilities;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
|
import org.openide.util.datatransfer.PasteType;
|
||||||
import org.openide.util.lookup.Lookups;
|
import org.openide.util.lookup.Lookups;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,15 +67,16 @@ public class FilterPostProcessorNode extends AbstractNode {
|
|||||||
private FilterPostProcessor fpp;
|
private FilterPostProcessor fpp;
|
||||||
|
|
||||||
public FilterPostProcessorNode(FilterDataObject dataObject) {
|
public FilterPostProcessorNode(FilterDataObject dataObject) {
|
||||||
super(new FilterChildren(dataObject),Lookups.singleton(new FilterIndexSupport()));
|
super(new FilterChildren(dataObject), Lookups.singleton(new FilterIndexSupport()));
|
||||||
|
|
||||||
//Lookups.singleton(new FilterIndexSupport((FilterChildren)this.getChildren()));
|
//Lookups.singleton(new FilterIndexSupport((FilterChildren)this.getChildren()));
|
||||||
this.dataObject = dataObject;
|
this.dataObject = dataObject;
|
||||||
setName(dataObject.getName());
|
setName(dataObject.getName());
|
||||||
getLookup().lookup(FilterIndexSupport.class).setFilterPostProcessorNode(this);
|
getLookup().lookup(FilterIndexSupport.class).setFilterPostProcessorNode(this);
|
||||||
((FilterChildren) getChildren()).setFilterPostProcessorNode(this);
|
((FilterChildren) getChildren()).setFilterPostProcessorNode(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -92,6 +96,28 @@ public class FilterPostProcessorNode extends AbstractNode {
|
|||||||
return fpp;
|
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() {
|
public void refresh() {
|
||||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||||
|
|
||||||
@ -205,7 +231,5 @@ public class FilterPostProcessorNode extends AbstractNode {
|
|||||||
}
|
}
|
||||||
return new Node[]{};
|
return new Node[]{};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user